update description template xml
This commit is contained in:
parent
7d66c1e857
commit
268b82eb49
|
@ -1,27 +0,0 @@
|
||||||
package eu.eudat.commons.enums;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
|
||||||
import eu.eudat.data.converters.enums.DatabaseEnum;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public enum FieldDataComboBoxType implements DatabaseEnum<String> {
|
|
||||||
Autocomplete("autocomplete"),
|
|
||||||
Wordlist("wordlist");
|
|
||||||
private final String value;
|
|
||||||
|
|
||||||
FieldDataComboBoxType(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonValue
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Map<String, FieldDataComboBoxType> map = EnumUtils.getEnumValueMap(FieldDataComboBoxType.class);
|
|
||||||
|
|
||||||
public static FieldDataComboBoxType of(String i) {
|
|
||||||
return map.get(i);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package eu.eudat.commons.enums;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
|
||||||
import eu.eudat.data.converters.enums.DatabaseEnum;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public enum FieldDataInternalDmpEntryType implements DatabaseEnum<String> {
|
|
||||||
Researchers("researchers"),
|
|
||||||
Dmps("dmps"),
|
|
||||||
Datasets("datasets");
|
|
||||||
private final String value;
|
|
||||||
|
|
||||||
FieldDataInternalDmpEntryType(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonValue
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Map<String, FieldDataInternalDmpEntryType> map = EnumUtils.getEnumValueMap(FieldDataInternalDmpEntryType.class);
|
|
||||||
|
|
||||||
public static FieldDataInternalDmpEntryType of(String i) {
|
|
||||||
return map.get(i);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,12 +6,10 @@ import eu.eudat.data.converters.enums.DatabaseEnum;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public enum FieldType implements DatabaseEnum<String> {
|
public enum FieldType implements DatabaseEnum<String> {
|
||||||
COMBO_BOX(Names.ComboBox), //TODO remove from xml an keep subtypes only AUTO_COMPLETE, WORD_LIST
|
|
||||||
AUTO_COMPLETE(Names.Autocomplete),
|
AUTO_COMPLETE(Names.Autocomplete),
|
||||||
WORD_LIST(Names.Wordlist),
|
WORD_LIST(Names.Wordlist),
|
||||||
BOOLEAN_DECISION(Names.BooleanDecision),
|
BOOLEAN_DECISION(Names.BooleanDecision),
|
||||||
RADIO_BOX(Names.RadioBox),
|
RADIO_BOX(Names.RadioBox),
|
||||||
INTERNAL_DMP_ENTRIES(Names.InternalDmpEntities), //TODO remove from xml an keep subtypes only INTERNAL_DMP_ENTRIES_RESEARCHERS. INTERNAL_DMP_ENTRIES_DMPS, INTERNAL_DMP_ENTRIES_DATASETS
|
|
||||||
INTERNAL_DMP_ENTRIES_RESEARCHERS(Names.InternalDmpResearchers),
|
INTERNAL_DMP_ENTRIES_RESEARCHERS(Names.InternalDmpResearchers),
|
||||||
INTERNAL_DMP_ENTRIES_DMPS(Names.InternalDmpDmps),
|
INTERNAL_DMP_ENTRIES_DMPS(Names.InternalDmpDmps),
|
||||||
INTERNAL_DMP_ENTRIES_DATASETS(Names.InternalDmpDatasets),
|
INTERNAL_DMP_ENTRIES_DATASETS(Names.InternalDmpDatasets),
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.commons.types.descriptiontemplate;
|
||||||
|
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||||
|
import jakarta.xml.bind.annotation.*;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
@ -11,8 +12,14 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DefinitionEntity implements XmlSerializable<DefinitionEntity> {
|
@XmlRootElement(name = "root")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class DefinitionEntity {
|
||||||
|
@XmlElementWrapper(name = "sections")
|
||||||
|
@XmlElement(name = "section")
|
||||||
private List<SectionEntity> sections;
|
private List<SectionEntity> sections;
|
||||||
|
@XmlElementWrapper(name = "pages")
|
||||||
|
@XmlElement(name = "page")
|
||||||
private List<PageEntity> pages;
|
private List<PageEntity> pages;
|
||||||
|
|
||||||
public List<SectionEntity> getSections() {
|
public List<SectionEntity> getSections() {
|
||||||
|
@ -31,52 +38,6 @@ public class DefinitionEntity implements XmlSerializable<DefinitionEntity> {
|
||||||
this.pages = pageEntities;
|
this.pages = pageEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = doc.createElement("root");
|
|
||||||
Element sections = doc.createElement("sections");
|
|
||||||
Element pages = doc.createElement("pages");
|
|
||||||
for (SectionEntity sectionEntity : this.sections) {
|
|
||||||
sectionEntity.setNumbering("" + (this.sections.indexOf(sectionEntity) + 1));
|
|
||||||
sections.appendChild(sectionEntity.toXml(doc));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (PageEntity pageEntity : this.pages) {
|
|
||||||
pages.appendChild(pageEntity.toXml(doc));
|
|
||||||
}
|
|
||||||
|
|
||||||
root.appendChild(pages);
|
|
||||||
root.appendChild(sections);
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DefinitionEntity fromXml(Element element) {
|
|
||||||
|
|
||||||
this.sections = new LinkedList();
|
|
||||||
Element sections = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "sections");
|
|
||||||
if (sections != null) {
|
|
||||||
NodeList sectionElements = sections.getChildNodes();
|
|
||||||
for (int temp = 0; temp < sectionElements.getLength(); temp++) {
|
|
||||||
Node sectionElement = sectionElements.item(temp);
|
|
||||||
if (sectionElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.sections.add(new SectionEntity().fromXml((Element) sectionElement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.pages = new LinkedList<>();
|
|
||||||
Element pages = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "pages");
|
|
||||||
if (pages != null) {
|
|
||||||
NodeList pagesElements = pages.getChildNodes();
|
|
||||||
for (int temp = 0; temp < pagesElements.getLength(); temp++) {
|
|
||||||
Node pageElement = pagesElements.item(temp);
|
|
||||||
if (pageElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.pages.add(new PageEntity().fromXml((Element) pageElement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public List<FieldEntity> getAllField(){
|
public List<FieldEntity> getAllField(){
|
||||||
List<FieldEntity> fieldEntities = new ArrayList<>();
|
List<FieldEntity> fieldEntities = new ArrayList<>();
|
||||||
if (this.getSections() != null){
|
if (this.getSections() != null){
|
||||||
|
|
|
@ -4,25 +4,62 @@ import eu.eudat.commons.enums.FieldValidationType;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
import jakarta.xml.bind.annotation.*;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FieldEntity implements DatabaseViewStyleDefinition, XmlSerializable<FieldEntity> {
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class FieldEntity implements DatabaseViewStyleDefinition {
|
||||||
|
@XmlAttribute(name="id")
|
||||||
private String id;
|
private String id;
|
||||||
|
@XmlAttribute(name="ordinal")
|
||||||
private int ordinal;
|
private int ordinal;
|
||||||
|
@XmlElementWrapper(name = "schematics")
|
||||||
|
@XmlElement(name = "schematic")
|
||||||
private List<String> schematics;
|
private List<String> schematics;
|
||||||
|
@XmlAttribute(name="numbering")
|
||||||
private String numbering;
|
private String numbering;
|
||||||
|
@XmlAttribute(name="defaultValue")
|
||||||
private String defaultValue;
|
private String defaultValue;
|
||||||
|
@XmlElementWrapper(name = "visibilityRules")
|
||||||
|
@XmlElement(name = "rule")
|
||||||
private List<RuleEntity> visibilityRules;
|
private List<RuleEntity> visibilityRules;
|
||||||
|
|
||||||
|
@XmlElements({
|
||||||
|
@XmlElement(name = FieldType.Names.CheckBox, type = LabelDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Validation, type = LabelDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.TextArea, type = LabelDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Taxonomies, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Tags, type = LabelDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Services, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.RichTextarea, type = LabelDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Researchers, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Registries, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.PubRepositories, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Publications, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Organizations, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Licenses, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.JournalRepositories, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.FreeText, type = LabelDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.ExternalDatasets, type = ExternalDatasetDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.DatePicker, type = LabelDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.DatasetIdentifier, type = LabelDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.DataRepositories, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Currency, type = LabelDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.BooleanDecision, type = LabelDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Upload, type = UploadDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.RadioBox, type = RadioBoxDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Wordlist, type = WordListDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.Autocomplete, type = AutoCompleteDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.InternalDmpDatasets, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.InternalDmpDmps, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
@XmlElement(name = FieldType.Names.InternalDmpResearchers, type = LabelAndMultiplicityDataEntity.class),
|
||||||
|
})
|
||||||
private BaseFieldDataEntity<?> data;
|
private BaseFieldDataEntity<?> data;
|
||||||
|
@XmlElementWrapper(name = "validations")
|
||||||
|
@XmlElement(name = "validation")
|
||||||
private List<FieldValidationType> validations;
|
private List<FieldValidationType> validations;
|
||||||
|
@XmlAttribute(name="includeInExport")
|
||||||
private Boolean includeInExport;
|
private Boolean includeInExport;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -90,138 +127,4 @@ public class FieldEntity implements DatabaseViewStyleDefinition, XmlSerializable
|
||||||
public void setVisibilityRules(List<RuleEntity> visibilityRules) {
|
public void setVisibilityRules(List<RuleEntity> visibilityRules) {
|
||||||
this.visibilityRules = visibilityRules;
|
this.visibilityRules = visibilityRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element rootElement = doc.createElement("field");
|
|
||||||
rootElement.setAttribute("id", this.id);
|
|
||||||
rootElement.setAttribute("ordinal", "" + this.ordinal);
|
|
||||||
|
|
||||||
Element schematics = doc.createElement("schematics");
|
|
||||||
if (this.schematics != null) {
|
|
||||||
for (String s : this.schematics) {
|
|
||||||
Element schematic = doc.createElement("schematic");
|
|
||||||
schematic.setTextContent(s);
|
|
||||||
schematics.appendChild(schematic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Element viewStyle = doc.createElement("viewStyle");
|
|
||||||
if (this.data != null) {
|
|
||||||
switch (this.data.getFieldType()){
|
|
||||||
case COMBO_BOX:
|
|
||||||
case AUTO_COMPLETE:
|
|
||||||
case WORD_LIST:{
|
|
||||||
viewStyle.setAttribute("renderstyle", FieldType.COMBO_BOX.getValue());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case INTERNAL_DMP_ENTRIES:
|
|
||||||
case INTERNAL_DMP_ENTRIES_DMPS:
|
|
||||||
case INTERNAL_DMP_ENTRIES_DATASETS:
|
|
||||||
case INTERNAL_DMP_ENTRIES_RESEARCHERS:{
|
|
||||||
viewStyle.setAttribute("renderstyle", FieldType.INTERNAL_DMP_ENTRIES.getValue());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case BOOLEAN_DECISION: viewStyle.setAttribute("renderstyle", this.data.getFieldType().getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Element visibilityRulesElement = doc.createElement("visible");
|
|
||||||
if (this.visibilityRules != null && !this.visibilityRules.isEmpty()) {
|
|
||||||
for (RuleEntity rule : this.visibilityRules) {
|
|
||||||
visibilityRulesElement.appendChild(rule.toXml(doc));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Element defaultValue = doc.createElement("defaultValue");
|
|
||||||
defaultValue.setAttribute("value", this.getDefaultValue());
|
|
||||||
|
|
||||||
Element validations = doc.createElement("validations");
|
|
||||||
for (FieldValidationType validationType : this.validations) {
|
|
||||||
Element validation = doc.createElement("validation");
|
|
||||||
validation.setAttribute("type", "" + validationType.getValue());
|
|
||||||
validations.appendChild(validation);
|
|
||||||
}
|
|
||||||
|
|
||||||
Element numbering = doc.createElement("numbering");
|
|
||||||
numbering.setTextContent(this.numbering);
|
|
||||||
|
|
||||||
rootElement.appendChild(schematics);
|
|
||||||
rootElement.appendChild(numbering);
|
|
||||||
rootElement.appendChild(validations);
|
|
||||||
rootElement.appendChild(defaultValue);
|
|
||||||
rootElement.appendChild(visibilityRulesElement);
|
|
||||||
rootElement.appendChild(viewStyle);
|
|
||||||
if (this.data != null) {
|
|
||||||
rootElement.appendChild(this.data.toXml(doc));
|
|
||||||
|
|
||||||
}
|
|
||||||
rootElement.setAttribute("export", this.includeInExport == null || this.includeInExport ? "true" : "false");
|
|
||||||
return rootElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldEntity fromXml(Element element) {
|
|
||||||
this.id = element.getAttribute("id");
|
|
||||||
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
|
|
||||||
|
|
||||||
|
|
||||||
Element viewStyle = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "viewStyle");
|
|
||||||
|
|
||||||
FieldType fieldType = FieldType.of(viewStyle.getAttribute("renderstyle"));
|
|
||||||
|
|
||||||
Element visibility = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "visible");
|
|
||||||
NodeList rulesElements = visibility.getChildNodes();
|
|
||||||
this.visibilityRules = new LinkedList();
|
|
||||||
for (int temp = 0; temp < rulesElements.getLength(); temp++) {
|
|
||||||
Node ruleElement = rulesElements.item(temp);
|
|
||||||
if (ruleElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.visibilityRules.add(new RuleEntity().fromXml((Element) ruleElement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Element numbering = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "numbering");
|
|
||||||
if (numbering != null) this.numbering = numbering.getTextContent();
|
|
||||||
|
|
||||||
this.schematics = new LinkedList<>();
|
|
||||||
Element schematics = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "schematics");
|
|
||||||
if(schematics != null){
|
|
||||||
NodeList schematicElements = schematics.getChildNodes();
|
|
||||||
for (int temp = 0; temp < schematicElements.getLength(); temp++) {
|
|
||||||
Node schematicElement = schematicElements.item(temp);
|
|
||||||
if (schematicElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.schematics.add(schematicElement.getTextContent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Element dataElement = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "data");
|
|
||||||
|
|
||||||
Element defaultValue = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "defaultValue");
|
|
||||||
|
|
||||||
this.defaultValue = defaultValue.getAttribute("value");
|
|
||||||
String subType = dataElement != null ? dataElement.getAttribute("type") : null;
|
|
||||||
this.data = new FieldDataHelper().create(fieldType, subType);
|
|
||||||
if (this.data != null) this.data.fromXml(dataElement);
|
|
||||||
|
|
||||||
this.validations = new LinkedList<>();
|
|
||||||
Element validations = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "validations");
|
|
||||||
if (validations != null) {
|
|
||||||
NodeList validationElements = validations.getChildNodes();
|
|
||||||
for (int temp = 0; temp < validationElements.getLength(); temp++) {
|
|
||||||
Node validationElement = validationElements.item(temp);
|
|
||||||
if (validationElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
Short enumValue = Short.parseShort(((Element) validationElement).getAttribute("type"));
|
|
||||||
FieldValidationType validationType = FieldValidationType.of(enumValue);
|
|
||||||
this.validations.add(validationType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (element.hasAttribute("export")) {
|
|
||||||
this.includeInExport = Boolean.parseBoolean(element.getAttribute("export"));
|
|
||||||
} else {
|
|
||||||
this.includeInExport = true;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.commons.types.descriptiontemplate;
|
||||||
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
|
import jakarta.xml.bind.annotation.*;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
@ -12,18 +13,30 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FieldSetEntity implements DatabaseViewStyleDefinition, XmlSerializable<FieldSetEntity> {
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class FieldSetEntity implements DatabaseViewStyleDefinition {
|
||||||
|
@XmlAttribute(name="id")
|
||||||
private String id;
|
private String id;
|
||||||
|
@XmlAttribute(name="ordinal")
|
||||||
private int ordinal;
|
private int ordinal;
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "fields")
|
||||||
|
@XmlElement(name = "field")
|
||||||
private List<FieldEntity> fields;
|
private List<FieldEntity> fields;
|
||||||
|
@XmlAttribute(name="numbering")
|
||||||
private String numbering;
|
private String numbering;
|
||||||
|
@XmlAttribute(name="title")
|
||||||
private String title;
|
private String title;
|
||||||
|
@XmlAttribute(name="description")
|
||||||
private String description;
|
private String description;
|
||||||
|
@XmlAttribute(name="extendedDescription")
|
||||||
private String extendedDescription;
|
private String extendedDescription;
|
||||||
|
@XmlAttribute(name="additionalInformation")
|
||||||
private String additionalInformation;
|
private String additionalInformation;
|
||||||
|
@XmlElement(name="multiplicity")
|
||||||
private MultiplicityEntity multiplicity;
|
private MultiplicityEntity multiplicity;
|
||||||
|
@XmlAttribute(name="hasCommentField")
|
||||||
private boolean hasCommentField;
|
private boolean hasCommentField;
|
||||||
// private String commentFieldValue; //TODO: DescriptionTemplate
|
|
||||||
|
|
||||||
public List<FieldEntity> getFields() {
|
public List<FieldEntity> getFields() {
|
||||||
return fields;
|
return fields;
|
||||||
|
@ -81,13 +94,6 @@ public class FieldSetEntity implements DatabaseViewStyleDefinition, XmlSerializa
|
||||||
this.hasCommentField = hasCommentField;
|
this.hasCommentField = hasCommentField;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public String getCommentFieldValue() {
|
|
||||||
// return commentFieldValue;
|
|
||||||
// }
|
|
||||||
// public void setCommentFieldValue(String commentFieldValue) {
|
|
||||||
// this.commentFieldValue = commentFieldValue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public String getNumbering() {
|
public String getNumbering() {
|
||||||
return numbering;
|
return numbering;
|
||||||
}
|
}
|
||||||
|
@ -102,95 +108,7 @@ public class FieldSetEntity implements DatabaseViewStyleDefinition, XmlSerializa
|
||||||
this.additionalInformation = additionalInformation;
|
this.additionalInformation = additionalInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element fieldSet = doc.createElement("fieldSet");
|
|
||||||
fieldSet.setAttribute("id", this.id);
|
|
||||||
fieldSet.setAttribute("ordinal", "" + this.ordinal);
|
|
||||||
Element title = doc.createElement("title");
|
|
||||||
title.setTextContent(this.title);
|
|
||||||
|
|
||||||
Element description = doc.createElement("description");
|
|
||||||
description.setTextContent(this.description);
|
|
||||||
|
|
||||||
Element extendedDescription = doc.createElement("extendedDescription");
|
|
||||||
extendedDescription.setTextContent(this.extendedDescription);
|
|
||||||
|
|
||||||
Element additionalInformation = doc.createElement("additionalInformation");
|
|
||||||
additionalInformation.setTextContent(this.additionalInformation);
|
|
||||||
|
|
||||||
Element multiplicity = doc.createElement("multiplicity");
|
|
||||||
multiplicity.setAttribute("min", "" + this.multiplicity.getMin());
|
|
||||||
multiplicity.setAttribute("max", "" + this.multiplicity.getMax());
|
|
||||||
multiplicity.setAttribute("placeholder", this.multiplicity.getPlaceholder());
|
|
||||||
multiplicity.setAttribute("tableView", String.valueOf(this.multiplicity.getTableView()));
|
|
||||||
|
|
||||||
Element commentField = doc.createElement("commentField");
|
|
||||||
commentField.setAttribute("hasCommentField", "" + this.hasCommentField);
|
|
||||||
// commentField.setAttribute("commentFieldValue", this.commentFieldValue);
|
|
||||||
|
|
||||||
Element numbering = doc.createElement("numbering");
|
|
||||||
numbering.setTextContent(this.numbering);
|
|
||||||
|
|
||||||
Element fieldsElement = doc.createElement("fields");
|
|
||||||
for (FieldEntity fieldEntity : fields) {
|
|
||||||
fieldEntity.setNumbering(this.numbering + "." + (this.fields.indexOf(fieldEntity) + 1));
|
|
||||||
fieldsElement.appendChild(fieldEntity.toXml(doc));
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldSet.appendChild(numbering);
|
|
||||||
fieldSet.appendChild(commentField);
|
|
||||||
fieldSet.appendChild(fieldsElement);
|
|
||||||
fieldSet.appendChild(multiplicity);
|
|
||||||
fieldSet.appendChild(title);
|
|
||||||
fieldSet.appendChild(description);
|
|
||||||
fieldSet.appendChild(extendedDescription);
|
|
||||||
fieldSet.appendChild(additionalInformation);
|
|
||||||
return fieldSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldSetEntity fromXml(Element element) {
|
|
||||||
this.id = element.getAttribute("id");
|
|
||||||
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
|
|
||||||
this.fields = new LinkedList();
|
|
||||||
Element title = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "title");
|
|
||||||
this.title = title.getTextContent();
|
|
||||||
Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "description");
|
|
||||||
this.description = description.getTextContent();
|
|
||||||
Element extendedDescription = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "extendedDescription");
|
|
||||||
this.extendedDescription = extendedDescription.getTextContent();
|
|
||||||
Element additionalInformation = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "additionalInformation");
|
|
||||||
if (additionalInformation != null)
|
|
||||||
this.additionalInformation = additionalInformation.getTextContent();
|
|
||||||
Element commentField = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "commentField");
|
|
||||||
this.hasCommentField = Boolean.parseBoolean(commentField.getAttribute("hasCommentField"));
|
|
||||||
// this.commentFieldValue = commentField.getAttribute("commentFieldValue");
|
|
||||||
Element fields = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "fields");
|
|
||||||
|
|
||||||
Element numbering = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "numbering");
|
|
||||||
if (numbering != null) this.numbering = numbering.getTextContent();
|
|
||||||
|
|
||||||
if (fields != null) {
|
|
||||||
NodeList fieldElements = fields.getChildNodes();
|
|
||||||
for (int temp = 0; temp < fieldElements.getLength(); temp++) {
|
|
||||||
Node fieldElement = fieldElements.item(temp);
|
|
||||||
if (fieldElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.fields.add(new FieldEntity().fromXml((Element) fieldElement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.multiplicity = new MultiplicityEntity();
|
|
||||||
Element multiplicity = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "multiplicity");
|
|
||||||
|
|
||||||
this.multiplicity.setMin(Integer.parseInt(multiplicity.getAttribute("min")));
|
|
||||||
this.multiplicity.setMax(Integer.parseInt(multiplicity.getAttribute("max")));
|
|
||||||
this.multiplicity.setPlaceholder(multiplicity.getAttribute("placeholder"));
|
|
||||||
this.multiplicity.setTableView(Boolean.parseBoolean(multiplicity.getAttribute("tableView")));
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public List<FieldEntity> getAllField() {
|
public List<FieldEntity> getAllField() {
|
||||||
return this.getFields() == null ? new ArrayList<>() : this.getFields();
|
return this.getFields() == null ? new ArrayList<>() : this.getFields();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate;
|
package eu.eudat.commons.types.descriptiontemplate;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class MultiplicityEntity {
|
public class MultiplicityEntity {
|
||||||
|
|
||||||
|
@XmlAttribute(name="min")
|
||||||
private int min;
|
private int min;
|
||||||
|
@XmlAttribute(name="max")
|
||||||
private int max;
|
private int max;
|
||||||
|
@XmlAttribute(name="placeholder")
|
||||||
private String placeholder;
|
private String placeholder;
|
||||||
|
@XmlAttribute(name="tableView")
|
||||||
private boolean tableView;
|
private boolean tableView;
|
||||||
|
|
||||||
public int getMin() {
|
public int getMin() {
|
||||||
|
|
|
@ -2,13 +2,20 @@ package eu.eudat.commons.types.descriptiontemplate;
|
||||||
|
|
||||||
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
|
||||||
public class PageEntity implements DatabaseViewStyleDefinition, XmlSerializable<PageEntity> {
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class PageEntity implements DatabaseViewStyleDefinition {
|
||||||
|
@XmlAttribute(name="id")
|
||||||
private String id;
|
private String id;
|
||||||
|
@XmlAttribute(name="ordinal")
|
||||||
private int ordinal;
|
private int ordinal;
|
||||||
|
@XmlAttribute(name="title")
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -35,20 +42,4 @@ public class PageEntity implements DatabaseViewStyleDefinition, XmlSerializable<
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = doc.createElement("page");
|
|
||||||
root.setAttribute("title", this.title);
|
|
||||||
root.setAttribute("ordinal", "" + this.ordinal);
|
|
||||||
root.setAttribute("id", this.id);
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageEntity fromXml(Element item) {
|
|
||||||
this.ordinal = Integer.parseInt(item.getAttribute("ordinal"));
|
|
||||||
this.id = item.getAttribute("id");
|
|
||||||
this.title = item.getAttribute("title");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate;
|
package eu.eudat.commons.types.descriptiontemplate;
|
||||||
|
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
public class RuleEntity implements XmlSerializable<RuleEntity> {
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class RuleEntity {
|
||||||
|
@XmlAttribute(name="target")
|
||||||
private String target;
|
private String target;
|
||||||
|
@XmlAttribute(name="value")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public String getTarget() {
|
public String getTarget() {
|
||||||
|
@ -24,29 +30,4 @@ public class RuleEntity implements XmlSerializable<RuleEntity> {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element rule = doc.createElement("rule");
|
|
||||||
rule.setAttribute("target", this.target);
|
|
||||||
|
|
||||||
Element value = doc.createElement("value");
|
|
||||||
value.setTextContent(this.value);
|
|
||||||
|
|
||||||
rule.appendChild(value);
|
|
||||||
return rule;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RuleEntity fromXml(Element item) {
|
|
||||||
this.target = item.getAttribute("target");
|
|
||||||
|
|
||||||
Element value = (Element) item.getElementsByTagName("value").item(0);
|
|
||||||
if (value != null) {
|
|
||||||
this.value = value.getTextContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,37 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate;
|
package eu.eudat.commons.types.descriptiontemplate;
|
||||||
|
|
||||||
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import jakarta.xml.bind.annotation.*;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SectionEntity implements DatabaseViewStyleDefinition, XmlSerializable<SectionEntity> {
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class SectionEntity implements DatabaseViewStyleDefinition{
|
||||||
|
@XmlAttribute(name="id")
|
||||||
private String id;
|
private String id;
|
||||||
|
@XmlAttribute(name="ordinal")
|
||||||
private int ordinal;
|
private int ordinal;
|
||||||
|
@XmlAttribute(name="defaultVisibility")
|
||||||
private boolean defaultVisibility;
|
private boolean defaultVisibility;
|
||||||
|
@XmlAttribute(name="numbering")
|
||||||
private String numbering;
|
private String numbering;
|
||||||
|
@XmlAttribute(name="page")
|
||||||
private String page;
|
private String page;
|
||||||
|
@XmlAttribute(name="title")
|
||||||
private String title;
|
private String title;
|
||||||
|
@XmlAttribute(name="description")
|
||||||
private String description;
|
private String description;
|
||||||
|
@XmlAttribute(name="extendedDescription")
|
||||||
private String extendedDescription;
|
private String extendedDescription;
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "sections")
|
||||||
|
@XmlElement(name = "section")
|
||||||
private List<SectionEntity> sections;
|
private List<SectionEntity> sections;
|
||||||
|
@XmlElementWrapper(name = "fieldSets")
|
||||||
|
@XmlElement(name = "fieldSet")
|
||||||
private List<FieldSetEntity> fieldSets;
|
private List<FieldSetEntity> fieldSets;
|
||||||
|
@XmlAttribute(name="multiplicity")
|
||||||
private Boolean multiplicity;
|
private Boolean multiplicity;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -113,102 +122,6 @@ public class SectionEntity implements DatabaseViewStyleDefinition, XmlSerializab
|
||||||
this.multiplicity = multiplicity;
|
this.multiplicity = multiplicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element rootElement = doc.createElement("section");
|
|
||||||
rootElement.setAttribute("id", this.id);
|
|
||||||
rootElement.setAttribute("ordinal", "" + this.ordinal);
|
|
||||||
rootElement.setAttribute("defaultVisibility", "" + this.defaultVisibility);
|
|
||||||
rootElement.setAttribute("page", "" + this.page);
|
|
||||||
rootElement.setAttribute("multiplicity", (this.multiplicity != null ? "" + this.multiplicity : "false"));
|
|
||||||
|
|
||||||
Element description = doc.createElement("description");
|
|
||||||
description.setTextContent(this.description);
|
|
||||||
|
|
||||||
Element extendedDescription = doc.createElement("extendedDescription");
|
|
||||||
extendedDescription.setTextContent(this.extendedDescription);
|
|
||||||
|
|
||||||
Element numbering = doc.createElement("numbering");
|
|
||||||
numbering.setTextContent(this.numbering);
|
|
||||||
|
|
||||||
Element title = doc.createElement("title");
|
|
||||||
title.setTextContent(this.title);
|
|
||||||
|
|
||||||
if (sections != null) {
|
|
||||||
Element sections = doc.createElement("sections");
|
|
||||||
for (SectionEntity sectionEntity : this.sections) {
|
|
||||||
sectionEntity.setNumbering(this.numbering + "." + (this.sections.indexOf(sectionEntity) + 1));
|
|
||||||
sections.appendChild(sectionEntity.toXml(doc));
|
|
||||||
}
|
|
||||||
rootElement.appendChild(sections);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.fieldSets != null) {
|
|
||||||
Element formGroups = doc.createElement("fieldSets");
|
|
||||||
for (FieldSetEntity fieldSetEntity : this.fieldSets) {
|
|
||||||
fieldSetEntity.setNumbering(this.numbering + "." + (this.fieldSets.indexOf(fieldSetEntity) + 1));
|
|
||||||
formGroups.appendChild(fieldSetEntity.toXml(doc));
|
|
||||||
}
|
|
||||||
rootElement.appendChild(formGroups);
|
|
||||||
}
|
|
||||||
|
|
||||||
rootElement.appendChild(numbering);
|
|
||||||
rootElement.appendChild(title);
|
|
||||||
rootElement.appendChild(extendedDescription);
|
|
||||||
rootElement.appendChild(description);
|
|
||||||
|
|
||||||
return rootElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SectionEntity fromXml(Element element) {
|
|
||||||
|
|
||||||
this.id = element.getAttribute("id");
|
|
||||||
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
|
|
||||||
this.defaultVisibility = Boolean.valueOf(element.getAttribute("defaultVisibility"));
|
|
||||||
this.page = element.getAttribute("page");
|
|
||||||
this.multiplicity = element.hasAttribute("multiplicity") ? Boolean.valueOf(element.getAttribute("multiplicity")) : false;
|
|
||||||
|
|
||||||
Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "description");
|
|
||||||
if (description != null) this.description = description.getTextContent();
|
|
||||||
|
|
||||||
Element extendedDescription = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "extendedDescription");
|
|
||||||
if (extendedDescription != null) this.extendedDescription = extendedDescription.getTextContent();
|
|
||||||
|
|
||||||
Element numbering = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "numbering");
|
|
||||||
if (numbering != null) this.numbering = numbering.getTextContent();
|
|
||||||
|
|
||||||
Element title = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "title");
|
|
||||||
if (title != null) this.title = title.getTextContent();
|
|
||||||
|
|
||||||
this.sections = new LinkedList<SectionEntity>();
|
|
||||||
Element sections = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "sections");
|
|
||||||
if (sections != null) {
|
|
||||||
NodeList sectionElements = sections.getChildNodes();
|
|
||||||
for (int temp = 0; temp < sectionElements.getLength(); temp++) {
|
|
||||||
Node sectionElement = sectionElements.item(temp);
|
|
||||||
if (sectionElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.sections.add(new SectionEntity().fromXml((Element) sectionElement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fieldSets = new LinkedList<FieldSetEntity>();
|
|
||||||
Element fieldGroups = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "fieldSets");
|
|
||||||
|
|
||||||
if (fieldGroups != null) {
|
|
||||||
NodeList fieldGroupElements = fieldGroups.getChildNodes();
|
|
||||||
for (int temp = 0; temp < fieldGroupElements.getLength(); temp++) {
|
|
||||||
Node fieldGroupElement = fieldGroupElements.item(temp);
|
|
||||||
if (fieldGroupElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.fieldSets.add(new FieldSetEntity().fromXml((Element) fieldGroupElement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FieldEntity> getAllField(){
|
public List<FieldEntity> getAllField(){
|
||||||
List<FieldEntity> fieldEntities = new ArrayList<>();
|
List<FieldEntity> fieldEntities = new ArrayList<>();
|
||||||
if (this.getFieldSets() != null){
|
if (this.getFieldSets() != null){
|
||||||
|
|
|
@ -2,28 +2,28 @@ package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
import eu.eudat.commons.enums.EnumUtils;
|
import eu.eudat.commons.enums.EnumUtils;
|
||||||
import eu.eudat.commons.enums.FieldDataComboBoxType;
|
|
||||||
import eu.eudat.commons.enums.FieldType;
|
|
||||||
import eu.eudat.data.converters.enums.DatabaseEnum;
|
import eu.eudat.data.converters.enums.DatabaseEnum;
|
||||||
import org.w3c.dom.Document;
|
import jakarta.xml.bind.annotation.*;
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AutoCompleteDataEntity extends ComboBoxDataEntity<AutoCompleteDataEntity> {
|
|
||||||
public AutoCompleteDataEntity() {
|
|
||||||
super(FieldType.AUTO_COMPLETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class AutoCompleteDataEntity extends ComboBoxDataEntity<AutoCompleteDataEntity> {
|
||||||
|
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public static class AuthAutoCompleteData {
|
public static class AuthAutoCompleteData {
|
||||||
|
@XmlAttribute(name="url")
|
||||||
private String url;
|
private String url;
|
||||||
|
@XmlAttribute(name="method")
|
||||||
private String method;
|
private String method;
|
||||||
|
@XmlAttribute(name="body")
|
||||||
private String body;
|
private String body;
|
||||||
|
@XmlAttribute(name="path")
|
||||||
private String path;
|
private String path;
|
||||||
|
@XmlAttribute(name="type")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
|
@ -66,13 +66,22 @@ public class AutoCompleteDataEntity extends ComboBoxDataEntity<AutoCompleteDataE
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public static class AutoCompleteSingleData {
|
public static class AutoCompleteSingleData {
|
||||||
|
@XmlAttribute(name="autocompleteType")
|
||||||
private AutocompleteType autocompleteType;
|
private AutocompleteType autocompleteType;
|
||||||
|
@XmlAttribute(name="url")
|
||||||
private String url;
|
private String url;
|
||||||
|
@XmlElement(name="option")
|
||||||
private ComboBoxDataEntity.Option autoCompleteOptions;
|
private ComboBoxDataEntity.Option autoCompleteOptions;
|
||||||
|
@XmlAttribute(name="optionsRoot")
|
||||||
private String optionsRoot;
|
private String optionsRoot;
|
||||||
|
@XmlAttribute(name="hasAuth")
|
||||||
private Boolean hasAuth;
|
private Boolean hasAuth;
|
||||||
|
@XmlElement(name="auth")
|
||||||
private AuthAutoCompleteData auth;
|
private AuthAutoCompleteData auth;
|
||||||
|
@XmlAttribute(name="method")
|
||||||
private String method;
|
private String method;
|
||||||
|
|
||||||
public AutocompleteType getAutocompleteType() {
|
public AutocompleteType getAutocompleteType() {
|
||||||
|
@ -129,11 +138,19 @@ public class AutoCompleteDataEntity extends ComboBoxDataEntity<AutoCompleteDataE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name="multiAutoComplete")
|
||||||
private Boolean multiAutoComplete;
|
private Boolean multiAutoComplete;
|
||||||
|
@XmlElementWrapper(name = "autoCompleteSingleDataList")
|
||||||
|
@XmlElement(name = "autoCompleteSingleData")
|
||||||
private List<AutoCompleteSingleData> autoCompleteSingleDataList;
|
private List<AutoCompleteSingleData> autoCompleteSingleDataList;
|
||||||
|
|
||||||
public Boolean getMultiAutoComplete() { return multiAutoComplete; }
|
public Boolean getMultiAutoComplete() {
|
||||||
public void setMultiAutoComplete(Boolean multiAutoComplete) { this.multiAutoComplete = multiAutoComplete; }
|
return multiAutoComplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultiAutoComplete(Boolean multiAutoComplete) {
|
||||||
|
this.multiAutoComplete = multiAutoComplete;
|
||||||
|
}
|
||||||
|
|
||||||
public List<AutoCompleteSingleData> getAutoCompleteSingleDataList() {
|
public List<AutoCompleteSingleData> getAutoCompleteSingleDataList() {
|
||||||
return autoCompleteSingleDataList;
|
return autoCompleteSingleDataList;
|
||||||
|
@ -143,92 +160,6 @@ public class AutoCompleteDataEntity extends ComboBoxDataEntity<AutoCompleteDataE
|
||||||
this.autoCompleteSingleDataList = autoCompleteSingleDataList;
|
this.autoCompleteSingleDataList = autoCompleteSingleDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataComboBoxType getFieldSubType() {
|
|
||||||
return FieldDataComboBoxType.Autocomplete;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = super.toXml(doc);
|
|
||||||
if (this.multiAutoComplete != null)
|
|
||||||
root.setAttribute("multiAutoComplete", this.multiAutoComplete.toString());
|
|
||||||
for (AutoCompleteSingleData singleData: this.autoCompleteSingleDataList) {
|
|
||||||
Element parent = doc.createElement("autocompleteSingle");
|
|
||||||
parent.setAttribute("url", singleData.url);
|
|
||||||
parent.setAttribute("optionsRoot", singleData.optionsRoot);
|
|
||||||
parent.setAttribute("autoCompleteType", Integer.toString(singleData.autocompleteType.getValue()));
|
|
||||||
parent.setAttribute("hasAuth", Boolean.toString(singleData.hasAuth));
|
|
||||||
parent.setAttribute("method", singleData.method);
|
|
||||||
Element element = doc.createElement("option");
|
|
||||||
element.setAttribute("label", singleData.autoCompleteOptions.getLabel());
|
|
||||||
element.setAttribute("value", singleData.autoCompleteOptions.getValue());
|
|
||||||
element.setAttribute("source", singleData.autoCompleteOptions.getSource());
|
|
||||||
parent.appendChild(element);
|
|
||||||
if (singleData.hasAuth) {
|
|
||||||
Element authElement = doc.createElement("auth");
|
|
||||||
authElement.setAttribute("url", singleData.auth.url);
|
|
||||||
authElement.setAttribute("method", singleData.auth.method);
|
|
||||||
authElement.setAttribute("body", singleData.auth.body);
|
|
||||||
authElement.setAttribute("path", singleData.auth.path);
|
|
||||||
authElement.setAttribute("type", singleData.auth.type);
|
|
||||||
parent.appendChild(authElement);
|
|
||||||
}
|
|
||||||
root.appendChild(parent);
|
|
||||||
}
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AutoCompleteDataEntity fromXml(Element item) {
|
|
||||||
super.fromXml(item);
|
|
||||||
this.autoCompleteSingleDataList = new ArrayList<>();
|
|
||||||
NodeList items = item.getElementsByTagName("autocompleteSingle");
|
|
||||||
if (items != null && items.getLength() > 0) {
|
|
||||||
for (int i = 0; i < items.getLength(); i++) {
|
|
||||||
this.autoCompleteSingleDataList.add(new AutoCompleteSingleData());
|
|
||||||
Element single = (Element) items.item(i);
|
|
||||||
this.mapFromXml(single, this.autoCompleteSingleDataList.get(i));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.autoCompleteSingleDataList.add(new AutoCompleteSingleData());
|
|
||||||
this.mapFromXml(item, this.autoCompleteSingleDataList.get(0));
|
|
||||||
}
|
|
||||||
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void mapFromXml(Element item, AutoCompleteSingleData singleData) {
|
|
||||||
singleData.url = item.getAttribute("url");
|
|
||||||
singleData.optionsRoot = item.getAttribute("optionsRoot");
|
|
||||||
this.multiAutoComplete = Boolean.parseBoolean(item.getAttribute("multiAutoComplete"));
|
|
||||||
if (item.getAttribute("autoCompleteType") == null || item.getAttribute("autoCompleteType").equals("") ) {
|
|
||||||
singleData.autocompleteType = AutocompleteType.UNCACHED;
|
|
||||||
} else {
|
|
||||||
singleData.autocompleteType = AutocompleteType.of(Integer.parseInt(item.getAttribute("autoCompleteType")));
|
|
||||||
}
|
|
||||||
singleData.hasAuth = Boolean.parseBoolean(item.getAttribute("hasAuth"));
|
|
||||||
singleData.method = item.hasAttribute("method") ? item.getAttribute("method") : "GET";
|
|
||||||
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
|
||||||
if (optionElement != null) {
|
|
||||||
singleData.autoCompleteOptions = new Option();
|
|
||||||
singleData.autoCompleteOptions.setLabel(optionElement.getAttribute("label"));
|
|
||||||
singleData.autoCompleteOptions.setValue(optionElement.getAttribute("value"));
|
|
||||||
singleData.autoCompleteOptions.setSource(optionElement.getAttribute("source"));
|
|
||||||
singleData.autoCompleteOptions.setUri(optionElement.getAttribute("uri"));
|
|
||||||
}
|
|
||||||
if (singleData.hasAuth) {
|
|
||||||
Element authElement = (Element) item.getElementsByTagName("auth").item(0);
|
|
||||||
if (authElement != null) {
|
|
||||||
singleData.auth = new AuthAutoCompleteData();
|
|
||||||
singleData.auth.setUrl(authElement.getAttribute("url"));
|
|
||||||
singleData.auth.setMethod(authElement.getAttribute("method"));
|
|
||||||
singleData.auth.setBody(authElement.getAttribute("body"));
|
|
||||||
singleData.auth.setPath(authElement.getAttribute("path"));
|
|
||||||
singleData.auth.setType(authElement.getAttribute("type"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public enum AutocompleteType implements DatabaseEnum<Integer> {
|
public enum AutocompleteType implements DatabaseEnum<Integer> {
|
||||||
UNCACHED(0),
|
UNCACHED(0),
|
||||||
CACHED(1);
|
CACHED(1);
|
||||||
|
|
|
@ -2,25 +2,22 @@ package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class BaseFieldDataEntity<T> implements XmlSerializable<T> {
|
|
||||||
|
|
||||||
private final FieldType fieldType;
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public abstract class BaseFieldDataEntity<T> {
|
||||||
public BaseFieldDataEntity(FieldType fieldType) {
|
|
||||||
this.fieldType = fieldType;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@XmlAttribute(name = "label")
|
||||||
private String label;
|
private String label;
|
||||||
|
@XmlAttribute(name = "fieldType")
|
||||||
|
private FieldType fieldType;
|
||||||
public FieldType getFieldType() {
|
|
||||||
return fieldType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return label;
|
return label;
|
||||||
|
@ -30,15 +27,11 @@ public abstract class BaseFieldDataEntity<T> implements XmlSerializable<T> {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element toXml(Document doc) {
|
public FieldType getFieldType() {
|
||||||
Element root = doc.createElement("data");
|
return fieldType;
|
||||||
root.setAttribute("label", this.getLabel());
|
|
||||||
return root;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromXml(Element item) {
|
public void setFieldType(FieldType fieldType) {
|
||||||
|
this.fieldType = fieldType;
|
||||||
this.setLabel(item.getAttribute("label"));
|
|
||||||
return (T) this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,21 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldDataComboBoxType;
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public abstract class ComboBoxDataEntity<T> extends BaseFieldDataEntity<T> {
|
public abstract class ComboBoxDataEntity<T> extends BaseFieldDataEntity<T> {
|
||||||
|
|
||||||
public ComboBoxDataEntity(FieldType fieldType) {
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
super(fieldType);
|
public static class Option {
|
||||||
}
|
@XmlAttribute(name="label")
|
||||||
|
|
||||||
public abstract FieldDataComboBoxType getFieldSubType();
|
|
||||||
|
|
||||||
public static class Option implements XmlSerializable<Option> {
|
|
||||||
private String label;
|
private String label;
|
||||||
|
@XmlAttribute(name="value")
|
||||||
private String value;
|
private String value;
|
||||||
|
@XmlAttribute(name="source")
|
||||||
private String source;
|
private String source;
|
||||||
|
@XmlAttribute(name="uri")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
@ -51,38 +46,6 @@ public abstract class ComboBoxDataEntity<T> extends BaseFieldDataEntity<T> {
|
||||||
public void setUri(String uri) {
|
public void setUri(String uri) {
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element option = doc.createElement("option");
|
|
||||||
option.setAttribute("label", this.label);
|
|
||||||
option.setAttribute("value", this.value);
|
|
||||||
option.setAttribute("source", this.source);
|
|
||||||
option.setAttribute("uri", this.uri);
|
|
||||||
return option;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ComboBoxDataEntity.Option fromXml(Element item) {
|
|
||||||
this.label = item.getAttribute("label");
|
|
||||||
this.value = item.getAttribute("value");
|
|
||||||
this.source = item.getAttribute("source");
|
|
||||||
this.uri = item.getAttribute("uri");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = super.toXml(doc);
|
|
||||||
root.setAttribute("type", this.getFieldSubType().toString());
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T fromXml(Element item) {
|
|
||||||
super.fromXml(item);
|
|
||||||
return (T) this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,20 @@ package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldDataExternalDatasetType;
|
import eu.eudat.commons.enums.FieldDataExternalDatasetType;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ExternalDatasetDataEntity extends BaseFieldDataEntity<ExternalDatasetDataEntity> {
|
public class ExternalDatasetDataEntity extends BaseFieldDataEntity<ExternalDatasetDataEntity> {
|
||||||
public ExternalDatasetDataEntity() {
|
@XmlAttribute(name="multiAutoComplete")
|
||||||
super(FieldType.EXTERNAL_DATASETS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean multiAutoComplete;
|
private Boolean multiAutoComplete;
|
||||||
|
@XmlAttribute(name="type")
|
||||||
private FieldDataExternalDatasetType type;
|
private FieldDataExternalDatasetType type;
|
||||||
|
|
||||||
public Boolean getMultiAutoComplete() {
|
public Boolean getMultiAutoComplete() {
|
||||||
|
@ -31,25 +33,4 @@ public class ExternalDatasetDataEntity extends BaseFieldDataEntity<ExternalDatas
|
||||||
public void setType(FieldDataExternalDatasetType type) {
|
public void setType(FieldDataExternalDatasetType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = doc.createElement("data");
|
|
||||||
root.setAttribute("label", this.getLabel());
|
|
||||||
if (this.getMultiAutoComplete() != null) {
|
|
||||||
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
|
|
||||||
}
|
|
||||||
if (this.getType() != null) {
|
|
||||||
root.setAttribute("type", this.getType().getValue());
|
|
||||||
}
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExternalDatasetDataEntity fromXml(Element item) {
|
|
||||||
this.setLabel(item != null ? item.getAttribute("label") : "");
|
|
||||||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
|
||||||
this.setType(item.getAttribute("type") != null ? FieldDataExternalDatasetType.of(item.getAttribute("type")): FieldDataExternalDatasetType.Other);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldDataComboBoxType;
|
|
||||||
import eu.eudat.commons.enums.FieldDataInternalDmpEntryType;
|
|
||||||
import eu.eudat.commons.enums.FieldType;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class FieldDataHelper {
|
|
||||||
public BaseFieldDataEntity<?> create(FieldType type, String subType) {
|
|
||||||
switch (type) {
|
|
||||||
case COMBO_BOX: {
|
|
||||||
if (subType != null && !subType.isBlank()) {
|
|
||||||
switch (FieldDataComboBoxType.of(subType)) {
|
|
||||||
case Wordlist: {
|
|
||||||
return new WordListDataEntity();
|
|
||||||
}
|
|
||||||
case Autocomplete: {
|
|
||||||
return new AutoCompleteDataEntity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case INTERNAL_DMP_ENTRIES: {
|
|
||||||
if (subType != null && !subType.isBlank()) {
|
|
||||||
switch (FieldDataInternalDmpEntryType.of(subType)){
|
|
||||||
case Dmps: {
|
|
||||||
return new InternalDmpBaseDataEntity(FieldType.INTERNAL_DMP_ENTRIES_DMPS, FieldDataInternalDmpEntryType.Dmps);
|
|
||||||
}
|
|
||||||
case Datasets: {
|
|
||||||
return new InternalDmpBaseDataEntity(FieldType.INTERNAL_DMP_ENTRIES_DATASETS, FieldDataInternalDmpEntryType.Datasets);
|
|
||||||
}
|
|
||||||
case Researchers : {
|
|
||||||
return new InternalDmpBaseDataEntity(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS, FieldDataInternalDmpEntryType.Researchers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LICENSES:
|
|
||||||
case ORGANIZATIONS:
|
|
||||||
case PUBLICATIONS:
|
|
||||||
case REGISTRIES:
|
|
||||||
case RESEARCHERS:
|
|
||||||
case SERVICES:
|
|
||||||
case TAXONOMIES:
|
|
||||||
case DATA_REPOSITORIES:
|
|
||||||
case JOURNAL_REPOSITORIES:
|
|
||||||
case PUB_REPOSITORIES:
|
|
||||||
case BOOLEAN_DECISION: return new LabelAndMultiplicityDataEntity(type);
|
|
||||||
|
|
||||||
case FREE_TEXT:
|
|
||||||
case DATE_PICKER:
|
|
||||||
case RICH_TEXT_AREA:
|
|
||||||
case TAGS:
|
|
||||||
case TEXT_AREA:
|
|
||||||
case VALIDATION:
|
|
||||||
case DATASET_IDENTIFIER:
|
|
||||||
case CURRENCY:
|
|
||||||
case CHECK_BOX: return new LabelDataEntity(type);
|
|
||||||
|
|
||||||
case RADIO_BOX: return new RadioBoxDataEntity();
|
|
||||||
case UPLOAD: return new UploadDataEntity();
|
|
||||||
case EXTERNAL_DATASETS: return new ExternalDatasetDataEntity();
|
|
||||||
default: return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +1,9 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldDataInternalDmpEntryType;
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
import org.w3c.dom.Document;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import org.w3c.dom.Element;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class InternalDmpBaseDataEntity extends LabelAndMultiplicityDataEntity {
|
public class InternalDmpBaseDataEntity extends LabelAndMultiplicityDataEntity {
|
||||||
|
|
||||||
private final FieldDataInternalDmpEntryType fieldSubType;
|
|
||||||
public InternalDmpBaseDataEntity(FieldType fieldType, FieldDataInternalDmpEntryType fieldSubType) {
|
|
||||||
super(fieldType);
|
|
||||||
this.fieldSubType = fieldSubType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FieldDataInternalDmpEntryType getFieldSubType() {
|
|
||||||
return fieldSubType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = super.toXml(doc);
|
|
||||||
root.setAttribute("type", this.getFieldSubType().toString());
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InternalDmpBaseDataEntity fromXml(Element item) {
|
|
||||||
super.fromXml(item);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class LabelAndMultiplicityDataEntity extends BaseFieldDataEntity<LabelAndMultiplicityDataEntity> {
|
public class LabelAndMultiplicityDataEntity extends BaseFieldDataEntity<LabelAndMultiplicityDataEntity> {
|
||||||
public LabelAndMultiplicityDataEntity(FieldType fieldType) {
|
|
||||||
super(fieldType);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@XmlAttribute(name = "multiAutoComplete")
|
||||||
private Boolean multiAutoComplete;
|
private Boolean multiAutoComplete;
|
||||||
|
|
||||||
public Boolean getMultiAutoComplete() {
|
public Boolean getMultiAutoComplete() {
|
||||||
|
@ -18,20 +20,4 @@ public class LabelAndMultiplicityDataEntity extends BaseFieldDataEntity<LabelAnd
|
||||||
public void setMultiAutoComplete(Boolean multiAutoComplete) {
|
public void setMultiAutoComplete(Boolean multiAutoComplete) {
|
||||||
this.multiAutoComplete = multiAutoComplete;
|
this.multiAutoComplete = multiAutoComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = super.toXml(doc);
|
|
||||||
if (this.getMultiAutoComplete() != null) {
|
|
||||||
root.setAttribute("multiAutoComplete", this.getMultiAutoComplete().toString());
|
|
||||||
}
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LabelAndMultiplicityDataEntity fromXml(Element item) {
|
|
||||||
super.fromXml(item);
|
|
||||||
this.setMultiAutoComplete(Boolean.parseBoolean(item.getAttribute("multiAutoComplete")));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
|
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class LabelDataEntity extends BaseFieldDataEntity<LabelDataEntity> {
|
public class LabelDataEntity extends BaseFieldDataEntity<LabelDataEntity> {
|
||||||
|
|
||||||
public LabelDataEntity(FieldType fieldType) {
|
|
||||||
super(fieldType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,16 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import jakarta.xml.bind.annotation.*;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class RadioBoxDataEntity extends BaseFieldDataEntity<RadioBoxDataEntity> {
|
public class RadioBoxDataEntity extends BaseFieldDataEntity<RadioBoxDataEntity> {
|
||||||
public RadioBoxDataEntity() {
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
super(FieldType.RADIO_BOX);
|
public static class RadioBoxDataOptionEntity {
|
||||||
}
|
@XmlAttribute(name="label")
|
||||||
|
|
||||||
public static class Option implements XmlSerializable<Option> {
|
|
||||||
private String label;
|
private String label;
|
||||||
|
@XmlAttribute(name="value")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
@ -36,60 +28,17 @@ public class RadioBoxDataEntity extends BaseFieldDataEntity<RadioBoxDataEntity>
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element option = doc.createElement("option");
|
|
||||||
option.setAttribute("label", this.label);
|
|
||||||
option.setAttribute("value", this.value);
|
|
||||||
return option;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@XmlElementWrapper(name = "options")
|
||||||
public Option fromXml(Element item) {
|
@XmlElement(name = "option")
|
||||||
this.label = item.getAttribute("label");
|
private List<RadioBoxDataOptionEntity> options;
|
||||||
this.value = item.getAttribute("value");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public List<RadioBoxDataOptionEntity> getOptions() {
|
||||||
}
|
|
||||||
|
|
||||||
private List<Option> options;
|
|
||||||
|
|
||||||
public List<Option> getOptions() {
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOptions(List<Option> options) {
|
public void setOptions(List<RadioBoxDataOptionEntity> options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = super.toXml(doc);
|
|
||||||
Element element = doc.createElement("options");
|
|
||||||
for (Option option : this.options) {
|
|
||||||
element.appendChild(option.toXml(doc));
|
|
||||||
}
|
|
||||||
root.appendChild(element);
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RadioBoxDataEntity fromXml(Element item) {
|
|
||||||
super.fromXml(item);
|
|
||||||
this.options = new LinkedList<>();
|
|
||||||
Element optionsElement = (Element) item.getElementsByTagName("options").item(0);
|
|
||||||
if (optionsElement != null) {
|
|
||||||
NodeList optionElements = optionsElement.getChildNodes();
|
|
||||||
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
|
||||||
Node optionElement = optionElements.item(temp);
|
|
||||||
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.options.add(new Option().fromXml((Element) optionElement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,18 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import jakarta.xml.bind.annotation.*;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class UploadDataEntity extends BaseFieldDataEntity<UploadDataEntity> {
|
public class UploadDataEntity extends BaseFieldDataEntity<UploadDataEntity> {
|
||||||
public UploadDataEntity() {
|
|
||||||
super(FieldType.UPLOAD);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Option implements XmlSerializable<UploadDataEntity.Option> {
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public static class UploadDataOptionEntity {
|
||||||
|
@XmlAttribute(name="label")
|
||||||
private String label;
|
private String label;
|
||||||
|
@XmlAttribute(name="value")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
@ -37,37 +30,24 @@ public class UploadDataEntity extends BaseFieldDataEntity<UploadDataEntity> {
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element option = doc.createElement("option");
|
|
||||||
option.setAttribute("label", this.label);
|
|
||||||
option.setAttribute("value", this.value);
|
|
||||||
return option;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@XmlElementWrapper(name = "types")
|
||||||
public UploadDataEntity.Option fromXml(Element item) {
|
@XmlElement(name = "type")
|
||||||
this.label = item.getAttribute("label");
|
private List<UploadDataOptionEntity> types;
|
||||||
this.value = item.getAttribute("value");
|
|
||||||
return this;
|
@XmlAttribute(name="maxFileSizeInMB")
|
||||||
}
|
private Integer maxFileSizeInMB;
|
||||||
|
|
||||||
|
|
||||||
}
|
public List<UploadDataOptionEntity> getTypes() {
|
||||||
|
|
||||||
private List<UploadDataEntity.Option> types;
|
|
||||||
|
|
||||||
public List<UploadDataEntity.Option> getTypes() {
|
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypes(List<UploadDataEntity.Option> types) {
|
public void setTypes(List<UploadDataOptionEntity> types) {
|
||||||
this.types = types;
|
this.types = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer maxFileSizeInMB;
|
|
||||||
|
|
||||||
public Integer getMaxFileSizeInMB() {
|
public Integer getMaxFileSizeInMB() {
|
||||||
return maxFileSizeInMB;
|
return maxFileSizeInMB;
|
||||||
}
|
}
|
||||||
|
@ -75,36 +55,4 @@ public class UploadDataEntity extends BaseFieldDataEntity<UploadDataEntity> {
|
||||||
public void setMaxFileSizeInMB(Integer maxFileSizeInMB) {
|
public void setMaxFileSizeInMB(Integer maxFileSizeInMB) {
|
||||||
this.maxFileSizeInMB = maxFileSizeInMB;
|
this.maxFileSizeInMB = maxFileSizeInMB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = super.toXml(doc);
|
|
||||||
Element element = doc.createElement("types");
|
|
||||||
for (UploadDataEntity.Option type : this.types) {
|
|
||||||
element.appendChild(type.toXml(doc));
|
|
||||||
}
|
|
||||||
root.setAttribute("maxFileSizeInMB", this.getMaxFileSizeInMB().toString());
|
|
||||||
root.appendChild(element);
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UploadDataEntity fromXml(Element item) {
|
|
||||||
this.types = new LinkedList<>();
|
|
||||||
super.fromXml(item);
|
|
||||||
Element optionsElement = (Element) item.getElementsByTagName("types").item(0);
|
|
||||||
if(item.getAttribute("maxFileSizeInMB") != null) {
|
|
||||||
this.setMaxFileSizeInMB(Integer.parseInt(item.getAttribute("maxFileSizeInMB")));
|
|
||||||
}
|
|
||||||
if (optionsElement != null) {
|
|
||||||
NodeList optionElements = optionsElement.getChildNodes();
|
|
||||||
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
|
||||||
Node optionElement = optionElements.item(temp);
|
|
||||||
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.types.add(new Option().fromXml((Element) optionElement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,16 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldDataComboBoxType;
|
import jakarta.xml.bind.annotation.*;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class WordListDataEntity extends ComboBoxDataEntity<WordListDataEntity> {
|
public class WordListDataEntity extends ComboBoxDataEntity<WordListDataEntity> {
|
||||||
|
@XmlElementWrapper(name = "options")
|
||||||
public WordListDataEntity() {
|
@XmlElement(name = "options")
|
||||||
super(FieldType.WORD_LIST);
|
|
||||||
}
|
|
||||||
private List<Option> options;
|
private List<Option> options;
|
||||||
|
|
||||||
|
@XmlAttribute(name="multiList")
|
||||||
private Boolean multiList;
|
private Boolean multiList;
|
||||||
|
|
||||||
public List<Option> getOptions() {
|
public List<Option> getOptions() {
|
||||||
|
@ -36,43 +28,4 @@ public class WordListDataEntity extends ComboBoxDataEntity<WordListDataEntity> {
|
||||||
public void setMultiList(Boolean multiList) {
|
public void setMultiList(Boolean multiList) {
|
||||||
this.multiList = multiList;
|
this.multiList = multiList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataComboBoxType getFieldSubType() {
|
|
||||||
return FieldDataComboBoxType.Wordlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = super.toXml(doc);
|
|
||||||
root.setAttribute("multiList", this.multiList != null ? this.multiList.toString() : "false");
|
|
||||||
Element element = doc.createElement("options");
|
|
||||||
if (this.options != null) {
|
|
||||||
for (Option option : this.options) {
|
|
||||||
element.appendChild(option.toXml(doc));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
root.appendChild(element);
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WordListDataEntity fromXml(Element item) {
|
|
||||||
super.fromXml(item);
|
|
||||||
this.options = new LinkedList<>();
|
|
||||||
Element optionsElement = (Element) item.getElementsByTagName("options").item(0);
|
|
||||||
|
|
||||||
if (optionsElement != null) {
|
|
||||||
NodeList optionElements = optionsElement.getChildNodes();
|
|
||||||
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
|
||||||
Node optionElement = optionElements.item(temp);
|
|
||||||
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.options.add(new Option().fromXml((Element) optionElement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Boolean temp = Boolean.parseBoolean(item.getAttribute("multiList"));
|
|
||||||
this.multiList = temp != null ? temp : false;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.importexport;
|
package eu.eudat.commons.types.descriptiontemplate.importexport;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
import eu.eudat.commons.enums.FieldValidationType;
|
import eu.eudat.commons.enums.FieldValidationType;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.BaseFieldDataEntity;
|
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.FieldDataHelper;
|
|
||||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.*;
|
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.*;
|
||||||
import eu.eudat.model.persist.descriptiontemplatedefinition.FieldPersist;
|
|
||||||
import eu.eudat.model.persist.descriptiontemplatedefinition.RulePersist;
|
|
||||||
import eu.eudat.service.fielddatahelper.FieldDataHelperService;
|
|
||||||
import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider;
|
|
||||||
import jakarta.xml.bind.annotation.*;
|
import jakarta.xml.bind.annotation.*;
|
||||||
import org.w3c.dom.Element;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@ -61,7 +54,7 @@ public class FieldImportExport {
|
||||||
@XmlElement(name = FieldType.Names.DatasetIdentifier, type = LabelDataImportExport.class),
|
@XmlElement(name = FieldType.Names.DatasetIdentifier, type = LabelDataImportExport.class),
|
||||||
@XmlElement(name = FieldType.Names.DataRepositories, type = LabelAndMultiplicityDataImportExport.class),
|
@XmlElement(name = FieldType.Names.DataRepositories, type = LabelAndMultiplicityDataImportExport.class),
|
||||||
@XmlElement(name = FieldType.Names.Currency, type = LabelDataImportExport.class),
|
@XmlElement(name = FieldType.Names.Currency, type = LabelDataImportExport.class),
|
||||||
@XmlElement(name = FieldType.Names.BooleanDecision, type = LabelAndMultiplicityDataImportExport.class),
|
@XmlElement(name = FieldType.Names.BooleanDecision, type = LabelDataImportExport.class),
|
||||||
@XmlElement(name = FieldType.Names.Upload, type = UploadDataImportExport.class),
|
@XmlElement(name = FieldType.Names.Upload, type = UploadDataImportExport.class),
|
||||||
@XmlElement(name = FieldType.Names.RadioBox, type = RadioBoxDataImportExport.class),
|
@XmlElement(name = FieldType.Names.RadioBox, type = RadioBoxDataImportExport.class),
|
||||||
@XmlElement(name = FieldType.Names.Wordlist, type = WordListDataImportExport.class),
|
@XmlElement(name = FieldType.Names.Wordlist, type = WordListDataImportExport.class),
|
||||||
|
|
|
@ -2,12 +2,14 @@ package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class BaseFieldDataImportExport {
|
public abstract class BaseFieldDataImportExport {
|
||||||
|
@XmlAttribute(name = "label")
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
|
|
@ -1,15 +1,8 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
|
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.FieldDataComboBoxType;
|
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
|
||||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ComboBoxDataOptionEntity {
|
public class ComboBoxDataOptionEntity {
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
package eu.eudat.commons.types.descriptiontemplate.todelete;
|
package eu.eudat.commons.types.descriptiontemplate.todelete;
|
||||||
|
|
||||||
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
||||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
import jakarta.xml.bind.annotation.*;
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class VisibilityEntity implements XmlSerializable<VisibilityEntity> {
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class VisibilityEntity {
|
||||||
|
@XmlElementWrapper(name = "rules")
|
||||||
|
@XmlElement(name = "rule")
|
||||||
private List<RuleEntity> rules;
|
private List<RuleEntity> rules;
|
||||||
|
@XmlAttribute(name="style")
|
||||||
private String style;
|
private String style;
|
||||||
|
|
||||||
public List<RuleEntity> getRules() {
|
public List<RuleEntity> getRules() {
|
||||||
|
@ -29,30 +27,4 @@ public class VisibilityEntity implements XmlSerializable<VisibilityEntity> {
|
||||||
public void setStyle(String style) {
|
public void setStyle(String style) {
|
||||||
this.style = style;
|
this.style = style;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element toXml(Document doc) {
|
|
||||||
Element root = doc.createElement("visible");
|
|
||||||
root.setAttribute("style", this.style);
|
|
||||||
if (rules != null && !rules.isEmpty()) {
|
|
||||||
for (RuleEntity rule : rules) {
|
|
||||||
root.appendChild(rule.toXml(doc));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VisibilityEntity fromXml(Element item) {
|
|
||||||
this.style = item.getAttribute("style");
|
|
||||||
this.rules = new LinkedList();
|
|
||||||
NodeList rulesElements = item.getChildNodes();
|
|
||||||
for (int temp = 0; temp < rulesElements.getLength(); temp++) {
|
|
||||||
Node ruleElement = rulesElements.item(temp);
|
|
||||||
if (ruleElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
this.rules.add(new RuleEntity().fromXml((Element) ruleElement));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class RadioBoxOptionBuilder extends BaseBuilder<RadioBoxOption, RadioBoxDataEntity.Option> {
|
public class RadioBoxOptionBuilder extends BaseBuilder<RadioBoxOption, RadioBoxDataEntity.RadioBoxDataOptionEntity> {
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@ -35,14 +35,14 @@ public class RadioBoxOptionBuilder extends BaseBuilder<RadioBoxOption, RadioBoxD
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RadioBoxOption> build(FieldSet fields, List<RadioBoxDataEntity.Option> data) throws MyApplicationException {
|
public List<RadioBoxOption> build(FieldSet fields, List<RadioBoxDataEntity.RadioBoxDataOptionEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
this.logger.trace(new DataLogEntry("requested fields", fields));
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
if (fields == null || data == null || fields.isEmpty())
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
||||||
List<RadioBoxOption> models = new ArrayList<>();
|
List<RadioBoxOption> models = new ArrayList<>();
|
||||||
for (RadioBoxDataEntity.Option d : data) {
|
for (RadioBoxDataEntity.RadioBoxDataOptionEntity d : data) {
|
||||||
RadioBoxOption m = new RadioBoxOption();
|
RadioBoxOption m = new RadioBoxOption();
|
||||||
if (fields.hasField(this.asIndexer(RadioBoxOption._label))) m.setLabel(d.getLabel());
|
if (fields.hasField(this.asIndexer(RadioBoxOption._label))) m.setLabel(d.getLabel());
|
||||||
if (fields.hasField(this.asIndexer(RadioBoxOption._value))) m.setValue(d.getValue());
|
if (fields.hasField(this.asIndexer(RadioBoxOption._value))) m.setValue(d.getValue());
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class UploadOptionBuilder extends BaseBuilder<UploadOption, UploadDataEntity.Option> {
|
public class UploadOptionBuilder extends BaseBuilder<UploadOption, UploadDataEntity.UploadDataOptionEntity> {
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@ -35,14 +35,14 @@ public class UploadOptionBuilder extends BaseBuilder<UploadOption, UploadDataEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UploadOption> build(FieldSet fields, List<UploadDataEntity.Option> data) throws MyApplicationException {
|
public List<UploadOption> build(FieldSet fields, List<UploadDataEntity.UploadDataOptionEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
this.logger.trace(new DataLogEntry("requested fields", fields));
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
if (fields == null || data == null || fields.isEmpty())
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
||||||
List<UploadOption> models = new ArrayList<>();
|
List<UploadOption> models = new ArrayList<>();
|
||||||
for (UploadDataEntity.Option d : data) {
|
for (UploadDataEntity.UploadDataOptionEntity d : data) {
|
||||||
UploadOption m = new UploadOption();
|
UploadOption m = new UploadOption();
|
||||||
if (fields.hasField(this.asIndexer(UploadOption._label))) m.setLabel(d.getLabel());
|
if (fields.hasField(this.asIndexer(UploadOption._label))) m.setLabel(d.getLabel());
|
||||||
if (fields.hasField(this.asIndexer(UploadOption._value))) m.setValue(d.getValue());
|
if (fields.hasField(this.asIndexer(UploadOption._value))) m.setValue(d.getValue());
|
||||||
|
|
|
@ -11,7 +11,6 @@ import eu.eudat.file.transformer.enums.FieldType;
|
||||||
import eu.eudat.file.transformer.enums.FieldValidationType;
|
import eu.eudat.file.transformer.enums.FieldValidationType;
|
||||||
import eu.eudat.file.transformer.models.descriptiontemplate.definition.*;
|
import eu.eudat.file.transformer.models.descriptiontemplate.definition.*;
|
||||||
import eu.eudat.file.transformer.models.descriptiontemplate.definition.fielddata.*;
|
import eu.eudat.file.transformer.models.descriptiontemplate.definition.fielddata.*;
|
||||||
import eu.eudat.model.descriptiontemplatedefinition.fielddata.UploadOption;
|
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
@ -195,9 +194,9 @@ public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFil
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<RadioBoxOptionFileTransformerModel> convertRadioBoxOptions(List<RadioBoxDataEntity.Option> data) {
|
private List<RadioBoxOptionFileTransformerModel> convertRadioBoxOptions(List<RadioBoxDataEntity.RadioBoxDataOptionEntity> data) {
|
||||||
List<RadioBoxOptionFileTransformerModel> result = new ArrayList<>();
|
List<RadioBoxOptionFileTransformerModel> result = new ArrayList<>();
|
||||||
for (RadioBoxDataEntity.Option d : data) {
|
for (RadioBoxDataEntity.RadioBoxDataOptionEntity d : data) {
|
||||||
RadioBoxOptionFileTransformerModel m = new RadioBoxOptionFileTransformerModel();
|
RadioBoxOptionFileTransformerModel m = new RadioBoxOptionFileTransformerModel();
|
||||||
m.setLabel(d.getLabel());
|
m.setLabel(d.getLabel());
|
||||||
m.setValue(d.getValue());
|
m.setValue(d.getValue());
|
||||||
|
@ -226,9 +225,9 @@ public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFil
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UploadOptionFileTransformerModel> convertUploadDataOptions(List<UploadDataEntity.Option> data) {
|
private List<UploadOptionFileTransformerModel> convertUploadDataOptions(List<UploadDataEntity.UploadDataOptionEntity> data) {
|
||||||
List<UploadOptionFileTransformerModel> result = new ArrayList<>();
|
List<UploadOptionFileTransformerModel> result = new ArrayList<>();
|
||||||
for (UploadDataEntity.Option d : data) {
|
for (UploadDataEntity.UploadDataOptionEntity d : data) {
|
||||||
UploadOptionFileTransformerModel m = new UploadOptionFileTransformerModel();
|
UploadOptionFileTransformerModel m = new UploadOptionFileTransformerModel();
|
||||||
m.setLabel(d.getLabel());
|
m.setLabel(d.getLabel());
|
||||||
m.setValue(d.getValue());
|
m.setValue(d.getValue());
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||||
visible = true)
|
visible = true)
|
||||||
@JsonSubTypes({
|
@JsonSubTypes({
|
||||||
@JsonSubTypes.Type(value = AutoCompleteDataPersist.class, name = FieldType.Names.Autocomplete),
|
@JsonSubTypes.Type(value = AutoCompleteDataPersist.class, name = FieldType.Names.Autocomplete),
|
||||||
@JsonSubTypes.Type(value = LabelAndMultiplicityDataPersist.class, name = FieldType.Names.BooleanDecision),
|
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.BooleanDecision),
|
||||||
@JsonSubTypes.Type(value = LabelAndMultiplicityDataPersist.class, name = FieldType.Names.InternalDmpDatasets),
|
@JsonSubTypes.Type(value = LabelAndMultiplicityDataPersist.class, name = FieldType.Names.InternalDmpDatasets),
|
||||||
@JsonSubTypes.Type(value = LabelAndMultiplicityDataPersist.class, name = FieldType.Names.InternalDmpDmps),
|
@JsonSubTypes.Type(value = LabelAndMultiplicityDataPersist.class, name = FieldType.Names.InternalDmpDmps),
|
||||||
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.CheckBox),
|
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.CheckBox),
|
||||||
|
|
|
@ -28,7 +28,6 @@ public class FieldDataHelperServiceProvider {
|
||||||
case REGISTRIES:
|
case REGISTRIES:
|
||||||
case SERVICES:
|
case SERVICES:
|
||||||
case RESEARCHERS:
|
case RESEARCHERS:
|
||||||
case BOOLEAN_DECISION:
|
|
||||||
case INTERNAL_DMP_ENTRIES_DATASETS:
|
case INTERNAL_DMP_ENTRIES_DATASETS:
|
||||||
case INTERNAL_DMP_ENTRIES_DMPS:
|
case INTERNAL_DMP_ENTRIES_DMPS:
|
||||||
case INTERNAL_DMP_ENTRIES_RESEARCHERS:
|
case INTERNAL_DMP_ENTRIES_RESEARCHERS:
|
||||||
|
@ -48,6 +47,7 @@ public class FieldDataHelperServiceProvider {
|
||||||
case DATASET_IDENTIFIER:
|
case DATASET_IDENTIFIER:
|
||||||
case CURRENCY:
|
case CURRENCY:
|
||||||
case CHECK_BOX:
|
case CHECK_BOX:
|
||||||
|
case BOOLEAN_DECISION:
|
||||||
case VALIDATION: {
|
case VALIDATION: {
|
||||||
item = this.applicationContext.getBean(LabelFieldDataHelperService.class);
|
item = this.applicationContext.getBean(LabelFieldDataHelperService.class);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class LabelAndMultiplicityFieldDataHelperService extends BaseFieldDataHel
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LabelAndMultiplicityDataEntity newDataInstanceInternal() {
|
public LabelAndMultiplicityDataEntity newDataInstanceInternal() {
|
||||||
return new LabelAndMultiplicityDataEntity(this.getFieldType());
|
return new LabelAndMultiplicityDataEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class LabelFieldDataHelperService extends BaseFieldDataHelperService<Labe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LabelDataEntity newDataInstanceInternal() {
|
public LabelDataEntity newDataInstanceInternal() {
|
||||||
return new LabelDataEntity(this.getFieldType());
|
return new LabelDataEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -92,8 +92,8 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull RadioBoxDataEntity.Option buildOption(RadioBoxOptionPersist persist){
|
private @NotNull RadioBoxDataEntity.RadioBoxDataOptionEntity buildOption(RadioBoxOptionPersist persist){
|
||||||
RadioBoxDataEntity.Option data = new RadioBoxDataEntity.Option();
|
RadioBoxDataEntity.RadioBoxDataOptionEntity data = new RadioBoxDataEntity.RadioBoxDataOptionEntity();
|
||||||
if (persist == null) return data;
|
if (persist == null) return data;
|
||||||
|
|
||||||
data.setLabel(persist.getLabel());
|
data.setLabel(persist.getLabel());
|
||||||
|
@ -127,7 +127,7 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
||||||
protected RadioBoxDataImportExport dataToImportExportXmlInternal(RadioBoxDataEntity data, RadioBoxDataImportExport xml) {
|
protected RadioBoxDataImportExport dataToImportExportXmlInternal(RadioBoxDataEntity data, RadioBoxDataImportExport xml) {
|
||||||
if (!this.conventionService.isListNullOrEmpty(data.getOptions())){
|
if (!this.conventionService.isListNullOrEmpty(data.getOptions())){
|
||||||
xml.setOptions(new ArrayList<>());
|
xml.setOptions(new ArrayList<>());
|
||||||
for (RadioBoxDataEntity.Option radioBoxOption: data.getOptions()) {
|
for (RadioBoxDataEntity.RadioBoxDataOptionEntity radioBoxOption: data.getOptions()) {
|
||||||
xml.getOptions().add(this.buildOption(radioBoxOption));
|
xml.getOptions().add(this.buildOption(radioBoxOption));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public class RadioBoxFieldDataHelperService extends BaseFieldDataHelperService<R
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull RadioBoxOption buildOption(RadioBoxDataEntity.Option data){
|
private @NotNull RadioBoxOption buildOption(RadioBoxDataEntity.RadioBoxDataOptionEntity data){
|
||||||
RadioBoxOption xml = new RadioBoxOption();
|
RadioBoxOption xml = new RadioBoxOption();
|
||||||
if (data == null) return xml;
|
if (data == null) return xml;
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,8 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull UploadDataEntity.Option buildOption(UploadOptionPersist persist){
|
private @NotNull UploadDataEntity.UploadDataOptionEntity buildOption(UploadOptionPersist persist){
|
||||||
UploadDataEntity.Option data = new UploadDataEntity.Option();
|
UploadDataEntity.UploadDataOptionEntity data = new UploadDataEntity.UploadDataOptionEntity();
|
||||||
if (persist == null) return data;
|
if (persist == null) return data;
|
||||||
|
|
||||||
data.setLabel(persist.getLabel());
|
data.setLabel(persist.getLabel());
|
||||||
|
@ -130,7 +130,7 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
||||||
protected UploadDataImportExport dataToImportExportXmlInternal(UploadDataEntity data, UploadDataImportExport xml) {
|
protected UploadDataImportExport dataToImportExportXmlInternal(UploadDataEntity data, UploadDataImportExport xml) {
|
||||||
if (!this.conventionService.isListNullOrEmpty(data.getTypes())){
|
if (!this.conventionService.isListNullOrEmpty(data.getTypes())){
|
||||||
xml.setTypes(new ArrayList<>());
|
xml.setTypes(new ArrayList<>());
|
||||||
for (UploadDataEntity.Option option: data.getTypes()) {
|
for (UploadDataEntity.UploadDataOptionEntity option: data.getTypes()) {
|
||||||
xml.getTypes().add(this.buildOption(option));
|
xml.getTypes().add(this.buildOption(option));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public class UploadFieldDataHelperService extends BaseFieldDataHelperService<Upl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull UploadDataOption buildOption(UploadDataEntity.Option data){
|
private @NotNull UploadDataOption buildOption(UploadDataEntity.UploadDataOptionEntity data){
|
||||||
UploadDataOption xml = new UploadDataOption();
|
UploadDataOption xml = new UploadDataOption();
|
||||||
if (data == null) return xml;
|
if (data == null) return xml;
|
||||||
|
|
||||||
|
|
|
@ -283,7 +283,6 @@ public class PrefillingServiceImpl implements PrefillingService {
|
||||||
Field field = new Field();
|
Field field = new Field();
|
||||||
field.setKey(id);
|
field.setKey(id);
|
||||||
switch (fieldEntity.getData().getFieldType()) {
|
switch (fieldEntity.getData().getFieldType()) {
|
||||||
case COMBO_BOX:
|
|
||||||
case AUTO_COMPLETE:
|
case AUTO_COMPLETE:
|
||||||
case WORD_LIST: {
|
case WORD_LIST: {
|
||||||
if (!parsedValues.stream().allMatch(Objects::isNull)) {
|
if (!parsedValues.stream().allMatch(Objects::isNull)) {
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class FileController {
|
||||||
}
|
}
|
||||||
if(acceptedFile.get() && uploadDataEntity.getTypes() != null && !uploadDataEntity.getTypes().isEmpty()) {
|
if(acceptedFile.get() && uploadDataEntity.getTypes() != null && !uploadDataEntity.getTypes().isEmpty()) {
|
||||||
acceptedFile.set(false);
|
acceptedFile.set(false);
|
||||||
for (UploadDataEntity.Option option: uploadDataEntity.getTypes()) {
|
for (UploadDataEntity.UploadDataOptionEntity option: uploadDataEntity.getTypes()) {
|
||||||
if(Objects.equals(file.getContentType(), option.getValue())) {
|
if(Objects.equals(file.getContentType(), option.getValue())) {
|
||||||
acceptedFile.set(true);
|
acceptedFile.set(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class DatasetProfileManager {
|
||||||
XPathExpression expr =
|
XPathExpression expr =
|
||||||
xpath.compile("//field[@id='" + fieldId + "']");
|
xpath.compile("//field[@id='" + fieldId + "']");
|
||||||
Element name = (Element) expr.evaluate(document, XPathConstants.NODE);
|
Element name = (Element) expr.evaluate(document, XPathConstants.NODE);
|
||||||
fieldEntity.fromXml(name);
|
// fieldEntity.fromXml(name);
|
||||||
return fieldEntity;
|
return fieldEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,8 @@ public class PrefillingMapper {
|
||||||
String renderStyle = node.isArray() ? node.get(0).get("viewStyle").get("renderStyle").asText() : node.get("viewStyle").get("renderStyle").asText();
|
String renderStyle = node.isArray() ? node.get(0).get("viewStyle").get("renderStyle").asText() : node.get("viewStyle").get("renderStyle").asText();
|
||||||
|
|
||||||
switch (FieldType.of(renderStyle)) {
|
switch (FieldType.of(renderStyle)) {
|
||||||
case COMBO_BOX:
|
case AUTO_COMPLETE:
|
||||||
|
case WORD_LIST:
|
||||||
if (parsedValues.isEmpty())
|
if (parsedValues.isEmpty())
|
||||||
parsedValues.add(parsedValue);
|
parsedValues.add(parsedValue);
|
||||||
if (!parsedValues.stream().allMatch(Objects::isNull)) {
|
if (!parsedValues.stream().allMatch(Objects::isNull)) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package eu.eudat.logic.utilities.documents.word;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.commons.enums.FieldDataComboBoxType;
|
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
|
@ -468,7 +467,7 @@ public class WordBuilder {
|
||||||
try {
|
try {
|
||||||
if(field.getViewStyle().getFieldType().equals("upload")){
|
if(field.getViewStyle().getFieldType().equals("upload")){
|
||||||
boolean isImage = false;
|
boolean isImage = false;
|
||||||
for(UploadDataEntity.Option type: ((UploadDataEntity)field.getData()).getTypes()){
|
for(UploadDataEntity.UploadDataOptionEntity type: ((UploadDataEntity)field.getData()).getTypes()){
|
||||||
String fileFormat = type.getValue();
|
String fileFormat = type.getValue();
|
||||||
if(IMAGE_TYPE_MAP.containsKey(fileFormat)){
|
if(IMAGE_TYPE_MAP.containsKey(fileFormat)){
|
||||||
isImage = true;
|
isImage = true;
|
||||||
|
@ -612,7 +611,7 @@ public class WordBuilder {
|
||||||
try {
|
try {
|
||||||
if(field.getViewStyle().getFieldType().equals("upload")){
|
if(field.getViewStyle().getFieldType().equals("upload")){
|
||||||
boolean isImage = false;
|
boolean isImage = false;
|
||||||
for(UploadDataEntity.Option type: ((UploadDataEntity)field.getData()).getTypes()){
|
for(UploadDataEntity.UploadDataOptionEntity type: ((UploadDataEntity)field.getData()).getTypes()){
|
||||||
String fileFormat = type.getValue();
|
String fileFormat = type.getValue();
|
||||||
if(IMAGE_TYPE_MAP.containsKey(fileFormat)){
|
if(IMAGE_TYPE_MAP.containsKey(fileFormat)){
|
||||||
isImage = true;
|
isImage = true;
|
||||||
|
@ -865,7 +864,6 @@ public class WordBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatter(Field field) throws IOException {
|
private String formatter(Field field) throws IOException {
|
||||||
FieldDataComboBoxType comboboxType = null;
|
|
||||||
if (field.getValue() == null) {
|
if (field.getValue() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -883,56 +881,56 @@ public class WordBuilder {
|
||||||
case REGISTRIES:
|
case REGISTRIES:
|
||||||
case SERVICES:
|
case SERVICES:
|
||||||
case TAGS:
|
case TAGS:
|
||||||
case CURRENCY:
|
// case CURRENCY:
|
||||||
comboboxType = FieldDataComboBoxType.Autocomplete;
|
// comboboxType = FieldDataComboBoxType.Autocomplete;
|
||||||
case COMBO_BOX: {
|
// case COMBO_BOX: {
|
||||||
if (comboboxType == null) {
|
// if (comboboxType == null) {
|
||||||
comboboxType = ((ComboBoxDataEntity) field.getData()).getFieldSubType();
|
// comboboxType = ((ComboBoxDataEntity) field.getData()).getFieldSubType();
|
||||||
}
|
// }
|
||||||
if (comboboxType.equals(FieldDataComboBoxType.Autocomplete)) {
|
// if (comboboxType.equals(FieldDataComboBoxType.Autocomplete)) {
|
||||||
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
|
// mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
|
||||||
if (field.getValue() == null) return null;
|
// if (field.getValue() == null) return null;
|
||||||
List<Map<String, Object>> mapList = new ArrayList<>();
|
// List<Map<String, Object>> mapList = new ArrayList<>();
|
||||||
if (!field.getValue().equals("") && field.getValue().toString() != null) {
|
// if (!field.getValue().equals("") && field.getValue().toString() != null) {
|
||||||
try {
|
// try {
|
||||||
mapList = Arrays.asList(mapper.readValue(field.getValue().toString(), HashMap[].class));
|
// mapList = Arrays.asList(mapper.readValue(field.getValue().toString(), HashMap[].class));
|
||||||
}catch (Exception e) {
|
// }catch (Exception e) {
|
||||||
// logger.warn(e.getMessage(), e);
|
// // logger.warn(e.getMessage(), e);
|
||||||
// logger.info("Moving to fallback parsing");
|
// // logger.info("Moving to fallback parsing");
|
||||||
Map <String, Object> map = new HashMap<>();
|
// Map <String, Object> map = new HashMap<>();
|
||||||
map.put("label", field.getValue().toString());
|
// map.put("label", field.getValue().toString());
|
||||||
mapList.add(map);
|
// mapList.add(map);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
StringBuilder sb = new StringBuilder();
|
// StringBuilder sb = new StringBuilder();
|
||||||
int index = 0;
|
// int index = 0;
|
||||||
for (Map<String, Object> map: mapList) {
|
// for (Map<String, Object> map: mapList) {
|
||||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
// for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
if (entry.getValue() != null && (entry.getKey().equals("label") || entry.getKey().equals("description") || entry.getKey().equals("name"))) {
|
// if (entry.getValue() != null && (entry.getKey().equals("label") || entry.getKey().equals("description") || entry.getKey().equals("name"))) {
|
||||||
sb.append(entry.getValue());
|
// sb.append(entry.getValue());
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (index != mapList.size() - 1) sb.append(", ");
|
// if (index != mapList.size() - 1) sb.append(", ");
|
||||||
index++;
|
// index++;
|
||||||
}
|
// }
|
||||||
return sb.toString();
|
// return sb.toString();
|
||||||
} else if (comboboxType.equals(FieldDataComboBoxType.Wordlist)) {
|
// } else if (comboboxType.equals(FieldDataComboBoxType.Wordlist)) {
|
||||||
WordListDataEntity wordListDataEntity = (WordListDataEntity) field.getData();
|
// WordListDataEntity wordListDataEntity = (WordListDataEntity) field.getData();
|
||||||
if (field.getValue() != null){
|
// if (field.getValue() != null){
|
||||||
ComboBoxDataEntity.Option selectedOption = null;
|
// ComboBoxDataEntity.Option selectedOption = null;
|
||||||
if (!wordListDataEntity.getOptions().isEmpty()) {
|
// if (!wordListDataEntity.getOptions().isEmpty()) {
|
||||||
for (ComboBoxDataEntity.Option option : wordListDataEntity.getOptions()) {
|
// for (ComboBoxDataEntity.Option option : wordListDataEntity.getOptions()) {
|
||||||
if (option.getValue().equals(field.getValue())) {
|
// if (option.getValue().equals(field.getValue())) {
|
||||||
selectedOption = option;
|
// selectedOption = option;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return selectedOption != null ? selectedOption.getLabel() : field.getValue().toString();
|
// return selectedOption != null ? selectedOption.getLabel() : field.getValue().toString();
|
||||||
}
|
// }
|
||||||
return "";
|
// return "";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
case BOOLEAN_DECISION:
|
case BOOLEAN_DECISION:
|
||||||
if (field.getValue() != null && field.getValue().equals("true")) return "Yes";
|
if (field.getValue() != null && field.getValue().equals("true")) return "Yes";
|
||||||
if (field.getValue() != null && field.getValue().equals("false")) return "No";
|
if (field.getValue() != null && field.getValue().equals("false")) return "No";
|
||||||
|
|
|
@ -212,7 +212,8 @@ public class ExportXmlBuilderDatasetProfile {
|
||||||
if (field.getData() != null) {
|
if (field.getData() != null) {
|
||||||
Element dataOut = element.createElement("data");
|
Element dataOut = element.createElement("data");
|
||||||
switch (field.getViewStyle().getFieldType()) {
|
switch (field.getViewStyle().getFieldType()) {
|
||||||
case COMBO_BOX:
|
case WORD_LIST:
|
||||||
|
case AUTO_COMPLETE:
|
||||||
ComboBoxDataEntity comboBoxDataEntityObject = (ComboBoxDataEntity) field.getData();
|
ComboBoxDataEntity comboBoxDataEntityObject = (ComboBoxDataEntity) field.getData();
|
||||||
if (comboBoxDataEntityObject.getFieldType().equals("wordlist")) {
|
if (comboBoxDataEntityObject.getFieldType().equals("wordlist")) {
|
||||||
WordListDataEntity wordListDataEntityObject = (WordListDataEntity) field.getData();
|
WordListDataEntity wordListDataEntityObject = (WordListDataEntity) field.getData();
|
||||||
|
@ -288,20 +289,22 @@ public class ExportXmlBuilderDatasetProfile {
|
||||||
BaseFieldDataEntity baseFieldDataObject = (BaseFieldDataEntity) field.getData();
|
BaseFieldDataEntity baseFieldDataObject = (BaseFieldDataEntity) field.getData();
|
||||||
dataOut.setAttribute("label", baseFieldDataObject.getLabel());
|
dataOut.setAttribute("label", baseFieldDataObject.getLabel());
|
||||||
break;
|
break;
|
||||||
case INTERNAL_DMP_ENTRIES:
|
case INTERNAL_DMP_ENTRIES_RESEARCHERS:
|
||||||
|
case INTERNAL_DMP_ENTRIES_DATASETS:
|
||||||
|
case INTERNAL_DMP_ENTRIES_DMPS:
|
||||||
InternalDmpBaseDataEntity internalDmpEntitiesData = (InternalDmpBaseDataEntity) field.getData();
|
InternalDmpBaseDataEntity internalDmpEntitiesData = (InternalDmpBaseDataEntity) field.getData();
|
||||||
dataOut.setAttribute("label", internalDmpEntitiesData.getLabel());
|
dataOut.setAttribute("label", internalDmpEntitiesData.getLabel());
|
||||||
dataOut.setAttribute("type", internalDmpEntitiesData.getFieldType().getValue());
|
dataOut.setAttribute("type", internalDmpEntitiesData.getFieldType().getValue());
|
||||||
switch (internalDmpEntitiesData.getFieldSubType()) {
|
switch (internalDmpEntitiesData.getFieldType()) {
|
||||||
case Researchers:
|
case INTERNAL_DMP_ENTRIES_RESEARCHERS:
|
||||||
InternalDmpBaseDataEntity researchersAutoCompleteData = (InternalDmpBaseDataEntity) internalDmpEntitiesData;
|
InternalDmpBaseDataEntity researchersAutoCompleteData = (InternalDmpBaseDataEntity) internalDmpEntitiesData;
|
||||||
dataOut.setAttribute("multiAutocomplete", researchersAutoCompleteData.getMultiAutoComplete().toString());
|
dataOut.setAttribute("multiAutocomplete", researchersAutoCompleteData.getMultiAutoComplete().toString());
|
||||||
break;
|
break;
|
||||||
case Datasets:
|
case INTERNAL_DMP_ENTRIES_DATASETS:
|
||||||
InternalDmpBaseDataEntity datasetAutoCompleteDataEntity = (InternalDmpBaseDataEntity) internalDmpEntitiesData;
|
InternalDmpBaseDataEntity datasetAutoCompleteDataEntity = (InternalDmpBaseDataEntity) internalDmpEntitiesData;
|
||||||
dataOut.setAttribute("multiAutocomplete", datasetAutoCompleteDataEntity.getMultiAutoComplete().toString());
|
dataOut.setAttribute("multiAutocomplete", datasetAutoCompleteDataEntity.getMultiAutoComplete().toString());
|
||||||
break;
|
break;
|
||||||
case Dmps:
|
case INTERNAL_DMP_ENTRIES_DMPS:
|
||||||
InternalDmpBaseDataEntity dmpAutoCompleteDataEntity = (InternalDmpBaseDataEntity) internalDmpEntitiesData;
|
InternalDmpBaseDataEntity dmpAutoCompleteDataEntity = (InternalDmpBaseDataEntity) internalDmpEntitiesData;
|
||||||
dataOut.setAttribute("multiAutocomplete", dmpAutoCompleteDataEntity.getMultiAutoComplete().toString());
|
dataOut.setAttribute("multiAutocomplete", dmpAutoCompleteDataEntity.getMultiAutoComplete().toString());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -5,7 +5,6 @@ import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.todelete.DefaultValueEntity;
|
import eu.eudat.commons.types.descriptiontemplate.todelete.DefaultValueEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.todelete.FieldDescriptionEntity;
|
import eu.eudat.commons.types.descriptiontemplate.todelete.FieldDescriptionEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.todelete.VisibilityEntity;
|
import eu.eudat.commons.types.descriptiontemplate.todelete.VisibilityEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.FieldDataHelper;
|
|
||||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
|
|
|
@ -7,7 +7,6 @@ import eu.eudat.commons.types.descriptiontemplate.todelete.DefaultValueEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.MultiplicityEntity;
|
import eu.eudat.commons.types.descriptiontemplate.MultiplicityEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.todelete.FieldDescriptionEntity;
|
import eu.eudat.commons.types.descriptiontemplate.todelete.FieldDescriptionEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.todelete.VisibilityEntity;
|
import eu.eudat.commons.types.descriptiontemplate.todelete.VisibilityEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.FieldDataHelper;
|
|
||||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
import eu.eudat.models.data.properties.PropertiesGenerator;
|
import eu.eudat.models.data.properties.PropertiesGenerator;
|
||||||
import eu.eudat.models.data.user.composite.PropertiesModelBuilder;
|
import eu.eudat.models.data.user.composite.PropertiesModelBuilder;
|
||||||
|
|
|
@ -0,0 +1,434 @@
|
||||||
|
package eu.old.eudat.migration;
|
||||||
|
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
import eu.eudat.commons.enums.FieldDataExternalDatasetType;
|
||||||
|
import eu.eudat.commons.enums.FieldType;
|
||||||
|
import eu.eudat.commons.enums.FieldValidationType;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.*;
|
||||||
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
|
import eu.eudat.model.DescriptionTemplate;
|
||||||
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
|
import eu.old.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
|
import eu.old.eudat.models.data.components.commons.Multiplicity;
|
||||||
|
import eu.old.eudat.models.data.components.commons.Rule;
|
||||||
|
import eu.old.eudat.models.data.components.commons.datafield.*;
|
||||||
|
import eu.old.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.*;
|
||||||
|
import gr.cite.tools.data.query.Ordering;
|
||||||
|
import gr.cite.tools.data.query.Paging;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DescriptionTemplateXmlMigrationService {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateXmlMigrationService.class));
|
||||||
|
private final EntityManager entityManager;
|
||||||
|
private final ConventionService conventionService;
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private static final int PageSize = 500;
|
||||||
|
private static final boolean TestMode = false;
|
||||||
|
|
||||||
|
public DescriptionTemplateXmlMigrationService(EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService, QueryFactory queryFactory) {
|
||||||
|
this.entityManager = entityManager;
|
||||||
|
this.conventionService = conventionService;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void migrate() throws IOException, NoSuchFieldException, IllegalAccessException, JAXBException, ParserConfigurationException, InstantiationException, SAXException, InvalidApplicationException, TransformerException {
|
||||||
|
long total = this.queryFactory.query(DescriptionTemplateQuery.class).count();
|
||||||
|
logger.debug("Migrate DescriptionTemplate Total : " + total);
|
||||||
|
int page = 0;
|
||||||
|
|
||||||
|
List<DescriptionTemplateEntity> items;
|
||||||
|
do {
|
||||||
|
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class);
|
||||||
|
query.setOrder(new Ordering().addDescending(DescriptionTemplate._createdAt));
|
||||||
|
query.setPage(new Paging(page * PageSize, PageSize));
|
||||||
|
items = query.collect();
|
||||||
|
|
||||||
|
if (items != null && !items.isEmpty()) {
|
||||||
|
|
||||||
|
logger.debug("Migrate DescriptionTemplate " + page * PageSize + " of " + total);
|
||||||
|
|
||||||
|
for (DescriptionTemplateEntity item : items) {
|
||||||
|
if (this.conventionService.isNullOrEmpty(item.getDefinition())) continue;
|
||||||
|
Document document = XmlBuilder.fromXml(item.getDefinition());
|
||||||
|
if (document == null){
|
||||||
|
logger.error("Migrate DescriptionTemplate " + item.getId() + " failed read xml");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ViewStyleModel viewStyleModel = new ViewStyleModel().fromXml(document.getDocumentElement());
|
||||||
|
item.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(viewStyleModel)));
|
||||||
|
} catch (Exception ex){
|
||||||
|
logger.error("Migrate DescriptionTemplate " + item.getId() + " failed read xml");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.entityManager.merge(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entityManager.flush();
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
} while (items != null && !items.isEmpty() && !TestMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull DefinitionEntity buildDefinitionEntity(ViewStyleModel persist) {
|
||||||
|
DefinitionEntity data = new DefinitionEntity();
|
||||||
|
if (persist == null)
|
||||||
|
return data;
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(persist.getSections())) {
|
||||||
|
data.setSections(new ArrayList<>());
|
||||||
|
for (Section sectionPersist : persist.getSections()) {
|
||||||
|
data.getSections().add(this.buildSectionEntity(sectionPersist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(persist.getPages())) {
|
||||||
|
data.setPages(new ArrayList<>());
|
||||||
|
for (Page pagePersist : persist.getPages()) {
|
||||||
|
data.getPages().add(this.buildPageEntity(pagePersist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull SectionEntity buildSectionEntity(Section persist) {
|
||||||
|
SectionEntity data = new SectionEntity();
|
||||||
|
if (persist == null)
|
||||||
|
return data;
|
||||||
|
|
||||||
|
data.setId(persist.getId());
|
||||||
|
data.setDescription(persist.getDescription());
|
||||||
|
data.setExtendedDescription(persist.getExtendedDescription());
|
||||||
|
data.setNumbering(persist.getNumbering());
|
||||||
|
data.setOrdinal(persist.getOrdinal());
|
||||||
|
data.setDefaultVisibility(persist.isDefaultVisibility());
|
||||||
|
data.setMultiplicity(persist.getMultiplicity());
|
||||||
|
data.setPage(persist.getPage());
|
||||||
|
data.setTitle(persist.getTitle());
|
||||||
|
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(persist.getSections())) {
|
||||||
|
data.setSections(new ArrayList<>());
|
||||||
|
for (Section sectionPersist : persist.getSections()) {
|
||||||
|
data.getSections().add(this.buildSectionEntity(sectionPersist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(persist.getFieldSets())) {
|
||||||
|
data.setFieldSets(new ArrayList<>());
|
||||||
|
for (FieldSet fieldSetPersist : persist.getFieldSets()) {
|
||||||
|
data.getFieldSets().add(this.buildFieldSetEntity(fieldSetPersist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull FieldSetEntity buildFieldSetEntity(FieldSet persist) {
|
||||||
|
FieldSetEntity data = new FieldSetEntity();
|
||||||
|
if (persist == null)
|
||||||
|
return data;
|
||||||
|
|
||||||
|
data.setId(persist.getId());
|
||||||
|
data.setOrdinal(persist.getOrdinal());
|
||||||
|
data.setNumbering(persist.getNumbering());
|
||||||
|
data.setTitle(persist.getTitle());
|
||||||
|
data.setExtendedDescription(persist.getExtendedDescription());
|
||||||
|
data.setAdditionalInformation(persist.getAdditionalInformation());
|
||||||
|
data.setHasCommentField(persist.getHasCommentField());
|
||||||
|
if (persist.getMultiplicity() != null) data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity()));
|
||||||
|
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(persist.getFields())) {
|
||||||
|
data.setFields(new ArrayList<>());
|
||||||
|
for (Field fieldPersist : persist.getFields()) {
|
||||||
|
data.getFields().add(this.buildFieldEntity(fieldPersist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull FieldEntity buildFieldEntity(Field persist) {
|
||||||
|
FieldEntity data = new FieldEntity();
|
||||||
|
if (persist == null)
|
||||||
|
return data;
|
||||||
|
|
||||||
|
data.setId(persist.getId());
|
||||||
|
data.setOrdinal(persist.getOrdinal());
|
||||||
|
data.setSchematics(persist.getSchematics());
|
||||||
|
data.setNumbering(persist.getNumbering());
|
||||||
|
if (persist.getDefaultValue() != null) data.setDefaultValue(persist.getDefaultValue().getValue());
|
||||||
|
if (persist.getValidations() != null) data.setValidations(persist.getValidations().stream().map(x-> {
|
||||||
|
switch (x){
|
||||||
|
case NONE -> {
|
||||||
|
return FieldValidationType.None;
|
||||||
|
}
|
||||||
|
case REQUIRED -> {
|
||||||
|
return FieldValidationType.Required;
|
||||||
|
}
|
||||||
|
case URL -> {
|
||||||
|
return FieldValidationType.Url;
|
||||||
|
}
|
||||||
|
default -> throw new MyApplicationException("Invalid type " + x);
|
||||||
|
}
|
||||||
|
|
||||||
|
}).toList());
|
||||||
|
data.setIncludeInExport(persist.getExport());
|
||||||
|
if (persist.getData() != null)
|
||||||
|
data.setData(this.buildFieldDataEntity(persist.getData(), persist.getViewStyle().getRenderStyle()));
|
||||||
|
|
||||||
|
if (persist.getVisible() != null && !this.conventionService.isListNullOrEmpty(persist.getVisible().getRules())) {
|
||||||
|
data.setVisibilityRules(new ArrayList<>());
|
||||||
|
for (Rule fieldPersist : persist.getVisible().getRules()) {
|
||||||
|
data.getVisibilityRules().add(this.buildRuleEntity(fieldPersist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BaseFieldDataEntity<?> buildFieldDataEntity(FieldData persist, String renderStyle) {
|
||||||
|
if (renderStyle.equals("checkBox")){
|
||||||
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.CHECK_BOX);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("validation")){
|
||||||
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.VALIDATION);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("textarea")){
|
||||||
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.TEXT_AREA);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("tags")){
|
||||||
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.TAGS);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("richTextarea")){
|
||||||
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.RICH_TEXT_AREA);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("freetext")){
|
||||||
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.FREE_TEXT);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("datePicker")){
|
||||||
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.DATE_PICKER);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("datasetIdentifier")){
|
||||||
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.DATASET_IDENTIFIER);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("currency")){
|
||||||
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.CURRENCY);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("taxonomies")){
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((TaxonomiesData)persist).getMultiAutoComplete(),FieldType.TAXONOMIES);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("services")){
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((ServicesData)persist).getMultiAutoComplete(),FieldType.SERVICES);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("researchers")){
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((ResearcherData)persist).getMultiAutoComplete(),FieldType.RESEARCHERS);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("registries")){
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((RegistriesData)persist).getMultiAutoComplete(),FieldType.REGISTRIES);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("pubRepositories")){
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DataRepositoriesData)persist).getMultiAutoComplete(),FieldType.PUB_REPOSITORIES);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("publications")){
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((PublicationsData)persist).getMultiAutoComplete(),FieldType.PUB_REPOSITORIES);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("organizations")){
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((OrganizationsData)persist).getMultiAutoComplete(),FieldType.ORGANIZATIONS);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("licenses")){
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((LicensesData)persist).getMultiAutoComplete(),FieldType.LICENSES);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("journalRepositories")){
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DataRepositoriesData)persist).getMultiAutoComplete(),FieldType.JOURNAL_REPOSITORIES);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("dataRepositories")){
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DataRepositoriesData)persist).getMultiAutoComplete(),FieldType.DATA_REPOSITORIES);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("booleanDecision")){
|
||||||
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.DATA_REPOSITORIES);
|
||||||
|
}
|
||||||
|
if (renderStyle.equals("internalDmpEntities")){
|
||||||
|
switch (((InternalDmpEntitiesData<?>)persist).getType()){
|
||||||
|
case "dmps":
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DMPsAutoCompleteData)persist).getMultiAutoComplete(),FieldType.INTERNAL_DMP_ENTRIES_DMPS);
|
||||||
|
case "datasets":
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((DatasetsAutoCompleteData)persist).getMultiAutoComplete(),FieldType.INTERNAL_DMP_ENTRIES_DATASETS);
|
||||||
|
case "researchers":
|
||||||
|
return this.buildLabelAndMultiplicityDataEntity(persist.getLabel(), ((ResearchersAutoCompleteData)persist).getMultiAutoComplete(),FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renderStyle.equals("externalDatasets")){
|
||||||
|
ExternalDatasetDataEntity data = new ExternalDatasetDataEntity();
|
||||||
|
data.setLabel(persist.getLabel());
|
||||||
|
data.setMultiAutoComplete(((ExternalDatasetsData)persist).getMultiAutoComplete());
|
||||||
|
data.setType(FieldDataExternalDatasetType.of(((ExternalDatasetsData)persist).getType()));
|
||||||
|
data.setFieldType(FieldType.EXTERNAL_DATASETS);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (renderStyle.equals("upload")){
|
||||||
|
UploadDataEntity data = new UploadDataEntity();
|
||||||
|
data.setLabel(persist.getLabel());
|
||||||
|
data.setMaxFileSizeInMB(((UploadData)persist).getMaxFileSizeInMB());
|
||||||
|
data.setTypes(new ArrayList<>());
|
||||||
|
if (((UploadData)persist).getTypes() != null){
|
||||||
|
for (UploadData.Option option : ((UploadData)persist).getTypes()){
|
||||||
|
UploadDataEntity.UploadDataOptionEntity optionEntity =new UploadDataEntity.UploadDataOptionEntity();
|
||||||
|
optionEntity.setValue(option.getValue());
|
||||||
|
optionEntity.setLabel(option.getLabel());
|
||||||
|
data.getTypes().add(optionEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.setFieldType(FieldType.UPLOAD);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renderStyle.equals("radiobox")){
|
||||||
|
RadioBoxDataEntity data = new RadioBoxDataEntity();
|
||||||
|
data.setLabel(persist.getLabel());
|
||||||
|
data.setOptions(new ArrayList<>());
|
||||||
|
if (((RadioBoxData)persist).getOptions() != null){
|
||||||
|
for (RadioBoxData.Option option : ((RadioBoxData)persist).getOptions()){
|
||||||
|
RadioBoxDataEntity.RadioBoxDataOptionEntity optionEntity = new RadioBoxDataEntity.RadioBoxDataOptionEntity();
|
||||||
|
optionEntity.setValue(option.getValue());
|
||||||
|
optionEntity.setLabel(option.getLabel());
|
||||||
|
data.getOptions().add(optionEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.setFieldType(FieldType.RADIO_BOX);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renderStyle.equals("combobox")){
|
||||||
|
switch (((ComboBoxData<?>)persist).getType()){
|
||||||
|
case "wordlist":{
|
||||||
|
WordListDataEntity data = new WordListDataEntity();
|
||||||
|
data.setLabel(persist.getLabel());
|
||||||
|
data.setOptions(new ArrayList<>());
|
||||||
|
data.setMultiList(((WordListData)persist).getMultiList());
|
||||||
|
if (((WordListData)persist).getOptions() != null){
|
||||||
|
for (ComboBoxData.Option option : ((WordListData)persist).getOptions()){
|
||||||
|
ComboBoxDataEntity.Option optionEntity = new ComboBoxDataEntity.Option();
|
||||||
|
optionEntity.setValue(option.getValue());
|
||||||
|
optionEntity.setLabel(option.getLabel());
|
||||||
|
optionEntity.setSource(option.getSource());
|
||||||
|
optionEntity.setUri(option.getUri());
|
||||||
|
data.getOptions().add(optionEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.setFieldType(FieldType.WORD_LIST);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
case "autocomplete":{
|
||||||
|
AutoCompleteDataEntity data = new AutoCompleteDataEntity();
|
||||||
|
data.setLabel(persist.getLabel());
|
||||||
|
data.setAutoCompleteSingleDataList(new ArrayList<>());
|
||||||
|
data.setMultiAutoComplete(((AutoCompleteData)persist).getMultiAutoComplete());
|
||||||
|
if (((AutoCompleteData)persist).getAutoCompleteSingleDataList() != null){
|
||||||
|
for (AutoCompleteData.AutoCompleteSingleData autoCompleteSingleData : ((AutoCompleteData)persist).getAutoCompleteSingleDataList()){
|
||||||
|
AutoCompleteDataEntity.AutoCompleteSingleData autoCompleteSingleDataEntity = new AutoCompleteDataEntity.AutoCompleteSingleData();
|
||||||
|
autoCompleteSingleDataEntity.setOptionsRoot(autoCompleteSingleData.getOptionsRoot());
|
||||||
|
autoCompleteSingleDataEntity.setUrl(autoCompleteSingleData.getUrl());
|
||||||
|
autoCompleteSingleDataEntity.setMethod(autoCompleteSingleData.getMethod());
|
||||||
|
autoCompleteSingleDataEntity.setHasAuth(autoCompleteSingleData.getHasAuth());
|
||||||
|
if (autoCompleteSingleData.getHasAuth() && autoCompleteSingleData.getAuth()!= null) {
|
||||||
|
AutoCompleteDataEntity.AuthAutoCompleteData optionEntity = new AutoCompleteDataEntity.AuthAutoCompleteData();
|
||||||
|
optionEntity.setBody(autoCompleteSingleData.getAuth().getBody());
|
||||||
|
optionEntity.setMethod(autoCompleteSingleData.getAuth().getMethod());
|
||||||
|
optionEntity.setUrl(autoCompleteSingleData.getAuth().getUrl());
|
||||||
|
optionEntity.setType(autoCompleteSingleData.getAuth().getType());
|
||||||
|
optionEntity.setBody(autoCompleteSingleData.getAuth().getBody());
|
||||||
|
autoCompleteSingleDataEntity.setAuth(optionEntity);
|
||||||
|
}
|
||||||
|
autoCompleteSingleDataEntity.setAutocompleteType(AutoCompleteDataEntity.AutocompleteType.of(autoCompleteSingleData.getAutocompleteType()));
|
||||||
|
if (autoCompleteSingleData.getAutoCompleteOptions() != null) {
|
||||||
|
ComboBoxDataEntity.Option optionEntity = new ComboBoxDataEntity.Option();
|
||||||
|
optionEntity.setValue(autoCompleteSingleData.getAutoCompleteOptions().getValue());
|
||||||
|
optionEntity.setLabel(autoCompleteSingleData.getAutoCompleteOptions().getLabel());
|
||||||
|
optionEntity.setSource(autoCompleteSingleData.getAutoCompleteOptions().getSource());
|
||||||
|
optionEntity.setUri(autoCompleteSingleData.getAutoCompleteOptions().getUri());
|
||||||
|
autoCompleteSingleDataEntity.setAutoCompleteOptions(optionEntity);
|
||||||
|
}
|
||||||
|
data.getAutoCompleteSingleDataList().add(autoCompleteSingleDataEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.setFieldType(FieldType.AUTO_COMPLETE);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new MyApplicationException("Can transform field data" + renderStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BaseFieldDataEntity<?> buildLabelDataEntity(String label, FieldType fieldType) {
|
||||||
|
LabelDataEntity data = new LabelDataEntity();
|
||||||
|
data.setLabel(label);
|
||||||
|
data.setFieldType(fieldType);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BaseFieldDataEntity<?> buildLabelAndMultiplicityDataEntity(String label, Boolean multiAutoComplete, FieldType fieldType) {
|
||||||
|
LabelAndMultiplicityDataEntity data = new LabelAndMultiplicityDataEntity();
|
||||||
|
data.setLabel(label);
|
||||||
|
data.setFieldType(fieldType);
|
||||||
|
data.setMultiAutoComplete(multiAutoComplete);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull RuleEntity buildRuleEntity(Rule persist) {
|
||||||
|
RuleEntity data = new RuleEntity();
|
||||||
|
if (persist == null)
|
||||||
|
return data;
|
||||||
|
|
||||||
|
data.setTarget(persist.getTarget());
|
||||||
|
data.setValue(persist.getValue());
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
private @NotNull MultiplicityEntity buildMultiplicityEntity(Multiplicity persist) {
|
||||||
|
MultiplicityEntity data = new MultiplicityEntity();
|
||||||
|
if (persist == null)
|
||||||
|
return data;
|
||||||
|
|
||||||
|
data.setMax(persist.getMax());
|
||||||
|
data.setMin(persist.getMin());
|
||||||
|
data.setPlaceholder(persist.getPlaceholder());
|
||||||
|
data.setTableView(persist.getTableView());
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private @NotNull PageEntity buildPageEntity(Page persist) {
|
||||||
|
PageEntity data = new PageEntity();
|
||||||
|
if (persist == null)
|
||||||
|
return data;
|
||||||
|
|
||||||
|
data.setId(persist.getId());
|
||||||
|
data.setOrdinal(persist.getOrdinal());
|
||||||
|
data.setTitle(persist.getTitle());
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,9 +35,9 @@ import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DmpBlueprintMigrationService {
|
public class DmpBlueprintXmlMigrationService {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintMigrationService.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintXmlMigrationService.class));
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
private final ConventionService conventionService;
|
private final ConventionService conventionService;
|
||||||
private final XmlHandlingService xmlHandlingService;
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
@ -46,7 +46,7 @@ public class DmpBlueprintMigrationService {
|
||||||
private static final int PageSize = 500;
|
private static final int PageSize = 500;
|
||||||
private static final boolean TestMode = false;
|
private static final boolean TestMode = false;
|
||||||
|
|
||||||
public DmpBlueprintMigrationService(EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService, QueryFactory queryFactory) {
|
public DmpBlueprintXmlMigrationService(EntityManager entityManager, ConventionService conventionService, XmlHandlingService xmlHandlingService, QueryFactory queryFactory) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.conventionService = conventionService;
|
this.conventionService = conventionService;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
|
@ -58,7 +58,6 @@ public class DmpBlueprintMigrationService {
|
||||||
logger.debug("Migrate DmpBlueprint Total : " + total);
|
logger.debug("Migrate DmpBlueprint Total : " + total);
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
|
||||||
Map<String, UUID> licenseIdByName = new HashMap<>();
|
|
||||||
List<DmpBlueprintEntity> items;
|
List<DmpBlueprintEntity> items;
|
||||||
List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).collectAs(new BaseFieldSet().ensure(eu.eudat.model.DescriptionTemplate._id).ensure(eu.eudat.model.DescriptionTemplate._groupId));
|
List<DescriptionTemplateEntity> descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).collectAs(new BaseFieldSet().ensure(eu.eudat.model.DescriptionTemplate._id).ensure(eu.eudat.model.DescriptionTemplate._groupId));
|
||||||
Map<UUID, UUID> descriptionTemplateGroupMap = new HashMap<>();
|
Map<UUID, UUID> descriptionTemplateGroupMap = new HashMap<>();
|
||||||
|
@ -86,9 +85,9 @@ public class DmpBlueprintMigrationService {
|
||||||
DataManagementPlanBlueprint dataManagementPlanBlueprint =new DataManagementPlanBlueprint().fromXml(document.getDocumentElement());
|
DataManagementPlanBlueprint dataManagementPlanBlueprint =new DataManagementPlanBlueprint().fromXml(document.getDocumentElement());
|
||||||
item.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(dataManagementPlanBlueprint, descriptionTemplateGroupMap)));
|
item.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(dataManagementPlanBlueprint, descriptionTemplateGroupMap)));
|
||||||
this.entityManager.merge(item);
|
this.entityManager.merge(item);
|
||||||
this.entityManager.flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.entityManager.flush();
|
||||||
page++;
|
page++;
|
||||||
}
|
}
|
||||||
} while (items != null && !items.isEmpty() && !TestMode);
|
} while (items != null && !items.isEmpty() && !TestMode);
|
|
@ -10,11 +10,62 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
|
|
||||||
|
public static class AuthAutoCompleteData {
|
||||||
|
private String url;
|
||||||
|
private String method;
|
||||||
|
private String body;
|
||||||
|
private String path;
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMethod() {
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethod(String method) {
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBody(String body) {
|
||||||
|
this.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
public static class AutoCompleteSingleData {
|
public static class AutoCompleteSingleData {
|
||||||
private int autocompleteType;
|
private int autocompleteType;
|
||||||
private String url;
|
private String url;
|
||||||
private ComboBoxData.Option autoCompleteOptions;
|
private ComboBoxData.Option autoCompleteOptions;
|
||||||
private String optionsRoot;
|
private String optionsRoot;
|
||||||
|
private Boolean hasAuth;
|
||||||
|
private AuthAutoCompleteData auth;
|
||||||
|
private String method;
|
||||||
|
|
||||||
public int getAutocompleteType() {
|
public int getAutocompleteType() {
|
||||||
return autocompleteType;
|
return autocompleteType;
|
||||||
|
@ -38,12 +89,36 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getHasAuth() {
|
||||||
|
return hasAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasAuth(Boolean hasAuth) {
|
||||||
|
this.hasAuth = hasAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthAutoCompleteData getAuth() {
|
||||||
|
return auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuth(AuthAutoCompleteData auth) {
|
||||||
|
this.auth = auth;
|
||||||
|
}
|
||||||
|
|
||||||
public ComboBoxData.Option getAutoCompleteOptions() {
|
public ComboBoxData.Option getAutoCompleteOptions() {
|
||||||
return autoCompleteOptions;
|
return autoCompleteOptions;
|
||||||
}
|
}
|
||||||
public void setAutoCompleteOptions(ComboBoxData.Option autoCompleteOptions) {
|
public void setAutoCompleteOptions(ComboBoxData.Option autoCompleteOptions) {
|
||||||
this.autoCompleteOptions = autoCompleteOptions;
|
this.autoCompleteOptions = autoCompleteOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMethod() {
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethod(String method) {
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean multiAutoComplete;
|
private Boolean multiAutoComplete;
|
||||||
|
@ -70,11 +145,22 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
parent.setAttribute("url", singleData.url);
|
parent.setAttribute("url", singleData.url);
|
||||||
parent.setAttribute("optionsRoot", singleData.optionsRoot);
|
parent.setAttribute("optionsRoot", singleData.optionsRoot);
|
||||||
parent.setAttribute("autoCompleteType", Integer.toString(singleData.autocompleteType));
|
parent.setAttribute("autoCompleteType", Integer.toString(singleData.autocompleteType));
|
||||||
|
parent.setAttribute("hasAuth", Boolean.toString(singleData.hasAuth));
|
||||||
|
parent.setAttribute("method", singleData.method);
|
||||||
Element element = doc.createElement("option");
|
Element element = doc.createElement("option");
|
||||||
element.setAttribute("label", singleData.autoCompleteOptions.getLabel());
|
element.setAttribute("label", singleData.autoCompleteOptions.getLabel());
|
||||||
element.setAttribute("value", singleData.autoCompleteOptions.getValue());
|
element.setAttribute("value", singleData.autoCompleteOptions.getValue());
|
||||||
element.setAttribute("source", singleData.autoCompleteOptions.getSource());
|
element.setAttribute("source", singleData.autoCompleteOptions.getSource());
|
||||||
parent.appendChild(element);
|
parent.appendChild(element);
|
||||||
|
if (singleData.hasAuth) {
|
||||||
|
Element authElement = doc.createElement("auth");
|
||||||
|
authElement.setAttribute("url", singleData.auth.url);
|
||||||
|
authElement.setAttribute("method", singleData.auth.method);
|
||||||
|
authElement.setAttribute("body", singleData.auth.body);
|
||||||
|
authElement.setAttribute("path", singleData.auth.path);
|
||||||
|
authElement.setAttribute("type", singleData.auth.type);
|
||||||
|
parent.appendChild(authElement);
|
||||||
|
}
|
||||||
root.appendChild(parent);
|
root.appendChild(parent);
|
||||||
}
|
}
|
||||||
return root;
|
return root;
|
||||||
|
@ -108,6 +194,8 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
} else {
|
} else {
|
||||||
singleData.autocompleteType = AutocompleteType.fromValue(Integer.parseInt(item.getAttribute("autoCompleteType"))).getValue();
|
singleData.autocompleteType = AutocompleteType.fromValue(Integer.parseInt(item.getAttribute("autoCompleteType"))).getValue();
|
||||||
}
|
}
|
||||||
|
singleData.hasAuth = Boolean.parseBoolean(item.getAttribute("hasAuth"));
|
||||||
|
singleData.method = item.hasAttribute("method") ? item.getAttribute("method") : "GET";
|
||||||
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
||||||
if (optionElement != null) {
|
if (optionElement != null) {
|
||||||
singleData.autoCompleteOptions = new Option();
|
singleData.autoCompleteOptions = new Option();
|
||||||
|
@ -116,6 +204,17 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
singleData.autoCompleteOptions.setSource(optionElement.getAttribute("source"));
|
singleData.autoCompleteOptions.setSource(optionElement.getAttribute("source"));
|
||||||
singleData.autoCompleteOptions.setUri(optionElement.getAttribute("uri"));
|
singleData.autoCompleteOptions.setUri(optionElement.getAttribute("uri"));
|
||||||
}
|
}
|
||||||
|
if (singleData.hasAuth) {
|
||||||
|
Element authElement = (Element) item.getElementsByTagName("auth").item(0);
|
||||||
|
if (authElement != null) {
|
||||||
|
singleData.auth = new AuthAutoCompleteData();
|
||||||
|
singleData.auth.setUrl(authElement.getAttribute("url"));
|
||||||
|
singleData.auth.setMethod(authElement.getAttribute("method"));
|
||||||
|
singleData.auth.setBody(authElement.getAttribute("body"));
|
||||||
|
singleData.auth.setPath(authElement.getAttribute("path"));
|
||||||
|
singleData.auth.setType(authElement.getAttribute("type"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -141,6 +240,8 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions = new Option();
|
this.autoCompleteSingleDataList.get(i).autoCompleteOptions = new Option();
|
||||||
this.autoCompleteSingleDataList.get(i).url = (String) singleData.get("url");
|
this.autoCompleteSingleDataList.get(i).url = (String) singleData.get("url");
|
||||||
this.autoCompleteSingleDataList.get(i).optionsRoot = (String) singleData.get("optionsRoot");
|
this.autoCompleteSingleDataList.get(i).optionsRoot = (String) singleData.get("optionsRoot");
|
||||||
|
this.autoCompleteSingleDataList.get(i).hasAuth = (Boolean) singleData.get("hasAuth");
|
||||||
|
this.autoCompleteSingleDataList.get(i).method = singleData.containsKey("method") ? (String) singleData.get("method") : "GET";
|
||||||
|
|
||||||
if (singleData.get("autoCompleteType") == null) {
|
if (singleData.get("autoCompleteType") == null) {
|
||||||
this.autoCompleteSingleDataList.get(i).autocompleteType = AutocompleteType.UNCACHED.getValue();
|
this.autoCompleteSingleDataList.get(i).autocompleteType = AutocompleteType.UNCACHED.getValue();
|
||||||
|
@ -154,6 +255,17 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setSource(options.get("source"));
|
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setSource(options.get("source"));
|
||||||
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setUri(options.get("uri"));
|
this.autoCompleteSingleDataList.get(i).autoCompleteOptions.setUri(options.get("uri"));
|
||||||
}
|
}
|
||||||
|
if (this.autoCompleteSingleDataList.get(i).hasAuth) {
|
||||||
|
Map<String, String> auth = (Map<String, String>) singleData.get("auth");
|
||||||
|
if (auth != null) {
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth = new AuthAutoCompleteData();
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth.setUrl(auth.get("url"));
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth.setType(auth.get("type"));
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth.setPath(auth.get("path"));
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth.setBody(auth.get("body"));
|
||||||
|
this.autoCompleteSingleDataList.get(i).auth.setMethod(auth.get("method"));
|
||||||
|
}
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,6 +302,8 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
node.appendChild(autoCompleteSingles.item(i));
|
node.appendChild(autoCompleteSingles.item(i));
|
||||||
node.setAttribute("url", item.getAttribute("url"));
|
node.setAttribute("url", item.getAttribute("url"));
|
||||||
node.setAttribute("optionsRoot", item.getAttribute("optionsRoot"));
|
node.setAttribute("optionsRoot", item.getAttribute("optionsRoot"));
|
||||||
|
node.setAttribute("hasAuth", item.getAttribute("hasAuth"));
|
||||||
|
node.setAttribute("method", item.hasAttribute("method") ? item.getAttribute("method") : "GET");
|
||||||
autoCompletes.add(singleToMap(node));
|
autoCompletes.add(singleToMap(node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,6 +328,16 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
return dataMap;
|
return dataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> authToMap(Element item){
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("url", item != null ? item.getAttribute("url") : "");
|
||||||
|
dataMap.put("method", item != null ? item.getAttribute("method") : "");
|
||||||
|
dataMap.put("body", item != null ? item.getAttribute("body") : "");
|
||||||
|
dataMap.put("path", item != null ? item.getAttribute("path") : "");
|
||||||
|
dataMap.put("type", item != null ? item.getAttribute("type") : "");
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, Object> singleToMap(Element item) {
|
private Map<String, Object> singleToMap(Element item) {
|
||||||
Map<String, Object> dataMap = new HashMap<>();
|
Map<String, Object> dataMap = new HashMap<>();
|
||||||
if (!item.getAttribute("autoCompleteType").isEmpty()) {
|
if (!item.getAttribute("autoCompleteType").isEmpty()) {
|
||||||
|
@ -221,8 +345,12 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
}
|
}
|
||||||
dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : "");
|
dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : "");
|
||||||
dataMap.put("url", item != null ? item.getAttribute("url") : "");
|
dataMap.put("url", item != null ? item.getAttribute("url") : "");
|
||||||
|
dataMap.put("hasAuth", item != null ? item.getAttribute("hasAuth") : "false");
|
||||||
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
||||||
dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null);
|
dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null);
|
||||||
|
Element authElement = (Element) item.getElementsByTagName("auth").item(0);
|
||||||
|
dataMap.put("auth", item != null ? authToMap(authElement) : null);
|
||||||
|
dataMap.put("method", item != null && item.hasAttribute("method") ? item.getAttribute("method") : "GET");
|
||||||
return dataMap;
|
return dataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ public class MigrationController {
|
||||||
private final UserContactInfoMigrationService userContactInfoMigrationService;
|
private final UserContactInfoMigrationService userContactInfoMigrationService;
|
||||||
private final DmpUserMigrationService dmpUserMigrationService;
|
private final DmpUserMigrationService dmpUserMigrationService;
|
||||||
private final UserMigrationService userMigrationService;
|
private final UserMigrationService userMigrationService;
|
||||||
private final DmpBlueprintMigrationService dmpBlueprintMigrationService;
|
private final DmpBlueprintXmlMigrationService dmpBlueprintXmlMigrationService;
|
||||||
|
private final DescriptionTemplateXmlMigrationService descriptionTemplateXmlMigrationService;
|
||||||
|
|
||||||
public MigrationController(
|
public MigrationController(
|
||||||
DmpMigrationService dmpMigrationService,
|
DmpMigrationService dmpMigrationService,
|
||||||
|
@ -58,7 +59,8 @@ public class MigrationController {
|
||||||
UserContactInfoMigrationService userContactInfoMigrationService,
|
UserContactInfoMigrationService userContactInfoMigrationService,
|
||||||
DmpUserMigrationService dmpUserMigrationService,
|
DmpUserMigrationService dmpUserMigrationService,
|
||||||
UserMigrationService userMigrationService,
|
UserMigrationService userMigrationService,
|
||||||
DmpBlueprintMigrationService dmpBlueprintMigrationService) {
|
DmpBlueprintXmlMigrationService dmpBlueprintXmlMigrationService,
|
||||||
|
DescriptionTemplateXmlMigrationService descriptionTemplateXmlMigrationService) {
|
||||||
this.dmpMigrationService = dmpMigrationService;
|
this.dmpMigrationService = dmpMigrationService;
|
||||||
this.datasetMigrationService = datasetMigrationService;
|
this.datasetMigrationService = datasetMigrationService;
|
||||||
this.dmpDatasetProfileMigrationService = dmpDatasetProfileMigrationService;
|
this.dmpDatasetProfileMigrationService = dmpDatasetProfileMigrationService;
|
||||||
|
@ -76,7 +78,8 @@ public class MigrationController {
|
||||||
this.userContactInfoMigrationService = userContactInfoMigrationService;
|
this.userContactInfoMigrationService = userContactInfoMigrationService;
|
||||||
this.dmpUserMigrationService = dmpUserMigrationService;
|
this.dmpUserMigrationService = dmpUserMigrationService;
|
||||||
this.userMigrationService = userMigrationService;
|
this.userMigrationService = userMigrationService;
|
||||||
this.dmpBlueprintMigrationService = dmpBlueprintMigrationService;
|
this.dmpBlueprintXmlMigrationService = dmpBlueprintXmlMigrationService;
|
||||||
|
this.descriptionTemplateXmlMigrationService = descriptionTemplateXmlMigrationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("all")
|
@GetMapping("all")
|
||||||
|
@ -105,14 +108,23 @@ public class MigrationController {
|
||||||
this.userMigrationService.migrate();
|
this.userMigrationService.migrate();
|
||||||
|
|
||||||
//XML recreate
|
//XML recreate
|
||||||
this.dmpBlueprintMigrationService.migrate();
|
this.dmpBlueprintXmlMigrationService.migrate();
|
||||||
|
this.descriptionTemplateXmlMigrationService.migrate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("dmp-blueprints")
|
@GetMapping("dmp-blueprints-xml")
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean migrateDmpBlueprint() throws JAXBException, InvalidApplicationException, IOException, ParserConfigurationException, NoSuchFieldException, TransformerException, IllegalAccessException, InstantiationException, SAXException {
|
public boolean migrateDmpBlueprint() throws JAXBException, InvalidApplicationException, IOException, ParserConfigurationException, NoSuchFieldException, TransformerException, IllegalAccessException, InstantiationException, SAXException {
|
||||||
this.dmpBlueprintMigrationService.migrate();
|
this.dmpBlueprintXmlMigrationService.migrate();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("description-template-xml")
|
||||||
|
@Transactional
|
||||||
|
public boolean migrateDescriptionTemplate() throws JAXBException, InvalidApplicationException, IOException, ParserConfigurationException, NoSuchFieldException, TransformerException, IllegalAccessException, InstantiationException, SAXException {
|
||||||
|
this.descriptionTemplateXmlMigrationService.migrate();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue