Fixes search criteria on Dataset listing.

This commit is contained in:
gkolokythas 2019-05-10 15:36:23 +03:00
parent 879ab28cbb
commit 4829151355
8 changed files with 149 additions and 56 deletions

View File

@ -16,12 +16,13 @@ public class DatasetCriteria extends Criteria<Dataset> {
private List<Tag> tags; private List<Tag> tags;
private boolean allVersions; private boolean allVersions;
private UUID profileDatasetId; private UUID profileDatasetId;
private List<String> organisations;
private Integer role;
private List<UUID> projects;
public boolean getAllVersions() { public boolean getAllVersions() {
return allVersions; return allVersions;
} }
public void setAllVersions(boolean allVersions) { public void setAllVersions(boolean allVersions) {
this.allVersions = allVersions; this.allVersions = allVersions;
} }
@ -29,7 +30,6 @@ public class DatasetCriteria extends Criteria<Dataset> {
public Integer getStatus() { public Integer getStatus() {
return status; return status;
} }
public void setStatus(Integer status) { public void setStatus(Integer status) {
this.status = status; this.status = status;
} }
@ -37,7 +37,6 @@ public class DatasetCriteria extends Criteria<Dataset> {
public Date getPeriodStart() { public Date getPeriodStart() {
return periodStart; return periodStart;
} }
public void setPeriodStart(Date periodStart) { public void setPeriodStart(Date periodStart) {
this.periodStart = periodStart; this.periodStart = periodStart;
} }
@ -45,7 +44,6 @@ public class DatasetCriteria extends Criteria<Dataset> {
public Date getPeriodEnd() { public Date getPeriodEnd() {
return periodEnd; return periodEnd;
} }
public void setPeriodEnd(Date periodEnd) { public void setPeriodEnd(Date periodEnd) {
this.periodEnd = periodEnd; this.periodEnd = periodEnd;
} }
@ -53,7 +51,6 @@ public class DatasetCriteria extends Criteria<Dataset> {
public List<UUID> getDmpIds() { public List<UUID> getDmpIds() {
return dmpIds; return dmpIds;
} }
public void setDmpIds(List<UUID> dmpIds) { public void setDmpIds(List<UUID> dmpIds) {
this.dmpIds = dmpIds; this.dmpIds = dmpIds;
} }
@ -61,7 +58,6 @@ public class DatasetCriteria extends Criteria<Dataset> {
public List<Tag> getTags() { public List<Tag> getTags() {
return tags; return tags;
} }
public void setTags(List<Tag> tags) { public void setTags(List<Tag> tags) {
this.tags = tags; this.tags = tags;
} }
@ -69,8 +65,28 @@ public class DatasetCriteria extends Criteria<Dataset> {
public UUID getProfileDatasetId() { public UUID getProfileDatasetId() {
return profileDatasetId; return profileDatasetId;
} }
public void setProfileDatasetId(UUID profileDatasetId) { public void setProfileDatasetId(UUID profileDatasetId) {
this.profileDatasetId = profileDatasetId; this.profileDatasetId = profileDatasetId;
} }
public List<String> getOrganisations() {
return organisations;
}
public void setOrganisations(List<String> organisations) {
this.organisations = organisations;
}
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
public List<UUID> getProjects() {
return projects;
}
public void setProjects(List<UUID> projects) {
this.projects = projects;
}
} }

View File

@ -43,6 +43,15 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>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))); query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>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()) if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty())
query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds())); 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()))); query.where(((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue())));
return query; return query;
} }

View File

@ -2,8 +2,11 @@ import { ExternalSourceItemModel } from "../../model/external-sources/external-s
import { BaseCriteria } from "../base-criteria"; import { BaseCriteria } from "../base-criteria";
export class DatasetCriteria extends BaseCriteria { export class DatasetCriteria extends BaseCriteria {
public status: Number; public projects?: string[] = [];
public dmpIds: String[] = []; public status?: Number;
public tags: ExternalSourceItemModel[] = []; public dmpIds?: String[] = [];
public allVersions: boolean; public tags?: ExternalSourceItemModel[] = [];
public allVersions?: boolean;
public role?: number;
public organisations?: string[] = [];
} }

