From d3659aad245f9582487a4e92aaf09cf8cb271140 Mon Sep 17 00:00:00 2001 From: amentis Date: Tue, 20 Feb 2024 11:37:09 +0200 Subject: [PATCH] add semantics to dmp blueprint --- .../types/dmpblueprint/FieldEntity.java | 12 +++++++++++ .../dmpblueprintdefinition/FieldBuilder.java | 1 + .../model/dmpblueprintdefinition/Field.java | 12 +++++++++++ .../dmpblueprintdefinition/FieldPersist.java | 11 ++++++++++ .../dmpblueprint/DmpBlueprintServiceImpl.java | 1 + .../core/model/dmp-blueprint/dmp-blueprint.ts | 2 ++ .../description-template.service.ts | 14 +++++++++++++ ...ption-template-editor-field.component.html | 2 +- ...ription-template-editor-field.component.ts | 20 ------------------- .../dmp-blueprint-editor.component.html | 9 +++++++++ .../editor/dmp-blueprint-editor.model.ts | 6 +++++- .../editor/dmp-blueprint-editor.resolver.ts | 1 + dmp-frontend/src/assets/i18n/en.json | 1 + 13 files changed, 70 insertions(+), 22 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/FieldEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/FieldEntity.java index ee78485a9..53f3d575b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/FieldEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/FieldEntity.java @@ -5,6 +5,7 @@ import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAttribute; +import java.util.List; import java.util.UUID; @XmlAccessorType(XmlAccessType.FIELD) @@ -24,6 +25,9 @@ public abstract class FieldEntity { @XmlAttribute(name="description") private String description; + @XmlAttribute(name="semantics") + private List semantics; + @XmlAttribute(name="ordinal") private Integer ordinal; @@ -65,6 +69,14 @@ public abstract class FieldEntity { this.description = description; } + public List getSemantics() { + return semantics; + } + + public void setSemantics(List semantics) { + this.semantics = semantics; + } + public Integer getOrdinal() { return ordinal; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/FieldBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/FieldBuilder.java index db4492ef4..bbbcc2072 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/FieldBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/FieldBuilder.java @@ -51,6 +51,7 @@ public abstract class FieldBuilder semantics; + public final static String _semantics = "semantics"; private Integer ordinal; public final static String _required = "required"; @@ -67,6 +71,14 @@ public abstract class Field { this.description = description; } + public List getSemantics() { + return semantics; + } + + public void setSemantics(List semantics) { + this.semantics = semantics; + } + public Integer getOrdinal() { return ordinal; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/FieldPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/FieldPersist.java index ad72cd0e0..ecfe4cfeb 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/FieldPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/FieldPersist.java @@ -45,6 +45,9 @@ public abstract class FieldPersist { private String description; + private List semantics = null; + public final static String _semantics = "semantics"; + private Integer ordinal = null; public static final String _ordinal = "ordinal"; @@ -85,6 +88,14 @@ public abstract class FieldPersist { this.placeholder = placeholder; } + public List getSemantics() { + return semantics; + } + + public void setSemantics(List semantics) { + this.semantics = semantics; + } + public String getDescription() { return description; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java index 3f04c8499..33fc249db 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java @@ -275,6 +275,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { data.setLabel(persist.getLabel()); data.setPlaceholder(persist.getPlaceholder()); data.setDescription(persist.getDescription()); + data.setSemantics(persist.getSemantics()); data.setOrdinal(persist.getOrdinal()); data.setRequired(persist.getRequired()); diff --git a/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts b/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts index 30ace1679..7398dcbff 100644 --- a/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts +++ b/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts @@ -43,6 +43,7 @@ export interface FieldInSection { label: string; placeholder: string; description: string; + semantics: string[]; required: boolean; ordinal: number; } @@ -101,6 +102,7 @@ export interface FieldInSectionPersist { label: string; placeholder: string; description: string; + semantics: string[]; required: boolean; ordinal: number; } diff --git a/dmp-frontend/src/app/core/services/description-template/description-template.service.ts b/dmp-frontend/src/app/core/services/description-template/description-template.service.ts index 1174d2f0b..46deab175 100644 --- a/dmp-frontend/src/app/core/services/description-template/description-template.service.ts +++ b/dmp-frontend/src/app/core/services/description-template/description-template.service.ts @@ -198,4 +198,18 @@ export class DescriptionTemplateService { if (like) { lookup.like = this.filterService.transformLike(like); } return lookup; } + + // Semantics Autocomplete + semanticsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { + initialItems: (data?: any) => this.searchSemantics(this.buildSemanticsAutocompleteLookup()).pipe(map(x => x)), + filterFn: (searchQuery: string, data?: any) => this.searchSemantics(this.buildSemanticsAutocompleteLookup(searchQuery)).pipe(map(x => x)), + displayFn: (item) => item, + titleFn: (item) => item, + } + + private buildSemanticsAutocompleteLookup(like?: string ): DescriptionTemplateSemanticsLookup { + const lookup: DescriptionTemplateSemanticsLookup = new DescriptionTemplateSemanticsLookup(); + if (like) { lookup.like = this.filterService.transformLike(like); } + return lookup; + } } diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html index 294de9085..b182b4ae1 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.html @@ -136,7 +136,7 @@ {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.SEMANTICS' | translate}} - + {{form.get('schematics').getError('backendError').message}} diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts index 7a1269635..dfd9e700e 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field/description-template-editor-field.component.ts @@ -20,13 +20,11 @@ import { DescriptionTemplateFieldPersist } from '@app/core/model/description-tem import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { BaseComponent } from '@common/base/base.component'; import { Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel } from '../../description-template-editor.model'; import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { DescriptionTemplateSemanticsLookup } from '@app/core/query/description-template-semantics.lookup'; import { FilterService } from '@common/modules/text-filter/filter-service'; @Component({ @@ -52,24 +50,6 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple readonly separatorKeysCodes: number[] = [ENTER, COMMA]; - semanticsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - initialItems: (data?: any) => this.descriptionTemplateService.searchSemantics(this.buildAutocompleteLookup()).pipe(map(x => x)), - filterFn: (searchQuery: string, data?: any) => this.descriptionTemplateService.searchSemantics(this.buildAutocompleteLookup(searchQuery)).pipe(map(x => x)), - displayFn: (item) => item, - titleFn: (item) => item, - } - - // filterSemantics(value: string): Observable { - // // return this.descriptionTemplateService.searchSemantics(value); - // return of([]); - // } - - private buildAutocompleteLookup(like?: string ): DescriptionTemplateSemanticsLookup { - const lookup: DescriptionTemplateSemanticsLookup = new DescriptionTemplateSemanticsLookup(); - if (like) { lookup.like = this.filterService.transformLike(like); } - return lookup; - } - constructor( public enumUtils: EnumUtils, public descriptionTemplateService: DescriptionTemplateService, diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html index b607f1573..833cdff0a 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html @@ -160,6 +160,15 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
+ + {{'DMP-BLUEPRINT-EDITOR.FIELDS.SEMANTICS' | translate}} + + + {{field.get('semantics').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}} {{field.get('required').getError('backendError').message}} diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts index 7bd00dead..afd72f7ce 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts @@ -297,6 +297,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist { public label: string; public placeholder: string; public description: string; + public semantics: string[]; public required: boolean = false; public ordinal: number; public dataType: DmpBlueprintExtraFieldDataType; @@ -315,6 +316,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist { this.label = item.label; this.placeholder = item.placeholder; this.description = item.description; + this.semantics = item.semantics; this.required = item.required; this.ordinal = item.ordinal; @@ -350,6 +352,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist { placeholder: [{ value: this.placeholder, disabled: disabled }, context.getValidation('placeholder').validators], description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], required: [{ value: this.required, disabled: disabled }, context.getValidation('required').validators], + semantics: [{ value: this.semantics, disabled: disabled }, context.getValidation('semantics').validators], ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators], dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').validators], systemFieldType: [{ value: this.systemFieldType, disabled: disabled }, context.getValidation('systemFieldType').validators], @@ -372,6 +375,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist { baseValidationArray.push({ key: 'label-extra', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] }); baseValidationArray.push({ key: 'placeholder', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}placeholder`)] }); baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] }); + baseValidationArray.push({ key: 'semantics', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}semantics`)] }); baseValidationArray.push({ key: 'required', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}required`)] }); baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] }); baseValidationArray.push({ key: 'dataType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] }); @@ -394,7 +398,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist { validationErrorModel }); - ['id', 'category', 'dataType', 'systemFieldType', 'referenceTypeId', 'label', 'placeholder', 'description', 'required', 'ordinal'].forEach(keyField => { + ['id', 'category', 'dataType', 'systemFieldType', 'referenceTypeId', 'label', 'placeholder', 'description', 'semantics', 'required', 'ordinal'].forEach(keyField => { const control = formGroup?.get(keyField); control?.clearValidators(); if (keyField == 'label') { diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts index c9d62e2ce..f80098b14 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts @@ -34,6 +34,7 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.semantics)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 2d81beefb..182266241 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1609,6 +1609,7 @@ "DATA-TYPE": "Data Type", "CATEGORY": "Field Type", "FIELD-REQUIRED": "Required", + "SEMANTICS": "Semantics", "DESCRIPTION-TEMPLATES": "Description Templates", "DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE-LABEL": "Label",