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

View File

@ -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[] = [];
}

View File

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

View File

@ -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,15 +92,15 @@ 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() {
@ -89,16 +108,26 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
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());
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<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) {
const dialogRef = this.dialog.open(DatasetUploadDialogue, {
data: {

View File

@ -78,7 +78,22 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
let fields: Array<string> = new Array();
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 });
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);
});
}

View File

@ -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<string> = new Array<string>();
fields.push('asc');

View File

@ -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",