View File

@ -5,7 +5,7 @@
<!-- Search Filter--> <!-- Search Filter-->
<mat-form-field class="col-11 search"> <mat-form-field class="col-11 search">
<input matInput placeholder="{{'CRITERIA.PROJECTS.LIKE'| translate}}" name="projectCriteriaLike" <input matInput placeholder="{{'CRITERIA.PROJECTS.LIKE'| translate}}" name="projectCriteriaLike"
[formControl]="formGroup.get('like')" (ngModelChange)="controlModified()"> [formControl]="formGroup.get('like')">
<mat-error *ngIf="formGroup.get('like').hasError('backendError')"> <mat-error *ngIf="formGroup.get('like').hasError('backendError')">
{{formGroup.get('like').getError('backendError').message}}</mat-error> {{formGroup.get('like').getError('backendError').message}}</mat-error>
<mat-icon matSuffix class="style-icon">search</mat-icon> <mat-icon matSuffix class="style-icon">search</mat-icon>
@ -13,22 +13,24 @@
<!-- End of Search Filter --> <!-- End of Search Filter -->
<!-- Status Filter--> <!-- Status Filter-->
<div class="col-10 gray-container" [formGroup]="options"> <div class="col-10 gray-container" >
<h6 class="category-title">STATUS</h6> <h6 class="category-title">{{'CRITERIA.DATA-SETS.STATUS'| translate}}</h6>
<mat-list-item><mat-checkbox formControlName="getDrafts">{{ 'TYPES.DATASET-STATUS.DRAFT' | translate }}</mat-checkbox></mat-list-item> <mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('status')">
<mat-list-item><mat-checkbox formControlName="getFinalized">{{ 'TYPES.DATASET-STATUS.FINALISED' | translate }}</mat-checkbox></mat-list-item> <mat-list-item><mat-radio-button value="0">{{ 'TYPES.DATASET-STATUS.DRAFT' | translate }}</mat-radio-button></mat-list-item>
<mat-list-item><mat-checkbox formControlName="getDmpStatuses">{{ 'TYPES.DATASET-STATUS.ANY' | translate }}</mat-checkbox></mat-list-item> <mat-list-item><mat-radio-button value="1">{{ 'TYPES.DATASET-STATUS.FINALISED' | translate }}</mat-radio-button></mat-list-item>
<mat-list-item><mat-radio-button value="null">{{ 'TYPES.DATASET-STATUS.ANY' | translate }}</mat-radio-button></mat-list-item>
</mat-radio-group>
</div> </div>
<!-- End of Status Filter--> <!-- End of Status Filter-->
<!-- Related Project Filters --> <!-- Related Project Filters -->
<div class="col-10 gray-container"> <div class="col-10 gray-container">
<h6 class="category-title">{{ 'DMP-RELATED-PROJECT.RELATED-PROJECT' | translate}}</h6> <h6 class="category-title">{{'CRITERIA.PROJECTS.LIKE' | translate}}</h6>
<mat-form-field> <mat-form-field>
<input matInput placeholder="Select Organizations"> <app-multiple-auto-complete [formControl]="formGroup.get('projects')"
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('projects')" placeholder="{{'CRITERIA.DATA-SET.SELECT-PROJECTS' | translate }}"
placeholder="{{'CRITERIA.DMP.SELECT-PROJECTS' | translate}}"
[configuration]="projectAutoCompleteConfiguration"> [configuration]="projectAutoCompleteConfiguration">
</app-multiple-auto-complete> --> </app-multiple-auto-complete>
<mat-icon matSuffix class="style-icon">arrow_drop_down</mat-icon> <mat-icon matSuffix class="style-icon">arrow_drop_down</mat-icon>
</mat-form-field> </mat-form-field>
</div> </div>
@ -36,16 +38,16 @@
<!-- Role Filter --> <!-- Role Filter -->
<div class="col-10 gray-container"> <div class="col-10 gray-container">
<h6 class="category-title">{{ 'DATASET-PROFILE-LISTING.COLUMNS.ROLE' | translate }}</h6> <h6 class="category-title">{{'CRITERIA.DATA-SETS.ROLE' | translate }}</h6>
<mat-radio-group aria-label="Select an option"> <mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('role')">
<mat-list-item> <mat-list-item>
<mat-radio-button value="1">{{ 'TYPES.DATASET-ROLE.ANY' | translate }}</mat-radio-button> <mat-radio-button value="null">{{ 'TYPES.DATASET-ROLE.ANY' | translate }}</mat-radio-button>
</mat-list-item> </mat-list-item>
<mat-list-item> <mat-list-item>
<mat-radio-button value="2">{{ 'TYPES.DATASET-ROLE.OWNER' | translate }}</mat-radio-button> <mat-radio-button value="0">{{ 'TYPES.DATASET-ROLE.OWNER' | translate }}</mat-radio-button>
</mat-list-item> </mat-list-item>
<mat-list-item> <mat-list-item>
<mat-radio-button value="3">{{ 'TYPES.DATASET-ROLE.MEMBER' | translate }}</mat-radio-button> <mat-radio-button value="1">{{ 'TYPES.DATASET-ROLE.MEMBER' | translate }}</mat-radio-button>
</mat-list-item> </mat-list-item>
</mat-radio-group> </mat-radio-group>
</div> </div>
@ -53,13 +55,12 @@
<!-- Related Organization Filter --> <!-- Related Organization Filter -->
<div class="col-10 gray-container"> <div class="col-10 gray-container">
<h6 class="category-title">RELATED ORGANIZATION</h6> <h6 class="category-title">{{'CRITERIA.DATA-SETS.ORGANIZATION' | translate }}</h6>
<mat-form-field> <mat-form-field>
<input matInput placeholder="Select Organizations"> <app-multiple-auto-complete [formControl]="formGroup.get('organisations')"
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('projects')" placeholder="{{'CRITERIA.DATA-SETS.SELECT-ORGANIZATIONS' | translate}}"
placeholder="Select Organizations" [configuration]="organisationAutoCompleteConfiguration">
[configuration]="projectAutoCompleteConfiguration"> </app-multiple-auto-complete>
</app-multiple-auto-complete> -->
<mat-icon matSuffix class="style-icon">arrow_drop_down</mat-icon> <mat-icon matSuffix class="style-icon">arrow_drop_down</mat-icon>
</mat-form-field> </mat-form-field>
</div> </div>

