Description export
This commit is contained in:
parent
30d338bbbd
commit
85b2258e19
|
@ -109,6 +109,7 @@ public final class Permission {
|
||||||
public static String FinalizeDescription = "FinalizeDescription";
|
public static String FinalizeDescription = "FinalizeDescription";
|
||||||
public static String DeleteDescription = "DeleteDescription";
|
public static String DeleteDescription = "DeleteDescription";
|
||||||
public static String CloneDescription = "CloneDescription";
|
public static String CloneDescription = "CloneDescription";
|
||||||
|
public static String ExportDescription = "ExportDescription";
|
||||||
|
|
||||||
//DescriptionTag
|
//DescriptionTag
|
||||||
public static String BrowseDescriptionTag = "BrowseDescriptionTag";
|
public static String BrowseDescriptionTag = "BrowseDescriptionTag";
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.opencdmp.commons.types.description.importexport;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class DescriptionExternalIdentifierImportExport {
|
||||||
|
|
||||||
|
@XmlElement(name = "identifier")
|
||||||
|
private String identifier;
|
||||||
|
|
||||||
|
@XmlElement(name = "type")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public String getIdentifier() {
|
||||||
|
return this.identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdentifier(String identifier) {
|
||||||
|
this.identifier = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package org.opencdmp.commons.types.description.importexport;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class DescriptionFieldImportExport {
|
||||||
|
@XmlElement(name = "fieldId")
|
||||||
|
private String fieldId;
|
||||||
|
@XmlElement(name = "textValue")
|
||||||
|
private String textValue;
|
||||||
|
@XmlElementWrapper(name = "textListValues")
|
||||||
|
@XmlElement(name = "textListValue")
|
||||||
|
private List<String> textListValue;
|
||||||
|
@XmlElement(name = "dateValue")
|
||||||
|
private Instant dateValue;
|
||||||
|
@XmlElement(name = "externalIdentifier")
|
||||||
|
private DescriptionExternalIdentifierImportExport externalIdentifier;
|
||||||
|
|
||||||
|
public String getFieldId() {
|
||||||
|
return this.fieldId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldId(String fieldId) {
|
||||||
|
this.fieldId = fieldId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTextValue() {
|
||||||
|
return this.textValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextValue(String textValue) {
|
||||||
|
this.textValue = textValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getTextListValue() {
|
||||||
|
return this.textListValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextListValue(List<String> textListValue) {
|
||||||
|
this.textListValue = textListValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getDateValue() {
|
||||||
|
return this.dateValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateValue(Instant dateValue) {
|
||||||
|
this.dateValue = dateValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionExternalIdentifierImportExport getExternalIdentifier() {
|
||||||
|
return this.externalIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExternalIdentifier(DescriptionExternalIdentifierImportExport externalIdentifier) {
|
||||||
|
this.externalIdentifier = externalIdentifier;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
package org.opencdmp.commons.types.description.importexport;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.annotation.*;
|
||||||
|
import org.opencdmp.commons.types.descriptiontemplate.importexport.DescriptionTemplateImportExport;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "description")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class DescriptionImportExport {
|
||||||
|
|
||||||
|
@XmlElement(name = "id")
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
@XmlElement(name = "description")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@XmlElement(name = "label")
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
@XmlElement(name = "finalizedAt")
|
||||||
|
private Instant finalizedAt;
|
||||||
|
|
||||||
|
@XmlElement(name = "sectionId")
|
||||||
|
private UUID sectionId;
|
||||||
|
|
||||||
|
@XmlElement(name = "descriptionTemplate")
|
||||||
|
private DescriptionTemplateImportExport descriptionTemplate;
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "references")
|
||||||
|
@XmlElement(name = "reference")
|
||||||
|
private List<DescriptionReferenceImportExport> references;
|
||||||
|
|
||||||
|
@XmlElement(name = "properties")
|
||||||
|
private DescriptionPropertyDefinitionImportExport properties;
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return this.label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getFinalizedAt() {
|
||||||
|
return this.finalizedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinalizedAt(Instant finalizedAt) {
|
||||||
|
this.finalizedAt = finalizedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getSectionId() {
|
||||||
|
return this.sectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSectionId(UUID sectionId) {
|
||||||
|
this.sectionId = sectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionTemplateImportExport getDescriptionTemplate() {
|
||||||
|
return this.descriptionTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptionTemplate(DescriptionTemplateImportExport descriptionTemplate) {
|
||||||
|
this.descriptionTemplate = descriptionTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DescriptionReferenceImportExport> getReferences() {
|
||||||
|
return this.references;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferences(List<DescriptionReferenceImportExport> references) {
|
||||||
|
this.references = references;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionPropertyDefinitionImportExport getProperties() {
|
||||||
|
return this.properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperties(DescriptionPropertyDefinitionImportExport properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package org.opencdmp.commons.types.description.importexport;
|
||||||
|
|
||||||
|
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.List;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class DescriptionPropertyDefinitionFieldSetImportExport {
|
||||||
|
|
||||||
|
@XmlElement(name = "fieldSetId")
|
||||||
|
private String fieldSetId;
|
||||||
|
@XmlElementWrapper(name = "items")
|
||||||
|
@XmlElement(name = "item")
|
||||||
|
private List<DescriptionPropertyDefinitionFieldSetItemImportExport> items;
|
||||||
|
|
||||||
|
public List<DescriptionPropertyDefinitionFieldSetItemImportExport> getItems() {
|
||||||
|
return this.items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<DescriptionPropertyDefinitionFieldSetItemImportExport> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFieldSetId() {
|
||||||
|
return this.fieldSetId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldSetId(String fieldSetId) {
|
||||||
|
this.fieldSetId = fieldSetId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package org.opencdmp.commons.types.description.importexport;
|
||||||
|
|
||||||
|
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.List;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class DescriptionPropertyDefinitionFieldSetItemImportExport {
|
||||||
|
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "fields")
|
||||||
|
@XmlElement(name = "field")
|
||||||
|
private List<DescriptionFieldImportExport> fields;
|
||||||
|
@XmlElement(name = "comment")
|
||||||
|
private String comment;
|
||||||
|
@XmlElement(name = "ordinal")
|
||||||
|
private int ordinal;
|
||||||
|
|
||||||
|
public List<DescriptionFieldImportExport> getFields() {
|
||||||
|
return this.fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(List<DescriptionFieldImportExport> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComment() {
|
||||||
|
return this.comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComment(String comment) {
|
||||||
|
this.comment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrdinal() {
|
||||||
|
return this.ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrdinal(int ordinal) {
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package org.opencdmp.commons.types.description.importexport;
|
||||||
|
|
||||||
|
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.List;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class DescriptionPropertyDefinitionImportExport {
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "fieldSets")
|
||||||
|
@XmlElement(name = "fieldSet")
|
||||||
|
private List<DescriptionPropertyDefinitionFieldSetImportExport> fieldSets;
|
||||||
|
|
||||||
|
public List<DescriptionPropertyDefinitionFieldSetImportExport> getFieldSets() {
|
||||||
|
return this.fieldSets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldSets(List<DescriptionPropertyDefinitionFieldSetImportExport> fieldSets) {
|
||||||
|
this.fieldSets = fieldSets;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package org.opencdmp.commons.types.description.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 DescriptionReferenceImportExport {
|
||||||
|
|
||||||
|
@XmlElement(name = "id")
|
||||||
|
private UUID id;
|
||||||
|
@XmlElement(name = "label")
|
||||||
|
private String label;
|
||||||
|
@XmlElement(name = "reference")
|
||||||
|
private String reference;
|
||||||
|
@XmlElement(name = "fieldId")
|
||||||
|
private String fieldId;
|
||||||
|
@XmlElement(name = "type")
|
||||||
|
private DescriptionReferenceTypeImportExport type;
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return this.label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReference() {
|
||||||
|
return this.reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReference(String reference) {
|
||||||
|
this.reference = reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceTypeImportExport getType() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(DescriptionReferenceTypeImportExport type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFieldId() {
|
||||||
|
return this.fieldId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldId(String fieldId) {
|
||||||
|
this.fieldId = fieldId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package org.opencdmp.commons.types.description.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 DescriptionReferenceTypeImportExport {
|
||||||
|
|
||||||
|
@XmlElement(name = "id")
|
||||||
|
private UUID id;
|
||||||
|
@XmlElement(name = "name")
|
||||||
|
private String name;
|
||||||
|
@XmlElement(name = "code")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ExternalIdentifierImportExport {
|
public class DescriptionTemplateExternalIdentifierImportExport {
|
||||||
|
|
||||||
@XmlAttribute(name="identifier")
|
@XmlAttribute(name="identifier")
|
||||||
private String identifier;
|
private String identifier;
|
|
@ -8,7 +8,7 @@ import jakarta.xml.bind.annotation.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class FieldImportExport {
|
public class DescriptionTemplateFieldImportExport {
|
||||||
|
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
private String id;
|
private String id;
|
||||||
|
@ -28,7 +28,7 @@ public class FieldImportExport {
|
||||||
|
|
||||||
@XmlElementWrapper(name = "visibilityRules")
|
@XmlElementWrapper(name = "visibilityRules")
|
||||||
@XmlElement(name = "visibilityRule")
|
@XmlElement(name = "visibilityRule")
|
||||||
private List<RuleImportExport> visibilityRules;
|
private List<DescriptionTemplateRuleImportExport> visibilityRules;
|
||||||
|
|
||||||
@XmlElement(name = "fieldType")
|
@XmlElement(name = "fieldType")
|
||||||
private FieldType fieldType;
|
private FieldType fieldType;
|
||||||
|
@ -111,11 +111,11 @@ public class FieldImportExport {
|
||||||
this.schematics = schematics;
|
this.schematics = schematics;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RuleImportExport> getVisibilityRules() {
|
public List<DescriptionTemplateRuleImportExport> getVisibilityRules() {
|
||||||
return visibilityRules;
|
return visibilityRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisibilityRules(List<RuleImportExport> visibilityRules) {
|
public void setVisibilityRules(List<DescriptionTemplateRuleImportExport> visibilityRules) {
|
||||||
this.visibilityRules = visibilityRules;
|
this.visibilityRules = visibilityRules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import jakarta.xml.bind.annotation.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class FieldSetImportExport {
|
public class DescriptionTemplateFieldSetImportExport {
|
||||||
|
|
||||||
@XmlAttribute(name="id")
|
@XmlAttribute(name="id")
|
||||||
private String id;
|
private String id;
|
||||||
|
@ -14,7 +14,7 @@ public class FieldSetImportExport {
|
||||||
|
|
||||||
@XmlElementWrapper(name = "fields")
|
@XmlElementWrapper(name = "fields")
|
||||||
@XmlElement(name = "field")
|
@XmlElement(name = "field")
|
||||||
private List<FieldImportExport> fields;
|
private List<DescriptionTemplateFieldImportExport> fields;
|
||||||
@XmlAttribute(name="numbering")
|
@XmlAttribute(name="numbering")
|
||||||
private String numbering;
|
private String numbering;
|
||||||
@XmlAttribute(name="title")
|
@XmlAttribute(name="title")
|
||||||
|
@ -26,7 +26,7 @@ public class FieldSetImportExport {
|
||||||
@XmlAttribute(name="additionalInformation")
|
@XmlAttribute(name="additionalInformation")
|
||||||
private String additionalInformation;
|
private String additionalInformation;
|
||||||
@XmlElement(name="multiplicity")
|
@XmlElement(name="multiplicity")
|
||||||
private MultiplicityImportExport multiplicity;
|
private DescriptionTemplateMultiplicityImportExport multiplicity;
|
||||||
|
|
||||||
@XmlAttribute(name="hasMultiplicity")
|
@XmlAttribute(name="hasMultiplicity")
|
||||||
private boolean hasMultiplicity;
|
private boolean hasMultiplicity;
|
||||||
|
@ -49,11 +49,11 @@ public class FieldSetImportExport {
|
||||||
this.ordinal = ordinal;
|
this.ordinal = ordinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FieldImportExport> getFields() {
|
public List<DescriptionTemplateFieldImportExport> getFields() {
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFields(List<FieldImportExport> fields) {
|
public void setFields(List<DescriptionTemplateFieldImportExport> fields) {
|
||||||
this.fields = fields;
|
this.fields = fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,11 +72,11 @@ public class FieldSetImportExport {
|
||||||
this.hasCommentField = hasCommentField;
|
this.hasCommentField = hasCommentField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultiplicityImportExport getMultiplicity() {
|
public DescriptionTemplateMultiplicityImportExport getMultiplicity() {
|
||||||
return multiplicity;
|
return multiplicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMultiplicity(MultiplicityImportExport multiplicity) {
|
public void setMultiplicity(DescriptionTemplateMultiplicityImportExport multiplicity) {
|
||||||
this.multiplicity = multiplicity;
|
this.multiplicity = multiplicity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
package org.opencdmp.commons.types.descriptiontemplate.importexport;
|
package org.opencdmp.commons.types.descriptiontemplate.importexport;
|
||||||
|
|
||||||
|
|
||||||
import org.opencdmp.commons.enums.DescriptionTemplateStatus;
|
|
||||||
|
|
||||||
import org.opencdmp.model.persist.DescriptionTemplatePersist;
|
|
||||||
import org.opencdmp.model.persist.NewVersionDescriptionTemplatePersist;
|
|
||||||
import org.opencdmp.model.persist.descriptiontemplatedefinition.DefinitionPersist;
|
|
||||||
import org.opencdmp.model.persist.descriptiontemplatedefinition.PagePersist;
|
|
||||||
import org.opencdmp.model.persist.descriptiontemplatedefinition.SectionPersist;
|
|
||||||
import org.opencdmp.service.fielddatahelper.FieldDataHelperServiceProvider;
|
|
||||||
import jakarta.xml.bind.annotation.*;
|
import jakarta.xml.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlRootElement(name = "root")
|
@XmlRootElement(name = "descriptionTemplate")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class DescriptionTemplateImportExport {
|
public class DescriptionTemplateImportExport {
|
||||||
|
|
||||||
|
@XmlElement(name = "id")
|
||||||
|
private UUID id;
|
||||||
@XmlAttribute(name = "description")
|
@XmlAttribute(name = "description")
|
||||||
private String description;
|
private String description;
|
||||||
@XmlAttribute(name = "language")
|
@XmlAttribute(name = "language")
|
||||||
|
@ -26,20 +20,27 @@ public class DescriptionTemplateImportExport {
|
||||||
private UUID type;
|
private UUID type;
|
||||||
@XmlElementWrapper(name = "pages")
|
@XmlElementWrapper(name = "pages")
|
||||||
@XmlElement(name = "page")
|
@XmlElement(name = "page")
|
||||||
private List<PageImportExport> pages;
|
private List<DescriptionTemplatePageImportExport> pages;
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
public List<PageImportExport> getPages() {
|
return this.id;
|
||||||
return pages;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPages(List<PageImportExport> pages) {
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DescriptionTemplatePageImportExport> getPages() {
|
||||||
|
return this.pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPages(List<DescriptionTemplatePageImportExport> pages) {
|
||||||
this.pages = pages;
|
this.pages = pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
|
@ -48,7 +49,7 @@ public class DescriptionTemplateImportExport {
|
||||||
|
|
||||||
|
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
return language;
|
return this.language;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLanguage(String language) {
|
public void setLanguage(String language) {
|
||||||
|
@ -57,7 +58,7 @@ public class DescriptionTemplateImportExport {
|
||||||
|
|
||||||
|
|
||||||
public UUID getType() {
|
public UUID getType() {
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(UUID type) {
|
public void setType(UUID type) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
|
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class MultiplicityImportExport {
|
public class DescriptionTemplateMultiplicityImportExport {
|
||||||
@XmlAttribute(name="min")
|
@XmlAttribute(name="min")
|
||||||
private int min;
|
private int min;
|
||||||
@XmlAttribute(name="max")
|
@XmlAttribute(name="max")
|
|
@ -1,14 +1,11 @@
|
||||||
package org.opencdmp.commons.types.descriptiontemplate.importexport;
|
package org.opencdmp.commons.types.descriptiontemplate.importexport;
|
||||||
|
|
||||||
import org.opencdmp.model.persist.descriptiontemplatedefinition.PagePersist;
|
|
||||||
import org.opencdmp.model.persist.descriptiontemplatedefinition.SectionPersist;
|
|
||||||
import org.opencdmp.service.fielddatahelper.FieldDataHelperServiceProvider;
|
|
||||||
import jakarta.xml.bind.annotation.*;
|
import jakarta.xml.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class PageImportExport {
|
public class DescriptionTemplatePageImportExport {
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
private String id;
|
private String id;
|
||||||
@XmlAttribute(name = "ordinal")
|
@XmlAttribute(name = "ordinal")
|
||||||
|
@ -18,7 +15,7 @@ public class PageImportExport {
|
||||||
private String title;
|
private String title;
|
||||||
@XmlElementWrapper(name = "sections")
|
@XmlElementWrapper(name = "sections")
|
||||||
@XmlElement(name = "section")
|
@XmlElement(name = "section")
|
||||||
private List<SectionImportExport> sections;
|
private List<DescriptionTemplateSectionImportExport> sections;
|
||||||
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -44,11 +41,11 @@ public class PageImportExport {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SectionImportExport> getSections() {
|
public List<DescriptionTemplateSectionImportExport> getSections() {
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSections(List<SectionImportExport> sections) {
|
public void setSections(List<DescriptionTemplateSectionImportExport> sections) {
|
||||||
this.sections = sections;
|
this.sections = sections;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class RuleImportExport {
|
public class DescriptionTemplateRuleImportExport {
|
||||||
|
|
||||||
@XmlAttribute(name="target")
|
@XmlAttribute(name="target")
|
||||||
private String target;
|
private String target;
|
||||||
|
@ -20,7 +20,7 @@ public class RuleImportExport {
|
||||||
private Instant dateValue;
|
private Instant dateValue;
|
||||||
|
|
||||||
@XmlElement(name="externalIdentifier")
|
@XmlElement(name="externalIdentifier")
|
||||||
private ExternalIdentifierImportExport externalIdentifier;
|
private DescriptionTemplateExternalIdentifierImportExport externalIdentifier;
|
||||||
|
|
||||||
public String getTarget() {
|
public String getTarget() {
|
||||||
return target;
|
return target;
|
||||||
|
@ -54,11 +54,11 @@ public class RuleImportExport {
|
||||||
this.dateValue = dateValue;
|
this.dateValue = dateValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalIdentifierImportExport getExternalIdentifier() {
|
public DescriptionTemplateExternalIdentifierImportExport getExternalIdentifier() {
|
||||||
return externalIdentifier;
|
return externalIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExternalIdentifier(ExternalIdentifierImportExport externalIdentifier) {
|
public void setExternalIdentifier(DescriptionTemplateExternalIdentifierImportExport externalIdentifier) {
|
||||||
this.externalIdentifier = externalIdentifier;
|
this.externalIdentifier = externalIdentifier;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ import jakarta.xml.bind.annotation.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class SectionImportExport {
|
public class DescriptionTemplateSectionImportExport {
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
private String id;
|
private String id;
|
||||||
@XmlAttribute(name = "ordinal")
|
@XmlAttribute(name = "ordinal")
|
||||||
|
@ -14,7 +14,7 @@ public class SectionImportExport {
|
||||||
private Boolean defaultVisibility;
|
private Boolean defaultVisibility;
|
||||||
@XmlElementWrapper(name = "fieldSets")
|
@XmlElementWrapper(name = "fieldSets")
|
||||||
@XmlElement(name = "fieldSet")
|
@XmlElement(name = "fieldSet")
|
||||||
private List<FieldSetImportExport> fieldSets;
|
private List<DescriptionTemplateFieldSetImportExport> fieldSets;
|
||||||
@XmlElement(name = "numbering")
|
@XmlElement(name = "numbering")
|
||||||
private String numbering;
|
private String numbering;
|
||||||
@XmlElement(name = "description")
|
@XmlElement(name = "description")
|
||||||
|
@ -23,7 +23,7 @@ public class SectionImportExport {
|
||||||
private String title;
|
private String title;
|
||||||
@XmlElementWrapper(name = "sections")
|
@XmlElementWrapper(name = "sections")
|
||||||
@XmlElement(name = "section")
|
@XmlElement(name = "section")
|
||||||
private List<SectionImportExport> sections;
|
private List<DescriptionTemplateSectionImportExport> sections;
|
||||||
@XmlAttribute(name = "multiplicity")
|
@XmlAttribute(name = "multiplicity")
|
||||||
private Boolean multiplicity;
|
private Boolean multiplicity;
|
||||||
|
|
||||||
|
@ -51,11 +51,11 @@ public class SectionImportExport {
|
||||||
this.defaultVisibility = defaultVisibility;
|
this.defaultVisibility = defaultVisibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FieldSetImportExport> getFieldSets() {
|
public List<DescriptionTemplateFieldSetImportExport> getFieldSets() {
|
||||||
return fieldSets;
|
return fieldSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFieldSets(List<FieldSetImportExport> fieldSets) {
|
public void setFieldSets(List<DescriptionTemplateFieldSetImportExport> fieldSets) {
|
||||||
this.fieldSets = fieldSets;
|
this.fieldSets = fieldSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,11 +83,11 @@ public class SectionImportExport {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SectionImportExport> getSections() {
|
public List<DescriptionTemplateSectionImportExport> getSections() {
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSections(List<SectionImportExport> sections) {
|
public void setSections(List<DescriptionTemplateSectionImportExport> sections) {
|
||||||
this.sections = sections;
|
this.sections = sections;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.opencdmp.commons.types.dmp.importexport;
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.*;
|
import jakarta.xml.bind.annotation.*;
|
||||||
import org.opencdmp.commons.enums.DmpAccessType;
|
import org.opencdmp.commons.enums.DmpAccessType;
|
||||||
|
import org.opencdmp.commons.types.description.importexport.DescriptionImportExport;
|
||||||
import org.opencdmp.commons.types.dmpblueprint.importexport.BlueprintImportExport;
|
import org.opencdmp.commons.types.dmpblueprint.importexport.BlueprintImportExport;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
@ -56,6 +57,10 @@ public class DmpImportExport {
|
||||||
@XmlElement(name = "reference")
|
@XmlElement(name = "reference")
|
||||||
private List<DmpReferenceImportExport> references;
|
private List<DmpReferenceImportExport> references;
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "descriptions")
|
||||||
|
@XmlElement(name = "description")
|
||||||
|
private List<DescriptionImportExport> descriptions;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
@ -160,5 +165,13 @@ public class DmpImportExport {
|
||||||
public void setReferences(List<DmpReferenceImportExport> references) {
|
public void setReferences(List<DmpReferenceImportExport> references) {
|
||||||
this.references = references;
|
this.references = references;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<DescriptionImportExport> getDescriptions() {
|
||||||
|
return this.descriptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptions(List<DescriptionImportExport> descriptions) {
|
||||||
|
this.descriptions = descriptions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,17 +6,17 @@ import java.util.List;
|
||||||
|
|
||||||
@XmlRootElement(name = "root")
|
@XmlRootElement(name = "root")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class DefinitionImportExport {
|
public class BlueprintDefinitionImportExport {
|
||||||
|
|
||||||
@XmlElementWrapper(name = "sections")
|
@XmlElementWrapper(name = "sections")
|
||||||
@XmlElement(name = "section")
|
@XmlElement(name = "section")
|
||||||
private List<SectionImportExport> sections;
|
private List<BlueprintSectionImportExport> sections;
|
||||||
|
|
||||||
public List<SectionImportExport> getSections() {
|
public List<BlueprintSectionImportExport> getSections() {
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSections(List<SectionImportExport> sections) {
|
public void setSections(List<BlueprintSectionImportExport> sections) {
|
||||||
this.sections = sections;
|
this.sections = sections;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,8 +7,7 @@ import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class DescriptionTemplateImportExport {
|
public class BlueprintDescriptionTemplateImportExport {
|
||||||
|
|
||||||
@XmlAttribute(name = "descriptionTemplateGroupId")
|
@XmlAttribute(name = "descriptionTemplateGroupId")
|
||||||
private UUID descriptionTemplateGroupId;
|
private UUID descriptionTemplateGroupId;
|
||||||
@XmlAttribute(name = "label")
|
@XmlAttribute(name = "label")
|
||||||
|
@ -19,7 +18,7 @@ public class DescriptionTemplateImportExport {
|
||||||
private int maxMultiplicity;
|
private int maxMultiplicity;
|
||||||
|
|
||||||
public UUID getDescriptionTemplateGroupId() {
|
public UUID getDescriptionTemplateGroupId() {
|
||||||
return descriptionTemplateGroupId;
|
return this.descriptionTemplateGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
|
public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
|
||||||
|
@ -27,7 +26,7 @@ public class DescriptionTemplateImportExport {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return label;
|
return this.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabel(String label) {
|
public void setLabel(String label) {
|
||||||
|
@ -35,7 +34,7 @@ public class DescriptionTemplateImportExport {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMinMultiplicity() {
|
public int getMinMultiplicity() {
|
||||||
return minMultiplicity;
|
return this.minMultiplicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinMultiplicity(int minMultiplicity) {
|
public void setMinMultiplicity(int minMultiplicity) {
|
||||||
|
@ -43,12 +42,10 @@ public class DescriptionTemplateImportExport {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxMultiplicity() {
|
public int getMaxMultiplicity() {
|
||||||
return maxMultiplicity;
|
return this.maxMultiplicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxMultiplicity(int maxMultiplicity) {
|
public void setMaxMultiplicity(int maxMultiplicity) {
|
||||||
this.maxMultiplicity = maxMultiplicity;
|
this.maxMultiplicity = maxMultiplicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package org.opencdmp.commons.types.dmpblueprint.importexport;
|
package org.opencdmp.commons.types.dmpblueprint.importexport;
|
||||||
|
|
||||||
import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType;
|
import org.opencdmp.commons.enums.DmpBlueprintExtraFieldDataType;
|
||||||
import org.opencdmp.commons.enums.DmpBlueprintSystemFieldType;
|
|
||||||
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;
|
||||||
|
@ -9,7 +8,7 @@ import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ExtraFieldImportExport {
|
public class BlueprintExtraFieldImportExport {
|
||||||
|
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
private UUID id;
|
private UUID id;
|
|
@ -1,12 +1,9 @@
|
||||||
package org.opencdmp.commons.types.dmpblueprint.importexport;
|
package org.opencdmp.commons.types.dmpblueprint.importexport;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
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.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
import org.opencdmp.data.DmpBlueprintEntity;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -21,7 +18,7 @@ public class BlueprintImportExport {
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
@XmlElement(name = "definition")
|
@XmlElement(name = "definition")
|
||||||
private DefinitionImportExport dmpBlueprintDefinition;
|
private BlueprintDefinitionImportExport dmpBlueprintDefinition;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
|
@ -39,11 +36,11 @@ public class BlueprintImportExport {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefinitionImportExport getDmpBlueprintDefinition() {
|
public BlueprintDefinitionImportExport getDmpBlueprintDefinition() {
|
||||||
return this.dmpBlueprintDefinition;
|
return this.dmpBlueprintDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmpBlueprintDefinition(DefinitionImportExport dmpBlueprintDefinition) {
|
public void setDmpBlueprintDefinition(BlueprintDefinitionImportExport dmpBlueprintDefinition) {
|
||||||
this.dmpBlueprintDefinition = dmpBlueprintDefinition;
|
this.dmpBlueprintDefinition = dmpBlueprintDefinition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ReferenceTypeFieldImportExport {
|
public class BlueprintReferenceTypeFieldImportExport {
|
||||||
|
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
private UUID id;
|
private UUID id;
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class SectionImportExport {
|
public class BlueprintSectionImportExport {
|
||||||
|
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
@ -18,18 +18,18 @@ public class SectionImportExport {
|
||||||
private int ordinal;
|
private int ordinal;
|
||||||
@XmlElementWrapper(name = "systemFields")
|
@XmlElementWrapper(name = "systemFields")
|
||||||
@XmlElement(name = "systemField")
|
@XmlElement(name = "systemField")
|
||||||
private List<SystemFieldImportExport> systemFields;
|
private List<BlueprintSystemFieldImportExport> systemFields;
|
||||||
@XmlElementWrapper(name = "extraFields")
|
@XmlElementWrapper(name = "extraFields")
|
||||||
@XmlElement(name = "extraField")
|
@XmlElement(name = "extraField")
|
||||||
private List<ExtraFieldImportExport> extraFields;
|
private List<BlueprintExtraFieldImportExport> extraFields;
|
||||||
@XmlElementWrapper(name = "referenceFields")
|
@XmlElementWrapper(name = "referenceFields")
|
||||||
@XmlElement(name = "referenceField")
|
@XmlElement(name = "referenceField")
|
||||||
private List<ReferenceTypeFieldImportExport> referenceFields;
|
private List<BlueprintReferenceTypeFieldImportExport> referenceFields;
|
||||||
@XmlAttribute(name = "hasTemplates")
|
@XmlAttribute(name = "hasTemplates")
|
||||||
private boolean hasTemplates;
|
private boolean hasTemplates;
|
||||||
@XmlElementWrapper(name = "descriptionTemplates")
|
@XmlElementWrapper(name = "descriptionTemplates")
|
||||||
@XmlElement(name = "descriptionTemplate")
|
@XmlElement(name = "descriptionTemplate")
|
||||||
private List<DescriptionTemplateImportExport> descriptionTemplates;
|
private List<BlueprintDescriptionTemplateImportExport> descriptionTemplates;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -63,27 +63,27 @@ public class SectionImportExport {
|
||||||
this.ordinal = ordinal;
|
this.ordinal = ordinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemFieldImportExport> getSystemFields() {
|
public List<BlueprintSystemFieldImportExport> getSystemFields() {
|
||||||
return systemFields;
|
return systemFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSystemFields(List<SystemFieldImportExport> systemFields) {
|
public void setSystemFields(List<BlueprintSystemFieldImportExport> systemFields) {
|
||||||
this.systemFields = systemFields;
|
this.systemFields = systemFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ExtraFieldImportExport> getExtraFields() {
|
public List<BlueprintExtraFieldImportExport> getExtraFields() {
|
||||||
return extraFields;
|
return extraFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExtraFields(List<ExtraFieldImportExport> extraFields) {
|
public void setExtraFields(List<BlueprintExtraFieldImportExport> extraFields) {
|
||||||
this.extraFields = extraFields;
|
this.extraFields = extraFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReferenceTypeFieldImportExport> getReferenceFields() {
|
public List<BlueprintReferenceTypeFieldImportExport> getReferenceFields() {
|
||||||
return referenceFields;
|
return referenceFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReferenceFields(List<ReferenceTypeFieldImportExport> referenceFields) {
|
public void setReferenceFields(List<BlueprintReferenceTypeFieldImportExport> referenceFields) {
|
||||||
this.referenceFields = referenceFields;
|
this.referenceFields = referenceFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,11 +95,11 @@ public class SectionImportExport {
|
||||||
this.hasTemplates = hasTemplates;
|
this.hasTemplates = hasTemplates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DescriptionTemplateImportExport> getDescriptionTemplates() {
|
public List<BlueprintDescriptionTemplateImportExport> getDescriptionTemplates() {
|
||||||
return descriptionTemplates;
|
return descriptionTemplates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescriptionTemplates(List<DescriptionTemplateImportExport> descriptionTemplates) {
|
public void setDescriptionTemplates(List<BlueprintDescriptionTemplateImportExport> descriptionTemplates) {
|
||||||
this.descriptionTemplates = descriptionTemplates;
|
this.descriptionTemplates = descriptionTemplates;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class SystemFieldImportExport {
|
public class BlueprintSystemFieldImportExport {
|
||||||
|
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
private UUID id;
|
private UUID id;
|
|
@ -1,5 +1,6 @@
|
||||||
package org.opencdmp.service.description;
|
package org.opencdmp.service.description;
|
||||||
|
|
||||||
|
import org.opencdmp.commons.types.description.importexport.DescriptionImportExport;
|
||||||
import org.opencdmp.data.StorageFileEntity;
|
import org.opencdmp.data.StorageFileEntity;
|
||||||
import org.opencdmp.model.Description;
|
import org.opencdmp.model.Description;
|
||||||
import org.opencdmp.model.DescriptionValidationResult;
|
import org.opencdmp.model.DescriptionValidationResult;
|
||||||
|
@ -14,11 +15,13 @@ import jakarta.xml.bind.JAXBException;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
import javax.crypto.IllegalBlockSizeException;
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
|
@ -45,4 +48,8 @@ public interface DescriptionService {
|
||||||
StorageFile uploadFieldFile(DescriptionFieldFilePersist model, MultipartFile file, FieldSet fields) throws IOException;
|
StorageFile uploadFieldFile(DescriptionFieldFilePersist model, MultipartFile file, FieldSet fields) throws IOException;
|
||||||
StorageFileEntity getFieldFile(UUID descriptionId, UUID storageFileId);
|
StorageFileEntity getFieldFile(UUID descriptionId, UUID storageFileId);
|
||||||
void updateDescriptionTemplate(UpdateDescriptionTemplatePersist model) throws InvalidApplicationException, IOException, JAXBException;
|
void updateDescriptionTemplate(UpdateDescriptionTemplatePersist model) throws InvalidApplicationException, IOException, JAXBException;
|
||||||
|
|
||||||
|
DescriptionImportExport exportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
||||||
|
|
||||||
|
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,14 @@ import org.opencdmp.commons.enums.*;
|
||||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
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.description.*;
|
import org.opencdmp.commons.types.description.*;
|
||||||
|
import org.opencdmp.commons.types.description.importexport.*;
|
||||||
import org.opencdmp.commons.types.descriptionreference.DescriptionReferenceDataEntity;
|
import org.opencdmp.commons.types.descriptionreference.DescriptionReferenceDataEntity;
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity;
|
import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
|
import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity;
|
||||||
import org.opencdmp.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
import org.opencdmp.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
||||||
|
import org.opencdmp.commons.types.dmp.DmpBlueprintValueEntity;
|
||||||
|
import org.opencdmp.commons.types.dmp.DmpContactEntity;
|
||||||
|
import org.opencdmp.commons.types.dmp.importexport.*;
|
||||||
import org.opencdmp.commons.types.notification.*;
|
import org.opencdmp.commons.types.notification.*;
|
||||||
import org.opencdmp.commons.types.reference.DefinitionEntity;
|
import org.opencdmp.commons.types.reference.DefinitionEntity;
|
||||||
import org.opencdmp.commons.notification.NotificationProperties;
|
import org.opencdmp.commons.notification.NotificationProperties;
|
||||||
|
@ -37,7 +41,9 @@ import org.opencdmp.model.persist.descriptionproperties.*;
|
||||||
import org.opencdmp.model.persist.descriptionreference.DescriptionReferenceDataPersist;
|
import org.opencdmp.model.persist.descriptionreference.DescriptionReferenceDataPersist;
|
||||||
import org.opencdmp.model.persist.referencedefinition.DefinitionPersist;
|
import org.opencdmp.model.persist.referencedefinition.DefinitionPersist;
|
||||||
import org.opencdmp.query.*;
|
import org.opencdmp.query.*;
|
||||||
|
import org.opencdmp.service.descriptiontemplate.DescriptionTemplateService;
|
||||||
import org.opencdmp.service.elastic.ElasticService;
|
import org.opencdmp.service.elastic.ElasticService;
|
||||||
|
import org.opencdmp.service.responseutils.ResponseUtilsService;
|
||||||
import org.opencdmp.service.storage.StorageFileProperties;
|
import org.opencdmp.service.storage.StorageFileProperties;
|
||||||
import org.opencdmp.service.storage.StorageFileService;
|
import org.opencdmp.service.storage.StorageFileService;
|
||||||
import org.opencdmp.service.filetransformer.FileTransformerService;
|
import org.opencdmp.service.filetransformer.FileTransformerService;
|
||||||
|
@ -66,11 +72,13 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.unit.DataSize;
|
import org.springframework.util.unit.DataSize;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
import javax.crypto.IllegalBlockSizeException;
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
|
@ -108,6 +116,8 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
private final AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler;
|
private final AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler;
|
||||||
private final AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler;
|
private final AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler;
|
||||||
private final TenantScope tenantScope;
|
private final TenantScope tenantScope;
|
||||||
|
private final ResponseUtilsService responseUtilsService;
|
||||||
|
private final DescriptionTemplateService descriptionTemplateService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DescriptionServiceImpl(
|
public DescriptionServiceImpl(
|
||||||
|
@ -122,7 +132,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
QueryFactory queryFactory,
|
QueryFactory queryFactory,
|
||||||
JsonHandlingService jsonHandlingService,
|
JsonHandlingService jsonHandlingService,
|
||||||
UserScope userScope,
|
UserScope userScope,
|
||||||
XmlHandlingService xmlHandlingService, NotifyIntegrationEventHandler eventHandler, NotificationProperties notificationProperties, FileTransformerService fileTransformerService, ElasticService elasticService, ValidatorFactory validatorFactory, StorageFileProperties storageFileConfig, StorageFileService storageFileService, AuthorizationContentResolver authorizationContentResolver, AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler, AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler, TenantScope tenantScope) {
|
XmlHandlingService xmlHandlingService, NotifyIntegrationEventHandler eventHandler, NotificationProperties notificationProperties, FileTransformerService fileTransformerService, ElasticService elasticService, ValidatorFactory validatorFactory, StorageFileProperties storageFileConfig, StorageFileService storageFileService, AuthorizationContentResolver authorizationContentResolver, AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler, AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler, TenantScope tenantScope, ResponseUtilsService responseUtilsService, DescriptionTemplateService descriptionTemplateService) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.deleterFactory = deleterFactory;
|
this.deleterFactory = deleterFactory;
|
||||||
|
@ -146,6 +156,8 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
this.annotationEntityTouchedIntegrationEventHandler = annotationEntityTouchedIntegrationEventHandler;
|
this.annotationEntityTouchedIntegrationEventHandler = annotationEntityTouchedIntegrationEventHandler;
|
||||||
this.annotationEntityRemovalIntegrationEventHandler = annotationEntityRemovalIntegrationEventHandler;
|
this.annotationEntityRemovalIntegrationEventHandler = annotationEntityRemovalIntegrationEventHandler;
|
||||||
this.tenantScope = tenantScope;
|
this.tenantScope = tenantScope;
|
||||||
|
this.responseUtilsService = responseUtilsService;
|
||||||
|
this.descriptionTemplateService = descriptionTemplateService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -175,7 +187,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
||||||
|
|
||||||
DmpDescriptionTemplateEntity dmpDescriptionTemplate = this.entityManager.find(DmpDescriptionTemplateEntity.class, model.getDmpDescriptionTemplateId());
|
DmpDescriptionTemplateEntity dmpDescriptionTemplate = this.entityManager.find(DmpDescriptionTemplateEntity.class, model.getDmpDescriptionTemplateId());
|
||||||
if (dmpDescriptionTemplate == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (dmpDescriptionTemplate == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
if (isUpdate) this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.EditDescription);
|
if (isUpdate) this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.EditDescription);
|
||||||
else this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionsAffiliationBySection(model.getDmpId(), dmpDescriptionTemplate.getSectionId())), Permission.EditDescription);
|
else this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionsAffiliationBySection(model.getDmpId(), dmpDescriptionTemplate.getSectionId())), Permission.EditDescription);
|
||||||
|
@ -183,7 +195,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
DescriptionEntity data;
|
DescriptionEntity data;
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
data = this.entityManager.find(DescriptionEntity.class, model.getId());
|
data = this.entityManager.find(DescriptionEntity.class, model.getId());
|
||||||
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||||
if (data.getStatus().equals(DescriptionStatus.Finalized)) throw new MyValidationException(this.errors.getDescriptionIsFinalized().getCode(), this.errors.getDescriptionIsFinalized().getMessage());
|
if (data.getStatus().equals(DescriptionStatus.Finalized)) throw new MyValidationException(this.errors.getDescriptionIsFinalized().getCode(), this.errors.getDescriptionIsFinalized().getMessage());
|
||||||
if (!data.getDmpId().equals(model.getDmpId())) throw new MyValidationException(this.errors.getDmpCanNotChange().getCode(), this.errors.getDmpCanNotChange().getMessage());
|
if (!data.getDmpId().equals(model.getDmpId())) throw new MyValidationException(this.errors.getDmpCanNotChange().getCode(), this.errors.getDmpCanNotChange().getMessage());
|
||||||
|
@ -199,12 +211,12 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());
|
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());
|
||||||
if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (descriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
if (!dmpDescriptionTemplate.getDescriptionTemplateGroupId().equals(descriptionTemplateEntity.getGroupId())) throw new MyValidationException(this.errors.getInvalidDescriptionTemplate().getCode(), this.errors.getInvalidDescriptionTemplate().getMessage());
|
if (!dmpDescriptionTemplate.getDescriptionTemplateGroupId().equals(descriptionTemplateEntity.getGroupId())) throw new MyValidationException(this.errors.getInvalidDescriptionTemplate().getCode(), this.errors.getInvalidDescriptionTemplate().getMessage());
|
||||||
|
|
||||||
DmpEntity dmp = this.entityManager.find(DmpEntity.class, data.getDmpId());
|
DmpEntity dmp = this.entityManager.find(DmpEntity.class, data.getDmpId());
|
||||||
if (dmp == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (dmp == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
if (dmp.getStatus().equals(DmpStatus.Finalized) && isUpdate) throw new MyValidationException(this.errors.getDmpIsFinalized().getCode(), this.errors.getDmpIsFinalized().getMessage());
|
if (dmp.getStatus().equals(DmpStatus.Finalized) && isUpdate) throw new MyValidationException(this.errors.getDmpIsFinalized().getCode(), this.errors.getDmpIsFinalized().getMessage());
|
||||||
|
|
||||||
|
@ -251,14 +263,14 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.EditDescription);
|
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.EditDescription);
|
||||||
|
|
||||||
DescriptionEntity data = this.entityManager.find(DescriptionEntity.class, model.getId());
|
DescriptionEntity data = this.entityManager.find(DescriptionEntity.class, model.getId());
|
||||||
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||||
|
|
||||||
DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, data.getDescriptionTemplateId());
|
DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, data.getDescriptionTemplateId());
|
||||||
if (oldDescriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (oldDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.entityManager.find(DmpDescriptionTemplateEntity.class, data.getDmpDescriptionTemplateId());
|
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.entityManager.find(DmpDescriptionTemplateEntity.class, data.getDmpDescriptionTemplateId());
|
||||||
if (dmpDescriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (dmpDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
||||||
List<DescriptionTemplateEntity> latestVersionDescriptionTemplates = this.queryFactory.query(DescriptionTemplateQuery.class)
|
List<DescriptionTemplateEntity> latestVersionDescriptionTemplates = this.queryFactory.query(DescriptionTemplateQuery.class)
|
||||||
|
@ -367,9 +379,9 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
List<ContactPair> contactPairs = new ArrayList<>();
|
List<ContactPair> contactPairs = new ArrayList<>();
|
||||||
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
||||||
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
||||||
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
event.setContactHint(this.jsonHandlingService.toJsonSafe(contactData));
|
||||||
|
|
||||||
event = this.applyNotificationType(description.getStatus(), event);
|
this.applyNotificationType(description.getStatus(), event);
|
||||||
NotificationFieldData data = new NotificationFieldData();
|
NotificationFieldData data = new NotificationFieldData();
|
||||||
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
||||||
fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName()));
|
fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName()));
|
||||||
|
@ -377,18 +389,18 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
fieldInfoList.add(new FieldInfo("{name}", DataType.String, description.getLabel()));
|
fieldInfoList.add(new FieldInfo("{name}", DataType.String, description.getLabel()));
|
||||||
fieldInfoList.add(new FieldInfo("{id}", DataType.String, description.getId().toString()));
|
fieldInfoList.add(new FieldInfo("{id}", DataType.String, description.getId().toString()));
|
||||||
data.setFields(fieldInfoList);
|
data.setFields(fieldInfoList);
|
||||||
event.setData(jsonHandlingService.toJsonSafe(data));
|
event.setData(this.jsonHandlingService.toJsonSafe(data));
|
||||||
|
|
||||||
eventHandler.handle(event);
|
this.eventHandler.handle(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private NotifyIntegrationEvent applyNotificationType(DescriptionStatus status, NotifyIntegrationEvent event) {
|
private NotifyIntegrationEvent applyNotificationType(DescriptionStatus status, NotifyIntegrationEvent event) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case Draft:
|
case Draft:
|
||||||
event.setNotificationType(notificationProperties.getDescriptionModifiedType());
|
event.setNotificationType(this.notificationProperties.getDescriptionModifiedType());
|
||||||
break;
|
break;
|
||||||
case Finalized:
|
case Finalized:
|
||||||
event.setNotificationType(notificationProperties.getDescriptionFinalisedType());
|
event.setNotificationType(this.notificationProperties.getDescriptionFinalisedType());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new MyApplicationException("Unsupported Description Status.");
|
throw new MyApplicationException("Unsupported Description Status.");
|
||||||
|
@ -403,13 +415,13 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.EditDescription);
|
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.EditDescription);
|
||||||
|
|
||||||
DescriptionEntity data = this.entityManager.find(DescriptionEntity.class, model.getId());
|
DescriptionEntity data = this.entityManager.find(DescriptionEntity.class, model.getId());
|
||||||
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||||
if (!data.getStatus().equals(model.getStatus())){
|
if (!data.getStatus().equals(model.getStatus())){
|
||||||
if (data.getStatus().equals(DescriptionStatus.Finalized)){
|
if (data.getStatus().equals(DescriptionStatus.Finalized)){
|
||||||
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.FinalizeDescription);
|
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(model.getId())), Permission.FinalizeDescription);
|
||||||
DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, data.getDmpId());
|
DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, data.getDmpId());
|
||||||
if (dmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpId(), DmpEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDmpId(), DmpEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
if(!dmpEntity.getStatus().equals(DmpStatus.Draft)) throw new MyValidationException(this.errors.getDmpIsFinalized().getCode(), this.errors.getDmpIsFinalized().getMessage());
|
if(!dmpEntity.getStatus().equals(DmpStatus.Draft)) throw new MyValidationException(this.errors.getDmpIsFinalized().getCode(), this.errors.getDmpIsFinalized().getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +454,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
|
|
||||||
DescriptionPersist.DescriptionPersistValidator validator = this.validatorFactory.validator(DescriptionPersist.DescriptionPersistValidator.class);
|
DescriptionPersist.DescriptionPersistValidator validator = this.validatorFactory.validator(DescriptionPersist.DescriptionPersistValidator.class);
|
||||||
validator.validate(this.buildDescriptionPersist(description));
|
validator.validate(this.buildDescriptionPersist(description));
|
||||||
if (validator.result().isValid()) descriptionValidationResult.setResult(DescriptionValidationOutput.Valid);;
|
if (validator.result().isValid()) descriptionValidationResult.setResult(DescriptionValidationOutput.Valid);
|
||||||
descriptionValidationResults.add(descriptionValidationResult);
|
descriptionValidationResults.add(descriptionValidationResult);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -523,10 +535,10 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getTextListValue())) persist.getTextListValue().stream().map(UUID::fromString).toList();
|
if (!this.conventionService.isListNullOrEmpty(persist.getTextListValue())) persist.getTextListValue().stream().map(UUID::fromString).toList();
|
||||||
else if (!this.conventionService.isNullOrEmpty(persist.getTextValue())) ids.add(UUID.fromString(persist.getTextValue()));
|
else if (!this.conventionService.isNullOrEmpty(persist.getTextValue())) ids.add(UUID.fromString(persist.getTextValue()));
|
||||||
|
|
||||||
if (ids.size() > 0){
|
if (!ids.isEmpty()){
|
||||||
Set<UUID> existingIds = this.queryFactory.query(DmpQuery.class).ids(ids).collectAs(new BaseFieldSet().ensure(Dmp._id)).stream().map(DmpEntity::getId).collect(Collectors.toSet());
|
Set<UUID> existingIds = this.queryFactory.query(DmpQuery.class).ids(ids).collectAs(new BaseFieldSet().ensure(Dmp._id)).stream().map(DmpEntity::getId).collect(Collectors.toSet());
|
||||||
for (UUID id : ids){
|
for (UUID id : ids){
|
||||||
if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (!existingIds.contains(id)) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,10 +546,10 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
if ( !this.conventionService.isListNullOrEmpty(persist.getTextListValue())) ids = persist.getTextListValue().stream().map(UUID::fromString).toList();
|
if ( !this.conventionService.isListNullOrEmpty(persist.getTextListValue())) ids = persist.getTextListValue().stream().map(UUID::fromString).toList();
|
||||||
else if (!this.conventionService.isNullOrEmpty(persist.getTextValue())) ids.add(UUID.fromString(persist.getTextValue()));
|
else if (!this.conventionService.isNullOrEmpty(persist.getTextValue())) ids.add(UUID.fromString(persist.getTextValue()));
|
||||||
|
|
||||||
if (ids.size() > 0) {
|
if (!ids.isEmpty()) {
|
||||||
Set<UUID> existingIds = this.queryFactory.query(DescriptionQuery.class).ids(ids).collectAs(new BaseFieldSet().ensure(Description._id)).stream().map(DescriptionEntity::getId).collect(Collectors.toSet());
|
Set<UUID> existingIds = this.queryFactory.query(DescriptionQuery.class).ids(ids).collectAs(new BaseFieldSet().ensure(Description._id)).stream().map(DescriptionEntity::getId).collect(Collectors.toSet());
|
||||||
for (UUID id : ids){
|
for (UUID id : ids){
|
||||||
if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (!existingIds.contains(id)) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,7 +593,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
if (definitionFieldSetItemPersist.getFields() != null && !definitionFieldSetItemPersist.getFields().isEmpty()) {
|
if (definitionFieldSetItemPersist.getFields() != null && !definitionFieldSetItemPersist.getFields().isEmpty()) {
|
||||||
for (String key : definitionFieldSetItemPersist.getFields().keySet()) {
|
for (String key : definitionFieldSetItemPersist.getFields().keySet()) {
|
||||||
FieldPersist fieldPersist = definitionFieldSetItemPersist.getFields().get(key);
|
FieldPersist fieldPersist = definitionFieldSetItemPersist.getFields().get(key);
|
||||||
BuildDescriptionReferencePersist(key, fieldPersist, descriptionReferencePersists);
|
this.BuildDescriptionReferencePersist(key, fieldPersist, descriptionReferencePersists);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,10 +646,10 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
ReferenceEntity referenceEntity = null;
|
ReferenceEntity referenceEntity = null;
|
||||||
if (this.conventionService.isValidGuid(referencePersist.getId())){
|
if (this.conventionService.isValidGuid(referencePersist.getId())){
|
||||||
referenceEntity = this.entityManager.find(ReferenceEntity.class, referencePersist.getId());
|
referenceEntity = this.entityManager.find(ReferenceEntity.class, referencePersist.getId());
|
||||||
if (referenceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{referencePersist.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (referenceEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{referencePersist.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
} else {
|
} else {
|
||||||
ReferenceTypeDataEntity fieldEntity = definition.getFieldById(model.getData().getFieldId()).stream().filter(x-> x.getData() != null && x.getData().getFieldType().equals(FieldType.REFERENCE_TYPES)).map(x-> (ReferenceTypeDataEntity)x.getData()).findFirst().orElse(null);
|
ReferenceTypeDataEntity fieldEntity = definition.getFieldById(model.getData().getFieldId()).stream().filter(x-> x.getData() != null && x.getData().getFieldType().equals(FieldType.REFERENCE_TYPES)).map(x-> (ReferenceTypeDataEntity)x.getData()).findFirst().orElse(null);
|
||||||
if (fieldEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getData().getFieldId(), ReferenceTypeDataEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (fieldEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getData().getFieldId(), ReferenceTypeDataEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).typeIds(fieldEntity.getReferenceTypeId()).sources(referencePersist.getSource()).isActive(IsActive.Active).references(referencePersist.getReference()).first();
|
referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).typeIds(fieldEntity.getReferenceTypeId()).sources(referencePersist.getSource()).isActive(IsActive.Active).references(referencePersist.getReference()).first();
|
||||||
if (referenceEntity == null){
|
if (referenceEntity == null){
|
||||||
|
@ -656,14 +668,14 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
referenceEntity.setSourceType(referencePersist.getSourceType());
|
referenceEntity.setSourceType(referencePersist.getSourceType());
|
||||||
try {
|
try {
|
||||||
ReferenceTypeEntity referenceType = this.queryFactory.query(ReferenceTypeQuery.class).ids(fieldEntity.getReferenceTypeId()).firstAs(new BaseFieldSet().ensure(ReferenceType._id).ensure(ReferenceTypeEntity._tenantId));
|
ReferenceTypeEntity referenceType = this.queryFactory.query(ReferenceTypeQuery.class).ids(fieldEntity.getReferenceTypeId()).firstAs(new BaseFieldSet().ensure(ReferenceType._id).ensure(ReferenceTypeEntity._tenantId));
|
||||||
if (referenceType == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{fieldEntity.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (referenceType == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{fieldEntity.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
if (referenceEntity.getSourceType().equals(ReferenceSourceType.External) && !this.tenantScope.isDefaultTenant() && referenceType.getTenantId() == null){
|
if (referenceEntity.getSourceType().equals(ReferenceSourceType.External) && !this.tenantScope.isDefaultTenant() && referenceType.getTenantId() == null){
|
||||||
this.tenantScope.setTempTenant(this.entityManager.getEntityManager(), null, this.tenantScope.getDefaultTenantCode());
|
this.tenantScope.setTempTenant(this.entityManager.getEntityManager(), null, this.tenantScope.getDefaultTenantCode());
|
||||||
}
|
}
|
||||||
this.entityManager.persist(referenceEntity);
|
this.entityManager.persist(referenceEntity);
|
||||||
} finally {
|
} finally {
|
||||||
tenantScope.removeTempTenant(this.entityManager.getEntityManager());
|
this.tenantScope.removeTempTenant(this.entityManager.getEntityManager());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -816,7 +828,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
newDescription.setDmpId(dmpId);
|
newDescription.setDmpId(dmpId);
|
||||||
newDescription.setDmpDescriptionTemplateId(existing.getDmpDescriptionTemplateId());
|
newDescription.setDmpDescriptionTemplateId(existing.getDmpDescriptionTemplateId());
|
||||||
newDescription.setDescriptionTemplateId(existing.getDescriptionTemplateId());
|
newDescription.setDescriptionTemplateId(existing.getDescriptionTemplateId());
|
||||||
newDescription.setCreatedById(userScope.getUserId());
|
newDescription.setCreatedById(this.userScope.getUserId());
|
||||||
newDescription.setCreatedAt(Instant.now());
|
newDescription.setCreatedAt(Instant.now());
|
||||||
newDescription.setUpdatedAt(Instant.now());
|
newDescription.setUpdatedAt(Instant.now());
|
||||||
newDescription.setIsActive(IsActive.Active);
|
newDescription.setIsActive(IsActive.Active);
|
||||||
|
@ -889,13 +901,13 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
this.authorizationService.authorizeForce(Permission.EditDescription);//TODO: Missing Description or dmp for authz
|
this.authorizationService.authorizeForce(Permission.EditDescription);//TODO: Missing Description or dmp for authz
|
||||||
|
|
||||||
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).ids(model.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).first();
|
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).ids(model.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).first();
|
||||||
if (descriptionTemplate == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (descriptionTemplate == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplate.getDefinition());
|
org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplate.getDefinition());
|
||||||
if (definition == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (definition == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
org.opencdmp.commons.types.descriptiontemplate.FieldEntity fieldEntity = definition.getFieldById(model.getFieldId()).stream().filter(x -> x != null && x.getData() != null && x.getData().getFieldType().equals(FieldType.UPLOAD)).findFirst().orElse(null);
|
org.opencdmp.commons.types.descriptiontemplate.FieldEntity fieldEntity = definition.getFieldById(model.getFieldId()).stream().filter(x -> x != null && x.getData() != null && x.getData().getFieldType().equals(FieldType.UPLOAD)).findFirst().orElse(null);
|
||||||
if (fieldEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getFieldId(), org.opencdmp.commons.types.descriptiontemplate.FieldEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (fieldEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getFieldId(), org.opencdmp.commons.types.descriptiontemplate.FieldEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
UploadDataEntity uploadDataEntity = (UploadDataEntity)fieldEntity.getData();
|
UploadDataEntity uploadDataEntity = (UploadDataEntity)fieldEntity.getData();
|
||||||
if (DataSize.ofBytes(file.getSize()).equals(DataSize.ofMegabytes(uploadDataEntity.getMaxFileSizeInMB()))) {
|
if (DataSize.ofBytes(file.getSize()).equals(DataSize.ofMegabytes(uploadDataEntity.getMaxFileSizeInMB()))) {
|
||||||
|
@ -929,13 +941,13 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(descriptionId)), Permission.BrowseDescription);
|
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(descriptionId)), Permission.BrowseDescription);
|
||||||
|
|
||||||
DescriptionEntity descriptionEntity = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).ids(descriptionId).first();
|
DescriptionEntity descriptionEntity = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).ids(descriptionId).first();
|
||||||
if (descriptionEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionId, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (descriptionEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionId, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first();
|
DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first();
|
||||||
if (dmpDescriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionEntity.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (dmpDescriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionEntity.getDmpDescriptionTemplateId(), DmpDescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
DmpEntity dmpEntity = this.queryFactory.query(DmpQuery.class).ids(dmpDescriptionTemplateEntity.getDmpId()).isActive(IsActive.Active).first();
|
DmpEntity dmpEntity = this.queryFactory.query(DmpQuery.class).ids(dmpDescriptionTemplateEntity.getDmpId()).isActive(IsActive.Active).first();
|
||||||
if (dmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDescriptionTemplateEntity.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (dmpEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDescriptionTemplateEntity.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
if (!dmpEntity.getAccessType().equals(DmpAccessType.Public))
|
if (!dmpEntity.getAccessType().equals(DmpAccessType.Public))
|
||||||
{
|
{
|
||||||
|
@ -944,7 +956,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
StorageFileEntity storageFile = this.queryFactory.query(StorageFileQuery.class).ids(storageFileId).first();
|
StorageFileEntity storageFile = this.queryFactory.query(StorageFileQuery.class).ids(storageFileId).first();
|
||||||
if (storageFile == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{storageFileId, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (storageFile == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{storageFileId, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
return storageFile;
|
return storageFile;
|
||||||
}
|
}
|
||||||
|
@ -957,7 +969,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
if (data == null) return persist;
|
if (data == null) return persist;
|
||||||
|
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, data.getDescriptionTemplateId());
|
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, data.getDescriptionTemplateId());
|
||||||
if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (descriptionTemplateEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
persist.setLabel(data.getLabel());
|
persist.setLabel(data.getLabel());
|
||||||
persist.setStatus(DescriptionStatus.Finalized);
|
persist.setStatus(DescriptionStatus.Finalized);
|
||||||
|
@ -997,9 +1009,9 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
|
|
||||||
if (data.getFieldSets() != null && !data.getFieldSets().isEmpty()){
|
if (data.getFieldSets() != null && !data.getFieldSets().isEmpty()){
|
||||||
for (PropertyDefinitionFieldSetEntity fieldSet: data.getFieldSets().values()) {
|
for (PropertyDefinitionFieldSetEntity fieldSet: data.getFieldSets().values()) {
|
||||||
if (!this.conventionService.isListNullOrEmpty(fieldSet.getItems()));
|
if (!this.conventionService.isListNullOrEmpty(fieldSet.getItems())){
|
||||||
for (PropertyDefinitionFieldSetItemEntity item: fieldSet.getItems()) {
|
for (PropertyDefinitionFieldSetItemEntity item: fieldSet.getItems()) {
|
||||||
if (item.getFields() != null && !item.getFields().isEmpty());
|
if (item.getFields() != null && !item.getFields().isEmpty()) {
|
||||||
for (String key : item.getFields().keySet()) {
|
for (String key : item.getFields().keySet()) {
|
||||||
if (definition.getFieldById(key).getFirst() != null && FieldType.isReferenceType(definition.getFieldById(key).getFirst().getData().getFieldType())) {
|
if (definition.getFieldById(key).getFirst() != null && FieldType.isReferenceType(definition.getFieldById(key).getFirst().getData().getFieldType())) {
|
||||||
if (!this.conventionService.isListNullOrEmpty(item.getFields().get(key).getTextListValue())) {
|
if (!this.conventionService.isListNullOrEmpty(item.getFields().get(key).getTextListValue())) {
|
||||||
|
@ -1010,10 +1022,12 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(referenceIds)) {
|
if (!this.conventionService.isListNullOrEmpty(referenceIds)) {
|
||||||
referenceIds = referenceIds.stream().distinct().collect(Collectors.toList());
|
referenceIds = referenceIds.stream().distinct().collect(Collectors.toList());
|
||||||
return referenceIds.stream().filter(x -> this.conventionService.isValidGuid(UUID.fromString(x))).collect(Collectors.toList()).stream().map(x -> UUID.fromString(x)).collect(Collectors.toList());
|
return referenceIds.stream().filter(x -> this.conventionService.isValidGuid(UUID.fromString(x))).toList().stream().map(UUID::fromString).collect(Collectors.toList());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,7 +1073,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
else if (FieldType.isExternalIdentifierType(fieldType) && data.getExternalIdentifier() != null) persist.setExternalIdentifier(this.buildExternalIdentifierPersist(data.getExternalIdentifier()));
|
else if (FieldType.isExternalIdentifierType(fieldType) && data.getExternalIdentifier() != null) persist.setExternalIdentifier(this.buildExternalIdentifierPersist(data.getExternalIdentifier()));
|
||||||
else if (FieldType.isReferenceType(fieldType) && fieldEntity != null ) {
|
else if (FieldType.isReferenceType(fieldType) && fieldEntity != null ) {
|
||||||
if (!this.conventionService.isListNullOrEmpty(data.getTextListValue()) && !this.conventionService.isListNullOrEmpty(references)){
|
if (!this.conventionService.isListNullOrEmpty(data.getTextListValue()) && !this.conventionService.isListNullOrEmpty(references)){
|
||||||
List<UUID> referenceIdsInField = data.getTextListValue().stream().filter(x -> this.conventionService.isValidGuid(UUID.fromString(x))).collect(Collectors.toList()).stream().map(x -> UUID.fromString(x)).collect(Collectors.toList());
|
List<UUID> referenceIdsInField = data.getTextListValue().stream().filter(x -> this.conventionService.isValidGuid(UUID.fromString(x))).toList().stream().map(UUID::fromString).collect(Collectors.toList());
|
||||||
if (!this.conventionService.isListNullOrEmpty(referenceIdsInField)){
|
if (!this.conventionService.isListNullOrEmpty(referenceIdsInField)){
|
||||||
List<ReferenceEntity> referencesInField = references.stream().filter(x -> referenceIdsInField.contains(x.getId())).collect(Collectors.toList());
|
List<ReferenceEntity> referencesInField = references.stream().filter(x -> referenceIdsInField.contains(x.getId())).collect(Collectors.toList());
|
||||||
if (!this.conventionService.isListNullOrEmpty(referencesInField)){
|
if (!this.conventionService.isListNullOrEmpty(referencesInField)){
|
||||||
|
@ -1101,4 +1115,167 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
|
|
||||||
return referencesPersist;
|
return referencesPersist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//region Export
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DescriptionImportExport exportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("export xml").And("id", id));
|
||||||
|
|
||||||
|
this.authorizationService.authorizeForce(Permission.ExportDescription);
|
||||||
|
DescriptionEntity data = this.entityManager.find(DescriptionEntity.class, id);
|
||||||
|
if (data == null)
|
||||||
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
PropertyDefinitionEntity definition = this.jsonHandlingService.fromJson(PropertyDefinitionEntity.class, data.getProperties());
|
||||||
|
return this.toExport(data, definition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("export xml").And("id", id));
|
||||||
|
|
||||||
|
this.authorizationService.authorizeForce(Permission.ExportDescription);
|
||||||
|
DescriptionEntity data = this.entityManager.find(DescriptionEntity.class, id);
|
||||||
|
if (data == null)
|
||||||
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
String xml = this.xmlHandlingService.toXml(this.exportXmlEntity(data.getId()));
|
||||||
|
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
private DescriptionImportExport toExport(DescriptionEntity data, PropertyDefinitionEntity propertiesEntity) throws InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
||||||
|
DescriptionImportExport xml = new DescriptionImportExport();
|
||||||
|
xml.setId(data.getId());
|
||||||
|
xml.setDescription(data.getDescription());
|
||||||
|
xml.setLabel(data.getLabel());
|
||||||
|
xml.setFinalizedAt(data.getFinalizedAt());
|
||||||
|
|
||||||
|
DescriptionTemplateEntity blueprintEntity = this.queryFactory.query(DescriptionTemplateQuery.class).ids(data.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).first();
|
||||||
|
if (blueprintEntity != null) {
|
||||||
|
xml.setDescriptionTemplate(this.descriptionTemplateService.exportXmlEntity(blueprintEntity.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (propertiesEntity != null) {
|
||||||
|
xml.setProperties(this.descriptionPropertyDefinitionToExport(propertiesEntity));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<DescriptionReferenceEntity> dmpReferences = this.queryFactory.query(DescriptionReferenceQuery.class).descriptionIds(data.getId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(dmpReferences)) {
|
||||||
|
List<ReferenceEntity> references = this.queryFactory.query(ReferenceQuery.class).ids(dmpReferences.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
||||||
|
Map<UUID, ReferenceEntity> referenceEntityMap = references == null ? new HashMap<>() : references.stream().collect(Collectors.toMap(ReferenceEntity::getId, x-> x));
|
||||||
|
List<ReferenceTypeEntity> referenceTypes = references == null ? new ArrayList<>() : this.queryFactory.query(ReferenceTypeQuery.class).ids(references.stream().map(ReferenceEntity::getTypeId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
||||||
|
Map<UUID, ReferenceTypeEntity> referenceTypeEntityMap = referenceTypes == null ? new HashMap<>() : referenceTypes.stream().collect(Collectors.toMap(ReferenceTypeEntity::getId, x-> x));
|
||||||
|
List<DescriptionReferenceImportExport> dmpReferenceImportExports = new LinkedList<>();
|
||||||
|
for (DescriptionReferenceEntity descriptionTemplateEntity : dmpReferences) {
|
||||||
|
dmpReferenceImportExports.add(this.descriptionReferenceToExport(descriptionTemplateEntity, referenceEntityMap, referenceTypeEntityMap));
|
||||||
|
}
|
||||||
|
xml.setReferences(dmpReferenceImportExports);
|
||||||
|
}
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DescriptionReferenceImportExport descriptionReferenceToExport(DescriptionReferenceEntity entity, Map<UUID, ReferenceEntity> referenceEntityMap, Map<UUID, ReferenceTypeEntity> referenceTypeEntityMap) {
|
||||||
|
DescriptionReferenceImportExport xml = new DescriptionReferenceImportExport();
|
||||||
|
if (entity == null) return xml;
|
||||||
|
DescriptionReferenceDataEntity referenceData = this.jsonHandlingService.fromJsonSafe(DescriptionReferenceDataEntity.class, entity.getData());
|
||||||
|
if (referenceData != null) xml.setFieldId(referenceData.getFieldId());
|
||||||
|
ReferenceEntity reference = referenceEntityMap.getOrDefault(entity.getReferenceId(), null);
|
||||||
|
|
||||||
|
if (reference != null){
|
||||||
|
xml.setId(reference.getId());
|
||||||
|
xml.setLabel(reference.getLabel());
|
||||||
|
xml.setReference(reference.getReference());
|
||||||
|
ReferenceTypeEntity referenceType = referenceTypeEntityMap.getOrDefault(reference.getTypeId(), null);
|
||||||
|
if (referenceType != null) xml.setType(this.descriptionReferenceTypeToExport(referenceType));
|
||||||
|
}
|
||||||
|
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DescriptionReferenceTypeImportExport descriptionReferenceTypeToExport(ReferenceTypeEntity entity) {
|
||||||
|
DescriptionReferenceTypeImportExport xml = new DescriptionReferenceTypeImportExport();
|
||||||
|
if (entity == null) return xml;
|
||||||
|
xml.setId(entity.getId());
|
||||||
|
xml.setCode(entity.getCode());
|
||||||
|
xml.setName(entity.getName());
|
||||||
|
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private DescriptionPropertyDefinitionImportExport descriptionPropertyDefinitionToExport(PropertyDefinitionEntity entity) {
|
||||||
|
DescriptionPropertyDefinitionImportExport xml = new DescriptionPropertyDefinitionImportExport();
|
||||||
|
if (entity == null) return xml;
|
||||||
|
|
||||||
|
if (entity.getFieldSets() != null && !entity.getFieldSets().isEmpty()) {
|
||||||
|
List<DescriptionPropertyDefinitionFieldSetImportExport> exports = new LinkedList<>();
|
||||||
|
for (Map.Entry<String, PropertyDefinitionFieldSetEntity> fieldSetEntityEntry : entity.getFieldSets().entrySet()) {
|
||||||
|
exports.add(this.descriptionPropertyDefinitionFieldSetToExport(fieldSetEntityEntry.getValue(), fieldSetEntityEntry.getKey()));
|
||||||
|
}
|
||||||
|
xml.setFieldSets(exports);
|
||||||
|
}
|
||||||
|
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DescriptionPropertyDefinitionFieldSetImportExport descriptionPropertyDefinitionFieldSetToExport(PropertyDefinitionFieldSetEntity entity, String fieldSetId) {
|
||||||
|
DescriptionPropertyDefinitionFieldSetImportExport xml = new DescriptionPropertyDefinitionFieldSetImportExport();
|
||||||
|
xml.setFieldSetId(fieldSetId);
|
||||||
|
if (entity == null) return xml;
|
||||||
|
|
||||||
|
if (entity.getItems() != null && !entity.getItems().isEmpty()) {
|
||||||
|
List<DescriptionPropertyDefinitionFieldSetItemImportExport> exports = new LinkedList<>();
|
||||||
|
for (PropertyDefinitionFieldSetItemEntity propertyDefinitionFieldSetItemEntity : entity.getItems()) {
|
||||||
|
exports.add(this.descriptionPropertyDefinitionFieldSetItemToExport(propertyDefinitionFieldSetItemEntity));
|
||||||
|
}
|
||||||
|
xml.setItems(exports);
|
||||||
|
}
|
||||||
|
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DescriptionPropertyDefinitionFieldSetItemImportExport descriptionPropertyDefinitionFieldSetItemToExport(PropertyDefinitionFieldSetItemEntity entity) {
|
||||||
|
DescriptionPropertyDefinitionFieldSetItemImportExport xml = new DescriptionPropertyDefinitionFieldSetItemImportExport();
|
||||||
|
if (entity == null) return xml;
|
||||||
|
|
||||||
|
xml.setComment(entity.getComment());
|
||||||
|
xml.setOrdinal(entity.getOrdinal());
|
||||||
|
if (entity.getFields() != null && !entity.getFields().isEmpty()) {
|
||||||
|
List<DescriptionFieldImportExport> exports = new LinkedList<>();
|
||||||
|
for (Map.Entry<String, FieldEntity> fieldSetEntityEntry : entity.getFields().entrySet()) {
|
||||||
|
exports.add(this.descriptionFieldImportExportToExport(fieldSetEntityEntry.getValue(), fieldSetEntityEntry.getKey()));
|
||||||
|
}
|
||||||
|
xml.setFields(exports);
|
||||||
|
}
|
||||||
|
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DescriptionFieldImportExport descriptionFieldImportExportToExport(FieldEntity entity, String fieldId) {
|
||||||
|
DescriptionFieldImportExport xml = new DescriptionFieldImportExport();
|
||||||
|
xml.setFieldId(fieldId);
|
||||||
|
if (entity == null) return xml;
|
||||||
|
|
||||||
|
xml.setDateValue(entity.getDateValue());
|
||||||
|
xml.setTextValue(entity.getTextValue());
|
||||||
|
xml.setTextListValue(entity.getTextListValue());
|
||||||
|
if (entity.getExternalIdentifier() != null) {
|
||||||
|
xml.setExternalIdentifier(this.descriptionExternalIdentifierToExport(entity.getExternalIdentifier()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DescriptionExternalIdentifierImportExport descriptionExternalIdentifierToExport(ExternalIdentifierEntity entity) {
|
||||||
|
DescriptionExternalIdentifierImportExport xml = new DescriptionExternalIdentifierImportExport();
|
||||||
|
if (entity == null) return xml;
|
||||||
|
|
||||||
|
xml.setIdentifier(entity.getIdentifier());
|
||||||
|
xml.setType(entity.getType());
|
||||||
|
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.opencdmp.service.descriptiontemplate;
|
package org.opencdmp.service.descriptiontemplate;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import org.opencdmp.commons.types.descriptiontemplate.importexport.DescriptionTemplateImportExport;
|
||||||
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;
|
||||||
|
@ -26,6 +27,9 @@ public interface DescriptionTemplateService {
|
||||||
DescriptionTemplate buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException;
|
DescriptionTemplate buildClone(UUID id, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException;
|
||||||
DescriptionTemplate createNewVersion(NewVersionDescriptionTemplatePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException;
|
DescriptionTemplate createNewVersion(NewVersionDescriptionTemplatePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException;
|
||||||
DescriptionTemplate importXml(byte[] bytes, UUID id, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
DescriptionTemplate importXml(byte[] bytes, UUID id, String label, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException;
|
||||||
|
|
||||||
|
DescriptionTemplateImportExport exportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
|
||||||
|
|
||||||
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException;
|
ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, TransformerException, InvalidApplicationException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.opencdmp.authorization.Permission;
|
||||||
import org.opencdmp.commons.JsonHandlingService;
|
import org.opencdmp.commons.JsonHandlingService;
|
||||||
import org.opencdmp.commons.XmlHandlingService;
|
import org.opencdmp.commons.XmlHandlingService;
|
||||||
import org.opencdmp.commons.enums.*;
|
import org.opencdmp.commons.enums.*;
|
||||||
import org.opencdmp.commons.enums.notification.NotificationContactType;
|
|
||||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
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.*;
|
||||||
|
@ -158,7 +157,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
data = this.entityManager.find(DescriptionTemplateEntity.class, model.getId());
|
data = this.entityManager.find(DescriptionTemplateEntity.class, model.getId());
|
||||||
if (data == null)
|
if (data == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash()))
|
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash()))
|
||||||
throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||||
if (data.getStatus().equals(DescriptionTemplateStatus.Finalized))
|
if (data.getStatus().equals(DescriptionTemplateStatus.Finalized))
|
||||||
|
@ -260,11 +259,11 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
UserEntity user = this.entityManager.find(UserEntity.class, userDescriptionTemplate.getUserId());
|
UserEntity user = this.entityManager.find(UserEntity.class, userDescriptionTemplate.getUserId());
|
||||||
if (user == null){
|
if (user == null){
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{userDescriptionTemplate.getUserId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{userDescriptionTemplate.getUserId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
}
|
}
|
||||||
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(userDescriptionTemplate.getDescriptionTemplateId()).first();
|
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(userDescriptionTemplate.getDescriptionTemplateId()).first();
|
||||||
if (descriptionTemplate == null){
|
if (descriptionTemplate == null){
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{userDescriptionTemplate.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{userDescriptionTemplate.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
}
|
}
|
||||||
event.setUserId(user.getId());
|
event.setUserId(user.getId());
|
||||||
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
|
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
|
||||||
|
@ -273,16 +272,16 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
List<ContactPair> contactPairs = new ArrayList<>();
|
List<ContactPair> contactPairs = new ArrayList<>();
|
||||||
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
||||||
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
||||||
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
event.setContactHint(this.jsonHandlingService.toJsonSafe(contactData));
|
||||||
event.setNotificationType(notificationProperties.getDescriptionTemplateInvitationType());
|
event.setNotificationType(this.notificationProperties.getDescriptionTemplateInvitationType());
|
||||||
NotificationFieldData data = new NotificationFieldData();
|
NotificationFieldData data = new NotificationFieldData();
|
||||||
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
||||||
fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName()));
|
fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName()));
|
||||||
fieldInfoList.add(new FieldInfo("{templateName}", DataType.String, descriptionTemplate.getLabel()));
|
fieldInfoList.add(new FieldInfo("{templateName}", DataType.String, descriptionTemplate.getLabel()));
|
||||||
fieldInfoList.add(new FieldInfo("{templateID}", DataType.String, descriptionTemplate.getId().toString()));
|
fieldInfoList.add(new FieldInfo("{templateID}", DataType.String, descriptionTemplate.getId().toString()));
|
||||||
data.setFields(fieldInfoList);
|
data.setFields(fieldInfoList);
|
||||||
event.setData(jsonHandlingService.toJsonSafe(data));
|
event.setData(this.jsonHandlingService.toJsonSafe(data));
|
||||||
eventHandler.handle(event);
|
this.eventHandler.handle(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOwner(DescriptionTemplateEntity descriptionTemplateEntity) throws InvalidApplicationException {
|
private void addOwner(DescriptionTemplateEntity descriptionTemplateEntity) throws InvalidApplicationException {
|
||||||
|
@ -292,7 +291,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
data.setCreatedAt(Instant.now());
|
data.setCreatedAt(Instant.now());
|
||||||
data.setUpdatedAt(Instant.now());
|
data.setUpdatedAt(Instant.now());
|
||||||
data.setRole(UserDescriptionTemplateRole.Owner);
|
data.setRole(UserDescriptionTemplateRole.Owner);
|
||||||
data.setUserId(userScope.getUserId());
|
data.setUserId(this.userScope.getUserId());
|
||||||
data.setDescriptionTemplateId(descriptionTemplateEntity.getId());
|
data.setDescriptionTemplateId(descriptionTemplateEntity.getId());
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
}
|
}
|
||||||
|
@ -418,13 +417,13 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
List<UUID> ids = persist.getTextListValue().stream().map(UUID::fromString).toList();
|
List<UUID> ids = persist.getTextListValue().stream().map(UUID::fromString).toList();
|
||||||
Set<UUID> existingIds = this.queryFactory.query(DmpQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Dmp._id)).stream().map(DmpEntity::getId).collect(Collectors.toSet());
|
Set<UUID> existingIds = this.queryFactory.query(DmpQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Dmp._id)).stream().map(DmpEntity::getId).collect(Collectors.toSet());
|
||||||
for (UUID id : ids){
|
for (UUID id : ids){
|
||||||
if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (!existingIds.contains(id)) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
}
|
}
|
||||||
} if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())){
|
} if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())){
|
||||||
List<UUID> ids = persist.getTextListValue().stream().map(UUID::fromString).toList();
|
List<UUID> ids = persist.getTextListValue().stream().map(UUID::fromString).toList();
|
||||||
Set<UUID> existingIds = this.queryFactory.query(DescriptionQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Description._id)).stream().map(DescriptionEntity::getId).collect(Collectors.toSet());
|
Set<UUID> existingIds = this.queryFactory.query(DescriptionQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Description._id)).stream().map(DescriptionEntity::getId).collect(Collectors.toSet());
|
||||||
for (UUID id : ids){
|
for (UUID id : ids){
|
||||||
if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (!existingIds.contains(id)) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.setTextListValue(persist.getTextListValue());
|
data.setTextListValue(persist.getTextListValue());
|
||||||
|
@ -456,7 +455,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
ReferenceEntity data;
|
ReferenceEntity data;
|
||||||
if (this.conventionService.isValidGuid(model.getId())){
|
if (this.conventionService.isValidGuid(model.getId())){
|
||||||
data = this.entityManager.find(ReferenceEntity.class, model.getId());
|
data = this.entityManager.find(ReferenceEntity.class, model.getId());
|
||||||
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
} else {
|
} else {
|
||||||
ReferenceTypeDataEntity referenceTypeDataEntity = ((ReferenceTypeDataEntity)fieldEntity.getData());
|
ReferenceTypeDataEntity referenceTypeDataEntity = ((ReferenceTypeDataEntity)fieldEntity.getData());
|
||||||
data = this.queryFactory.query(ReferenceQuery.class).sourceTypes(model.getSourceType()).typeIds(referenceTypeDataEntity.getReferenceTypeId()).sources(model.getSource()).isActive(IsActive.Active).references(model.getReference()).first();
|
data = this.queryFactory.query(ReferenceQuery.class).sourceTypes(model.getSourceType()).typeIds(referenceTypeDataEntity.getReferenceTypeId()).sources(model.getSource()).isActive(IsActive.Active).references(model.getReference()).first();
|
||||||
|
@ -476,14 +475,14 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ReferenceTypeEntity referenceType = this.queryFactory.query(ReferenceTypeQuery.class).ids(referenceTypeDataEntity.getReferenceTypeId()).firstAs(new BaseFieldSet().ensure(ReferenceType._id).ensure(ReferenceTypeEntity._tenantId));
|
ReferenceTypeEntity referenceType = this.queryFactory.query(ReferenceTypeQuery.class).ids(referenceTypeDataEntity.getReferenceTypeId()).firstAs(new BaseFieldSet().ensure(ReferenceType._id).ensure(ReferenceTypeEntity._tenantId));
|
||||||
if (referenceType == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{referenceTypeDataEntity.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
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){
|
if (data.getSourceType().equals(ReferenceSourceType.External) && !this.tenantScope.isDefaultTenant() && referenceType.getTenantId() == null){
|
||||||
this.tenantScope.setTempTenant(this.entityManager.getEntityManager(), null, this.tenantScope.getDefaultTenantCode());
|
this.tenantScope.setTempTenant(this.entityManager.getEntityManager(), null, this.tenantScope.getDefaultTenantCode());
|
||||||
}
|
}
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
} finally {
|
} finally {
|
||||||
tenantScope.removeTempTenant(this.entityManager.getEntityManager());
|
this.tenantScope.removeTempTenant(this.entityManager.getEntityManager());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -562,7 +561,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
this.authorizationService.authorizeForce(Permission.DeleteDescriptionTemplate);
|
this.authorizationService.authorizeForce(Permission.DeleteDescriptionTemplate);
|
||||||
|
|
||||||
DescriptionTemplateEntity data = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
DescriptionTemplateEntity data = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
||||||
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
if (data.getVersionStatus().equals(DescriptionTemplateVersionStatus.Current)){
|
if (data.getVersionStatus().equals(DescriptionTemplateVersionStatus.Current)){
|
||||||
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class)
|
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class)
|
||||||
|
@ -597,7 +596,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
DescriptionTemplate model = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fields, query.firstAs(fields));
|
DescriptionTemplate model = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fields, query.firstAs(fields));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
model.setLabel(model.getLabel() + " new ");
|
model.setLabel(model.getLabel() + " new ");
|
||||||
model.setId(null);
|
model.setId(null);
|
||||||
|
@ -678,7 +677,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getId());
|
DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getId());
|
||||||
if (oldDescriptionTemplateEntity == null)
|
if (oldDescriptionTemplateEntity == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
if (!this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt()).equals(model.getHash()))
|
if (!this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt()).equals(model.getHash()))
|
||||||
throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||||
|
|
||||||
|
@ -742,6 +741,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
this.authorizationService.authorizeForce(Permission.ImportDescriptionTemplate);
|
this.authorizationService.authorizeForce(Permission.ImportDescriptionTemplate);
|
||||||
|
|
||||||
DescriptionTemplateImportExport importXml = this.xmlHandlingService.fromXml(DescriptionTemplateImportExport.class, new String(bytes, StandardCharsets.UTF_8));
|
DescriptionTemplateImportExport importXml = this.xmlHandlingService.fromXml(DescriptionTemplateImportExport.class, new String(bytes, StandardCharsets.UTF_8));
|
||||||
|
if (id == null) id = importXml.getId();
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
|
DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
|
||||||
persist.setLabel(label);
|
persist.setLabel(label);
|
||||||
|
@ -764,7 +764,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
DescriptionTemplateEntity oldDescriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
||||||
if (oldDescriptionTemplateEntity == null)
|
if (oldDescriptionTemplateEntity == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
persist.setHash(this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt()));
|
persist.setHash(this.conventionService.hashValue(oldDescriptionTemplateEntity.getUpdatedAt()));
|
||||||
this.validatorFactory.validator(DescriptionTemplatePersist.DescriptionTemplatePersistValidator.class).validateForce(persist);
|
this.validatorFactory.validator(DescriptionTemplatePersist.DescriptionTemplatePersistValidator.class).validateForce(persist);
|
||||||
return this.createNewVersion(persist, fields);
|
return this.createNewVersion(persist, fields);
|
||||||
|
@ -778,7 +778,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
List<PagePersist> pagesDatasetEntity = new LinkedList<>();
|
List<PagePersist> pagesDatasetEntity = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(importExport.getPages())) {
|
if (!this.conventionService.isListNullOrEmpty(importExport.getPages())) {
|
||||||
for (PageImportExport xmlPage : importExport.getPages()) {
|
for (DescriptionTemplatePageImportExport xmlPage : importExport.getPages()) {
|
||||||
pagesDatasetEntity.add(this.xmlPageToPersist(xmlPage));
|
pagesDatasetEntity.add(this.xmlPageToPersist(xmlPage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -787,14 +787,14 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return definitionPersist;
|
return definitionPersist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagePersist xmlPageToPersist(PageImportExport importExport) {
|
public PagePersist xmlPageToPersist(DescriptionTemplatePageImportExport importExport) {
|
||||||
PagePersist pageEntity = new PagePersist();
|
PagePersist pageEntity = new PagePersist();
|
||||||
pageEntity.setId(importExport.getId());
|
pageEntity.setId(importExport.getId());
|
||||||
pageEntity.setOrdinal(importExport.getOrdinal());
|
pageEntity.setOrdinal(importExport.getOrdinal());
|
||||||
pageEntity.setTitle(importExport.getTitle());
|
pageEntity.setTitle(importExport.getTitle());
|
||||||
if (!this.conventionService.isListNullOrEmpty(importExport.getSections())) {
|
if (!this.conventionService.isListNullOrEmpty(importExport.getSections())) {
|
||||||
List<SectionPersist> sectionsListEntity = new LinkedList<>();
|
List<SectionPersist> sectionsListEntity = new LinkedList<>();
|
||||||
for (SectionImportExport xmlSection : importExport.getSections()) {
|
for (DescriptionTemplateSectionImportExport xmlSection : importExport.getSections()) {
|
||||||
sectionsListEntity.add(this.xmlSectionToPersist(xmlSection));
|
sectionsListEntity.add(this.xmlSectionToPersist(xmlSection));
|
||||||
}
|
}
|
||||||
pageEntity.setSections(sectionsListEntity);
|
pageEntity.setSections(sectionsListEntity);
|
||||||
|
@ -803,12 +803,12 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return pageEntity;
|
return pageEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SectionPersist xmlSectionToPersist(SectionImportExport importExport) {
|
public SectionPersist xmlSectionToPersist(DescriptionTemplateSectionImportExport importExport) {
|
||||||
SectionPersist sectionEntity = new SectionPersist();
|
SectionPersist sectionEntity = new SectionPersist();
|
||||||
List<SectionPersist> sectionsListEntity = new LinkedList<>();
|
List<SectionPersist> sectionsListEntity = new LinkedList<>();
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(importExport.getSections())) {
|
if (!this.conventionService.isListNullOrEmpty(importExport.getSections())) {
|
||||||
for (SectionImportExport xmlSection : importExport.getSections()) {
|
for (DescriptionTemplateSectionImportExport xmlSection : importExport.getSections()) {
|
||||||
sectionsListEntity.add(this.xmlSectionToPersist(xmlSection));
|
sectionsListEntity.add(this.xmlSectionToPersist(xmlSection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -818,7 +818,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
sectionEntity.setDescription(importExport.getDescription());
|
sectionEntity.setDescription(importExport.getDescription());
|
||||||
List<FieldSetPersist> fieldSetEntity = new LinkedList<>();
|
List<FieldSetPersist> fieldSetEntity = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(importExport.getFieldSets())) {
|
if (!this.conventionService.isListNullOrEmpty(importExport.getFieldSets())) {
|
||||||
for (FieldSetImportExport xmlFieldSet : importExport.getFieldSets()) {
|
for (DescriptionTemplateFieldSetImportExport xmlFieldSet : importExport.getFieldSets()) {
|
||||||
fieldSetEntity.add(this.toFieldSetModel(xmlFieldSet));
|
fieldSetEntity.add(this.toFieldSetModel(xmlFieldSet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -829,7 +829,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return sectionEntity;
|
return sectionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldSetPersist toFieldSetModel(FieldSetImportExport importExport) {
|
public FieldSetPersist toFieldSetModel(DescriptionTemplateFieldSetImportExport importExport) {
|
||||||
FieldSetPersist fieldSet1Entity = new FieldSetPersist();
|
FieldSetPersist fieldSet1Entity = new FieldSetPersist();
|
||||||
fieldSet1Entity.setId(importExport.getId());
|
fieldSet1Entity.setId(importExport.getId());
|
||||||
fieldSet1Entity.setOrdinal(importExport.getOrdinal());
|
fieldSet1Entity.setOrdinal(importExport.getOrdinal());
|
||||||
|
@ -843,7 +843,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
List<FieldPersist> fieldsEntity = new LinkedList<>();
|
List<FieldPersist> fieldsEntity = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(importExport.getFields())) {
|
if (!this.conventionService.isListNullOrEmpty(importExport.getFields())) {
|
||||||
for (FieldImportExport xmlField : importExport.getFields()) {
|
for (DescriptionTemplateFieldImportExport xmlField : importExport.getFields()) {
|
||||||
fieldsEntity.add(this.xmlFieldToPersist(xmlField));
|
fieldsEntity.add(this.xmlFieldToPersist(xmlField));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -851,7 +851,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return fieldSet1Entity;
|
return fieldSet1Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldPersist xmlFieldToPersist(FieldImportExport importExport) {
|
public FieldPersist xmlFieldToPersist(DescriptionTemplateFieldImportExport importExport) {
|
||||||
FieldPersist fieldEntity = new FieldPersist();
|
FieldPersist fieldEntity = new FieldPersist();
|
||||||
fieldEntity.setId(importExport.getId());
|
fieldEntity.setId(importExport.getId());
|
||||||
fieldEntity.setOrdinal(importExport.getOrdinal());
|
fieldEntity.setOrdinal(importExport.getOrdinal());
|
||||||
|
@ -859,7 +859,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
fieldEntity.setDefaultValue(importExport.getDefaultValue());
|
fieldEntity.setDefaultValue(importExport.getDefaultValue());
|
||||||
List<RulePersist> rulePersists = new ArrayList<>();
|
List<RulePersist> rulePersists = new ArrayList<>();
|
||||||
if (importExport.getVisibilityRules() != null) {
|
if (importExport.getVisibilityRules() != null) {
|
||||||
for (RuleImportExport xmlRule : importExport.getVisibilityRules()) {
|
for (DescriptionTemplateRuleImportExport xmlRule : importExport.getVisibilityRules()) {
|
||||||
rulePersists.add(this.toRuleModel(xmlRule));
|
rulePersists.add(this.toRuleModel(xmlRule));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -874,7 +874,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return fieldEntity;
|
return fieldEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RulePersist toRuleModel(RuleImportExport importExport) {
|
public RulePersist toRuleModel(DescriptionTemplateRuleImportExport importExport) {
|
||||||
RulePersist ruleEntity = new RulePersist();
|
RulePersist ruleEntity = new RulePersist();
|
||||||
ruleEntity.setTarget(importExport.getTarget());
|
ruleEntity.setTarget(importExport.getTarget());
|
||||||
ruleEntity.setDateValue(importExport.getDateValue());
|
ruleEntity.setDateValue(importExport.getDateValue());
|
||||||
|
@ -884,7 +884,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return ruleEntity;
|
return ruleEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultiplicityPersist xmlMultiplicityToPersist(MultiplicityImportExport importXml) {
|
public MultiplicityPersist xmlMultiplicityToPersist(DescriptionTemplateMultiplicityImportExport importXml) {
|
||||||
MultiplicityPersist multiplicityEntity = new MultiplicityPersist();
|
MultiplicityPersist multiplicityEntity = new MultiplicityPersist();
|
||||||
multiplicityEntity.setMax(importXml.getMax());
|
multiplicityEntity.setMax(importXml.getMax());
|
||||||
multiplicityEntity.setMin(importXml.getMin());
|
multiplicityEntity.setMin(importXml.getMin());
|
||||||
|
@ -898,25 +898,41 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
//region Export
|
//region Export
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
public DescriptionTemplateImportExport exportXmlEntity(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("persisting data").And("id", id));
|
logger.debug(new MapLogEntry("exportXml").And("id", id));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);
|
this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);
|
||||||
DescriptionTemplateEntity data = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
DescriptionTemplateEntity data = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
||||||
if (data == null)
|
if (data == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
DefinitionEntity definition = this.xmlHandlingService.fromXml(DefinitionEntity.class, data.getDefinition());
|
DefinitionEntity definition = this.xmlHandlingService.fromXml(DefinitionEntity.class, data.getDefinition());
|
||||||
String xml = this.xmlHandlingService.toXml(this.definitionXmlToExport(data, definition));
|
return this.definitionXmlToExport(data, definition);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("exportXml").And("id", id));
|
||||||
|
|
||||||
|
this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate);
|
||||||
|
DescriptionTemplateEntity data = this.entityManager.find(DescriptionTemplateEntity.class, id);
|
||||||
|
if (data == null)
|
||||||
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
DefinitionEntity definition = this.xmlHandlingService.fromXml(DefinitionEntity.class, data.getDefinition());
|
||||||
|
String xml = this.xmlHandlingService.toXml(this.exportXmlEntity(id));
|
||||||
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
return this.responseUtilsService.buildResponseFileFromText(xml, data.getLabel() + ".xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
private DescriptionTemplateImportExport definitionXmlToExport(DescriptionTemplateEntity data, DefinitionEntity entity) {
|
private DescriptionTemplateImportExport definitionXmlToExport(DescriptionTemplateEntity data, DefinitionEntity entity) {
|
||||||
DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport();
|
DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport();
|
||||||
|
xml.setId(data.getId());
|
||||||
|
xml.setType(data.getTypeId());
|
||||||
xml.setType(data.getTypeId());
|
xml.setType(data.getTypeId());
|
||||||
xml.setLanguage(data.getLanguage());
|
xml.setLanguage(data.getLanguage());
|
||||||
xml.setDescription(data.getDescription());
|
xml.setDescription(data.getDescription());
|
||||||
List<PageImportExport> pagesDatasetEntity = new LinkedList<>();
|
List<DescriptionTemplatePageImportExport> pagesDatasetEntity = new LinkedList<>();
|
||||||
for (PageEntity xmlPage : entity.getPages()) {
|
for (PageEntity xmlPage : entity.getPages()) {
|
||||||
pagesDatasetEntity.add(this.pageXmlToExport(xmlPage));
|
pagesDatasetEntity.add(this.pageXmlToExport(xmlPage));
|
||||||
}
|
}
|
||||||
|
@ -925,12 +941,12 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PageImportExport pageXmlToExport(PageEntity entity) {
|
private DescriptionTemplatePageImportExport pageXmlToExport(PageEntity entity) {
|
||||||
PageImportExport xml = new PageImportExport();
|
DescriptionTemplatePageImportExport xml = new DescriptionTemplatePageImportExport();
|
||||||
xml.setId(entity.getId());
|
xml.setId(entity.getId());
|
||||||
xml.setOrdinal(entity.getOrdinal());
|
xml.setOrdinal(entity.getOrdinal());
|
||||||
xml.setTitle(entity.getTitle());
|
xml.setTitle(entity.getTitle());
|
||||||
List<SectionImportExport> sectionsListEntity = new LinkedList<>();
|
List<DescriptionTemplateSectionImportExport> sectionsListEntity = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(entity.getSections())) {
|
if (!this.conventionService.isListNullOrEmpty(entity.getSections())) {
|
||||||
for (SectionEntity section : entity.getSections()) {
|
for (SectionEntity section : entity.getSections()) {
|
||||||
sectionsListEntity.add(this.sectionXmlToExport(section));
|
sectionsListEntity.add(this.sectionXmlToExport(section));
|
||||||
|
@ -941,9 +957,9 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SectionImportExport sectionXmlToExport(SectionEntity entity) {
|
private DescriptionTemplateSectionImportExport sectionXmlToExport(SectionEntity entity) {
|
||||||
SectionImportExport xml = new SectionImportExport();
|
DescriptionTemplateSectionImportExport xml = new DescriptionTemplateSectionImportExport();
|
||||||
List<SectionImportExport> sectionsListEntity = new LinkedList<>();
|
List<DescriptionTemplateSectionImportExport> sectionsListEntity = new LinkedList<>();
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(entity.getSections())) {
|
if (!this.conventionService.isListNullOrEmpty(entity.getSections())) {
|
||||||
for (SectionEntity xmlSection : entity.getSections()) {
|
for (SectionEntity xmlSection : entity.getSections()) {
|
||||||
|
@ -956,7 +972,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
xml.setOrdinal(entity.getOrdinal());
|
xml.setOrdinal(entity.getOrdinal());
|
||||||
xml.setTitle(entity.getTitle());
|
xml.setTitle(entity.getTitle());
|
||||||
xml.setDescription(entity.getDescription());
|
xml.setDescription(entity.getDescription());
|
||||||
List<FieldSetImportExport> fieldSetEntity = new LinkedList<>();
|
List<DescriptionTemplateFieldSetImportExport> fieldSetEntity = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(entity.getFieldSets())) {
|
if (!this.conventionService.isListNullOrEmpty(entity.getFieldSets())) {
|
||||||
for (FieldSetEntity xmlFieldSet : entity.getFieldSets()) {
|
for (FieldSetEntity xmlFieldSet : entity.getFieldSets()) {
|
||||||
fieldSetEntity.add(this.fieldSetXmlToExport(xmlFieldSet));
|
fieldSetEntity.add(this.fieldSetXmlToExport(xmlFieldSet));
|
||||||
|
@ -968,8 +984,8 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FieldSetImportExport fieldSetXmlToExport(FieldSetEntity entity) {
|
private DescriptionTemplateFieldSetImportExport fieldSetXmlToExport(FieldSetEntity entity) {
|
||||||
FieldSetImportExport fieldSet1Entity = new FieldSetImportExport();
|
DescriptionTemplateFieldSetImportExport fieldSet1Entity = new DescriptionTemplateFieldSetImportExport();
|
||||||
fieldSet1Entity.setId(entity.getId());
|
fieldSet1Entity.setId(entity.getId());
|
||||||
fieldSet1Entity.setOrdinal(entity.getOrdinal());
|
fieldSet1Entity.setOrdinal(entity.getOrdinal());
|
||||||
fieldSet1Entity.setHasCommentField(entity.getHasCommentField());
|
fieldSet1Entity.setHasCommentField(entity.getHasCommentField());
|
||||||
|
@ -980,7 +996,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
fieldSet1Entity.setExtendedDescription(entity.getExtendedDescription());
|
fieldSet1Entity.setExtendedDescription(entity.getExtendedDescription());
|
||||||
fieldSet1Entity.setAdditionalInformation(entity.getAdditionalInformation());
|
fieldSet1Entity.setAdditionalInformation(entity.getAdditionalInformation());
|
||||||
|
|
||||||
List<FieldImportExport> fieldsEntity = new LinkedList<>();
|
List<DescriptionTemplateFieldImportExport> fieldsEntity = new LinkedList<>();
|
||||||
if (entity.getFields() != null) {
|
if (entity.getFields() != null) {
|
||||||
for (FieldEntity xmlField : entity.getFields()) {
|
for (FieldEntity xmlField : entity.getFields()) {
|
||||||
fieldsEntity.add(this.fieldXmlToExport(xmlField));
|
fieldsEntity.add(this.fieldXmlToExport(xmlField));
|
||||||
|
@ -990,13 +1006,13 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return fieldSet1Entity;
|
return fieldSet1Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FieldImportExport fieldXmlToExport(FieldEntity entity) {
|
private DescriptionTemplateFieldImportExport fieldXmlToExport(FieldEntity entity) {
|
||||||
FieldImportExport xml = new FieldImportExport();
|
DescriptionTemplateFieldImportExport xml = new DescriptionTemplateFieldImportExport();
|
||||||
xml.setId(entity.getId());
|
xml.setId(entity.getId());
|
||||||
xml.setOrdinal(entity.getOrdinal());
|
xml.setOrdinal(entity.getOrdinal());
|
||||||
xml.setValidations(entity.getValidations());
|
xml.setValidations(entity.getValidations());
|
||||||
xml.setDefaultValue(entity.getDefaultValue());
|
xml.setDefaultValue(entity.getDefaultValue());
|
||||||
List<RuleImportExport> rulePersists = new ArrayList<>();
|
List<DescriptionTemplateRuleImportExport> rulePersists = new ArrayList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(entity.getVisibilityRules())) {
|
if (!this.conventionService.isListNullOrEmpty(entity.getVisibilityRules())) {
|
||||||
for (RuleEntity xmlRule : entity.getVisibilityRules()) {
|
for (RuleEntity xmlRule : entity.getVisibilityRules()) {
|
||||||
rulePersists.add(this.toRuleModel(xmlRule));
|
rulePersists.add(this.toRuleModel(xmlRule));
|
||||||
|
@ -1013,22 +1029,22 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RuleImportExport toRuleModel(RuleEntity entity) {
|
private DescriptionTemplateRuleImportExport toRuleModel(RuleEntity entity) {
|
||||||
RuleImportExport xml = new RuleImportExport();
|
DescriptionTemplateRuleImportExport xml = new DescriptionTemplateRuleImportExport();
|
||||||
xml.setTarget(entity.getTarget());
|
xml.setTarget(entity.getTarget());
|
||||||
xml.setDateValue(entity.getDateValue());
|
xml.setDateValue(entity.getDateValue());
|
||||||
xml.setTextListValue(entity.getTextListValue());
|
xml.setTextListValue(entity.getTextListValue());
|
||||||
xml.setTextValue(entity.getTextValue());
|
xml.setTextValue(entity.getTextValue());
|
||||||
if (entity.getExternalIdentifier() != null){
|
if (entity.getExternalIdentifier() != null){
|
||||||
xml.setExternalIdentifier(new ExternalIdentifierImportExport());
|
xml.setExternalIdentifier(new DescriptionTemplateExternalIdentifierImportExport());
|
||||||
xml.getExternalIdentifier().setIdentifier(entity.getExternalIdentifier().getIdentifier());
|
xml.getExternalIdentifier().setIdentifier(entity.getExternalIdentifier().getIdentifier());
|
||||||
xml.getExternalIdentifier().setType(entity.getExternalIdentifier().getType());
|
xml.getExternalIdentifier().setType(entity.getExternalIdentifier().getType());
|
||||||
}
|
}
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MultiplicityImportExport multiplicityXmlToExport(MultiplicityEntity entity) {
|
private DescriptionTemplateMultiplicityImportExport multiplicityXmlToExport(MultiplicityEntity entity) {
|
||||||
MultiplicityImportExport xml = new MultiplicityImportExport();
|
DescriptionTemplateMultiplicityImportExport xml = new DescriptionTemplateMultiplicityImportExport();
|
||||||
xml.setMax(entity.getMax());
|
xml.setMax(entity.getMax());
|
||||||
xml.setMin(entity.getMin());
|
xml.setMin(entity.getMin());
|
||||||
xml.setPlaceholder(entity.getPlaceholder());
|
xml.setPlaceholder(entity.getPlaceholder());
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.opencdmp.commons.enums.notification.NotificationContactType;
|
||||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
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.actionconfirmation.DmpInvitationEntity;
|
import org.opencdmp.commons.types.actionconfirmation.DmpInvitationEntity;
|
||||||
|
import org.opencdmp.commons.types.description.importexport.DescriptionImportExport;
|
||||||
import org.opencdmp.commons.types.dmp.DmpBlueprintValueEntity;
|
import org.opencdmp.commons.types.dmp.DmpBlueprintValueEntity;
|
||||||
import org.opencdmp.commons.types.dmp.DmpContactEntity;
|
import org.opencdmp.commons.types.dmp.DmpContactEntity;
|
||||||
import org.opencdmp.commons.types.dmp.DmpPropertiesEntity;
|
import org.opencdmp.commons.types.dmp.DmpPropertiesEntity;
|
||||||
|
@ -142,6 +143,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
private final TenantScope tenantScope;
|
private final TenantScope tenantScope;
|
||||||
private final ResponseUtilsService responseUtilsService;
|
private final ResponseUtilsService responseUtilsService;
|
||||||
private final DmpBlueprintService dmpBlueprintService;
|
private final DmpBlueprintService dmpBlueprintService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DmpServiceImpl(
|
public DmpServiceImpl(
|
||||||
TenantEntityManager entityManager,
|
TenantEntityManager entityManager,
|
||||||
|
@ -231,8 +233,8 @@ public class DmpServiceImpl implements DmpService {
|
||||||
private void checkIfDescriptionTemplateIsUse (List<DmpDescriptionTemplatePersist> descriptionTemplates, UUID id){
|
private void checkIfDescriptionTemplateIsUse (List<DmpDescriptionTemplatePersist> descriptionTemplates, UUID id){
|
||||||
List<DmpDescriptionTemplateEntity> existingDmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(id).isActive(IsActive.Active).collect();
|
List<DmpDescriptionTemplateEntity> existingDmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(id).isActive(IsActive.Active).collect();
|
||||||
|
|
||||||
List<DmpDescriptionTemplateEntity> removedDescriptionTemplates = existingDmpDescriptionTemplates.stream().filter(x -> descriptionTemplates.stream().noneMatch(y -> y.getDescriptionTemplateGroupId().equals(x.getDescriptionTemplateGroupId()))).collect(Collectors.toList());
|
List<DmpDescriptionTemplateEntity> removedDescriptionTemplates = existingDmpDescriptionTemplates.stream().filter(x -> descriptionTemplates.stream().noneMatch(y -> y.getDescriptionTemplateGroupId().equals(x.getDescriptionTemplateGroupId()))).toList();
|
||||||
DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).isActive(IsActive.Active).dmpIds(id).descriptionTemplateGroupIds(removedDescriptionTemplates.stream().map(x -> x.getDescriptionTemplateGroupId()).collect(Collectors.toList()));
|
DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).isActive(IsActive.Active).dmpIds(id).descriptionTemplateGroupIds(removedDescriptionTemplates.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateGroupId).collect(Collectors.toList()));
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpDescriptionTemplateSubQuery(dmpDescriptionTemplateQuery).isActive(IsActive.Active);
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpDescriptionTemplateSubQuery(dmpDescriptionTemplateQuery).isActive(IsActive.Active);
|
||||||
|
|
||||||
if (query != null && query.count() > 0) throw new MyValidationException(this.errors.getDmpDescriptionTemplateCanNotRemove().getCode(), this.errors.getDmpDescriptionTemplateCanNotRemove().getMessage());
|
if (query != null && query.count() > 0) throw new MyValidationException(this.errors.getDmpDescriptionTemplateCanNotRemove().getCode(), this.errors.getDmpDescriptionTemplateCanNotRemove().getMessage());
|
||||||
|
@ -1066,7 +1068,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities)){
|
if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities)){
|
||||||
persist.setDescriptionTemplates(new ArrayList<>());
|
persist.setDescriptionTemplates(new ArrayList<>());
|
||||||
for (DmpDescriptionTemplateEntity descriptionTemplateEntity: dmpDescriptionTemplateEntities) {
|
for (DmpDescriptionTemplateEntity descriptionTemplateEntity: dmpDescriptionTemplateEntities) {
|
||||||
persist.getDescriptionTemplates().add(this.buildDmpDescriptionTemplatePersists(descriptionTemplateEntity, definition.getSections()));
|
persist.getDescriptionTemplates().add(this.buildDmpDescriptionTemplatePersists(descriptionTemplateEntity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
persist.setProperties(this.buildDmpPropertyDefinitionPersist( this.jsonHandlingService.fromJsonSafe(DmpPropertiesEntity.class, data.getProperties()), dmpReferenceEntities, definition.getSections()));
|
persist.setProperties(this.buildDmpPropertyDefinitionPersist( this.jsonHandlingService.fromJsonSafe(DmpPropertiesEntity.class, data.getProperties()), dmpReferenceEntities, definition.getSections()));
|
||||||
|
@ -1100,7 +1102,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
for (DmpReferenceEntity dmpReferenceEntity : dmpReferenceEntities) {
|
for (DmpReferenceEntity dmpReferenceEntity : dmpReferenceEntities) {
|
||||||
DmpReferenceData referenceData = this.jsonHandlingService.fromJsonSafe(DmpReferenceData.class, dmpReferenceEntity.getData());
|
DmpReferenceData referenceData = this.jsonHandlingService.fromJsonSafe(DmpReferenceData.class, dmpReferenceEntity.getData());
|
||||||
|
|
||||||
ReferenceEntity reference = referencesFromAllFields.stream().filter(x -> x.getId().equals(dmpReferenceEntity.getReferenceId())).collect(Collectors.toList()).getFirst();
|
ReferenceEntity reference = referencesFromAllFields.stream().filter(x -> x.getId().equals(dmpReferenceEntity.getReferenceId())).toList().getFirst();
|
||||||
if (referenceData.getBlueprintFieldId().equals(fieldEntity.getId()) && reference != null) {
|
if (referenceData.getBlueprintFieldId().equals(fieldEntity.getId()) && reference != null) {
|
||||||
referencePersists.add(this.buildReferencePersist(reference));
|
referencePersists.add(this.buildReferencePersist(reference));
|
||||||
}
|
}
|
||||||
|
@ -1152,7 +1154,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull DmpDescriptionTemplatePersist buildDmpDescriptionTemplatePersists(DmpDescriptionTemplateEntity data, List<SectionEntity> sectionEntities){
|
private @NotNull DmpDescriptionTemplatePersist buildDmpDescriptionTemplatePersists(DmpDescriptionTemplateEntity data){
|
||||||
DmpDescriptionTemplatePersist persist = new DmpDescriptionTemplatePersist();
|
DmpDescriptionTemplatePersist persist = new DmpDescriptionTemplatePersist();
|
||||||
if (data == null) return persist;
|
if (data == null) return persist;
|
||||||
|
|
||||||
|
@ -1234,7 +1236,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
if (userId != null){
|
if (userId != null){
|
||||||
user.setUser(userId);
|
user.setUser(userId);
|
||||||
usersToAssign.add(user);
|
usersToAssign.add(user);
|
||||||
if (this.userScope.getUserId() != userId && !existingUsers.stream().map(x -> x.getUserId()).collect(Collectors.toList()).contains(userId)){
|
if (this.userScope.getUserId() != userId && !existingUsers.stream().map(DmpUserEntity::getUserId).toList().contains(userId)){
|
||||||
this.sendDmpInvitationExistingUser(user.getUser(), dmp, user.getRole());
|
this.sendDmpInvitationExistingUser(user.getUser(), dmp, user.getRole());
|
||||||
}
|
}
|
||||||
}else if (user.getEmail() != null) {
|
}else if (user.getEmail() != null) {
|
||||||
|
@ -1380,7 +1382,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
|
|
||||||
if (propertiesEntity != null && !this.conventionService.isListNullOrEmpty(propertiesEntity.getContacts())) {
|
if (propertiesEntity != null && !this.conventionService.isListNullOrEmpty(propertiesEntity.getContacts())) {
|
||||||
List<DmpContactImportExport> dmpContactImportExports = new LinkedList<>();
|
List<DmpContactImportExport> dmpContactImportExports = new LinkedList<>();
|
||||||
List<UserEntity> users = this.queryFactory.query(UserQuery.class).ids(propertiesEntity.getContacts().stream().filter(x-> x.getUserId() != null).map(DmpContactEntity::getUserId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
List<UserEntity> users = this.queryFactory.query(UserQuery.class).ids(propertiesEntity.getContacts().stream().map(DmpContactEntity::getUserId).filter(Objects::nonNull).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).isActive(IsActive.Active).collect();
|
||||||
Map<UUID, UserEntity> usersMap = users == null ? new HashMap<>() : users.stream().collect(Collectors.toMap(UserEntity::getId, x-> x));
|
Map<UUID, UserEntity> usersMap = users == null ? new HashMap<>() : users.stream().collect(Collectors.toMap(UserEntity::getId, x-> x));
|
||||||
for (DmpContactEntity contactEntity : propertiesEntity.getContacts()) {
|
for (DmpContactEntity contactEntity : propertiesEntity.getContacts()) {
|
||||||
dmpContactImportExports.add(this.dmpContactToExport(contactEntity, usersMap));
|
dmpContactImportExports.add(this.dmpContactToExport(contactEntity, usersMap));
|
||||||
|
@ -1432,6 +1434,14 @@ public class DmpServiceImpl implements DmpService {
|
||||||
}
|
}
|
||||||
xml.setReferences(dmpReferenceImportExports);
|
xml.setReferences(dmpReferenceImportExports);
|
||||||
}
|
}
|
||||||
|
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).dmpIds(data.getId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(data.getId()).isActive(IsActive.Active).collect();
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(descriptions)) {
|
||||||
|
List<DescriptionImportExport> descriptionImportExports = new LinkedList<>();
|
||||||
|
for (DescriptionEntity description : descriptions) {
|
||||||
|
descriptionImportExports.add(this.descriptionService.exportXmlEntity(description.getId()));
|
||||||
|
}
|
||||||
|
xml.setDescriptions(descriptionImportExports);
|
||||||
|
}
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -481,11 +481,11 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DefinitionImportExport definitionXmlToExport(DefinitionEntity entity) {
|
private BlueprintDefinitionImportExport definitionXmlToExport(DefinitionEntity entity) {
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
return null;
|
return null;
|
||||||
DefinitionImportExport xml = new DefinitionImportExport();
|
BlueprintDefinitionImportExport xml = new BlueprintDefinitionImportExport();
|
||||||
List<SectionImportExport> dmpBlueprintSections = new ArrayList<>();
|
List<BlueprintSectionImportExport> dmpBlueprintSections = new ArrayList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(entity.getSections())) {
|
if (!this.conventionService.isListNullOrEmpty(entity.getSections())) {
|
||||||
for (SectionEntity section : entity.getSections()) {
|
for (SectionEntity section : entity.getSections()) {
|
||||||
dmpBlueprintSections.add(this.sectionXmlToExport(section));
|
dmpBlueprintSections.add(this.sectionXmlToExport(section));
|
||||||
|
@ -495,14 +495,14 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SectionImportExport sectionXmlToExport(SectionEntity entity) {
|
private BlueprintSectionImportExport sectionXmlToExport(SectionEntity entity) {
|
||||||
SectionImportExport xml = new SectionImportExport();
|
BlueprintSectionImportExport xml = new BlueprintSectionImportExport();
|
||||||
xml.setId(entity.getId());
|
xml.setId(entity.getId());
|
||||||
xml.setLabel(entity.getLabel());
|
xml.setLabel(entity.getLabel());
|
||||||
xml.setDescription(entity.getDescription());
|
xml.setDescription(entity.getDescription());
|
||||||
xml.setOrdinal(entity.getOrdinal());
|
xml.setOrdinal(entity.getOrdinal());
|
||||||
xml.setHasTemplates(entity.getHasTemplates());
|
xml.setHasTemplates(entity.getHasTemplates());
|
||||||
List<SystemFieldImportExport> dmpBlueprintSystemFieldModels = new LinkedList<>();
|
List<BlueprintSystemFieldImportExport> dmpBlueprintSystemFieldModels = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(entity.getFields())) {
|
if (!this.conventionService.isListNullOrEmpty(entity.getFields())) {
|
||||||
for (SystemFieldEntity systemField : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.System).map(x -> (SystemFieldEntity) x).toList()) {
|
for (SystemFieldEntity systemField : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.System).map(x -> (SystemFieldEntity) x).toList()) {
|
||||||
dmpBlueprintSystemFieldModels.add(this.systemFieldXmlToExport(systemField));
|
dmpBlueprintSystemFieldModels.add(this.systemFieldXmlToExport(systemField));
|
||||||
|
@ -510,7 +510,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
}
|
}
|
||||||
xml.setSystemFields(dmpBlueprintSystemFieldModels);
|
xml.setSystemFields(dmpBlueprintSystemFieldModels);
|
||||||
|
|
||||||
List<ExtraFieldImportExport> dmpBlueprintExtraFieldModels = new LinkedList<>();
|
List<BlueprintExtraFieldImportExport> dmpBlueprintExtraFieldModels = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(entity.getFields())) {
|
if (!this.conventionService.isListNullOrEmpty(entity.getFields())) {
|
||||||
for (ExtraFieldEntity systemField : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.Extra).map(x -> (ExtraFieldEntity) x).toList()) {
|
for (ExtraFieldEntity systemField : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.Extra).map(x -> (ExtraFieldEntity) x).toList()) {
|
||||||
dmpBlueprintExtraFieldModels.add(this.extraFieldXmlToExport(systemField));
|
dmpBlueprintExtraFieldModels.add(this.extraFieldXmlToExport(systemField));
|
||||||
|
@ -518,7 +518,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
}
|
}
|
||||||
xml.setExtraFields(dmpBlueprintExtraFieldModels);
|
xml.setExtraFields(dmpBlueprintExtraFieldModels);
|
||||||
|
|
||||||
List<ReferenceTypeFieldImportExport> dmpBlueprintReferenceFieldModels = new LinkedList<>();
|
List<BlueprintReferenceTypeFieldImportExport> dmpBlueprintReferenceFieldModels = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(entity.getFields())) {
|
if (!this.conventionService.isListNullOrEmpty(entity.getFields())) {
|
||||||
for (ReferenceTypeFieldEntity referenceTypeFieldEntity : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.ReferenceType).map(x -> (ReferenceTypeFieldEntity) x).toList()) {
|
for (ReferenceTypeFieldEntity referenceTypeFieldEntity : entity.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.ReferenceType).map(x -> (ReferenceTypeFieldEntity) x).toList()) {
|
||||||
dmpBlueprintReferenceFieldModels.add(this.referenceFieldXmlToExport(referenceTypeFieldEntity));
|
dmpBlueprintReferenceFieldModels.add(this.referenceFieldXmlToExport(referenceTypeFieldEntity));
|
||||||
|
@ -526,7 +526,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
}
|
}
|
||||||
xml.setReferenceFields(dmpBlueprintReferenceFieldModels);
|
xml.setReferenceFields(dmpBlueprintReferenceFieldModels);
|
||||||
|
|
||||||
List<DescriptionTemplateImportExport> dmpBlueprintDescriptionTemplates = new LinkedList<>();
|
List<BlueprintDescriptionTemplateImportExport> dmpBlueprintDescriptionTemplates = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(entity.getDescriptionTemplates())) {
|
if (!this.conventionService.isListNullOrEmpty(entity.getDescriptionTemplates())) {
|
||||||
for (DescriptionTemplateEntity descriptionTemplate : entity.getDescriptionTemplates()) {
|
for (DescriptionTemplateEntity descriptionTemplate : entity.getDescriptionTemplates()) {
|
||||||
dmpBlueprintDescriptionTemplates.add(this.descriptionTemplateXmlToExport(descriptionTemplate));
|
dmpBlueprintDescriptionTemplates.add(this.descriptionTemplateXmlToExport(descriptionTemplate));
|
||||||
|
@ -536,8 +536,8 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DescriptionTemplateImportExport descriptionTemplateXmlToExport(DescriptionTemplateEntity entity) {
|
private BlueprintDescriptionTemplateImportExport descriptionTemplateXmlToExport(DescriptionTemplateEntity entity) {
|
||||||
DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport();
|
BlueprintDescriptionTemplateImportExport xml = new BlueprintDescriptionTemplateImportExport();
|
||||||
xml.setDescriptionTemplateGroupId(entity.getDescriptionTemplateGroupId());
|
xml.setDescriptionTemplateGroupId(entity.getDescriptionTemplateGroupId());
|
||||||
xml.setLabel(entity.getLabel());
|
xml.setLabel(entity.getLabel());
|
||||||
if (entity.getMinMultiplicity() != null ) xml.setMinMultiplicity(entity.getMinMultiplicity());
|
if (entity.getMinMultiplicity() != null ) xml.setMinMultiplicity(entity.getMinMultiplicity());
|
||||||
|
@ -545,8 +545,8 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExtraFieldImportExport extraFieldXmlToExport(ExtraFieldEntity entity) {
|
private BlueprintExtraFieldImportExport extraFieldXmlToExport(ExtraFieldEntity entity) {
|
||||||
ExtraFieldImportExport xml = new ExtraFieldImportExport();
|
BlueprintExtraFieldImportExport xml = new BlueprintExtraFieldImportExport();
|
||||||
xml.setId(entity.getId());
|
xml.setId(entity.getId());
|
||||||
xml.setType(entity.getType());
|
xml.setType(entity.getType());
|
||||||
xml.setLabel(entity.getLabel());
|
xml.setLabel(entity.getLabel());
|
||||||
|
@ -557,8 +557,8 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReferenceTypeFieldImportExport referenceFieldXmlToExport(ReferenceTypeFieldEntity entity) {
|
private BlueprintReferenceTypeFieldImportExport referenceFieldXmlToExport(ReferenceTypeFieldEntity entity) {
|
||||||
ReferenceTypeFieldImportExport xml = new ReferenceTypeFieldImportExport();
|
BlueprintReferenceTypeFieldImportExport xml = new BlueprintReferenceTypeFieldImportExport();
|
||||||
xml.setId(entity.getId());
|
xml.setId(entity.getId());
|
||||||
xml.setReferenceTypeId(entity.getReferenceTypeId());
|
xml.setReferenceTypeId(entity.getReferenceTypeId());
|
||||||
xml.setLabel(entity.getLabel());
|
xml.setLabel(entity.getLabel());
|
||||||
|
@ -570,8 +570,8 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SystemFieldImportExport systemFieldXmlToExport(SystemFieldEntity entity) {
|
private BlueprintSystemFieldImportExport systemFieldXmlToExport(SystemFieldEntity entity) {
|
||||||
SystemFieldImportExport xml = new SystemFieldImportExport();
|
BlueprintSystemFieldImportExport xml = new BlueprintSystemFieldImportExport();
|
||||||
xml.setId(entity.getId());
|
xml.setId(entity.getId());
|
||||||
xml.setType(entity.getType());
|
xml.setType(entity.getType());
|
||||||
xml.setLabel(entity.getLabel());
|
xml.setLabel(entity.getLabel());
|
||||||
|
@ -614,13 +614,13 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return this.persist(persist, fields);
|
return this.persist(persist, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DefinitionPersist xmlDefinitionToPersist(DefinitionImportExport importXml) {
|
private DefinitionPersist xmlDefinitionToPersist(BlueprintDefinitionImportExport importXml) {
|
||||||
if (importXml == null)
|
if (importXml == null)
|
||||||
return null;
|
return null;
|
||||||
DefinitionPersist persist = new DefinitionPersist();
|
DefinitionPersist persist = new DefinitionPersist();
|
||||||
List<SectionPersist> dmpBlueprintSections = new ArrayList<>();
|
List<SectionPersist> dmpBlueprintSections = new ArrayList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(importXml.getSections())) {
|
if (!this.conventionService.isListNullOrEmpty(importXml.getSections())) {
|
||||||
for (SectionImportExport section : importXml.getSections()) {
|
for (BlueprintSectionImportExport section : importXml.getSections()) {
|
||||||
dmpBlueprintSections.add(this.xmlSectionToPersist(section));
|
dmpBlueprintSections.add(this.xmlSectionToPersist(section));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,7 +628,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SectionPersist xmlSectionToPersist(SectionImportExport importXml) {
|
private SectionPersist xmlSectionToPersist(BlueprintSectionImportExport importXml) {
|
||||||
SectionPersist persist = new SectionPersist();
|
SectionPersist persist = new SectionPersist();
|
||||||
persist.setId(importXml.getId());
|
persist.setId(importXml.getId());
|
||||||
persist.setLabel(importXml.getLabel());
|
persist.setLabel(importXml.getLabel());
|
||||||
|
@ -637,24 +637,24 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
persist.setHasTemplates(importXml.isHasTemplates());
|
persist.setHasTemplates(importXml.isHasTemplates());
|
||||||
List<FieldPersist> dmpBlueprintFieldModels = new LinkedList<>();
|
List<FieldPersist> dmpBlueprintFieldModels = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(importXml.getSystemFields())) {
|
if (!this.conventionService.isListNullOrEmpty(importXml.getSystemFields())) {
|
||||||
for (SystemFieldImportExport systemField : importXml.getSystemFields()) {
|
for (BlueprintSystemFieldImportExport systemField : importXml.getSystemFields()) {
|
||||||
dmpBlueprintFieldModels.add(this.xmlSystemFieldToPersist(systemField));
|
dmpBlueprintFieldModels.add(this.xmlSystemFieldToPersist(systemField));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.conventionService.isListNullOrEmpty(importXml.getReferenceFields())) {
|
if (!this.conventionService.isListNullOrEmpty(importXml.getReferenceFields())) {
|
||||||
for (ReferenceTypeFieldImportExport referenceField : importXml.getReferenceFields()) {
|
for (BlueprintReferenceTypeFieldImportExport referenceField : importXml.getReferenceFields()) {
|
||||||
dmpBlueprintFieldModels.add(this.xmlReferenceFieldToPersist(referenceField));
|
dmpBlueprintFieldModels.add(this.xmlReferenceFieldToPersist(referenceField));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.conventionService.isListNullOrEmpty(importXml.getExtraFields())) {
|
if (!this.conventionService.isListNullOrEmpty(importXml.getExtraFields())) {
|
||||||
for (ExtraFieldImportExport extraField : importXml.getExtraFields()) {
|
for (BlueprintExtraFieldImportExport extraField : importXml.getExtraFields()) {
|
||||||
dmpBlueprintFieldModels.add(this.xmlExtraFieldToPersist(extraField));
|
dmpBlueprintFieldModels.add(this.xmlExtraFieldToPersist(extraField));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
persist.setFields(dmpBlueprintFieldModels);
|
persist.setFields(dmpBlueprintFieldModels);
|
||||||
List<DescriptionTemplatePersist> dmpBlueprintDescriptionTemplates = new LinkedList<>();
|
List<DescriptionTemplatePersist> dmpBlueprintDescriptionTemplates = new LinkedList<>();
|
||||||
if (!this.conventionService.isListNullOrEmpty(importXml.getDescriptionTemplates())) {
|
if (!this.conventionService.isListNullOrEmpty(importXml.getDescriptionTemplates())) {
|
||||||
for (DescriptionTemplateImportExport descriptionTemplate : importXml.getDescriptionTemplates()) {
|
for (BlueprintDescriptionTemplateImportExport descriptionTemplate : importXml.getDescriptionTemplates()) {
|
||||||
dmpBlueprintDescriptionTemplates.add(this.xmlDescriptionTemplateToPersist(descriptionTemplate));
|
dmpBlueprintDescriptionTemplates.add(this.xmlDescriptionTemplateToPersist(descriptionTemplate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,7 +662,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DescriptionTemplatePersist xmlDescriptionTemplateToPersist(DescriptionTemplateImportExport importXml) {
|
private DescriptionTemplatePersist xmlDescriptionTemplateToPersist(BlueprintDescriptionTemplateImportExport importXml) {
|
||||||
DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
|
DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
|
||||||
persist.setDescriptionTemplateGroupId(importXml.getDescriptionTemplateGroupId());
|
persist.setDescriptionTemplateGroupId(importXml.getDescriptionTemplateGroupId());
|
||||||
persist.setLabel(importXml.getLabel());
|
persist.setLabel(importXml.getLabel());
|
||||||
|
@ -671,7 +671,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FieldPersist xmlExtraFieldToPersist(ExtraFieldImportExport importXml) {
|
private FieldPersist xmlExtraFieldToPersist(BlueprintExtraFieldImportExport importXml) {
|
||||||
ExtraFieldPersist persist = new ExtraFieldPersist();
|
ExtraFieldPersist persist = new ExtraFieldPersist();
|
||||||
persist.setId(importXml.getId());
|
persist.setId(importXml.getId());
|
||||||
persist.setCategory(DmpBlueprintFieldCategory.Extra);
|
persist.setCategory(DmpBlueprintFieldCategory.Extra);
|
||||||
|
@ -684,7 +684,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FieldPersist xmlSystemFieldToPersist(SystemFieldImportExport importXml) {
|
private FieldPersist xmlSystemFieldToPersist(BlueprintSystemFieldImportExport importXml) {
|
||||||
SystemFieldPersist persist = new SystemFieldPersist();
|
SystemFieldPersist persist = new SystemFieldPersist();
|
||||||
persist.setId(importXml.getId());
|
persist.setId(importXml.getId());
|
||||||
persist.setCategory(DmpBlueprintFieldCategory.System);
|
persist.setCategory(DmpBlueprintFieldCategory.System);
|
||||||
|
@ -697,7 +697,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FieldPersist xmlReferenceFieldToPersist(ReferenceTypeFieldImportExport importXml) {
|
private FieldPersist xmlReferenceFieldToPersist(BlueprintReferenceTypeFieldImportExport importXml) {
|
||||||
ReferenceTypeFieldPersist persist = new ReferenceTypeFieldPersist();
|
ReferenceTypeFieldPersist persist = new ReferenceTypeFieldPersist();
|
||||||
persist.setId(importXml.getId());
|
persist.setId(importXml.getId());
|
||||||
persist.setCategory(DmpBlueprintFieldCategory.ReferenceType);
|
persist.setCategory(DmpBlueprintFieldCategory.ReferenceType);
|
||||||
|
|
|
@ -46,11 +46,13 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
import javax.crypto.IllegalBlockSizeException;
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
|
@ -121,7 +123,7 @@ public class DescriptionController {
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(EnumSet.of(Public)).ids(id).dmpSubQuery(this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public));
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(EnumSet.of(Public)).ids(id).dmpSubQuery(this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public));
|
||||||
|
|
||||||
PublicDescription model = this.builderFactory.builder(PublicDescriptionBuilder.class).authorize(EnumSet.of(Public)).build(fieldSet, query.firstAs(fieldSet));
|
PublicDescription model = this.builderFactory.builder(PublicDescriptionBuilder.class).authorize(EnumSet.of(Public)).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, PublicDescription.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, PublicDescription.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Description_PublicLookup, Map.ofEntries(
|
this.auditService.track(AuditableAction.Description_PublicLookup, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||||
|
@ -154,7 +156,7 @@ public class DescriptionController {
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
Description model = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
Description model = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Description_Lookup, Map.ofEntries(
|
this.auditService.track(AuditableAction.Description_Lookup, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||||
|
@ -208,7 +210,7 @@ public class DescriptionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("validate")
|
@GetMapping("validate")
|
||||||
public List<DescriptionValidationResult> validate(@RequestParam(value="descriptionIds") List<UUID> descriptionIds) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
|
public List<DescriptionValidationResult> validate(@RequestParam("descriptionIds") List<UUID> descriptionIds) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("validating" + Description.class.getSimpleName()).And("descriptionIds", descriptionIds));
|
logger.debug(new MapLogEntry("validating" + Description.class.getSimpleName()).And("descriptionIds", descriptionIds));
|
||||||
|
|
||||||
this.censorFactory.censor(DescriptionCensor.class).censor(null, null);
|
this.censorFactory.censor(DescriptionCensor.class).censor(null, null);
|
||||||
|
@ -261,7 +263,7 @@ public class DescriptionController {
|
||||||
StorageFileEntity storageFile = this.descriptionService.getFieldFile(id, fileId);
|
StorageFileEntity storageFile = this.descriptionService.getFieldFile(id, fileId);
|
||||||
|
|
||||||
byte[] file = this.storageFileService.readAsBytesSafe(id);
|
byte[] file = this.storageFileService.readAsBytesSafe(id);
|
||||||
if (file == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (file == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, StorageFile.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Description_GetFieldFile, Map.ofEntries(
|
this.auditService.track(AuditableAction.Description_GetFieldFile, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("id", id)
|
new AbstractMap.SimpleEntry<String, Object>("id", id)
|
||||||
|
@ -289,4 +291,16 @@ public class DescriptionController {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"/xml/export/{id}"}, produces = "application/xml")
|
||||||
|
public @ResponseBody ResponseEntity<byte[]> getXml(@PathVariable UUID id) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("export" + DmpBlueprint.class.getSimpleName()).And("id", id));
|
||||||
|
|
||||||
|
ResponseEntity<byte[]> response = this.descriptionService.exportXml(id);
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.DmpBlueprint_GetXml, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("id", id)
|
||||||
|
));
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
import javax.crypto.IllegalBlockSizeException;
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
|
@ -331,4 +332,16 @@ public class DmpController {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"/xml/export/{id}"}, produces = "application/xml")
|
||||||
|
public @ResponseBody ResponseEntity<byte[]> getXml(@PathVariable UUID id) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("export" + DmpBlueprint.class.getSimpleName()).And("id", id));
|
||||||
|
|
||||||
|
ResponseEntity<byte[]> response = this.dmpService.exportXml(id);
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.DmpBlueprint_GetXml, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("id", id)
|
||||||
|
));
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,6 +221,18 @@ permissions:
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
|
ExportDescription:
|
||||||
|
roles:
|
||||||
|
- TenantAdmin
|
||||||
|
dmp:
|
||||||
|
roles:
|
||||||
|
- Owner
|
||||||
|
- User
|
||||||
|
- DescriptionContributor
|
||||||
|
- Reviewer
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
# Tag
|
# Tag
|
||||||
BrowseTag:
|
BrowseTag:
|
||||||
roles:
|
roles:
|
||||||
|
|
|
@ -105,6 +105,18 @@ export class DescriptionService {
|
||||||
catchError((error: any) => throwError(error)));
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
downloadXML(id: Guid): Observable<HttpResponse<Blob>> {
|
||||||
|
const url = `${this.apiBase}/xml/export/${id}`;
|
||||||
|
let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml');
|
||||||
|
const params = new BaseHttpParams();
|
||||||
|
params.interceptorContext = {
|
||||||
|
excludedInterceptors: [InterceptorType.JSONContentType]
|
||||||
|
};
|
||||||
|
return this.httpClient.get(url, { params: params, responseType: 'blob', observe: 'response', headers: headerXml });
|
||||||
|
}
|
||||||
|
|
||||||
// public downloadPDF(id: string): Observable<HttpResponse<Blob>> {
|
// public downloadPDF(id: string): Observable<HttpResponse<Blob>> {
|
||||||
// return this.httpClient.get(`${this.apiBase}/${id}/export/Pdf`, { responseType: 'blob', observe: 'response', headers: this.headers });
|
// return this.httpClient.get(`${this.apiBase}/${id}/export/Pdf`, { responseType: 'blob', observe: 'response', headers: this.headers });
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { AuthService } from '../auth/auth.service';
|
||||||
import { RepositoryFileFormat } from '@app/core/model/file/file-format.model';
|
import { RepositoryFileFormat } from '@app/core/model/file/file-format.model';
|
||||||
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
|
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
|
||||||
import { DmpService } from '../dmp/dmp.service';
|
import { DmpService } from '../dmp/dmp.service';
|
||||||
|
import { DescriptionService } from '../description/description.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FileTransformerService extends BaseService {
|
export class FileTransformerService extends BaseService {
|
||||||
|
@ -19,6 +20,7 @@ export class FileTransformerService extends BaseService {
|
||||||
private matomoService: MatomoService,
|
private matomoService: MatomoService,
|
||||||
private fileUtils: FileUtils,
|
private fileUtils: FileUtils,
|
||||||
private dmpService: DmpService,
|
private dmpService: DmpService,
|
||||||
|
private descriptionService: DescriptionService,
|
||||||
private authentication: AuthService,
|
private authentication: AuthService,
|
||||||
) { super(); }
|
) { super(); }
|
||||||
|
|
||||||
|
@ -94,6 +96,15 @@ export class FileTransformerService extends BaseService {
|
||||||
|
|
||||||
exportDescription(id: Guid, repositoryId: string, format: string) {
|
exportDescription(id: Guid, repositoryId: string, format: string) {
|
||||||
this._loading = true;
|
this._loading = true;
|
||||||
|
if (repositoryId == this.xmlExportRepo.repositoryId) {
|
||||||
|
this.descriptionService.downloadXML(id)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(response => {
|
||||||
|
const blob = new Blob([response.body], { type: 'application/xml' });
|
||||||
|
const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
||||||
|
FileSaver.saveAs(blob, filename);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
this.fileTransformerHttpService.exportDescription(id, repositoryId, format).pipe(takeUntil(this._destroyed), catchError((error) => {
|
this.fileTransformerHttpService.exportDescription(id, repositoryId, format).pipe(takeUntil(this._destroyed), catchError((error) => {
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
return null;
|
return null;
|
||||||
|
@ -108,3 +119,4 @@ export class FileTransformerService extends BaseService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue