Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Sofia Papacharalampous 2024-06-11 16:13:04 +03:00
commit c3ee8c68c8
34 changed files with 378 additions and 254 deletions

View File

@ -2,7 +2,6 @@ package org.opencdmp.commons.types.descriptiontemplate.importexport;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opencdmp.commons.xmladapter.InstantXmlAdapter;
@ -11,7 +10,7 @@ import java.time.Instant;
@XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateDefaultValueImportExport {
@XmlAttribute(name="value")
@XmlElement(name="value")
private String textValue;
@XmlElement(name = "dateValue")
@XmlJavaTypeAdapter(InstantXmlAdapter.class)

View File

@ -10,10 +10,10 @@ import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateFieldImportExport {
@XmlAttribute(name = "id")
@XmlElement(name = "id")
private String id;
@XmlAttribute(name = "ordinal")
@XmlElement(name = "ordinal")
private int ordinal;
@XmlElementWrapper(name = "validations")
@ -44,7 +44,7 @@ public class DescriptionTemplateFieldImportExport {
@XmlElement(name = "semantic")
private List<String> semantics;
@XmlAttribute(name="includeInExport")
@XmlElement(name="includeInExport")
private Boolean includeInExport;
public String getId() {
@ -112,7 +112,7 @@ public class DescriptionTemplateFieldImportExport {
}
public Boolean getIncludeInExport() {
return includeInExport;
return this.includeInExport;
}
public void setIncludeInExport(Boolean includeInExport) {

View File

@ -1,6 +1,9 @@
package org.opencdmp.commons.types.descriptiontemplate.importexport;
import jakarta.xml.bind.annotation.*;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.ArrayList;
import java.util.List;
@ -8,28 +11,28 @@ import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateFieldSetImportExport {
@XmlAttribute(name="id")
@XmlElement(name="id")
private String id;
@XmlAttribute(name="ordinal")
@XmlElement(name="ordinal")
private int ordinal;
@XmlElementWrapper(name = "fields")
@XmlElement(name = "field")
private List<DescriptionTemplateFieldImportExport> fields;
@XmlAttribute(name="title")
@XmlElement(name="title")
private String title;
@XmlAttribute(name="description")
@XmlElement(name="description")
private String description;
@XmlAttribute(name="extendedDescription")
@XmlElement(name="extendedDescription")
private String extendedDescription;
@XmlAttribute(name="additionalInformation")
@XmlElement(name="additionalInformation")
private String additionalInformation;
@XmlElement(name="multiplicity")
private DescriptionTemplateMultiplicityImportExport multiplicity;
@XmlAttribute(name="hasMultiplicity")
@XmlElement(name="hasMultiplicity")
private boolean hasMultiplicity;
@XmlAttribute(name="hasCommentField")
@XmlElement(name="hasCommentField")
private Boolean hasCommentField;
public String getId() {

View File

@ -13,13 +13,13 @@ public class DescriptionTemplateImportExport {
@XmlElement(name = "id")
private UUID id;
@XmlAttribute(name = "description")
@XmlElement(name = "description")
private String description;
@XmlAttribute(name = "language")
@XmlElement(name = "language")
private String language;
@XmlAttribute(name = "type")
@XmlElement(name = "type")
private UUID type;
@XmlAttribute(name = "version")
@XmlElement(name = "version")
private Short version;
@XmlElement(name = "groupId")
private UUID groupId;

View File

@ -3,6 +3,7 @@ package org.opencdmp.commons.types.descriptiontemplate.importexport;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
@XmlAccessorType(XmlAccessType.FIELD)
@ -11,13 +12,13 @@ public class DescriptionTemplateMultiplicityImportExport {
private int min;
@XmlAttribute(name="max")
private int max;
@XmlAttribute(name="placeholder")
@XmlElement(name="placeholder")
private String placeholder;
@XmlAttribute(name="tableView")
@XmlElement(name="tableView")
private boolean tableView;
public int getMin() {
return min;
return this.min;
}
public void setMin(int min) {
@ -25,7 +26,7 @@ public class DescriptionTemplateMultiplicityImportExport {
}
public int getMax() {
return max;
return this.max;
}
public void setMax(int max) {
@ -33,7 +34,7 @@ public class DescriptionTemplateMultiplicityImportExport {
}
public String getPlaceholder() {
return placeholder;
return this.placeholder;
}
public void setPlaceholder(String placeholder) {
@ -41,7 +42,7 @@ public class DescriptionTemplateMultiplicityImportExport {
}
public boolean getTableView() {
return tableView;
return this.tableView;
}
public void setTableView(boolean tableView) {

View File

@ -1,18 +1,21 @@
package org.opencdmp.commons.types.descriptiontemplate.importexport;
import jakarta.xml.bind.annotation.*;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.ArrayList;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplatePageImportExport {
@XmlAttribute(name = "id")
@XmlElement(name = "id")
private String id;
@XmlAttribute(name = "ordinal")
@XmlElement(name = "ordinal")
private int ordinal;
@XmlAttribute(name = "title")
@XmlElement(name = "title")
private String title;
@XmlElementWrapper(name = "sections")
@XmlElement(name = "section")
@ -20,7 +23,7 @@ public class DescriptionTemplatePageImportExport {
public String getId() {
return id;
return this.id;
}
public void setId(String id) {
@ -28,14 +31,14 @@ public class DescriptionTemplatePageImportExport {
}
public int getOrdinal() {
return ordinal;
return this.ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public String getTitle() {
return title;
return this.title;
}
public void setTitle(String title) {
@ -43,7 +46,7 @@ public class DescriptionTemplatePageImportExport {
}
public List<DescriptionTemplateSectionImportExport> getSections() {
return sections;
return this.sections;
}
public void setSections(List<DescriptionTemplateSectionImportExport> sections) {

View File

@ -2,7 +2,6 @@ package org.opencdmp.commons.types.descriptiontemplate.importexport;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opencdmp.commons.xmladapter.InstantXmlAdapter;
@ -12,9 +11,9 @@ import java.time.Instant;
@XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateRuleImportExport {
@XmlAttribute(name="target")
@XmlElement(name="target")
private String target;
@XmlAttribute(name="value")
@XmlElement(name="value")
private String textValue;
@XmlElement(name = "dateValue")

View File

@ -1,15 +1,18 @@
package org.opencdmp.commons.types.descriptiontemplate.importexport;
import jakarta.xml.bind.annotation.*;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.ArrayList;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateSectionImportExport {
@XmlAttribute(name = "id")
@XmlElement(name = "id")
private String id;
@XmlAttribute(name = "ordinal")
@XmlElement(name = "ordinal")
private int ordinal;
@XmlElementWrapper(name = "fieldSets")
@XmlElement(name = "fieldSet")

View File

@ -1,19 +1,19 @@
package org.opencdmp.commons.types.descriptiontemplate.importexport.fielddata;
import org.opencdmp.commons.enums.FieldType;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import org.opencdmp.commons.enums.FieldType;
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class BaseFieldDataImportExport {
@XmlAttribute(name = "label")
@XmlElement(name = "label")
private String label;
@XmlAttribute(name = "fieldType")
@XmlElement(name = "fieldType")
private FieldType fieldType;
public String getLabel() {
return label;
return this.label;
}
public void setLabel(String label) {
@ -21,7 +21,7 @@ public abstract class BaseFieldDataImportExport {
}
public FieldType getFieldType() {
return fieldType;
return this.fieldType;
}
public void setFieldType(FieldType fieldType) {

View File

@ -12,7 +12,7 @@ public class LabelAndMultiplicityDataImportExport extends BaseFieldDataImportExp
private Boolean multipleSelect;
public Boolean getMultipleSelect() {
return multipleSelect;
return this.multipleSelect;
}
public void setMultipleSelect(Boolean multipleSelect) {

View File

@ -3,6 +3,7 @@ package org.opencdmp.commons.types.descriptiontemplate.importexport.fielddata;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import java.util.UUID;
@ -13,11 +14,14 @@ public class ReferenceTypeDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multipleSelect")
private Boolean multipleSelect;
@XmlAttribute(name = "referenceTypeId")
@XmlElement(name = "referenceTypeId")
private UUID referenceTypeId;
@XmlElement(name = "referenceTypeCode")
private String referenceTypeCode;
public Boolean getMultipleSelect() {
return multipleSelect;
return this.multipleSelect;
}
public void setMultipleSelect(Boolean multipleSelect) {
@ -25,10 +29,18 @@ public class ReferenceTypeDataImportExport extends BaseFieldDataImportExport {
}
public UUID getReferenceTypeId() {
return referenceTypeId;
return this.referenceTypeId;
}
public void setReferenceTypeId(UUID referenceTypeId) {
this.referenceTypeId = referenceTypeId;
}
public String getReferenceTypeCode() {
return this.referenceTypeCode;
}
public void setReferenceTypeCode(String referenceTypeCode) {
this.referenceTypeCode = referenceTypeCode;
}
}

View File

@ -12,11 +12,11 @@ public class UploadDataImportExport extends BaseFieldDataImportExport {
@XmlElement(name = "type")
private List<UploadDataOption> types;
@XmlAttribute(name = "maxFileSizeInMB")
@XmlElement(name = "maxFileSizeInMB")
private Integer maxFileSizeInMB;
public List<UploadDataOption> getTypes() {
return types;
return this.types;
}
public void setTypes(List<UploadDataOption> types) {
@ -24,7 +24,7 @@ public class UploadDataImportExport extends BaseFieldDataImportExport {
}
public Integer getMaxFileSizeInMB() {
return maxFileSizeInMB;
return this.maxFileSizeInMB;
}
public void setMaxFileSizeInMB(Integer maxFileSizeInMB) {
@ -39,7 +39,7 @@ public class UploadDataImportExport extends BaseFieldDataImportExport {
private String value;
public String getLabel() {
return label;
return this.label;
}
public void setLabel(String label) {
@ -47,7 +47,7 @@ public class UploadDataImportExport extends BaseFieldDataImportExport {
}
public String getValue() {
return value;
return this.value;
}
public void setValue(String value) {

View File

@ -14,7 +14,7 @@ public class DefinitionEntity {
private List<SectionEntity> sections;
public List<SectionEntity> getSections() {
return sections;
return this.sections;
}
public void setSections(List<SectionEntity> sections) {
this.sections = sections;

View File

@ -19,7 +19,7 @@ public class DescriptionTemplateEntity {
private Integer maxMultiplicity;
public UUID getDescriptionTemplateGroupId() {
return descriptionTemplateGroupId;
return this.descriptionTemplateGroupId;
}
public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
@ -27,21 +27,21 @@ public class DescriptionTemplateEntity {
}
public String getLabel() {
return label;
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
public Integer getMinMultiplicity() {
return minMultiplicity;
return this.minMultiplicity;
}
public void setMinMultiplicity(Integer minMultiplicity) {
this.minMultiplicity = minMultiplicity;
}
public Integer getMaxMultiplicity() {
return maxMultiplicity;
return this.maxMultiplicity;
}
public void setMaxMultiplicity(Integer maxMultiplicity) {
this.maxMultiplicity = maxMultiplicity;

View File

@ -1,9 +1,9 @@
package org.opencdmp.commons.types.dmpblueprint;
import org.opencdmp.commons.enums.DmpBlueprintFieldCategory;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import org.opencdmp.commons.enums.DmpBlueprintFieldCategory;
import java.util.List;
import java.util.UUID;
@ -35,42 +35,42 @@ public abstract class FieldEntity {
private boolean required;
public UUID getId() {
return id;
return this.id;
}
public void setId(UUID id) {
this.id = id;
}
public DmpBlueprintFieldCategory getCategory() {
return category;
return this.category;
}
public void setCategory(DmpBlueprintFieldCategory category) {
this.category = category;
}
public String getLabel() {
return label;
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
public String getPlaceholder() {
return placeholder;
return this.placeholder;
}
public void setPlaceholder(String placeholder) {
this.placeholder = placeholder;
}
public String getDescription() {
return description;
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public List<String> getSemantics() {
return semantics;
return this.semantics;
}
public void setSemantics(List<String> semantics) {
@ -78,14 +78,14 @@ public abstract class FieldEntity {
}
public Integer getOrdinal() {
return ordinal;
return this.ordinal;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public boolean isRequired() {
return required;
return this.required;
}
public void setRequired(boolean required) {
this.required = required;

View File

@ -15,7 +15,7 @@ public class ReferenceTypeFieldEntity extends FieldEntity {
@XmlAttribute(name = "multipleSelect")
private Boolean multipleSelect;
public UUID getReferenceTypeId() {
return referenceTypeId;
return this.referenceTypeId;
}
public void setReferenceTypeId(UUID referenceTypeId) {
@ -23,7 +23,7 @@ public class ReferenceTypeFieldEntity extends FieldEntity {
}
public Boolean getMultipleSelect() {
return multipleSelect;
return this.multipleSelect;
}
public void setMultipleSelect(Boolean multipleSelect) {

View File

@ -1,7 +1,7 @@
package org.opencdmp.commons.types.dmpblueprint;
import org.opencdmp.commons.enums.DmpBlueprintFieldCategory;
import jakarta.xml.bind.annotation.*;
import org.opencdmp.commons.enums.DmpBlueprintFieldCategory;
import java.util.ArrayList;
import java.util.List;
@ -42,56 +42,56 @@ public class SectionEntity {
private List<UUID> prefillingSourcesIds;
public UUID getId() {
return id;
return this.id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getOrdinal() {
return ordinal;
return this.ordinal;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public List<FieldEntity> getFields() {
return fields;
return this.fields;
}
public void setFields(List<FieldEntity> fields) {
this.fields = fields;
}
public Boolean getHasTemplates() {
return hasTemplates;
return this.hasTemplates;
}
public void setHasTemplates(Boolean hasTemplates) {
this.hasTemplates = hasTemplates;
}
public List<DescriptionTemplateEntity> getDescriptionTemplates() {
return descriptionTemplates;
return this.descriptionTemplates;
}
public void setDescriptionTemplates(List<DescriptionTemplateEntity> descriptionTemplates) {
this.descriptionTemplates = descriptionTemplates;
}
public List<UUID> getPrefillingSourcesIds() {
return prefillingSourcesIds;
return this.prefillingSourcesIds;
}
public void setPrefillingSourcesIds(List<UUID> prefillingSourcesIds) {

View File

@ -1,11 +1,9 @@
package org.opencdmp.commons.types.dmpblueprint;
import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import java.util.UUID;
import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType;
@XmlAccessorType(XmlAccessType.FIELD)
public class SystemFieldEntity extends FieldEntity {
@ -14,7 +12,7 @@ public class SystemFieldEntity extends FieldEntity {
private DmpBlueprintSystemFieldType type;
public DmpBlueprintSystemFieldType getType() {
return type;
return this.type;
}
public void setType(DmpBlueprintSystemFieldType type) {
this.type = type;

View File

@ -3,14 +3,15 @@ package org.opencdmp.commons.types.dmpblueprint.importexport;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD)
public class BlueprintDescriptionTemplateImportExport {
@XmlAttribute(name = "descriptionTemplateGroupId")
@XmlElement(name = "descriptionTemplateGroupId")
private UUID descriptionTemplateGroupId;
@XmlAttribute(name = "label")
@XmlElement(name = "label")
private String label;
@XmlAttribute(name = "minMultiplicity")
private Integer minMultiplicity;
@ -34,7 +35,7 @@ public class BlueprintDescriptionTemplateImportExport {
}
public Integer getMinMultiplicity() {
return minMultiplicity;
return this.minMultiplicity;
}
public void setMinMultiplicity(Integer minMultiplicity) {
@ -42,7 +43,7 @@ public class BlueprintDescriptionTemplateImportExport {
}
public Integer getMaxMultiplicity() {
return maxMultiplicity;
return this.maxMultiplicity;
}
public void setMaxMultiplicity(Integer maxMultiplicity) {

View File

@ -1,9 +1,10 @@
package org.opencdmp.commons.types.dmpblueprint.importexport;
import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType;
import java.util.List;
import java.util.UUID;
@ -11,17 +12,17 @@ import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD)
public class BlueprintExtraFieldImportExport {
@XmlAttribute(name = "id")
@XmlElement(name = "id")
private UUID id;
@XmlAttribute(name = "type")
@XmlElement(name = "type")
private DmpBlueprintExtraFieldDataType type;
@XmlAttribute(name = "label")
@XmlElement(name = "label")
private String label;
@XmlAttribute(name = "placeholder")
@XmlElement(name = "placeholder")
private String placeholder;
@XmlAttribute(name = "description")
@XmlElement(name = "description")
private String description;
@XmlAttribute(name="semantics")
@XmlElement(name="semantics")
private List<String> semantics;
@XmlAttribute(name = "ordinal")
private int ordinal;
@ -29,7 +30,7 @@ public class BlueprintExtraFieldImportExport {
private boolean required;
public UUID getId() {
return id;
return this.id;
}
public void setId(UUID id) {
@ -37,7 +38,7 @@ public class BlueprintExtraFieldImportExport {
}
public DmpBlueprintExtraFieldDataType getType() {
return type;
return this.type;
}
public void setType(DmpBlueprintExtraFieldDataType type) {
@ -45,7 +46,7 @@ public class BlueprintExtraFieldImportExport {
}
public String getLabel() {
return label;
return this.label;
}
public void setLabel(String label) {
@ -53,7 +54,7 @@ public class BlueprintExtraFieldImportExport {
}
public String getPlaceholder() {
return placeholder;
return this.placeholder;
}
public void setPlaceholder(String placeholder) {
@ -61,7 +62,7 @@ public class BlueprintExtraFieldImportExport {
}
public String getDescription() {
return description;
return this.description;
}
public void setDescription(String description) {
@ -69,7 +70,7 @@ public class BlueprintExtraFieldImportExport {
}
public int getOrdinal() {
return ordinal;
return this.ordinal;
}
public void setOrdinal(int ordinal) {
@ -77,7 +78,7 @@ public class BlueprintExtraFieldImportExport {
}
public boolean isRequired() {
return required;
return this.required;
}
public void setRequired(boolean required) {
@ -85,7 +86,7 @@ public class BlueprintExtraFieldImportExport {
}
public List<String> getSemantics() {
return semantics;
return this.semantics;
}
public void setSemantics(List<String> semantics) {

View File

@ -0,0 +1,21 @@
package org.opencdmp.commons.types.dmpblueprint.importexport;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD)
public class BlueprintPrefillingSourceImportExport {
@XmlElement(name = "id")
private UUID id;
public UUID getId() {
return this.id;
}
public void setId(UUID id) {
this.id = id;
}
}

View File

@ -3,6 +3,7 @@ package org.opencdmp.commons.types.dmpblueprint.importexport;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import java.util.List;
import java.util.UUID;
@ -10,28 +11,30 @@ import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD)
public class BlueprintReferenceTypeFieldImportExport {
@XmlAttribute(name = "id")
@XmlElement(name = "id")
private UUID id;
@XmlAttribute(name = "referenceTypeId")
@XmlElement(name = "referenceTypeId")
private UUID referenceTypeId;
@XmlAttribute(name = "label")
@XmlElement(name = "referenceTypeCode")
private String referenceTypeCode;
@XmlElement(name = "label")
private String label;
@XmlAttribute(name = "placeholder")
@XmlElement(name = "placeholder")
private String placeholder;
@XmlAttribute(name = "description")
@XmlElement(name = "description")
private String description;
@XmlAttribute(name="semantics")
@XmlElement(name="semantics")
private List<String> semantics;
@XmlAttribute(name = "ordinal")
private int ordinal;
@XmlAttribute(name = "required")
private boolean required;
@XmlAttribute(name = "multipleSelect")
@XmlElement(name = "multipleSelect")
private Boolean multipleSelect;
public UUID getId() {
return id;
return this.id;
}
public void setId(UUID id) {
@ -39,7 +42,7 @@ public class BlueprintReferenceTypeFieldImportExport {
}
public UUID getReferenceTypeId() {
return referenceTypeId;
return this.referenceTypeId;
}
public void setReferenceTypeId(UUID referenceTypeId) {
@ -47,7 +50,7 @@ public class BlueprintReferenceTypeFieldImportExport {
}
public String getLabel() {
return label;
return this.label;
}
public void setLabel(String label) {
@ -55,7 +58,7 @@ public class BlueprintReferenceTypeFieldImportExport {
}
public String getPlaceholder() {
return placeholder;
return this.placeholder;
}
public void setPlaceholder(String placeholder) {
@ -63,7 +66,7 @@ public class BlueprintReferenceTypeFieldImportExport {
}
public String getDescription() {
return description;
return this.description;
}
public void setDescription(String description) {
@ -71,7 +74,7 @@ public class BlueprintReferenceTypeFieldImportExport {
}
public int getOrdinal() {
return ordinal;
return this.ordinal;
}
public void setOrdinal(int ordinal) {
@ -79,7 +82,7 @@ public class BlueprintReferenceTypeFieldImportExport {
}
public boolean isRequired() {
return required;
return this.required;
}
public void setRequired(boolean required) {
@ -87,7 +90,7 @@ public class BlueprintReferenceTypeFieldImportExport {
}
public Boolean getMultipleSelect() {
return multipleSelect;
return this.multipleSelect;
}
public void setMultipleSelect(Boolean multipleSelect) {
@ -95,10 +98,18 @@ public class BlueprintReferenceTypeFieldImportExport {
}
public List<String> getSemantics() {
return semantics;
return this.semantics;
}
public void setSemantics(List<String> semantics) {
this.semantics = semantics;
}
public String getReferenceTypeCode() {
return this.referenceTypeCode;
}
public void setReferenceTypeCode(String referenceTypeCode) {
this.referenceTypeCode = referenceTypeCode;
}
}

View File

@ -8,13 +8,13 @@ import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD)
public class BlueprintSectionImportExport {
@XmlAttribute(name = "id")
@XmlElement(name = "id")
private UUID id;
@XmlAttribute(name = "label")
@XmlElement(name = "label")
private String label;
@XmlAttribute(name = "description")
@XmlElement(name = "description")
private String description;
@XmlAttribute(name = "ordinal")
@XmlElement(name = "ordinal")
private int ordinal;
@XmlElementWrapper(name = "systemFields")
@XmlElement(name = "systemField")
@ -31,6 +31,10 @@ public class BlueprintSectionImportExport {
@XmlElement(name = "descriptionTemplate")
private List<BlueprintDescriptionTemplateImportExport> descriptionTemplates;
@XmlElementWrapper(name = "prefillingSources")
@XmlElement(name = "prefillingSource")
private List<BlueprintPrefillingSourceImportExport> prefillingSources;
public UUID getId() {
return this.id;
}
@ -103,4 +107,11 @@ public class BlueprintSectionImportExport {
this.descriptionTemplates = descriptionTemplates;
}
public List<BlueprintPrefillingSourceImportExport> getPrefillingSources() {
return this.prefillingSources;
}
public void setPrefillingSources(List<BlueprintPrefillingSourceImportExport> prefillingSources) {
this.prefillingSources = prefillingSources;
}
}

View File

@ -1,9 +1,10 @@
package org.opencdmp.commons.types.dmpblueprint.importexport;
import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType;
import java.util.List;
import java.util.UUID;
@ -11,17 +12,17 @@ import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD)
public class BlueprintSystemFieldImportExport {
@XmlAttribute(name = "id")
@XmlElement(name = "id")
private UUID id;
@XmlAttribute(name = "type")
@XmlElement(name = "type")
private DmpBlueprintSystemFieldType type;
@XmlAttribute(name = "label")
@XmlElement(name = "label")
private String label;
@XmlAttribute(name = "placeholder")
@XmlElement(name = "placeholder")
private String placeholder;
@XmlAttribute(name = "description")
@XmlElement(name = "description")
private String description;
@XmlAttribute(name="semantics")
@XmlElement(name="semantics")
private List<String> semantics;
@XmlAttribute(name = "ordinal")
private int ordinal;
@ -29,7 +30,7 @@ public class BlueprintSystemFieldImportExport {
private boolean required;
public UUID getId() {
return id;
return this.id;
}
public void setId(UUID id) {
@ -37,7 +38,7 @@ public class BlueprintSystemFieldImportExport {
}
public DmpBlueprintSystemFieldType getType() {
return type;
return this.type;
}
public void setType(DmpBlueprintSystemFieldType type) {
@ -45,7 +46,7 @@ public class BlueprintSystemFieldImportExport {
}
public String getLabel() {
return label;
return this.label;
}
public void setLabel(String label) {
@ -53,7 +54,7 @@ public class BlueprintSystemFieldImportExport {
}
public String getPlaceholder() {
return placeholder;
return this.placeholder;
}
public void setPlaceholder(String placeholder) {
@ -61,7 +62,7 @@ public class BlueprintSystemFieldImportExport {
}
public String getDescription() {
return description;
return this.description;
}
public void setDescription(String description) {
@ -69,7 +70,7 @@ public class BlueprintSystemFieldImportExport {
}
public int getOrdinal() {
return ordinal;
return this.ordinal;
}
public void setOrdinal(int ordinal) {
@ -77,7 +78,7 @@ public class BlueprintSystemFieldImportExport {
}
public boolean isRequired() {
return required;
return this.required;
}
public void setRequired(boolean required) {
@ -85,7 +86,7 @@ public class BlueprintSystemFieldImportExport {
}
public List<String> getSemantics() {
return semantics;
return this.semantics;
}
public void setSemantics(List<String> semantics) {

View File

@ -1,5 +1,7 @@
package org.opencdmp.data;
import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import org.opencdmp.commons.enums.DescriptionTemplateStatus;
import org.opencdmp.commons.enums.DescriptionTemplateVersionStatus;
import org.opencdmp.commons.enums.IsActive;
@ -8,8 +10,6 @@ import org.opencdmp.data.converters.enums.DescriptionTemplateVersionStatusConver
import org.opencdmp.data.converters.enums.IsActiveConverter;
import org.opencdmp.data.tenant.TenantScopedBaseEntity;
import org.opencdmp.data.types.SQLXMLType;
import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import java.time.Instant;
import java.util.UUID;
@ -27,7 +27,7 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity {
public static final String _label = "label";
public static final int _labelLength = 250;
@Type(value = SQLXMLType.class)
@Type(SQLXMLType.class)
@Column(name = "definition", nullable = false, columnDefinition = "xml")
private String definition;
public static final String _definition = "definition";
@ -44,7 +44,7 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity {
@Column(name = "created_at", nullable = false)
private Instant createdAt = null;
private Instant createdAt;
public static final String _createdAt = "createdAt";
@Column(name = "updated_at", nullable = false)
@ -77,46 +77,46 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity {
public static final String _typeId = "typeId";
public String getDescription() {
return description;
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public UUID getId() {
return id;
return this.id;
}
public void setId(UUID id) { this.id = id;}
public String getLabel() {
return label;
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDefinition() {
return definition;
return this.definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public UUID getGroupId() { return groupId; }
public UUID getGroupId() { return this.groupId; }
public void setGroupId(UUID groupId) { this.groupId = groupId;}
public Short getVersion() { return version; }
public Short getVersion() { return this.version; }
public void setVersion(Short version) { this.version = version; }
public String getLanguage() {
return language;
return this.language;
}
public void setLanguage(String language) {
this.language = language;
}
public DescriptionTemplateStatus getStatus() {
return status;
return this.status;
}
public void setStatus(DescriptionTemplateStatus status) {
@ -124,7 +124,7 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity {
}
public IsActive getIsActive() {
return isActive;
return this.isActive;
}
public void setIsActive(IsActive isActive) {
@ -132,7 +132,7 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity {
}
public Instant getCreatedAt() {
return createdAt;
return this.createdAt;
}
public void setCreatedAt(Instant createdAt) {
@ -140,7 +140,7 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity {
}
public Instant getUpdatedAt() {
return updatedAt;
return this.updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
@ -148,7 +148,7 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity {
}
public UUID getTypeId() {
return typeId;
return this.typeId;
}
public void setTypeId(UUID typeId) {
@ -156,7 +156,7 @@ public class DescriptionTemplateEntity extends TenantScopedBaseEntity {
}
public DescriptionTemplateVersionStatus getVersionStatus() {
return versionStatus;
return this.versionStatus;
}
public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) {

View File

@ -214,7 +214,7 @@ public class QueueInboxQuery extends QueryBase<QueueInboxEntity> {
queryContext.CriteriaBuilder.lessThanOrEqualTo(queryContext.Root.get(QueueInboxEntity._retryCount), this.retryThreshold)));
}
if (predicates.size() > 0) {
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {

View File

@ -28,11 +28,13 @@ import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.commons.types.descriptiontemplate.*;
import org.opencdmp.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
import org.opencdmp.commons.types.descriptiontemplate.importexport.*;
import org.opencdmp.commons.types.notification.*;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.*;
import org.opencdmp.data.DescriptionTemplateEntity;
import org.opencdmp.data.TenantEntityManager;
import org.opencdmp.data.UserDescriptionTemplateEntity;
import org.opencdmp.data.UserEntity;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent;
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
@ -43,14 +45,13 @@ import org.opencdmp.model.deleter.UserDescriptionTemplateDeleter;
import org.opencdmp.model.descriptiontemplate.*;
import org.opencdmp.model.persist.DescriptionTemplatePersist;
import org.opencdmp.model.persist.NewVersionDescriptionTemplatePersist;
import org.opencdmp.model.persist.ReferencePersist;
import org.opencdmp.model.persist.UserDescriptionTemplatePersist;
import org.opencdmp.model.persist.descriptiontemplatedefinition.*;
import org.opencdmp.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldDataPersist;
import org.opencdmp.model.reference.Reference;
import org.opencdmp.model.referencetype.ReferenceType;
import org.opencdmp.model.user.User;
import org.opencdmp.query.*;
import org.opencdmp.query.DescriptionTemplateQuery;
import org.opencdmp.query.UserContactInfoQuery;
import org.opencdmp.query.UserDescriptionTemplateQuery;
import org.opencdmp.service.fielddatahelper.FieldDataHelperService;
import org.opencdmp.service.fielddatahelper.FieldDataHelperServiceProvider;
import org.opencdmp.service.responseutils.ResponseUtilsService;
@ -292,7 +293,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
this.eventHandler.handle(event);
}
private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist) throws InvalidApplicationException {
private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist) {
DefinitionEntity data = new DefinitionEntity();
if (persist == null)
return data;
@ -307,7 +308,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data;
}
private @NotNull SectionEntity buildSectionEntity(SectionPersist persist) throws InvalidApplicationException {
private @NotNull SectionEntity buildSectionEntity(SectionPersist persist) {
SectionEntity data = new SectionEntity();
if (persist == null)
return data;
@ -334,7 +335,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data;
}
private @NotNull FieldSetEntity buildFieldSetEntity(FieldSetPersist persist) throws InvalidApplicationException {
private @NotNull FieldSetEntity buildFieldSetEntity(FieldSetPersist persist) {
FieldSetEntity data = new FieldSetEntity();
if (persist == null)
return data;
@ -363,7 +364,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data;
}
private @NotNull FieldEntity buildFieldEntity(FieldPersist persist) throws InvalidApplicationException {
private @NotNull FieldEntity buildFieldEntity(FieldPersist persist) {
FieldEntity data = new FieldEntity();
if (persist == null)
return data;
@ -393,7 +394,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return this.fieldDataHelperServiceProvider.get(persist.getFieldType()).applyPersist(persist);
}
private @NotNull RuleEntity buildRuleEntity(RulePersist persist, FieldEntity fieldEntity) throws InvalidApplicationException {
private @NotNull RuleEntity buildRuleEntity(RulePersist persist, FieldEntity fieldEntity) {
FieldType fieldType = fieldEntity != null && fieldEntity.getData() != null ? fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
RuleEntity data = new RuleEntity();
if (persist == null) return data;
@ -446,77 +447,6 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data;
}
private List<UUID> patchAndSaveReferences(List<ReferencePersist> models, FieldEntity fieldEntity) throws InvalidApplicationException {
if (models == null) models = new ArrayList<>();
List<UUID> referenceIds = new ArrayList<>();
for (ReferencePersist model : models) {
ReferenceEntity data;
if (this.conventionService.isValidGuid(model.getId())){
data = this.entityManager.find(ReferenceEntity.class, model.getId());
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
} else {
ReferenceTypeDataEntity referenceTypeDataEntity = ((ReferenceTypeDataEntity)fieldEntity.getData());
data = this.queryFactory.query(ReferenceQuery.class).disableTracking().sourceTypes(model.getSourceType()).typeIds(referenceTypeDataEntity.getReferenceTypeId()).sources(model.getSource()).isActive(IsActive.Active).references(model.getReference()).first();
if (data == null){
data = new ReferenceEntity();
data.setId(UUID.randomUUID());
data.setIsActive(IsActive.Active);
data.setCreatedAt(Instant.now());
data.setTypeId(referenceTypeDataEntity.getReferenceTypeId());
data.setDefinition(this.xmlHandlingService.toXmlSafe(this.buildReferenceDefinitionEntity(model.getDefinition())));
data.setUpdatedAt(Instant.now());
data.setReference(model.getReference());
data.setAbbreviation(model.getAbbreviation());
data.setSource(model.getSource());
data.setSourceType(model.getSourceType());
try {
ReferenceTypeEntity referenceType = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(referenceTypeDataEntity.getReferenceTypeId()).firstAs(new BaseFieldSet().ensure(ReferenceType._id).ensure(ReferenceTypeEntity._tenantId));
if (referenceType == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{referenceTypeDataEntity.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
if (data.getSourceType().equals(ReferenceSourceType.External) && !this.tenantScope.isDefaultTenant() && referenceType.getTenantId() == null){
this.tenantScope.setTempTenant(this.entityManager, null, this.tenantScope.getDefaultTenantCode());
}
this.entityManager.persist(data);
} finally {
this.tenantScope.removeTempTenant(this.entityManager);
}
}
}
referenceIds.add(data.getId());
}
this.entityManager.flush();
return referenceIds;
}
private @NotNull org.opencdmp.commons.types.reference.DefinitionEntity buildReferenceDefinitionEntity(org.opencdmp.model.persist.referencedefinition.DefinitionPersist persist){
org.opencdmp.commons.types.reference.DefinitionEntity data = new org.opencdmp.commons.types.reference.DefinitionEntity();
if (persist == null) return data;
if (!this.conventionService.isListNullOrEmpty(persist.getFields())){
data.setFields(new ArrayList<>());
for (org.opencdmp.model.persist.referencedefinition.FieldPersist fieldPersist: persist.getFields()) {
data.getFields().add(this.buildRefernceFieldEntity(fieldPersist));
}
}
return data;
}
private @NotNull org.opencdmp.commons.types.reference.FieldEntity buildRefernceFieldEntity(org.opencdmp.model.persist.referencedefinition.FieldPersist persist){
org.opencdmp.commons.types.reference.FieldEntity data = new org.opencdmp.commons.types.reference.FieldEntity();
if (persist == null) return data;
data.setCode(persist.getCode());
data.setDataType(persist.getDataType());
data.setCode(persist.getCode());
return data;
}
private @NotNull MultiplicityEntity buildMultiplicityEntity(MultiplicityPersist persist) {
MultiplicityEntity data = new MultiplicityEntity();
if (persist == null)
@ -533,7 +463,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data;
}
private @NotNull PageEntity buildPageEntity(PagePersist persist) throws InvalidApplicationException {
private @NotNull PageEntity buildPageEntity(PagePersist persist) {
PageEntity data = new PageEntity();
if (persist == null)
return data;
@ -907,7 +837,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
//region Export
@Override
public DescriptionTemplateImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
public DescriptionTemplateImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
logger.debug(new MapLogEntry("exportXml").And("id", id));
if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);

View File

@ -25,10 +25,12 @@ import org.opencdmp.commons.types.dmpblueprint.*;
import org.opencdmp.commons.types.dmpblueprint.importexport.*;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.DmpBlueprintEntity;
import org.opencdmp.data.ReferenceTypeEntity;
import org.opencdmp.data.TenantEntityManager;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
import org.opencdmp.model.builder.dmpblueprint.DmpBlueprintBuilder;
import org.opencdmp.model.deleter.DmpBlueprintDeleter;
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
import org.opencdmp.model.dmpblueprint.Definition;
import org.opencdmp.model.dmpblueprint.DmpBlueprint;
import org.opencdmp.model.dmpblueprint.Field;
@ -36,7 +38,12 @@ import org.opencdmp.model.dmpblueprint.Section;
import org.opencdmp.model.persist.DmpBlueprintPersist;
import org.opencdmp.model.persist.NewVersionDmpBlueprintPersist;
import org.opencdmp.model.persist.dmpblueprintdefinition.*;
import org.opencdmp.model.prefillingsource.PrefillingSource;
import org.opencdmp.model.referencetype.ReferenceType;
import org.opencdmp.query.DescriptionTemplateQuery;
import org.opencdmp.query.DmpBlueprintQuery;
import org.opencdmp.query.PrefillingSourceQuery;
import org.opencdmp.query.ReferenceTypeQuery;
import org.opencdmp.service.responseutils.ResponseUtilsService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -385,7 +392,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
//region NewVersion
@Override
public DmpBlueprint createNewVersion(NewVersionDmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
public DmpBlueprint createNewVersion(NewVersionDmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException {
logger.debug(new MapLogEntry("persisting data dmpBlueprint").And("model", model).And("fields", fields));
this.authorizationService.authorizeForce(Permission.CreateNewVersionDmpBlueprint);
@ -448,7 +455,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
@Override
public BlueprintImportExport getExportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
public BlueprintImportExport getExportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
logger.debug(new MapLogEntry("export xml").And("id", id));
if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDmpBlueprint);
@ -530,14 +537,22 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
List<BlueprintDescriptionTemplateImportExport> dmpBlueprintDescriptionTemplates = new LinkedList<>();
if (!this.conventionService.isListNullOrEmpty(entity.getDescriptionTemplates())) {
for (DescriptionTemplateEntity descriptionTemplate : entity.getDescriptionTemplates()) {
dmpBlueprintDescriptionTemplates.add(this.descriptionTemplateXmlToExport(descriptionTemplate));
dmpBlueprintDescriptionTemplates.add(this.prefillingSourceXmlToExport(descriptionTemplate));
}
}
xml.setDescriptionTemplates(dmpBlueprintDescriptionTemplates);
List<BlueprintPrefillingSourceImportExport> blueprintPrefillingSourceImportExports = new LinkedList<>();
if (!this.conventionService.isListNullOrEmpty(entity.getDescriptionTemplates())) {
for (UUID prefillingSourceIda : entity.getPrefillingSourcesIds()) {
blueprintPrefillingSourceImportExports.add(this.prefillingSourceXmlToExport(prefillingSourceIda));
}
}
xml.setPrefillingSources(blueprintPrefillingSourceImportExports);
return xml;
}
private BlueprintDescriptionTemplateImportExport descriptionTemplateXmlToExport(DescriptionTemplateEntity entity) {
private BlueprintDescriptionTemplateImportExport prefillingSourceXmlToExport(DescriptionTemplateEntity entity) {
BlueprintDescriptionTemplateImportExport xml = new BlueprintDescriptionTemplateImportExport();
xml.setDescriptionTemplateGroupId(entity.getDescriptionTemplateGroupId());
xml.setLabel(entity.getLabel());
@ -546,6 +561,12 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
return xml;
}
private BlueprintPrefillingSourceImportExport prefillingSourceXmlToExport(UUID id) {
BlueprintPrefillingSourceImportExport xml = new BlueprintPrefillingSourceImportExport();
xml.setId(id);
return xml;
}
private BlueprintExtraFieldImportExport extraFieldXmlToExport(ExtraFieldEntity entity) {
BlueprintExtraFieldImportExport xml = new BlueprintExtraFieldImportExport();
xml.setId(entity.getId());
@ -561,8 +582,12 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
private BlueprintReferenceTypeFieldImportExport referenceFieldXmlToExport(ReferenceTypeFieldEntity entity) {
BlueprintReferenceTypeFieldImportExport xml = new BlueprintReferenceTypeFieldImportExport();
ReferenceTypeEntity data = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(entity.getReferenceTypeId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._code));
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{entity.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
xml.setId(entity.getId());
xml.setReferenceTypeId(entity.getReferenceTypeId());
xml.setReferenceTypeCode(data.getCode());
xml.setLabel(entity.getLabel());
xml.setPlaceholder(entity.getPlaceholder());
xml.setDescription(entity.getDescription());
@ -654,10 +679,21 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
}
}
persist.setDescriptionTemplates(dmpBlueprintDescriptionTemplates);
List<UUID> prefillingSources = new LinkedList<>();
if (!this.conventionService.isListNullOrEmpty(importXml.getPrefillingSources())) {
for (BlueprintPrefillingSourceImportExport prefillingSource : importXml.getPrefillingSources()) {
prefillingSources.add(this.xmlPrefillingSourceToPersist(prefillingSource));
}
}
persist.setPrefillingSourcesIds(prefillingSources);
return persist;
}
private DescriptionTemplatePersist xmlDescriptionTemplateToPersist(BlueprintDescriptionTemplateImportExport importXml) {
org.opencdmp.data.DescriptionTemplateEntity data = importXml.getDescriptionTemplateGroupId() != null ? this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().groupIds(importXml.getDescriptionTemplateGroupId()).disableTracking().firstAs(new BaseFieldSet().ensure(DescriptionTemplate._groupId)) : null;
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{importXml.getDescriptionTemplateGroupId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
persist.setDescriptionTemplateGroupId(importXml.getDescriptionTemplateGroupId());
persist.setLabel(importXml.getLabel());
@ -666,6 +702,13 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
return persist;
}
private UUID xmlPrefillingSourceToPersist(BlueprintPrefillingSourceImportExport importXml) {
org.opencdmp.data.PrefillingSourceEntity data = importXml.getId() != null ? this.queryFactory.query(PrefillingSourceQuery.class).disableTracking().ids(importXml.getId()).disableTracking().firstAs(new BaseFieldSet().ensure(PrefillingSource._id)) : null;
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{importXml.getId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
return data.getId();
}
private FieldPersist xmlExtraFieldToPersist(BlueprintExtraFieldImportExport importXml) {
ExtraFieldPersist persist = new ExtraFieldPersist();
persist.setId(importXml.getId());
@ -695,10 +738,17 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
}
private FieldPersist xmlReferenceFieldToPersist(BlueprintReferenceTypeFieldImportExport importXml) {
ReferenceTypeEntity data = importXml.getReferenceTypeId() != null ? this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(importXml.getReferenceTypeId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id)) : null;
if (data == null){
if (!this.conventionService.isNullOrEmpty(importXml.getReferenceTypeCode())) data = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().codes(importXml.getReferenceTypeCode()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id));
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{importXml.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
}
ReferenceTypeFieldPersist persist = new ReferenceTypeFieldPersist();
persist.setId(importXml.getId());
persist.setCategory(DmpBlueprintFieldCategory.ReferenceType);
persist.setReferenceTypeId(importXml.getReferenceTypeId());
persist.setReferenceTypeId(data.getId());
persist.setLabel(importXml.getLabel());
persist.setPlaceholder(importXml.getPlaceholder());
persist.setDescription(importXml.getDescription());

View File

@ -1,17 +1,26 @@
package org.opencdmp.service.fielddatahelper;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.validation.Validator;
import gr.cite.tools.validation.ValidatorFactory;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commonmodels.models.descriptiotemplate.fielddata.ReferenceTypeDataModel;
import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
import org.opencdmp.commons.types.descriptiontemplate.importexport.fielddata.ReferenceTypeDataImportExport;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.ReferenceTypeEntity;
import org.opencdmp.model.builder.commonmodels.descriptiontemplate.fielddata.ReferenceTypeDataCommonModelBuilder;
import org.opencdmp.model.builder.descriptiontemplate.fielddata.ReferenceTypeDataBuilder;
import org.opencdmp.model.descriptiontemplate.fielddata.ReferenceTypeData;
import org.opencdmp.model.persist.descriptiontemplatedefinition.fielddata.ReferenceTypeDataPersist;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.validation.Validator;
import gr.cite.tools.validation.ValidatorFactory;
import org.opencdmp.model.referencetype.ReferenceType;
import org.opencdmp.query.ReferenceTypeQuery;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.EnumSet;
@ -19,12 +28,18 @@ import java.util.List;
@Component
public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperService<ReferenceTypeData, ReferenceTypeDataPersist, ReferenceTypeDataEntity, ReferenceTypeDataImportExport, ReferenceTypeDataModel> {
private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
private final ConventionService conventionService;
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
public ReferenceTypeFieldDataHelperService(BuilderFactory builderFactory, ValidatorFactory validatorFactory) {
public ReferenceTypeFieldDataHelperService(BuilderFactory builderFactory, QueryFactory queryFactory, ConventionService conventionService, MessageSource messageSource, ValidatorFactory validatorFactory) {
this.builderFactory = builderFactory;
this.queryFactory = queryFactory;
this.conventionService = conventionService;
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@ -100,14 +115,23 @@ public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperServ
@Override
protected ReferenceTypeDataPersist importExportMapDataToPersistInternal(ReferenceTypeDataImportExport data, ReferenceTypeDataPersist persist){
ReferenceTypeEntity referenceTypeEntity = data.getReferenceTypeId() != null ? this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(data.getReferenceTypeId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id)) : null;
if (referenceTypeEntity == null){
if (!this.conventionService.isNullOrEmpty(data.getReferenceTypeCode())) referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().codes(data.getReferenceTypeCode()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id));
if (referenceTypeEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
}
persist.setMultipleSelect(data.getMultipleSelect());
persist.setReferenceTypeId(data.getReferenceTypeId());
persist.setReferenceTypeId(referenceTypeEntity.getId());
return persist;
}
@Override
protected ReferenceTypeDataImportExport dataToImportExportXmlInternal(ReferenceTypeDataEntity data, ReferenceTypeDataImportExport xml) {
ReferenceTypeEntity referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(data.getReferenceTypeId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._code));
if (referenceTypeEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
xml.setMultipleSelect(data.getMultipleSelect());
xml.setReferenceTypeCode(referenceTypeEntity.getCode());
xml.setReferenceTypeId(data.getReferenceTypeId());
return xml;
}

View File

@ -25,6 +25,7 @@ import org.opencdmp.commons.enums.DmpAccessType;
import org.opencdmp.commons.enums.DmpStatus;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.controllers.swagger.SwaggerHelpers;
import org.opencdmp.controllers.swagger.annotation.Swagger400;
import org.opencdmp.controllers.swagger.annotation.Swagger404;
import org.opencdmp.controllers.swagger.annotation.SwaggerErrorResponses;
import org.opencdmp.convention.ConventionService;
@ -229,6 +230,7 @@ public class DescriptionController {
@PostMapping("persist")
@Operation(summary = "Create a new or update an existing description")
@Swagger400
@Swagger404
@Transactional
@ValidationFilterAnnotation(validator = DescriptionPersist.DescriptionPersistValidator.ValidatorName, argumentName = "model")
@ -251,6 +253,7 @@ public class DescriptionController {
@PostMapping("persist-status")
@Operation(summary = "Update the status of an existing description")
@Swagger400
@Swagger404
@Transactional
@ValidationFilterAnnotation(validator = DescriptionStatusPersist.DescriptionStatusPersistValidator.ValidatorName, argumentName = "model")
@ -331,6 +334,7 @@ public class DescriptionController {
@PostMapping("field-file/upload")
@Operation(summary = "Upload a file attachment on a field that supports it")
@Swagger400
@Swagger404
@Transactional
@ValidationFilterAnnotation(validator = DescriptionFieldFilePersist.PersistValidator.ValidatorName, argumentName = "model")
@ -381,6 +385,7 @@ public class DescriptionController {
@PostMapping("update-description-template")
@Operation(summary = "Change the template of a description")
@Swagger400
@Swagger404
@Transactional
@ValidationFilterAnnotation(validator = UpdateDescriptionTemplatePersist.UpdateDescriptionTemplatePersistValidator.ValidatorName, argumentName = "model")

View File

@ -25,6 +25,7 @@ import org.opencdmp.commons.enums.DmpAccessType;
import org.opencdmp.commons.enums.DmpStatus;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.controllers.swagger.SwaggerHelpers;
import org.opencdmp.controllers.swagger.annotation.Swagger400;
import org.opencdmp.controllers.swagger.annotation.Swagger404;
import org.opencdmp.controllers.swagger.annotation.SwaggerErrorResponses;
import org.opencdmp.model.DescriptionsToBeFinalized;
@ -217,6 +218,7 @@ public class DmpController {
@PostMapping("persist")
@Operation(summary = "Create a new or update an existing plan")
@Swagger400
@Swagger404
@Transactional
@ValidationFilterAnnotation(validator = DmpPersist.DmpPersistValidator.ValidatorName, argumentName = "model")
@ -310,6 +312,7 @@ public class DmpController {
@PostMapping("clone")
@Operation(summary = "Create a clone of an existing plan")
@Swagger400
@Swagger404
@Transactional
@ValidationFilterAnnotation(validator = CloneDmpPersist.CloneDmpPersistValidator.ValidatorName, argumentName = "model")
@ -333,6 +336,7 @@ public class DmpController {
@PostMapping("new-version")
@Operation(summary = "Create a new version of an existing plan")
@Swagger400
@Swagger404
@Transactional
@ValidationFilterAnnotation(validator = NewVersionDmpPersist.NewVersionDmpPersistValidator.ValidatorName, argumentName = "model")

View File

@ -12,11 +12,25 @@ public class SwaggerHelpers {
public static class Errors {
public static final String message_400 =
"""
{
"code": 400,
"message" "validation error",
"errors": {
"key": "name",
"message": [
"name is required"
]
}
}
""";
public static final String message_403 =
"""
{
"code": 403
"message" null
"code": 403,
"message": null
}
""";

View File

@ -0,0 +1,33 @@
package org.opencdmp.controllers.swagger.annotation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import java.lang.annotation.*;
import static org.opencdmp.controllers.swagger.SwaggerHelpers.Errors.message_400;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
@ApiResponse(
description = "This is generally the response you should expect when you don't provide correct information and a validation error occurs.",
responseCode = "400",
content = {
@Content(
examples = {
@ExampleObject(
name = "400 example response",
description = "This could be a response in case of a 400 bad request error. " +
"It should contain a list of all the data requirements that are not fulfilled. " +
"In our example, the property 'name' is mandatory and was not provided in the request body, resulting in the validation error above.",
value = message_400
)
}
)
}
)
public @interface Swagger400 {
}

View File

@ -18,7 +18,7 @@ import static org.opencdmp.controllers.swagger.SwaggerHelpers.Errors.message_403
@Content(
examples = {
@ExampleObject(
name = "404 response",
name = "403 response",
description = "This is the response in case of a 403 error.",
value = message_403
)