Fixes Visibility Criteria on DMP listing.

This commit is contained in:
gkolokythas 2019-05-07 12:30:03 +03:00
parent caa6be46d8
commit c0a780086c
5 changed files with 84 additions and 46 deletions

View File

@ -1,6 +1,7 @@
package eu.eudat.data.dao.criteria; package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Organisation;
import eu.eudat.data.entities.Project; import eu.eudat.data.entities.Project;
import java.util.Date; import java.util.Date;
@ -10,39 +11,14 @@ import java.util.UUID;
public class DataManagementPlanCriteria extends Criteria<DMP> { public class DataManagementPlanCriteria extends Criteria<DMP> {
private Date periodStart; private Date periodStart;
private Date periodEnd; private Date periodEnd;
private List<eu.eudat.data.entities.Project> projects;
private boolean allVersions; private boolean allVersions;
private List<UUID> groupIds; private List<UUID> groupIds;
private Integer status;
private List<eu.eudat.data.entities.Project> projects;
public boolean getAllVersions() {
return allVersions;
}
public void setAllVersions(boolean allVersions) {
this.allVersions = allVersions;
}
public List<UUID> getGroupIds() {
return groupIds;
}
public void setGroupIds(List<UUID> groupIds) {
this.groupIds = groupIds;
}
public Date getPeriodStart() { public Date getPeriodStart() {
return periodStart; return periodStart;
} }
public List<Project> getProjects() {
return projects;
}
public void setProjects(List<Project> projects) {
this.projects = projects;
}
public void setPeriodStart(Date periodStart) { public void setPeriodStart(Date periodStart) {
this.periodStart = periodStart; this.periodStart = periodStart;
} }
@ -50,9 +26,35 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
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;
} }
public List<Project> getProjects() {
return projects;
}
public void setProjects(List<Project> projects) {
this.projects = projects;
}
public boolean getAllVersions() {
return allVersions;
}
public void setAllVersions(boolean allVersions) {
this.allVersions = allVersions;
}
public List<UUID> getGroupIds() {
return groupIds;
}
public void setGroupIds(List<UUID> groupIds) {
this.groupIds = groupIds;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
} }

View File

@ -45,6 +45,14 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class))); nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty()) if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds())); query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
if (criteria.getStatus() != null) {
if (criteria.getStatus() == DMP.DMPStatus.FINALISED.getValue()){
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.FINALISED.getValue()));
}
else if (criteria.getStatus() == DMP.DMPStatus.ACTIVE.getValue()){
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
}
}
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue())); query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
return query; return query;
} }

View File

@ -5,4 +5,5 @@ export class DmpCriteria extends BaseCriteria {
public projects: ProjectListingModel[] = []; public projects: ProjectListingModel[] = [];
public groupIds: string[]; public groupIds: string[];
public allVersions: boolean; public allVersions: boolean;
public status?: number;
} }

View File

