diff --git a/backend/core/pom.xml b/backend/core/pom.xml index 754a12321..49bb470e8 100644 --- a/backend/core/pom.xml +++ b/backend/core/pom.xml @@ -57,12 +57,12 @@ org.opencdmp repositorydepositbase - 2.0.16 + 1.0.0-dev org.opencdmp common-models - 0.0.19 + 1.0.0-dev gr.cite @@ -72,7 +72,7 @@ org.opencdmp file-transformer-base - 0.0.24 + 1.0.0-dev gr.cite diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/description/PropertyDefinitionFieldSetEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/description/PropertyDefinitionFieldSetEntity.java index ea90ad4f5..b830322d1 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/description/PropertyDefinitionFieldSetEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/description/PropertyDefinitionFieldSetEntity.java @@ -5,6 +5,8 @@ import java.util.List; public class PropertyDefinitionFieldSetEntity { private List items; + private String comment; + public List getItems() { return this.items; } @@ -12,4 +14,12 @@ public class PropertyDefinitionFieldSetEntity { public void setItems(List items) { this.items = items; } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionPropertyDefinitionFieldSetImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionPropertyDefinitionFieldSetImportExport.java index c8a500b34..88654b70e 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionPropertyDefinitionFieldSetImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionPropertyDefinitionFieldSetImportExport.java @@ -16,6 +16,9 @@ public class DescriptionPropertyDefinitionFieldSetImportExport { @XmlElement(name = "item") private List items; + @XmlElement(name = "comment") + private String comment; + public List getItems() { return this.items; } @@ -31,4 +34,12 @@ public class DescriptionPropertyDefinitionFieldSetImportExport { public void setFieldSetId(String fieldSetId) { this.fieldSetId = fieldSetId; } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionPropertyDefinitionFieldSetItemImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionPropertyDefinitionFieldSetItemImportExport.java index 73f3d45b2..d9bef65da 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionPropertyDefinitionFieldSetItemImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionPropertyDefinitionFieldSetItemImportExport.java @@ -14,8 +14,6 @@ public class DescriptionPropertyDefinitionFieldSetItemImportExport { @XmlElementWrapper(name = "fields") @XmlElement(name = "field") private List fields; - @XmlElement(name = "comment") - private String comment; @XmlElement(name = "ordinal") private int ordinal; @@ -27,14 +25,6 @@ public class DescriptionPropertyDefinitionFieldSetItemImportExport { this.fields = fields; } - public String getComment() { - return this.comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - public int getOrdinal() { return this.ordinal; } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/PropertyDefinitionFieldSetCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/PropertyDefinitionFieldSetCommonModelBuilder.java index f5f265f63..16a88b2e2 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/PropertyDefinitionFieldSetCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/PropertyDefinitionFieldSetCommonModelBuilder.java @@ -57,6 +57,7 @@ public class PropertyDefinitionFieldSetCommonModelBuilder extends BaseCommonMode List> models = new ArrayList<>(); for (PropertyDefinitionFieldSetEntity d : data) { PropertyDefinitionFieldSetModel m = new PropertyDefinitionFieldSetModel(); + m.setComment(d.getComment()); if (d.getItems() != null) m.setItems(this.builderFactory.builder(PropertyDefinitionFieldSetItemModelCommonModelBuilder.class).useSharedStorage(useSharedStorage).withFieldSetEntity(this.fieldSetEntity).authorize(this.authorize).build(d.getItems())); models.add(new CommonModelBuilderItemResponse<>(m, d)); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/PropertyDefinitionFieldSetItemModelCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/PropertyDefinitionFieldSetItemModelCommonModelBuilder.java index 95523c825..36253b1c5 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/PropertyDefinitionFieldSetItemModelCommonModelBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/PropertyDefinitionFieldSetItemModelCommonModelBuilder.java @@ -61,7 +61,6 @@ public class PropertyDefinitionFieldSetItemModelCommonModelBuilder extends BaseC for (PropertyDefinitionFieldSetItemEntity d : data) { PropertyDefinitionFieldSetItemModel m = new PropertyDefinitionFieldSetItemModel(); - m.setComment(d.getComment()); m.setOrdinal(d.getOrdinal()); if (d.getFields() != null && !d.getFields().isEmpty()) { m.setFields(new HashMap<>()); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/description/PropertyDefinitionFieldSetBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/description/PropertyDefinitionFieldSetBuilder.java index df111db92..4a775b72c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/description/PropertyDefinitionFieldSetBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/description/PropertyDefinitionFieldSetBuilder.java @@ -58,6 +58,7 @@ public class PropertyDefinitionFieldSetBuilder extends BaseBuilder items; + public final static String _comment = "comment"; + private String comment; + public List getItems() { return items; } @@ -14,4 +17,12 @@ public class PropertyDefinitionFieldSet { public void setItems(List items) { this.items = items; } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/descriptionproperties/PropertyDefinitionFieldSetItemPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/descriptionproperties/PropertyDefinitionFieldSetItemPersist.java index 1cf180d86..9de70b06b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/descriptionproperties/PropertyDefinitionFieldSetItemPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/descriptionproperties/PropertyDefinitionFieldSetItemPersist.java @@ -25,9 +25,6 @@ public class PropertyDefinitionFieldSetItemPersist { public final static String _fields = "fields"; private Map fields; - public final static String _comment = "comment"; - private String comment; - public final static String _ordinal = "ordinal"; private Integer ordinal = null; @@ -39,14 +36,6 @@ public class PropertyDefinitionFieldSetItemPersist { this.fields = fields; } - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - public Integer getOrdinal() { return ordinal; } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/descriptionproperties/PropertyDefinitionFieldSetPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/descriptionproperties/PropertyDefinitionFieldSetPersist.java index 1799ff4f9..bea116506 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/descriptionproperties/PropertyDefinitionFieldSetPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/descriptionproperties/PropertyDefinitionFieldSetPersist.java @@ -23,6 +23,9 @@ public class PropertyDefinitionFieldSetPersist { public final static String _items = "items"; private List items; + public final static String _comment = "comment"; + private String comment; + public List getItems() { return items; } @@ -31,6 +34,14 @@ public class PropertyDefinitionFieldSetPersist { this.items = items; } + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + @Component(PersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public static class PersistValidator extends BaseValidator { diff --git a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java index 8bd44b609..3acd35912 100644 --- a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java @@ -543,6 +543,7 @@ public class DescriptionServiceImpl implements DescriptionService { private @NotNull PropertyDefinitionFieldSetEntity buildPropertyDefinitionFieldSetEntity(PropertyDefinitionFieldSetPersist persist, FieldSetEntity fieldSetEntity, Map> fieldToReferenceMap, VisibilityService visibilityService) throws InvalidApplicationException { PropertyDefinitionFieldSetEntity data = new PropertyDefinitionFieldSetEntity(); if (persist == null) return data; + data.setComment(persist.getComment()); if (!this.conventionService.isListNullOrEmpty(persist.getItems())){ data.setItems(new ArrayList<>()); for (PropertyDefinitionFieldSetItemPersist itemsPersist: persist.getItems()) { @@ -557,7 +558,6 @@ public class DescriptionServiceImpl implements DescriptionService { if (persist == null) return data; if (persist.getFields() != null && !persist.getFields().isEmpty()){ data.setOrdinal(persist.getOrdinal()); - data.setComment(persist.getComment()); data.setFields(new HashMap<>()); for (String key: persist.getFields().keySet()) { org.opencdmp.commons.types.descriptiontemplate.FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getFieldById(key).stream().findFirst().orElse(null) : null; @@ -1069,6 +1069,7 @@ public class DescriptionServiceImpl implements DescriptionService { private @NotNull PropertyDefinitionFieldSetPersist buildPropertyDefinitionFieldSetPersist(PropertyDefinitionFieldSetEntity data, FieldSetEntity fieldSetEntity, List references){ PropertyDefinitionFieldSetPersist persist = new PropertyDefinitionFieldSetPersist(); if (data == null) return persist; + persist.setComment(data.getComment()); if (!this.conventionService.isListNullOrEmpty(data.getItems())){ persist.setItems(new ArrayList<>()); for (PropertyDefinitionFieldSetItemEntity itemsPersist: data.getItems()) { @@ -1083,7 +1084,6 @@ public class DescriptionServiceImpl implements DescriptionService { if (data == null) return persist; if (data.getFields() != null && !data.getFields().isEmpty()){ persist.setOrdinal(data.getOrdinal()); - persist.setComment(data.getComment()); persist.setFields(new HashMap<>()); for (String key: data.getFields().keySet()) { org.opencdmp.commons.types.descriptiontemplate.FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getFieldById(key).stream().findFirst().orElse(null) : null; @@ -1314,6 +1314,7 @@ public class DescriptionServiceImpl implements DescriptionService { xml.setFieldSetId(fieldSetId); if (entity == null) return xml; + xml.setComment(entity.getComment()); if (entity.getItems() != null && !entity.getItems().isEmpty()) { List exports = new LinkedList<>(); for (PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity : entity.getItems()) { @@ -1329,7 +1330,6 @@ public class DescriptionServiceImpl implements DescriptionService { DescriptionPropertyDefinitionFieldSetItemImportExport xml = new DescriptionPropertyDefinitionFieldSetItemImportExport(); if (entity == null) return xml; - xml.setComment(entity.getComment()); xml.setOrdinal(entity.getOrdinal()); if (entity.getFields() != null && !entity.getFields().isEmpty()) { List exports = new LinkedList<>(); @@ -1463,7 +1463,7 @@ public class DescriptionServiceImpl implements DescriptionService { return null; PropertyDefinitionFieldSetPersist persist = new PropertyDefinitionFieldSetPersist(); - + persist.setComment(importXml.getComment()); if (!this.conventionService.isListNullOrEmpty(importXml.getItems())){ List items = new ArrayList<>(); for (DescriptionPropertyDefinitionFieldSetItemImportExport fieldSetItem: importXml.getItems()) { @@ -1481,8 +1481,6 @@ public class DescriptionServiceImpl implements DescriptionService { return null; PropertyDefinitionFieldSetItemPersist persist = new PropertyDefinitionFieldSetItemPersist(); - - persist.setComment(importXml.getComment()); persist.setOrdinal(importXml.getOrdinal()); Map fields = new HashMap<>(); @@ -1675,7 +1673,7 @@ public class DescriptionServiceImpl implements DescriptionService { return null; PropertyDefinitionFieldSetPersist persist = new PropertyDefinitionFieldSetPersist(); - + persist.setComment(commonModel.getComment()); if (!this.conventionService.isListNullOrEmpty(commonModel.getItems())){ List items = new ArrayList<>(); for (PropertyDefinitionFieldSetItemModel fieldSetItem: commonModel.getItems()) { @@ -1695,7 +1693,6 @@ public class DescriptionServiceImpl implements DescriptionService { PropertyDefinitionFieldSetItemPersist persist = new PropertyDefinitionFieldSetItemPersist(); - persist.setComment(commonModel.getComment()); persist.setOrdinal(commonModel.getOrdinal()); Map fields = new HashMap<>(); diff --git a/frontend/src/app/core/model/description/description.ts b/frontend/src/app/core/model/description/description.ts index dacfd5f27..2838f02e2 100644 --- a/frontend/src/app/core/model/description/description.ts +++ b/frontend/src/app/core/model/description/description.ts @@ -29,11 +29,11 @@ export interface DescriptionPropertyDefinition { export interface DescriptionPropertyDefinitionFieldSet { items?: DescriptionPropertyDefinitionFieldSetItem[]; + comment?: string; } export interface DescriptionPropertyDefinitionFieldSetItem { fields?: Map; - comment?: string; ordinal?: number; } @@ -88,11 +88,11 @@ export interface DescriptionPropertyDefinitionPersist { export interface DescriptionPropertyDefinitionFieldSetPersist { items?: DescriptionPropertyDefinitionFieldSetItemPersist[]; + comment?: string; } export interface DescriptionPropertyDefinitionFieldSetItemPersist { fields?: Map; - comment?: string; ordinal?: number; } diff --git a/frontend/src/app/ui/description/editor/description-editor.model.ts b/frontend/src/app/ui/description/editor/description-editor.model.ts index 4c1e409f6..d33f5d3a0 100644 --- a/frontend/src/app/ui/description/editor/description-editor.model.ts +++ b/frontend/src/app/ui/description/editor/description-editor.model.ts @@ -268,6 +268,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp export class DescriptionPropertyDefinitionFieldSetEditorModel implements DescriptionPropertyDefinitionFieldSetPersist { items?: DescriptionPropertyDefinitionFieldSetItemEditorModel[] = []; + comment?: string; protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); fieldSetDefinition: DescriptionTemplateFieldSet; @@ -279,6 +280,7 @@ export class DescriptionPropertyDefinitionFieldSetEditorModel implements Descrip public fromModel(item: DescriptionPropertyDefinitionFieldSet, descriptionReferences: DescriptionReference[], definitionFieldSet: DescriptionTemplateFieldSet): DescriptionPropertyDefinitionFieldSetEditorModel { this.fieldSetDefinition = definitionFieldSet; if (item) { + this.comment = item.comment; if (item.items) { item.items.sort(x=> x.ordinal).map(x => this.items.push(new DescriptionPropertyDefinitionFieldSetItemEditorModel(this.validationErrorModel).fromModel(x, descriptionReferences, definitionFieldSet))); } } return this; @@ -307,7 +309,8 @@ export class DescriptionPropertyDefinitionFieldSetEditorModel implements Descrip visibilityRulesService: params.visibilityRulesService }) ), context.getValidation('items').validators - ) + ), + comment: [{ value: this.comment, disabled: disabled }, context.getValidation('comment').validators], }); } @@ -336,6 +339,7 @@ export class DescriptionPropertyDefinitionFieldSetEditorModel implements Descrip } baseValidationArray.push({ key: 'items', validators: validators }); + baseValidationArray.push({ key: 'comment', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}comment`)] }); baseContext.validation = baseValidationArray; return baseContext; } @@ -363,7 +367,6 @@ export class DescriptionPropertyDefinitionFieldSetEditorModel implements Descrip export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements DescriptionPropertyDefinitionFieldSetItemPersist { fields: Map = new Map; - comment?: string; ordinal?: number; protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); @@ -373,7 +376,6 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des public fromModel(item: DescriptionPropertyDefinitionFieldSetItem, descriptionReferences: DescriptionReference[], definitionFieldSet: DescriptionTemplateFieldSet): DescriptionPropertyDefinitionFieldSetItemEditorModel { if (item) { - this.comment = item.comment; this.ordinal = item.ordinal; if (item.fields) { //TODO: don't like it. Find a common way to parse it either its Map or json. @@ -405,7 +407,6 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des } const formGroup = this.formBuilder.group({}); - formGroup.addControl('comment', new FormControl({ value: this.comment, disabled: disabled }, context.getValidation('comment').validators)); formGroup.addControl('ordinal', new FormControl({ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators)); @@ -430,7 +431,6 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des const baseContext: ValidationContext = new ValidationContext(); const baseValidationArray: Validation[] = new Array(); baseValidationArray.push({ key: 'fields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] }); - baseValidationArray.push({ key: 'comment', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}comment`)] }); baseValidationArray.push({ key: 'ordinal', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] }); baseContext.validation = baseValidationArray; @@ -465,7 +465,7 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des }) }); - ['comment', 'ordinal'].forEach(keyField => { + ['ordinal'].forEach(keyField => { const control = formGroup?.get(keyField); control?.clearValidators(); control?.addValidators(context.getValidation(keyField).validators); diff --git a/frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html b/frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html index 08972bc7b..405362dc6 100644 --- a/frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html +++ b/frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html @@ -93,10 +93,9 @@ -
-
- +
+
diff --git a/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts b/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts index bed8915f2..d20972e08 100644 --- a/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts +++ b/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts @@ -65,7 +65,7 @@ export class DescriptionEditorEntityResolver extends BaseEditorResolver { [nameof(x => x.planDescriptionTemplate), nameof(x => x.sectionId)].join('.'), [nameof(x => x.planDescriptionTemplate), nameof(x => x.isActive)].join('.'), - [nameof(x => x.properties), nameof(x => x.fieldSets), nameof(x => x.items), nameof(x => x.comment)].join('.'), + [nameof(x => x.properties), nameof(x => x.fieldSets), nameof(x => x.comment)].join('.'), [nameof(x => x.properties), nameof(x => x.fieldSets), nameof(x => x.items), nameof(x => x.ordinal)].join('.'), [nameof(x => x.properties), nameof(x => x.fieldSets), nameof(x => x.items), nameof(x => x.fields), nameof(x => x.textValue)].join('.'), [nameof(x => x.properties), nameof(x => x.fieldSets), nameof(x => x.items), nameof(x => x.fields), nameof(x => x.textListValue)].join('.'),