diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetCriteria.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetCriteria.java index 82bf14934..6c2ca51b0 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetCriteria.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetCriteria.java @@ -16,12 +16,13 @@ public class DatasetCriteria extends Criteria { private List tags; private boolean allVersions; private UUID profileDatasetId; - + private List organisations; + private Integer role; + private List projects; public boolean getAllVersions() { return allVersions; } - public void setAllVersions(boolean allVersions) { this.allVersions = allVersions; } @@ -29,7 +30,6 @@ public class DatasetCriteria extends Criteria { public Integer getStatus() { return status; } - public void setStatus(Integer status) { this.status = status; } @@ -37,7 +37,6 @@ public class DatasetCriteria extends Criteria { public Date getPeriodStart() { return periodStart; } - public void setPeriodStart(Date periodStart) { this.periodStart = periodStart; } @@ -45,7 +44,6 @@ public class DatasetCriteria extends Criteria { public Date getPeriodEnd() { return periodEnd; } - public void setPeriodEnd(Date periodEnd) { this.periodEnd = periodEnd; } @@ -53,7 +51,6 @@ public class DatasetCriteria extends Criteria { public List getDmpIds() { return dmpIds; } - public void setDmpIds(List dmpIds) { this.dmpIds = dmpIds; } @@ -61,7 +58,6 @@ public class DatasetCriteria extends Criteria { public List getTags() { return tags; } - public void setTags(List tags) { this.tags = tags; } @@ -69,8 +65,28 @@ public class DatasetCriteria extends Criteria { public UUID getProfileDatasetId() { return profileDatasetId; } - public void setProfileDatasetId(UUID profileDatasetId) { this.profileDatasetId = profileDatasetId; } + + public List getOrganisations() { + return organisations; + } + public void setOrganisations(List organisations) { + this.organisations = organisations; + } + + public Integer getRole() { + return role; + } + public void setRole(Integer role) { + this.role = role; + } + + public List getProjects() { + return projects; + } + public void setProjects(List projects) { + this.projects = projects; + } } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java index 40b728a82..60e18fdb0 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java @@ -43,6 +43,15 @@ public class DatasetDaoImpl extends DatabaseAccess implements DatasetDa query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class))); if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty()) query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds())); + if (criteria.getRole() != null) { + query.where((builder, root) -> builder.equal(root.join("dmp").join("users").get("role"), criteria.getRole())); + } + if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty()) { + query.where((builder, root) -> root.join("dmp").join("organisations").get("reference").in(criteria.getOrganisations())); + } + if (criteria.getProjects() != null) { + query.where((builder, root) -> root.join("dmp").join("project").get("id").in(criteria.getProjects())); + } query.where(((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()))); return query; } diff --git a/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts b/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts index d662d56e6..5612a2dd0 100644 --- a/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts +++ b/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts @@ -2,8 +2,11 @@ import { ExternalSourceItemModel } from "../../model/external-sources/external-s import { BaseCriteria } from "../base-criteria"; export class DatasetCriteria extends BaseCriteria { - public status: Number; - public dmpIds: String[] = []; - public tags: ExternalSourceItemModel[] = []; - public allVersions: boolean; + public projects?: string[] = []; + public status?: Number; + public dmpIds?: String[] = []; + public tags?: ExternalSourceItemModel[] = []; + public allVersions?: boolean; + public role?: number; + public organisations?: string[] = []; } diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html index 5aaa254c3..13884ff7a 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html +++ b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html @@ -5,7 +5,7 @@ + [formControl]="formGroup.get('like')"> {{formGroup.get('like').getError('backendError').message}} search @@ -13,22 +13,24 @@ -
-
STATUS
- {{ 'TYPES.DATASET-STATUS.DRAFT' | translate }} - {{ 'TYPES.DATASET-STATUS.FINALISED' | translate }} - {{ 'TYPES.DATASET-STATUS.ANY' | translate }} +
+
{{'CRITERIA.DATA-SETS.STATUS'| translate}}
+ + {{ 'TYPES.DATASET-STATUS.DRAFT' | translate }} + {{ 'TYPES.DATASET-STATUS.FINALISED' | translate }} + {{ 'TYPES.DATASET-STATUS.ANY' | translate }} +
+
-
{{ 'DMP-RELATED-PROJECT.RELATED-PROJECT' | translate}}
+
{{'CRITERIA.PROJECTS.LIKE' | translate}}
- - + arrow_drop_down
@@ -36,16 +38,16 @@
-
{{ 'DATASET-PROFILE-LISTING.COLUMNS.ROLE' | translate }}
- +
{{'CRITERIA.DATA-SETS.ROLE' | translate }}
+ - {{ 'TYPES.DATASET-ROLE.ANY' | translate }} + {{ 'TYPES.DATASET-ROLE.ANY' | translate }} - {{ 'TYPES.DATASET-ROLE.OWNER' | translate }} + {{ 'TYPES.DATASET-ROLE.OWNER' | translate }} - {{ 'TYPES.DATASET-ROLE.MEMBER' | translate }} + {{ 'TYPES.DATASET-ROLE.MEMBER' | translate }}
@@ -53,13 +55,12 @@
-
RELATED ORGANIZATION
+
{{'CRITERIA.DATA-SETS.ORGANIZATION' | translate }}
- - + + arrow_drop_down
diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts index fc36950ef..4b36e06db 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts +++ b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts @@ -25,6 +25,11 @@ import { UiNotificationService, SnackBarNotificationLevel } from '../../../../co import { Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { FormGroup, FormBuilder, FormControl } from '@angular/forms'; +import { MultipleAutoCompleteConfiguration } from '../../../../library/auto-complete/multiple/multiple-auto-complete-configuration'; +import { OrganisationCriteria } from '../../../../core/query/organisation/organisation-criteria'; +import { OrganisationService } from '../../../../core/services/organisation/organisation.service'; +import { ProjectCriteria } from '../../../../core/query/project/project-criteria'; +import { ProjectService } from '../../../../core/services/project/project.service'; @Component({ selector: 'app-dataset-criteria-component', @@ -42,11 +47,11 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O options: FormGroup; public formGroup = new FormBuilder().group({ - like: new FormControl() - // projects: new FormControl(), - // status: new FormControl(), - // role: new FormControl(), - // organisations: new FormControl() + like: new FormControl(), + projects: new FormControl(), + status: new FormControl(), + role: new FormControl(), + organisations: new FormControl() }); tagsAutoCompleteConfiguration = { @@ -63,6 +68,20 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O titleFn: (item) => item['label'] }; + projectAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { + filterFn: this.filterProject.bind(this), + initialItems: (excludedItems: any[]) => this.filterProject('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)), + displayFn: (item) => item['label'], + titleFn: (item) => item['label'] + }; + + organisationAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { + filterFn: this.filterOrganisations.bind(this), + initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)), + displayFn: (item) => item['name'], + titleFn: (item) => item['name'] + } + constructor( private externalSourcesService: ExternalSourcesService, public enumUtils: EnumUtils, @@ -73,32 +92,42 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O private uiNotificationService: UiNotificationService, private router: Router, private language: TranslateService, + public projectService: ProjectService, + private organisationService: OrganisationService, fb: FormBuilder ) { super(new ValidationErrorModel()); - this.options = fb.group({ - getDrafts: false, - getFinalized: false, - getDmpStatuses: false, - floatLabel: 'auto', - }); + // this.options = fb.group({ + // status: new FormControl(), + // floatLabel: 'auto', + // }); } ngOnInit() { super.ngOnInit(); this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.controlModified()); - // this.formGroup.get('projects').valueChanges - // .pipe(takeUntil(this._destroyed)) - // .subscribe(x => this.controlModified()); - + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.controlModified()); + this.formGroup.get('projects').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.controlModified()); + this.formGroup.get('status').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.controlModified()); + this.formGroup.get('role').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.controlModified()); + this.formGroup.get('organisations').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.controlModified()); // if (this.criteria == null) { this.criteria = {}; } } setCriteria(criteria: DatasetCriteria): void { this.formGroup.get('like').patchValue(criteria.like); + this.formGroup.get('status').patchValue(criteria.like); // this.formGroup.get('projects').patchValue(criteria.projects); + this.formGroup.get('role').patchValue(criteria.like); // this.criteria = criteria; } @@ -136,6 +165,25 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete"); } + filterProject(query: string) { + const fields: Array = new Array(); + fields.push('asc'); + const projectRequestItem: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); + projectRequestItem.criteria = new ProjectCriteria(); + projectRequestItem.criteria.like = query; + return this.projectService.getPaged(projectRequestItem, "autocomplete").map(x => x.data); + } + + filterOrganisations(value: string) { + const fields: Array = new Array(); + fields.push('asc'); + const dataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); + dataTableRequest.criteria = new OrganisationCriteria(); + dataTableRequest.criteria.labelLike = value; + + return this.organisationService.searchInternalOrganisations(dataTableRequest).map(x => x.data); + } + fileImport(event) { const dialogRef = this.dialog.open(DatasetUploadDialogue, { data: { diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts index 1b9468eef..a77b11fcb 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts +++ b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts @@ -78,7 +78,22 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB let fields: Array = new Array(); if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; } const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this.criteria.formGroup.value; + let value = this.criteria.formGroup.value; + request.criteria = { + like: value.like, + status: value.status, + allVersions: value.allVersions, + role: value.role + } + if (value.projects) { + request.criteria.projects = value.projects.map(x => x.id); + } + if (value.dmpIds) { + request.criteria.dmpIds = value.dmpIds; + } + if (value.organisations) { + request.criteria.organisations = value.organisations.map(x => x.id); + } // if (this.itemId) { // // request.criteria.groupIds = [this.itemId]; // request.criteria.allVersions = true; @@ -87,7 +102,6 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB if (!result) { return []; } if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } this.listingItems = result.data; - console.log(result); }); } diff --git a/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts b/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts index 0b8d9bd1e..9c060eb80 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts @@ -34,7 +34,6 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni sizeError = false; maxFileSize: number = 1048576; filteringOrganisationsAsync = false; - filteredOrganisations: ExternalSourceItemModel[]; filteredProjects: ProjectListingModel[]; public formGroup = new FormBuilder().group({ @@ -119,7 +118,6 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni } filterOrganisations(value: string) { - this.filteredOrganisations = undefined; this.filteringOrganisationsAsync = true; const fields: Array = new Array(); fields.push('asc'); diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 57dc60698..4d7608c69 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -483,7 +483,11 @@ "STATUS": "Status", "NONE": "-", "TAGS": "Tags", - "LIKE": "Search Datasets" + "LIKE": "Search Datasets", + "SELECT-PROJECTS": "Select Projects", + "ROLE": "Role", + "ORGANIZATION": "Organization", + "SELECT-ORGANIZATIONS": "Select Organizations" }, "DMP": { "LIKE": "Search DMPs",