@ -4,8 +4,8 @@
<div class="row" style="justify-content: center;"> <div class="row" style="justify-content: center;">
<!-- 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.DMP.LIKE'| translate}}" name="likeCriteria"
[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>
@ -15,10 +15,10 @@
<!-- Visibility Filter--> <!-- Visibility Filter-->
<div *ngIf="showProject" class="col-10 filter-category"> <div *ngIf="showProject" class="col-10 filter-category">
<h6 class="category-title">{{ 'TYPES.DMP-VISIBILITY.VISIBILITY' | translate }}</h6> <h6 class="category-title">{{ 'TYPES.DMP-VISIBILITY.VISIBILITY' | translate }}</h6>
<mat-radio-group aria-label="Select an option"> <mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('status')">
<mat-list-item><mat-radio-button value="1">{{ 'TYPES.DMP-VISIBILITY.ANY' | translate }}</mat-radio-button></mat-list-item> <mat-list-item><mat-radio-button value="null">{{ 'TYPES.DMP-VISIBILITY.ANY' | translate }}</mat-radio-button></mat-list-item>
<mat-list-item><mat-radio-button value="2">{{ 'TYPES.DMP-VISIBILITY.PUBLIC' | translate }}</mat-radio-button></mat-list-item> <mat-list-item><mat-radio-button value="1">{{ 'TYPES.DMP-VISIBILITY.PUBLIC' | translate }}</mat-radio-button></mat-list-item>
<mat-list-item><mat-radio-button value="3">{{ 'TYPES.DMP-VISIBILITY.PRIVATE' | translate }}</mat-radio-button></mat-list-item> <mat-list-item><mat-radio-button value="0">{{ 'TYPES.DMP-VISIBILITY.PRIVATE' | translate }}</mat-radio-button></mat-list-item>
</mat-radio-group> </mat-radio-group>
</div> </div>
<!-- End of Visibility Filter--> <!-- End of Visibility Filter-->
@ -65,11 +65,10 @@
<div *ngIf="showProject" class="col-10 filter-category"> <div *ngIf="showProject" class="col-10 filter-category">
<h6 class="category-title">{{ 'DMP-RELATED-ORGANIZATION.RELATED-ORGANIZATION' | translate }}</h6> <h6 class="category-title">{{ 'DMP-RELATED-ORGANIZATION.RELATED-ORGANIZATION' | translate }}</h6>
<mat-form-field> <mat-form-field>
<input matInput placeholder="{{ 'DMP-RELATED-ORGANIZATION.SELECT-ORGANIZATIONS' | translate }}"> <app-multiple-auto-complete [formControl]="formGroup.get('organisations')"
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('projects')" placeholder="{{'DMP-RELATED-ORGANIZATION.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

@ -14,6 +14,9 @@ import { DataTableRequest } from '../../../../core/model/data-table/data-table-r
import { DmpService } from '../../../../core/services/dmp/dmp.service'; import { DmpService } from '../../../../core/services/dmp/dmp.service';
import { MatDialog } from '@angular/material'; import { MatDialog } from '@angular/material';
import { DmpUploadDialogue } from './upload-dialogue/dmp-upload-dialogue.component'; import { DmpUploadDialogue } from './upload-dialogue/dmp-upload-dialogue.component';
import { Observable } from 'rxjs';
import { ExternalSourceItemModel } from '../../../../core/model/external-sources/external-source-item';
import { ExternalSourcesService } from '../../../../core/services/external-sources/external-sources.service';
@Component({ @Component({
selector: 'app-dmp-criteria-component', selector: 'app-dmp-criteria-component',
@ -26,14 +29,17 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
filteringProjectsAsync = false; filteringProjectsAsync = false;
sizeError = false; sizeError = false;
maxFileSize: number = 1048576; maxFileSize: number = 1048576;
filteringOrganisationsAsync = false;
options: FormGroup; filteredOrganisations: ExternalSourceItemModel[];
filteredProjects: ProjectListingModel[]; filteredProjects: ProjectListingModel[];
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(),
organisations: new FormControl()
}); });
projectAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { projectAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
filterFn: this.filterProject.bind(this), filterFn: this.filterProject.bind(this),
initialItems: (excludedItems: any[]) => this.filterProject('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)), initialItems: (excludedItems: any[]) => this.filterProject('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)),
@ -41,12 +47,20 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
titleFn: (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(
public language: TranslateService, public language: TranslateService,
public projectService: ProjectService, public projectService: ProjectService,
private dmpService: DmpService, private dmpService: DmpService,
public formBuilder: FormBuilder, public formBuilder: FormBuilder,
private dialog: MatDialog private dialog: MatDialog,
private externalSourcesService: ExternalSourcesService
) { ) {
super(new ValidationErrorModel()); super(new ValidationErrorModel());
} }
@ -54,6 +68,12 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
ngOnInit() { ngOnInit() {
super.ngOnInit(); super.ngOnInit();
this.formGroup.get('organisations').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('projects').valueChanges this.formGroup.get('projects').valueChanges
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(x => this.controlModified()); .subscribe(x => this.controlModified());
@ -66,6 +86,7 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
setCriteria(criteria: DmpCriteria): void { setCriteria(criteria: DmpCriteria): void {
this.formGroup.get('like').patchValue(criteria.like); this.formGroup.get('like').patchValue(criteria.like);
this.formGroup.get('projects').patchValue(criteria.projects); this.formGroup.get('projects').patchValue(criteria.projects);
this.formGroup.get('status').patchValue(criteria.status);
} }
onCallbackError(error: any) { onCallbackError(error: any) {
@ -77,7 +98,7 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
if (this.refreshCallback != null && if (this.refreshCallback != null &&
(this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2) (this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2)
) { ) {
this.refreshCallback(); setTimeout(() => this.refreshCallback());
} }
} }
@ -90,6 +111,13 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
return this.projectService.getPaged(projectRequestItem, "autocomplete").map(x => x.data); return this.projectService.getPaged(projectRequestItem, "autocomplete").map(x => x.data);
} }
filterOrganisations(value: string): Observable<ExternalSourceItemModel[]> {
this.filteredOrganisations = undefined;
this.filteringOrganisationsAsync = true;
return this.externalSourcesService.searchDMPOrganizations(value);
}
fileSave(event) { fileSave(event) {
const dialogRef = this.dialog.open(DmpUploadDialogue, { const dialogRef = this.dialog.open(DmpUploadDialogue, {
data: { data: {