description template import changes

This commit is contained in:
Efstratios Giannopoulos 2024-06-11 16:04:41 +03:00
parent c522de12ec
commit 697218826b
21 changed files with 151 additions and 176 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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opencdmp.commons.xmladapter.InstantXmlAdapter; import org.opencdmp.commons.xmladapter.InstantXmlAdapter;
@ -11,7 +10,7 @@ import java.time.Instant;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateDefaultValueImportExport { public class DescriptionTemplateDefaultValueImportExport {
@XmlAttribute(name="value") @XmlElement(name="value")
private String textValue; private String textValue;
@XmlElement(name = "dateValue") @XmlElement(name = "dateValue")
@XmlJavaTypeAdapter(InstantXmlAdapter.class) @XmlJavaTypeAdapter(InstantXmlAdapter.class)

View File

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

View File

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

View File

@ -13,13 +13,13 @@ public class DescriptionTemplateImportExport {
@XmlElement(name = "id") @XmlElement(name = "id")
private UUID id; private UUID id;
@XmlAttribute(name = "description") @XmlElement(name = "description")
private String description; private String description;
@XmlAttribute(name = "language") @XmlElement(name = "language")
private String language; private String language;
@XmlAttribute(name = "type") @XmlElement(name = "type")
private UUID type; private UUID type;
@XmlAttribute(name = "version") @XmlElement(name = "version")
private Short version; private Short version;
@XmlElement(name = "groupId") @XmlElement(name = "groupId")
private UUID 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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@ -11,13 +12,13 @@ public class DescriptionTemplateMultiplicityImportExport {
private int min; private int min;
@XmlAttribute(name="max") @XmlAttribute(name="max")
private int max; private int max;
@XmlAttribute(name="placeholder") @XmlElement(name="placeholder")
private String placeholder; private String placeholder;
@XmlAttribute(name="tableView") @XmlElement(name="tableView")
private boolean tableView; private boolean tableView;
public int getMin() { public int getMin() {
return min; return this.min;
} }
public void setMin(int min) { public void setMin(int min) {
@ -25,7 +26,7 @@ public class DescriptionTemplateMultiplicityImportExport {
} }
public int getMax() { public int getMax() {
return max; return this.max;
} }
public void setMax(int max) { public void setMax(int max) {
@ -33,7 +34,7 @@ public class DescriptionTemplateMultiplicityImportExport {
} }
public String getPlaceholder() { public String getPlaceholder() {
return placeholder; return this.placeholder;
} }
public void setPlaceholder(String placeholder) { public void setPlaceholder(String placeholder) {
@ -41,7 +42,7 @@ public class DescriptionTemplateMultiplicityImportExport {
} }
public boolean getTableView() { public boolean getTableView() {
return tableView; return this.tableView;
} }
public void setTableView(boolean tableView) { public void setTableView(boolean tableView) {

View File

@ -1,18 +1,21 @@
package org.opencdmp.commons.types.descriptiontemplate.importexport; 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.ArrayList;
import java.util.List; import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplatePageImportExport { public class DescriptionTemplatePageImportExport {
@XmlAttribute(name = "id") @XmlElement(name = "id")
private String id; private String id;
@XmlAttribute(name = "ordinal") @XmlElement(name = "ordinal")
private int ordinal; private int ordinal;
@XmlAttribute(name = "title") @XmlElement(name = "title")
private String title; private String title;
@XmlElementWrapper(name = "sections") @XmlElementWrapper(name = "sections")
@XmlElement(name = "section") @XmlElement(name = "section")
@ -20,7 +23,7 @@ public class DescriptionTemplatePageImportExport {
public String getId() { public String getId() {
return id; return this.id;
} }
public void setId(String id) { public void setId(String id) {
@ -28,14 +31,14 @@ public class DescriptionTemplatePageImportExport {
} }
public int getOrdinal() { public int getOrdinal() {
return ordinal; return this.ordinal;
} }
public void setOrdinal(int ordinal) { public void setOrdinal(int ordinal) {
this.ordinal = ordinal; this.ordinal = ordinal;
} }
public String getTitle() { public String getTitle() {
return title; return this.title;
} }
public void setTitle(String title) { public void setTitle(String title) {
@ -43,7 +46,7 @@ public class DescriptionTemplatePageImportExport {
} }
public List<DescriptionTemplateSectionImportExport> getSections() { public List<DescriptionTemplateSectionImportExport> getSections() {
return sections; return this.sections;
} }
public void setSections(List<DescriptionTemplateSectionImportExport> 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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opencdmp.commons.xmladapter.InstantXmlAdapter; import org.opencdmp.commons.xmladapter.InstantXmlAdapter;
@ -12,9 +11,9 @@ import java.time.Instant;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateRuleImportExport { public class DescriptionTemplateRuleImportExport {
@XmlAttribute(name="target") @XmlElement(name="target")
private String target; private String target;
@XmlAttribute(name="value") @XmlElement(name="value")
private String textValue; private String textValue;
@XmlElement(name = "dateValue") @XmlElement(name = "dateValue")

View File

@ -1,15 +1,18 @@
package org.opencdmp.commons.types.descriptiontemplate.importexport; 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.ArrayList;
import java.util.List; import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateSectionImportExport { public class DescriptionTemplateSectionImportExport {
@XmlAttribute(name = "id") @XmlElement(name = "id")
private String id; private String id;
@XmlAttribute(name = "ordinal") @XmlElement(name = "ordinal")
private int ordinal; private int ordinal;
@XmlElementWrapper(name = "fieldSets") @XmlElementWrapper(name = "fieldSets")
@XmlElement(name = "fieldSet") @XmlElement(name = "fieldSet")

View File

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

View File

@ -12,7 +12,7 @@ public class LabelAndMultiplicityDataImportExport extends BaseFieldDataImportExp
private Boolean multipleSelect; private Boolean multipleSelect;
public Boolean getMultipleSelect() { public Boolean getMultipleSelect() {
return multipleSelect; return this.multipleSelect;
} }
public void setMultipleSelect(Boolean 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.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import java.util.UUID; import java.util.UUID;
@ -13,11 +14,14 @@ public class ReferenceTypeDataImportExport extends BaseFieldDataImportExport {
@XmlAttribute(name = "multipleSelect") @XmlAttribute(name = "multipleSelect")
private Boolean multipleSelect; private Boolean multipleSelect;
@XmlAttribute(name = "referenceTypeId") @XmlElement(name = "referenceTypeId")
private UUID referenceTypeId; private UUID referenceTypeId;
@XmlElement(name = "referenceTypeCode")
private String referenceTypeCode;
public Boolean getMultipleSelect() { public Boolean getMultipleSelect() {
return multipleSelect; return this.multipleSelect;
} }
public void setMultipleSelect(Boolean multipleSelect) { public void setMultipleSelect(Boolean multipleSelect) {
@ -25,10 +29,18 @@ public class ReferenceTypeDataImportExport extends BaseFieldDataImportExport {
} }
public UUID getReferenceTypeId() { public UUID getReferenceTypeId() {
return referenceTypeId; return this.referenceTypeId;
} }
public void setReferenceTypeId(UUID referenceTypeId) { public void setReferenceTypeId(UUID referenceTypeId) {
this.referenceTypeId = 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") @XmlElement(name = "type")
private List<UploadDataOption> types; private List<UploadDataOption> types;
@XmlAttribute(name = "maxFileSizeInMB") @XmlElement(name = "maxFileSizeInMB")
private Integer maxFileSizeInMB; private Integer maxFileSizeInMB;
public List<UploadDataOption> getTypes() { public List<UploadDataOption> getTypes() {
return types; return this.types;
} }
public void setTypes(List<UploadDataOption> types) { public void setTypes(List<UploadDataOption> types) {
@ -24,7 +24,7 @@ public class UploadDataImportExport extends BaseFieldDataImportExport {
} }
public Integer getMaxFileSizeInMB() { public Integer getMaxFileSizeInMB() {
return maxFileSizeInMB; return this.maxFileSizeInMB;
} }
public void setMaxFileSizeInMB(Integer maxFileSizeInMB) { public void setMaxFileSizeInMB(Integer maxFileSizeInMB) {
@ -39,7 +39,7 @@ public class UploadDataImportExport extends BaseFieldDataImportExport {
private String value; private String value;
public String getLabel() { public String getLabel() {
return label; return this.label;
} }
public void setLabel(String label) { public void setLabel(String label) {
@ -47,7 +47,7 @@ public class UploadDataImportExport extends BaseFieldDataImportExport {
} }
public String getValue() { public String getValue() {
return value; return this.value;
} }
public void setValue(String value) { public void setValue(String value) {

View File

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

View File

@ -2,6 +2,7 @@ package org.opencdmp.commons.types.dmpblueprint.importexport;
import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import java.util.UUID; import java.util.UUID;
@ -12,9 +13,9 @@ public class BlueprintDescriptionTemplateImportExport {
private UUID descriptionTemplateGroupId; private UUID descriptionTemplateGroupId;
@XmlElement(name = "label") @XmlElement(name = "label")
private String label; private String label;
@XmlElement(name = "minMultiplicity") @XmlAttribute(name = "minMultiplicity")
private Integer minMultiplicity; private Integer minMultiplicity;
@XmlElement(name = "maxMultiplicity") @XmlAttribute(name = "maxMultiplicity")
private Integer maxMultiplicity; private Integer maxMultiplicity;
public UUID getDescriptionTemplateGroupId() { public UUID getDescriptionTemplateGroupId() {

View File

@ -2,6 +2,7 @@ package org.opencdmp.commons.types.dmpblueprint.importexport;
import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType; import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType;
@ -23,9 +24,9 @@ public class BlueprintExtraFieldImportExport {
private String description; private String description;
@XmlElement(name="semantics") @XmlElement(name="semantics")
private List<String> semantics; private List<String> semantics;
@XmlElement(name = "ordinal") @XmlAttribute(name = "ordinal")
private int ordinal; private int ordinal;
@XmlElement(name = "required") @XmlAttribute(name = "required")
private boolean required; private boolean required;
public UUID getId() { public UUID getId() {

View File

@ -2,6 +2,7 @@ package org.opencdmp.commons.types.dmpblueprint.importexport;
import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import java.util.List; import java.util.List;
@ -24,9 +25,9 @@ public class BlueprintReferenceTypeFieldImportExport {
private String description; private String description;
@XmlElement(name="semantics") @XmlElement(name="semantics")
private List<String> semantics; private List<String> semantics;
@XmlElement(name = "ordinal") @XmlAttribute(name = "ordinal")
private int ordinal; private int ordinal;
@XmlElement(name = "required") @XmlAttribute(name = "required")
private boolean required; private boolean required;
@XmlElement(name = "multipleSelect") @XmlElement(name = "multipleSelect")

View File

@ -1,9 +1,6 @@
package org.opencdmp.commons.types.dmpblueprint.importexport; package org.opencdmp.commons.types.dmpblueprint.importexport;
import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.*;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -28,7 +25,7 @@ public class BlueprintSectionImportExport {
@XmlElementWrapper(name = "referenceFields") @XmlElementWrapper(name = "referenceFields")
@XmlElement(name = "referenceField") @XmlElement(name = "referenceField")
private List<BlueprintReferenceTypeFieldImportExport> referenceFields; private List<BlueprintReferenceTypeFieldImportExport> referenceFields;
@XmlElement(name = "hasTemplates") @XmlAttribute(name = "hasTemplates")
private boolean hasTemplates; private boolean hasTemplates;
@XmlElementWrapper(name = "descriptionTemplates") @XmlElementWrapper(name = "descriptionTemplates")
@XmlElement(name = "descriptionTemplate") @XmlElement(name = "descriptionTemplate")

View File

@ -2,6 +2,7 @@ package org.opencdmp.commons.types.dmpblueprint.importexport;
import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType; import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType;
@ -23,9 +24,9 @@ public class BlueprintSystemFieldImportExport {
private String description; private String description;
@XmlElement(name="semantics") @XmlElement(name="semantics")
private List<String> semantics; private List<String> semantics;
@XmlElement(name = "ordinal") @XmlAttribute(name = "ordinal")
private int ordinal; private int ordinal;
@XmlElement(name = "required") @XmlAttribute(name = "required")
private boolean required; private boolean required;
public UUID getId() { public UUID getId() {

View File

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

View File

@ -28,11 +28,13 @@ import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.commons.scope.user.UserScope; import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.commons.types.descriptiontemplate.*; import org.opencdmp.commons.types.descriptiontemplate.*;
import org.opencdmp.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity; 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.descriptiontemplate.importexport.*;
import org.opencdmp.commons.types.notification.*; import org.opencdmp.commons.types.notification.*;
import org.opencdmp.convention.ConventionService; 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.errorcode.ErrorThesaurusProperties;
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent; import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEvent;
import org.opencdmp.integrationevent.outbox.notification.NotifyIntegrationEventHandler; 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.descriptiontemplate.*;
import org.opencdmp.model.persist.DescriptionTemplatePersist; import org.opencdmp.model.persist.DescriptionTemplatePersist;
import org.opencdmp.model.persist.NewVersionDescriptionTemplatePersist; import org.opencdmp.model.persist.NewVersionDescriptionTemplatePersist;
import org.opencdmp.model.persist.ReferencePersist;
import org.opencdmp.model.persist.UserDescriptionTemplatePersist; import org.opencdmp.model.persist.UserDescriptionTemplatePersist;
import org.opencdmp.model.persist.descriptiontemplatedefinition.*; import org.opencdmp.model.persist.descriptiontemplatedefinition.*;
import org.opencdmp.model.persist.descriptiontemplatedefinition.fielddata.BaseFieldDataPersist; 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.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.FieldDataHelperService;
import org.opencdmp.service.fielddatahelper.FieldDataHelperServiceProvider; import org.opencdmp.service.fielddatahelper.FieldDataHelperServiceProvider;
import org.opencdmp.service.responseutils.ResponseUtilsService; import org.opencdmp.service.responseutils.ResponseUtilsService;
@ -292,7 +293,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
this.eventHandler.handle(event); this.eventHandler.handle(event);
} }
private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist) throws InvalidApplicationException { private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist) {
DefinitionEntity data = new DefinitionEntity(); DefinitionEntity data = new DefinitionEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -307,7 +308,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data; return data;
} }
private @NotNull SectionEntity buildSectionEntity(SectionPersist persist) throws InvalidApplicationException { private @NotNull SectionEntity buildSectionEntity(SectionPersist persist) {
SectionEntity data = new SectionEntity(); SectionEntity data = new SectionEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -334,7 +335,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data; return data;
} }
private @NotNull FieldSetEntity buildFieldSetEntity(FieldSetPersist persist) throws InvalidApplicationException { private @NotNull FieldSetEntity buildFieldSetEntity(FieldSetPersist persist) {
FieldSetEntity data = new FieldSetEntity(); FieldSetEntity data = new FieldSetEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -363,7 +364,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data; return data;
} }
private @NotNull FieldEntity buildFieldEntity(FieldPersist persist) throws InvalidApplicationException { private @NotNull FieldEntity buildFieldEntity(FieldPersist persist) {
FieldEntity data = new FieldEntity(); FieldEntity data = new FieldEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -393,7 +394,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return this.fieldDataHelperServiceProvider.get(persist.getFieldType()).applyPersist(persist); 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; FieldType fieldType = fieldEntity != null && fieldEntity.getData() != null ? fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
RuleEntity data = new RuleEntity(); RuleEntity data = new RuleEntity();
if (persist == null) return data; if (persist == null) return data;
@ -446,77 +447,6 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data; 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) { private @NotNull MultiplicityEntity buildMultiplicityEntity(MultiplicityPersist persist) {
MultiplicityEntity data = new MultiplicityEntity(); MultiplicityEntity data = new MultiplicityEntity();
if (persist == null) if (persist == null)
@ -533,7 +463,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
return data; return data;
} }
private @NotNull PageEntity buildPageEntity(PagePersist persist) throws InvalidApplicationException { private @NotNull PageEntity buildPageEntity(PagePersist persist) {
PageEntity data = new PageEntity(); PageEntity data = new PageEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -907,7 +837,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
//region Export //region Export
@Override @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)); logger.debug(new MapLogEntry("exportXml").And("id", id));
if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate); if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);

View File

@ -1,17 +1,26 @@
package org.opencdmp.service.fielddatahelper; 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.authorization.AuthorizationFlags;
import org.opencdmp.commonmodels.models.descriptiotemplate.fielddata.ReferenceTypeDataModel; import org.opencdmp.commonmodels.models.descriptiotemplate.fielddata.ReferenceTypeDataModel;
import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity; import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
import org.opencdmp.commons.types.descriptiontemplate.importexport.fielddata.ReferenceTypeDataImportExport; 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.commonmodels.descriptiontemplate.fielddata.ReferenceTypeDataCommonModelBuilder;
import org.opencdmp.model.builder.descriptiontemplate.fielddata.ReferenceTypeDataBuilder; import org.opencdmp.model.builder.descriptiontemplate.fielddata.ReferenceTypeDataBuilder;
import org.opencdmp.model.descriptiontemplate.fielddata.ReferenceTypeData; import org.opencdmp.model.descriptiontemplate.fielddata.ReferenceTypeData;
import org.opencdmp.model.persist.descriptiontemplatedefinition.fielddata.ReferenceTypeDataPersist; import org.opencdmp.model.persist.descriptiontemplatedefinition.fielddata.ReferenceTypeDataPersist;
import gr.cite.tools.data.builder.BuilderFactory; import org.opencdmp.model.referencetype.ReferenceType;
import gr.cite.tools.fieldset.FieldSet; import org.opencdmp.query.ReferenceTypeQuery;
import gr.cite.tools.validation.Validator; import org.springframework.context.MessageSource;
import gr.cite.tools.validation.ValidatorFactory; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.EnumSet; import java.util.EnumSet;
@ -21,10 +30,16 @@ import java.util.List;
public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperService<ReferenceTypeData, ReferenceTypeDataPersist, ReferenceTypeDataEntity, ReferenceTypeDataImportExport, ReferenceTypeDataModel> { public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperService<ReferenceTypeData, ReferenceTypeDataPersist, ReferenceTypeDataEntity, ReferenceTypeDataImportExport, ReferenceTypeDataModel> {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
private final ConventionService conventionService;
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory; 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.builderFactory = builderFactory;
this.queryFactory = queryFactory;
this.conventionService = conventionService;
this.messageSource = messageSource;
this.validatorFactory = validatorFactory; this.validatorFactory = validatorFactory;
} }
@ -100,14 +115,23 @@ public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperServ
@Override @Override
protected ReferenceTypeDataPersist importExportMapDataToPersistInternal(ReferenceTypeDataImportExport data, ReferenceTypeDataPersist persist){ 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.setMultipleSelect(data.getMultipleSelect());
persist.setReferenceTypeId(data.getReferenceTypeId()); persist.setReferenceTypeId(referenceTypeEntity.getId());
return persist; return persist;
} }
@Override @Override
protected ReferenceTypeDataImportExport dataToImportExportXmlInternal(ReferenceTypeDataEntity data, ReferenceTypeDataImportExport xml) { 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.setMultipleSelect(data.getMultipleSelect());
xml.setReferenceTypeCode(referenceTypeEntity.getCode());
xml.setReferenceTypeId(data.getReferenceTypeId()); xml.setReferenceTypeId(data.getReferenceTypeId());
return xml; return xml;
} }