Organisations filter on "Public DMPs" now exposes only the ones associated with public DMPs. (Ticket #79)
This commit is contained in:
parent
3905f68121
commit
b8559f9f52
|
@ -4,6 +4,7 @@ import eu.eudat.data.entities.Organisation;
|
||||||
|
|
||||||
public class OrganisationCriteria extends Criteria<Organisation> {
|
public class OrganisationCriteria extends Criteria<Organisation> {
|
||||||
private String labelLike;
|
private String labelLike;
|
||||||
|
private Boolean isPublic;
|
||||||
|
|
||||||
public String getLabelLike() {
|
public String getLabelLike() {
|
||||||
return labelLike;
|
return labelLike;
|
||||||
|
@ -11,4 +12,11 @@ public class OrganisationCriteria extends Criteria<Organisation> {
|
||||||
public void setLabelLike(String labelLike) {
|
public void setLabelLike(String labelLike) {
|
||||||
this.labelLike = labelLike;
|
this.labelLike = labelLike;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getPublic() {
|
||||||
|
return isPublic;
|
||||||
|
}
|
||||||
|
public void setPublic(Boolean aPublic) {
|
||||||
|
isPublic = aPublic;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.data.dao.entities;
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.Organisation;
|
import eu.eudat.data.entities.Organisation;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.persistence.criteria.JoinType;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@ -29,6 +31,9 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
|
||||||
if (criteria.getLabelLike() != null) {
|
if (criteria.getLabelLike() != null) {
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLabelLike().toUpperCase() + "%"));
|
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLabelLike().toUpperCase() + "%"));
|
||||||
}
|
}
|
||||||
|
if (criteria.getPublic()) {
|
||||||
|
query.where((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
||||||
|
}
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,5 +51,12 @@ public class Organisations extends BaseController {
|
||||||
DataTableData<Organisation> organisationDataTableData = this.organisationsManager.getPagedOrganisations(organisationsTableRequest, principal);
|
DataTableData<Organisation> organisationDataTableData = this.organisationsManager.getPagedOrganisations(organisationsTableRequest, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Organisation>>().payload(organisationDataTableData).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Organisation>>().payload(organisationDataTableData).status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/public/organisations"}, produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<DataTableData<Organisation>>> getPublicPaged(@Valid @RequestBody OrganisationsTableRequest organisationsTableRequest) throws Exception{
|
||||||
|
DataTableData<Organisation> organisationDataTableData = this.organisationsManager.getPublicPagedOrganisations(organisationsTableRequest);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Organisation>>().payload(organisationDataTableData).status(ApiMessageCode.NO_MESSAGE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,22 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||||
import eu.eudat.data.dao.entities.OrganisationDao;
|
import eu.eudat.data.dao.entities.OrganisationDao;
|
||||||
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
|
||||||
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
|
import eu.eudat.models.HintedModelFactory;
|
||||||
import eu.eudat.models.data.dmp.Organisation;
|
import eu.eudat.models.data.dmp.Organisation;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
|
import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -40,6 +46,22 @@ public class OrganisationsManager {
|
||||||
DataTableData<Organisation> organisationDataTableData = new DataTableData<>();
|
DataTableData<Organisation> organisationDataTableData = new DataTableData<>();
|
||||||
organisationDataTableData.setData(org);
|
organisationDataTableData.setData(org);
|
||||||
organisationDataTableData.setTotalCount(pagedItems.count());
|
organisationDataTableData.setTotalCount(pagedItems.count());
|
||||||
|
|
||||||
|
return organisationDataTableData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTableData<Organisation> getPublicPagedOrganisations(OrganisationsTableRequest organisationsTableRequest) throws Exception {
|
||||||
|
organisationsTableRequest.getCriteria().setPublic(true);
|
||||||
|
OrganisationDao organisationDao = databaseRepository.getOrganisationDao();
|
||||||
|
|
||||||
|
QueryableList<eu.eudat.data.entities.Organisation> items = organisationDao.getWithCriteria(organisationsTableRequest.getCriteria());
|
||||||
|
QueryableList<eu.eudat.data.entities.Organisation> pagedItems = PaginationManager.applyPaging(items, organisationsTableRequest);
|
||||||
|
|
||||||
|
List<Organisation> org = pagedItems.toList().stream().distinct().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
||||||
|
DataTableData<Organisation> organisationDataTableData = new DataTableData<>();
|
||||||
|
organisationDataTableData.setData(org);
|
||||||
|
organisationDataTableData.setTotalCount(pagedItems.count());
|
||||||
|
|
||||||
return organisationDataTableData;
|
return organisationDataTableData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ export class ExternalSourcesService {
|
||||||
|
|
||||||
public searchDMPOrganizations(like: string): Observable<ExternalSourceItemModel[]> {
|
public searchDMPOrganizations(like: string): Observable<ExternalSourceItemModel[]> {
|
||||||
return this.http.get<ExternalSourceItemModel[]>(this.actionUrl + 'organisations' + '?query=' + like, { headers: this.headers });
|
return this.http.get<ExternalSourceItemModel[]>(this.actionUrl + 'organisations' + '?query=' + like, { headers: this.headers });
|
||||||
}//organizationscriteria.criteria.like
|
}
|
||||||
|
|
||||||
// TODO: currently not used.
|
// TODO: currently not used.
|
||||||
public searchDMPProfiles(like: string): Observable<ExternalSourceItemModel[]> {
|
public searchDMPProfiles(like: string): Observable<ExternalSourceItemModel[]> {
|
||||||
|
|
|
@ -26,4 +26,8 @@ export class OrganisationService {
|
||||||
public searchInternalOrganisations(dataTableRequest: DataTableRequest<OrganisationCriteria>): Observable<DataTableData<OrganizationModel>> {
|
public searchInternalOrganisations(dataTableRequest: DataTableRequest<OrganisationCriteria>): Observable<DataTableData<OrganizationModel>> {
|
||||||
return this.http.post<DataTableData<OrganizationModel>>(this.actionUrl + 'internal/organisations', dataTableRequest , { headers: this.headers });
|
return this.http.post<DataTableData<OrganizationModel>>(this.actionUrl + 'internal/organisations', dataTableRequest , { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public searchPublicOrganisations(dataTableRequest: DataTableRequest<OrganisationCriteria>): Observable<DataTableData<OrganizationModel>> {
|
||||||
|
return this.http.post<DataTableData<OrganizationModel>>(this.actionUrl + 'public/organisations', dataTableRequest , { headers: this.headers });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,11 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
|
||||||
ProjectStateType = ProjectStateType;
|
ProjectStateType = ProjectStateType;
|
||||||
projects: Observable<ProjectListingModel[]>;
|
projects: Observable<ProjectListingModel[]>;
|
||||||
profiles: Observable<DatasetProfileModel[]>;
|
profiles: Observable<DatasetProfileModel[]>;
|
||||||
dmpOrganisations: Observable<ExternalSourceItemModel[]>;
|
dmpOrganisations: Observable<OrganizationModel[]>;
|
||||||
projectOptions: Observable<ProjectListingModel[]>;
|
projectOptions: Observable<ProjectListingModel[]>;
|
||||||
projectStateOptions: Observable<any[]>;
|
projectStateOptions: Observable<any[]>;
|
||||||
filteringOrganisationsAsync = false;
|
filteringOrganisationsAsync = false;
|
||||||
filteredOrganisations: ExternalSourceItemModel[];
|
filteredOrganisations: OrganizationModel[];
|
||||||
status: ProjectStateType;
|
status: ProjectStateType;
|
||||||
IsChecked: boolean;
|
IsChecked: boolean;
|
||||||
IsIndeterminate: boolean;
|
IsIndeterminate: boolean;
|
||||||
|
@ -118,7 +118,9 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
this.profiles = this.datasetProfileService.getDatasetProfiles();
|
this.profiles = this.datasetProfileService.getDatasetProfiles();
|
||||||
this.dmpOrganisations = this.externalSourcesService.searchDMPOrganizations('');
|
const fields: Array<string> = new Array<string>();
|
||||||
|
fields.push('asc');
|
||||||
|
this.dmpOrganisations = this.organisationService.searchPublicOrganisations(new DataTableRequest<OrganisationCriteria>(0 , null, { fields: fields })).map(x => x.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
|
@ -265,8 +267,13 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
|
||||||
return this.datasetProfileService.getDatasetProfiles();
|
return this.datasetProfileService.getDatasetProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
dmpOrganisationSearch(value: string): Observable<ExternalSourceItemModel[]> {
|
dmpOrganisationSearch(value: string): Observable<OrganizationModel[]> {
|
||||||
return this.externalSourcesService.searchDMPOrganizations(value);
|
const fields: Array<string> = new Array<string>();
|
||||||
|
fields.push('asc');
|
||||||
|
const dataTableRequest: DataTableRequest<OrganisationCriteria> = new DataTableRequest(0, null, { fields: fields });
|
||||||
|
dataTableRequest.criteria = new OrganisationCriteria();
|
||||||
|
dataTableRequest.criteria.labelLike = value;
|
||||||
|
return this.organisationService.searchPublicOrganisations(dataTableRequest).map(x => x.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeOrganisation(organisation) {
|
removeOrganisation(organisation) {
|
||||||
|
@ -279,7 +286,12 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
|
||||||
}
|
}
|
||||||
|
|
||||||
getOrganisations() {
|
getOrganisations() {
|
||||||
return this.externalSourcesService.searchDMPOrganizations('');
|
const fields: Array<string> = new Array<string>();
|
||||||
|
fields.push('asc');
|
||||||
|
const dataTableRequest: DataTableRequest<OrganisationCriteria> = new DataTableRequest(0, null, { fields: fields });
|
||||||
|
dataTableRequest.criteria = new OrganisationCriteria();
|
||||||
|
dataTableRequest.criteria.labelLike = '';
|
||||||
|
return this.organisationService.searchPublicOrganisations(dataTableRequest).map(x => x.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterProject(query: string) {
|
filterProject(query: string) {
|
||||||
|
@ -309,7 +321,7 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
|
||||||
dataTableRequest.criteria = new OrganisationCriteria();
|
dataTableRequest.criteria = new OrganisationCriteria();
|
||||||
dataTableRequest.criteria.labelLike = value;
|
dataTableRequest.criteria.labelLike = value;
|
||||||
|
|
||||||
return this.organisationService.searchInternalOrganisations(dataTableRequest).map(x => x.data);
|
return this.organisationService.searchPublicOrganisations(dataTableRequest).map(x => x.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
displayLabel(value) {
|
displayLabel(value) {
|
||||||
|
|
Loading…
Reference in New Issue