View File

@ -25,6 +25,11 @@ import { UiNotificationService, SnackBarNotificationLevel } from '../../../../co
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms'; 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({ @Component({
selector: 'app-dataset-criteria-component', selector: 'app-dataset-criteria-component',
@ -42,11 +47,11 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
options: FormGroup; options: FormGroup;
public formGroup = new FormBuilder().group({ public formGroup = new FormBuilder().group({
like: new FormControl() like: new FormControl(),
// projects: new FormControl(), projects: new FormControl(),
// status: new FormControl(), status: new FormControl(),
// role: new FormControl(), role: new FormControl(),
// organisations: new FormControl() organisations: new FormControl()
}); });
tagsAutoCompleteConfiguration = { tagsAutoCompleteConfiguration = {
@ -63,6 +68,20 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
titleFn: (item) => item['label'] 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( constructor(
private externalSourcesService: ExternalSourcesService, private externalSourcesService: ExternalSourcesService,
public enumUtils: EnumUtils, public enumUtils: EnumUtils,
@ -73,15 +92,15 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
private uiNotificationService: UiNotificationService, private uiNotificationService: UiNotificationService,
private router: Router, private router: Router,
private language: TranslateService, private language: TranslateService,
public projectService: ProjectService,
private organisationService: OrganisationService,
fb: FormBuilder fb: FormBuilder
) { ) {
super(new ValidationErrorModel()); super(new ValidationErrorModel());
this.options = fb.group({ // this.options = fb.group({
getDrafts: false, // status: new FormControl(),
getFinalized: false, // floatLabel: 'auto',
getDmpStatuses: false, // });
floatLabel: 'auto',
});
} }
ngOnInit() { ngOnInit() {
@ -89,16 +108,26 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
this.formGroup.get('like').valueChanges this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(x => this.controlModified()); .subscribe(x => this.controlModified());
// this.formGroup.get('projects').valueChanges this.formGroup.get('projects').valueChanges
// .pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
// .subscribe(x => this.controlModified()); .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 = {}; } // if (this.criteria == null) { this.criteria = {}; }
} }
setCriteria(criteria: DatasetCriteria): void { setCriteria(criteria: DatasetCriteria): void {
this.formGroup.get('like').patchValue(criteria.like); this.formGroup.get('like').patchValue(criteria.like);
this.formGroup.get('status').patchValue(criteria.like);
// this.formGroup.get('projects').patchValue(criteria.projects); // this.formGroup.get('projects').patchValue(criteria.projects);
this.formGroup.get('role').patchValue(criteria.like);
// this.criteria = criteria; // this.criteria = criteria;
} }
@ -136,6 +165,25 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete"); return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete");
} }
filterProject(query: string) {
const fields: Array<string> = new Array<string>();
fields.push('asc');
const projectRequestItem: DataTableRequest<ProjectCriteria> = 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<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.searchInternalOrganisations(dataTableRequest).map(x => x.data);
}
fileImport(event) { fileImport(event) {
const dialogRef = this.dialog.open(DatasetUploadDialogue, { const dialogRef = this.dialog.open(DatasetUploadDialogue, {
data: { data: {

View File

@ -78,7 +78,22 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
let fields: Array<string> = new Array(); let fields: Array<string> = new Array();
if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; } if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; }
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields }); const request = new DataTableRequest<DatasetCriteria>(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) { // if (this.itemId) {
// // request.criteria.groupIds = [this.itemId]; // // request.criteria.groupIds = [this.itemId];
// request.criteria.allVersions = true; // request.criteria.allVersions = true;
@ -87,7 +102,6 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
if (!result) { return []; } if (!result) { return []; }
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
this.listingItems = result.data; this.listingItems = result.data;
console.log(result);
}); });
} }

