Fixes the Project filter in ExploreDmp to have the same functionality when user is logged in or not.
This commit is contained in:
parent
a6ed45e75f
commit
c1449bd333
|
@ -46,11 +46,17 @@ public class Projects extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<ProjectListingModel>>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest, @RequestParam String fieldsGroup, Principal principal) throws Exception {
|
||||
System.out.println(fieldsGroup);
|
||||
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = this.projectManager.getPaged(projectTableRequest, principal, fieldsGroup);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.data.project.ProjectListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"public/paged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<ProjectListingModel>>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest) throws Exception {
|
||||
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = this.projectManager.getPublicPaged(projectTableRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.data.project.ProjectListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<eu.eudat.models.data.project.Project>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
|
|
|
@ -88,6 +88,22 @@ public class ProjectManager {
|
|||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTableData<eu.eudat.models.data.project.ProjectListingModel> getPublicPaged(ProjectTableRequest projectTableRequest) throws Exception {
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
QueryableList<eu.eudat.data.entities.Project> items = projectRepository.getWithCriteria(projectTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.data.entities.Project> pagedItems = PaginationManager.applyPaging(items, projectTableRequest);
|
||||
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = new DataTableData<>();
|
||||
CompletableFuture projectsFuture;
|
||||
projectsFuture = pagedItems.selectAsync(item -> new ProjectListingModel().fromDataModel(item))
|
||||
.whenComplete((results, throwable) -> {
|
||||
dataTable.setData(results);
|
||||
});
|
||||
CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
||||
|
||||
CompletableFuture.allOf(projectsFuture, countFuture).join();
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.project.Project getSingle(String id) throws InstantiationException, IllegalAccessException {
|
||||
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
||||
project.fromDataModel(databaseRepository.getProjectDao().find(UUID.fromString(id)));
|
||||
|
|
|
@ -29,6 +29,10 @@ export class ProjectService {
|
|||
}
|
||||
}
|
||||
|
||||
getPublicPaged(dataTableRequest: DataTableRequest<ProjectCriteria>): Observable<DataTableData<ProjectListingModel>> {
|
||||
return this.http.post<DataTableData<ProjectListingModel>>(this.actionUrl + 'public/paged', dataTableRequest, { headers: this.headers });
|
||||
}
|
||||
|
||||
getWithExternal(requestItem: RequestItem<ProjectCriteria>): Observable<ProjectListingModel[]> {
|
||||
return this.http.post<ProjectListingModel[]>(this.actionUrl + 'external', requestItem, { headers: this.headers });
|
||||
}
|
||||
|
@ -45,5 +49,4 @@ export class ProjectService {
|
|||
delete(id: String): Observable<ProjectListingModel> {
|
||||
return this.http.delete<ProjectListingModel>(this.actionUrl + id, { headers: this.headers });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -99,13 +99,10 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
|
|||
dataTableRequest.criteria.projectStateType = this.facetCriteria.projectStatus;
|
||||
dataTableRequest.criteria['length'] = 10;
|
||||
|
||||
if (this.authentication.current()) {
|
||||
this.projects = this.projectService.getPaged(dataTableRequest, "autocomplete").map(x => x.data);
|
||||
this.projects = this.projectService.getPublicPaged(dataTableRequest).map(x => x.data);
|
||||
this.facetCriteria.projects = [];
|
||||
}
|
||||
}
|
||||
this.facetCriteriaChange.emit(this.facetCriteria);
|
||||
|
||||
}
|
||||
|
||||
public projectChanged(event: any) {
|
||||
|
@ -163,7 +160,8 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
|
|||
const dataTableRequest: DataTableRequest<ProjectCriteria> = new DataTableRequest(0, null, { fields: fields });
|
||||
dataTableRequest.criteria = projectCriteria;
|
||||
//const dataTableRequest: RequestItem<ProjectCriteria> = { criteria: projectCriteria };
|
||||
return this.projectService.getPaged(dataTableRequest, "autocomplete").map(x => x.data);
|
||||
//return this.projectService.getPaged(dataTableRequest, "autocomplete").map(x => x.data);
|
||||
return this.projectService.getPublicPaged(dataTableRequest).map(x => x.data);
|
||||
}
|
||||
|
||||
public dmpOrganisationSearch(value: string): Observable<ExternalSourceItemModel[]> {
|
||||
|
|
Loading…
Reference in New Issue