added description template filter

This commit is contained in:
Sofia Papacharalampous 2024-06-26 12:39:28 +03:00
parent ef5134c629
commit 69f74e48fe
6 changed files with 56 additions and 17 deletions

View File

@ -38,7 +38,10 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
private DmpQuery dmpQuery;
private DescriptionTemplateQuery descriptionTemplateQuery;
private DescriptionReferenceQuery descriptionReferenceQuery;
private DescriptionTagQuery descriptionTagQuery;
private Instant createdAfter;
@ -155,6 +158,11 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
return this;
}
public DescriptionQuery descriptionTemplateSubQuery(DescriptionTemplateQuery subQuery) {
this.descriptionTemplateQuery = subQuery;
return this;
}
public DescriptionQuery descriptionReferenceSubQuery(DescriptionReferenceQuery subQuery) {
this.descriptionReferenceQuery = subQuery;
return this;
@ -344,6 +352,10 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
QueryContext<DmpEntity, UUID> subQuery = this.applySubQuery(this.dmpQuery, queryContext, UUID.class, dmpEntityRoot -> dmpEntityRoot.get(DmpEntity._id));
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpId)).value(subQuery.Query));
}
if (this.descriptionTemplateQuery != null) {
QueryContext<DescriptionTemplateEntity, UUID> subQuery = this.applySubQuery(this.descriptionTemplateQuery, queryContext, UUID.class, descriptionTemplateEntityRoot -> descriptionTemplateEntityRoot.get(DescriptionTemplateEntity._id));
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._descriptionTemplateId)).value(subQuery.Query));
}
if (this.descriptionReferenceQuery != null) {
QueryContext<DescriptionReferenceEntity, UUID> subQuery = this.applySubQuery(this.descriptionReferenceQuery, queryContext, UUID.class, descriptionReferenceEntityRoot -> descriptionReferenceEntityRoot.get(DescriptionReferenceEntity._descriptionId));
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._id)).value(subQuery.Query));

View File