View File

@ -34,7 +34,6 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
sizeError = false; sizeError = false;
maxFileSize: number = 1048576; maxFileSize: number = 1048576;
filteringOrganisationsAsync = false; filteringOrganisationsAsync = false;
filteredOrganisations: ExternalSourceItemModel[];
filteredProjects: ProjectListingModel[]; filteredProjects: ProjectListingModel[];
public formGroup = new FormBuilder().group({ public formGroup = new FormBuilder().group({
@ -119,7 +118,6 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
} }
filterOrganisations(value: string) { filterOrganisations(value: string) {
this.filteredOrganisations = undefined;
this.filteringOrganisationsAsync = true; this.filteringOrganisationsAsync = true;
const fields: Array<string> = new Array<string>(); const fields: Array<string> = new Array<string>();
fields.push('asc'); fields.push('asc');

View File

@ -483,7 +483,11 @@
"STATUS": "Status", "STATUS": "Status",
"NONE": "-", "NONE": "-",
"TAGS": "Tags", "TAGS": "Tags",
"LIKE": "Search Datasets" "LIKE": "Search Datasets",
"SELECT-PROJECTS": "Select Projects",
"ROLE": "Role",
"ORGANIZATION": "Organization",
"SELECT-ORGANIZATIONS": "Select Organizations"
}, },
"DMP": { "DMP": {
"LIKE": "Search DMPs", "LIKE": "Search DMPs",