@ -25,6 +25,7 @@ public class DescriptionLookup extends Lookup {
private Instant finalizedBefore;
private DmpLookup dmpSubQuery;
private DescriptionTemplateLookup descriptionTemplateSubQuery;
private DescriptionReferenceLookup descriptionReferenceSubQuery;
private DescriptionTagLookup descriptionTagSubQuery;
@ -76,9 +77,11 @@ public class DescriptionLookup extends Lookup {
return this.dmpSubQuery;
}
public void setDmpSubQuery(DmpLookup dmpSubQuery) {
this.dmpSubQuery = dmpSubQuery;
}
public void setDmpSubQuery(DmpLookup dmpSubQuery) { this.dmpSubQuery = dmpSubQuery; }
public DescriptionTemplateLookup getDescriptionTemplateSubQuery() { return this.descriptionTemplateSubQuery; }
public void setDescriptionTemplateSubQuery(DescriptionTemplateLookup dmpSubQuery) { this.descriptionTemplateSubQuery = dmpSubQuery; }
public DescriptionReferenceLookup getDescriptionReferenceSubQuery() { return this.descriptionReferenceSubQuery; }
@ -126,6 +129,7 @@ public class DescriptionLookup extends Lookup {
if (this.ids != null) query.ids(this.ids);
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
if (this.dmpSubQuery != null) query.dmpSubQuery(this.dmpSubQuery.enrich(queryFactory));
if (this.descriptionTemplateSubQuery != null) query.descriptionTemplateSubQuery(this.descriptionTemplateSubQuery.enrich(queryFactory));
if (this.descriptionReferenceSubQuery != null) query.descriptionReferenceSubQuery(this.descriptionReferenceSubQuery.enrich(queryFactory));
if (this.descriptionTagSubQuery != null) query.descriptionTagSubQuery(this.descriptionTagSubQuery.enrich(queryFactory));
if (this.isActive != null) query.isActive(this.isActive);

View File

@ -7,6 +7,7 @@ import { DmpUserRole } from '../common/enum/dmp-user-role';
import { ReferenceType } from '../model/reference-type/reference-type';
import { DescriptionReferenceLookup } from './reference.lookup';
import { DescriptionTagLookup } from './tag.lookup';
import { DescriptionTemplateLookup } from './description-template.lookup';
export class DescriptionLookup extends Lookup implements DescriptionFilter {
ids: Guid[];
@ -16,16 +17,17 @@ export class DescriptionLookup extends Lookup implements DescriptionFilter {
createdBefore: Date;
finalizedAfter: Date;
finalizedBefore: Date;
dmpSubQuery: DmpLookup;
isActive: IsActive[];
statuses: DescriptionStatus[];
showAllVersions: boolean; //TODO
descriptionTemplateIds: Guid[]; //TODO
roleInDmp: DmpUserRole[]; //TODO
dmpSubQuery: DmpLookup;
descriptionTemplateSubQuery: DescriptionTemplateLookup;
descriptionTagSubQuery: DescriptionTagLookup;
descriptionReferenceSubQuery: DescriptionReferenceLookup;
roleInDmp: DmpUserRole[]; //TODO
showAllVersions: boolean; //TODO
constructor() {
super();
}
@ -39,12 +41,13 @@ export interface DescriptionFilter {
createdBefore: Date;
finalizedAfter: Date;
finalizedBefore: Date;
dmpSubQuery: DmpLookup;
isActive: IsActive[];
statuses: DescriptionStatus[];
showAllVersions: boolean;
descriptionTemplateIds: Guid[];
roleInDmp: DmpUserRole[];
dmpSubQuery: DmpLookup;
descriptionTemplateSubQuery: DescriptionTemplateLookup;
descriptionTagSubQuery: DescriptionTagLookup;
descriptionReferenceSubQuery: DescriptionReferenceLookup;
}

View File

@ -29,7 +29,7 @@
</button>
</div>
</div>
<div *ngIf="listingItems && listingItems.length > 0 || lookup.like || lookup.descriptionTemplateIds || lookup.dmpSubQuery || lookup.roleInDmp || lookup.descriptionTagSubQuery || lookup.descriptionReferenceSubQuery"
<div *ngIf="listingItems && listingItems.length > 0 || lookup.like || lookup.descriptionTemplateSubQuery || lookup.dmpSubQuery || lookup.roleInDmp || lookup.descriptionTagSubQuery || lookup.descriptionReferenceSubQuery"
class="filter-btn" [style.right]="dialog.getDialogById('filters') ? '446px' : '0px'" [style.width]="listingItems.length > 2 ? '57px' : '37px'" (click)="openFiltersDialog()">
<button mat-raised-button class="p-0">
<mat-icon class="mr-4 filter-icon">filter_alt</mat-icon>

View File

@ -41,6 +41,7 @@ import { DescriptionTagLookup } from '@app/core/query/tag.lookup';
import { Tag } from '@app/core/model/tag/tag';
import { D } from '@angular/cdk/keycodes';
import { DmpLookup } from '@app/core/query/dmp.lookup';
import { DescriptionTemplateLookup } from '@app/core/query/description-template.lookup';
@Component({
selector: 'app-description-listing-component',
@ -232,6 +233,19 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
return lookup;
}
protected initializeDescriptionTemplateLookup(): DescriptionTemplateLookup {
const lookup = new DescriptionTemplateLookup();
lookup.metadata = { countAll: true };
lookup.isActive = [IsActive.Active];
lookup.project = {
fields: [
[nameof<Description>(x => x.descriptionTemplate), nameof<DescriptionTemplate>(x => x.id)].join('.'),
]
};
return lookup;
}
protected setupColumns() {
}
@ -409,7 +423,13 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
lookup.statuses = formGroup.get("status")?.value !== null ? [formGroup.get("status")?.value] : null;
lookup.showAllVersions = formGroup.get("showAllVersions")?.value ?? false;
lookup.roleInDmp = formGroup.get("role")?.value !== null ? [formGroup.get("role")?.value] : null;
lookup.descriptionTemplateIds = formGroup.get("descriptionTemplates")?.value ?? null;
// Description Templates
let descriptionTemplates = formGroup.get("descriptionTemplates")?.value ?? null;
if (descriptionTemplates && descriptionTemplates?.length > 0) {
lookup.descriptionTemplateSubQuery = this.initializeDescriptionTemplateLookup();
lookup.descriptionTemplateSubQuery.ids = descriptionTemplates;
} else lookup.descriptionTemplateSubQuery = null;
// Dmps
let dmps = formGroup.get("associatedDmpIds")?.value ?? null;
@ -458,7 +478,7 @@ export class DescriptionListingComponent extends BaseListingComponent<BaseDescri
status: [lookup.statuses?.length > 0 ? lookup.statuses[0] : null],
role: [lookup.roleInDmp?.length > 0 ? lookup.roleInDmp[0] : null],
showAllVersions: [lookup.showAllVersions ?? false],
descriptionTemplates: [lookup.descriptionTemplateIds],
descriptionTemplates: lookup.descriptionTemplateSubQuery?.ids ? [lookup.descriptionTemplateSubQuery?.ids] : [],
associatedDmpIds: lookup.dmpSubQuery?.ids ? [lookup.dmpSubQuery?.ids] : [],
tags: lookup.descriptionTagSubQuery?.tagIds ? [lookup.descriptionTagSubQuery?.tagIds] : [],
references: formArray

View File

@ -5,7 +5,7 @@ import { DescriptionStatus } from '@app/core/common/enum/description-status';
import { ReferenceType } from '@app/core/model/reference-type/reference-type';
import { Reference } from '@app/core/model/reference/reference';
import { AuthService } from '@app/core/services/auth/auth.service';
import { DescriptionTemplateTypeService } from '@app/core/services/description-template-type/description-template-type.service';
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
import { DmpService } from '@app/core/services/dmp/dmp.service';
import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
import { ReferenceService } from '@app/core/services/reference/reference.service';
@ -46,7 +46,7 @@ export class DescriptionFilterComponent extends BaseCriteriaComponent implements
constructor(
public enumUtils: EnumUtils,
private authentication: AuthService,
private descriptionTemplateTypeService: DescriptionTemplateTypeService,
private descriptionTemplateService: DescriptionTemplateService,
private dmpService: DmpService,
private tagService: TagService,
private referenceService: ReferenceService,
@ -64,7 +64,7 @@ export class DescriptionFilterComponent extends BaseCriteriaComponent implements
if (changes['filterFormGroup']) {
this.selectedReferenceTypes = this._buildSelectedReferenceTypes(this.filterFormGroup);
this.descriptionTemplateAutoCompleteConfiguration = this.descriptionTemplateTypeService.getMultipleAutoCompleteSearchConfiguration();
this.descriptionTemplateAutoCompleteConfiguration = this.descriptionTemplateService.multipleAutocompleteConfiguration;
this.dmpAutoCompleteConfiguration = this.dmpService.multipleAutocompleteConfiguration;
this.tagAutoCompleteConfiguration = this.tagService.multipleAutocompleteConfiguration;
this.referenceTypeAutocompleteConfiguration = this.getReferenceTypeAutocompleteConfiguration(this.selectedReferenceTypes);