Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
5377b1db18
|
@ -1,11 +1,6 @@
|
|||
package eu.eudat.commons;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import eu.eudat.commons.types.dmpblueprint.DefinitionEntity;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||
import jakarta.xml.bind.JAXBContext;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import jakarta.xml.bind.Marshaller;
|
||||
|
@ -44,13 +39,8 @@ public class XmlHandlingService {
|
|||
return writer.toString();
|
||||
}
|
||||
|
||||
public String toXml(Object item) throws JsonProcessingException, JAXBException, ParserConfigurationException, InvalidApplicationException, TransformerException {
|
||||
if (XmlSerializable.class.isAssignableFrom(item.getClass())){
|
||||
Document document = this.getDocument();
|
||||
if (document == null) throw new InvalidApplicationException("Can not create document");
|
||||
document.appendChild(((XmlSerializable)item).toXml(document));
|
||||
return this.generateXml(document);
|
||||
}
|
||||
public String toXml(Object item) throws JAXBException {
|
||||
|
||||
|
||||
JAXBContext context = JAXBContext.newInstance(item.getClass());
|
||||
Marshaller marshaller = context.createMarshaller();
|
||||
|
@ -69,15 +59,10 @@ public class XmlHandlingService {
|
|||
}
|
||||
|
||||
public <T> T fromXml(Class<T> type, String xmlString) throws JAXBException, InstantiationException, IllegalAccessException, ParserConfigurationException, IOException, SAXException {
|
||||
if (XmlSerializable.class.isAssignableFrom(type)){
|
||||
XmlSerializable<T> object = (XmlSerializable<T>)type.newInstance();
|
||||
return (T) object.fromXml(this.getDocument(xmlString).getDocumentElement());
|
||||
} else {
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(type);
|
||||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(type);
|
||||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||
|
||||
return (T) jaxbUnmarshaller.unmarshal(new StringReader(xmlString));
|
||||
}
|
||||
return (T) jaxbUnmarshaller.unmarshal(new StringReader(xmlString));
|
||||
}
|
||||
|
||||
public <T> T fromXmlSafe(Class<T> type, String xmlString) {
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate;
|
||||
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
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.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "root")
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate;
|
||||
|
||||
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
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.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate;
|
||||
|
||||
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
|
||||
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.Element;
|
||||
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate;
|
||||
|
||||
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.Element;
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class RuleEntity {
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate.fielddata;
|
||||
|
||||
import eu.eudat.commons.enums.FieldType;
|
||||
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.Element;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
package eu.eudat.commons.types.descriptiontemplate.importexport.fielddata;
|
||||
|
||||
import eu.eudat.commons.enums.FieldType;
|
||||
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.Map;
|
||||
|
||||
public abstract class BaseFieldDataImportExport {
|
||||
@XmlAttribute(name = "label")
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
package eu.eudat.commons.types.dmpblueprint;
|
||||
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
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;
|
||||
|
||||
@XmlRootElement(name = "root")
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package eu.eudat.commons.types.dmpblueprint;
|
||||
|
||||
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.Element;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
package eu.eudat.commons.types.dmpblueprint;
|
||||
|
||||
import eu.eudat.commons.enums.DmpBlueprintExtraFieldDataType;
|
||||
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
||||
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 jakarta.xml.bind.annotation.XmlTransient;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
package eu.eudat.commons.types.dmpblueprint;
|
||||
|
||||
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeSourceBaseConfigurationEntity;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeSourceExternalApiConfigurationEntity;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeSourceStaticOptionConfigurationEntity;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
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.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class SectionEntity {
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
package eu.eudat.commons.types.dmpblueprint;
|
||||
|
||||
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
||||
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
|
||||
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.Element;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class SystemFieldEntity extends FieldEntity {
|
||||
|
|
|
@ -54,5 +54,5 @@ public class DmpToPublicApiDmpMapper {
|
|||
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
package eu.eudat.model.publicapi.associatedprofile;
|
||||
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||
import eu.eudat.model.DescriptionTemplate;
|
||||
import eu.eudat.model.DmpDescriptionTemplate;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import jakarta.xml.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AssociatedProfilePublicModel implements XmlSerializable<AssociatedProfilePublicModel> {
|
||||
@XmlRootElement(name = "profile")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class AssociatedProfilePublicModel {
|
||||
@XmlAttribute(name="profileId")
|
||||
private UUID id;
|
||||
@XmlAttribute(name="descriptionTemplateId")
|
||||
private UUID descriptionTemplateId;
|
||||
@XmlAttribute(name="label")
|
||||
private String label;
|
||||
@XmlElement(name="data")
|
||||
private Map<String, Object> data;
|
||||
|
||||
public UUID getId() {
|
||||
|
@ -49,36 +50,8 @@ public class AssociatedProfilePublicModel implements XmlSerializable<AssociatedP
|
|||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element profile = doc.createElement("profile");
|
||||
profile.setAttribute("profileId", this.id.toString());
|
||||
profile.setAttribute("label", this.label);
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssociatedProfilePublicModel fromXml(Element item) {
|
||||
this.descriptionTemplateId = UUID.fromString(item.getAttribute("profileId"));
|
||||
this.label = item.getAttribute("label");
|
||||
return this;
|
||||
}
|
||||
|
||||
public static AssociatedProfilePublicModel fromDmpDescriptionTemplate(DmpDescriptionTemplate dmpDescriptionTemplate) {
|
||||
AssociatedProfilePublicModel model = new AssociatedProfilePublicModel();
|
||||
return model;
|
||||
}
|
||||
|
||||
public DescriptionTemplateEntity toData() {
|
||||
DescriptionTemplateEntity profile = new DescriptionTemplateEntity();
|
||||
profile.setId(this.descriptionTemplateId);
|
||||
profile.setLabel(this.label);
|
||||
return profile;
|
||||
}
|
||||
|
||||
public AssociatedProfilePublicModel fromData(DescriptionTemplateEntity entity) {
|
||||
this.descriptionTemplateId = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import eu.eudat.commons.XmlHandlingService;
|
|||
import eu.eudat.commons.enums.*;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.commons.types.dmpblueprint.*;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.logic.xml.XmlBuilder;
|
||||
import eu.eudat.data.*;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.logic.managers;
|
|||
|
||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.logic.xml.XmlBuilder;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||
import eu.eudat.service.remotefetcher.config.entities.GeneralUrls;
|
||||
|
@ -23,18 +23,9 @@ import org.springframework.http.MediaType;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.xpath.*;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.logic.utilities.documents.xml;
|
|||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.logic.xml.XmlBuilder;
|
||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.ExternalDatasetDataEntity;
|
||||
import eu.eudat.models.data.user.components.datasetprofile.Field;
|
||||
import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
||||
|
|
|
@ -6,7 +6,7 @@ import eu.eudat.models.data.admin.components.datasetprofile.Page;
|
|||
import eu.eudat.models.data.user.components.datasetprofile.Field;
|
||||
import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
||||
import eu.eudat.models.data.user.components.datasetprofile.Section;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.logic.xml.XmlBuilder;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.w3c.dom.Document;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.commons.types.xml;
|
||||
package eu.eudat.logic.xml;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.commons.types.xml;
|
||||
package eu.eudat.logic.xml;
|
||||
|
||||
|
||||
import org.w3c.dom.Document;
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.models.data.dmp;
|
||||
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.commons.types.xml.XmlSerializable;
|
||||
import eu.eudat.logic.xml.XmlSerializable;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.jayway.jsonpath.JsonPath;
|
||||
import eu.eudat.data.DescriptionEntity;
|
||||
import eu.eudat.logic.managers.DatasetManager;
|
||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||
import eu.eudat.logic.xml.XmlBuilder;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
|
Loading…
Reference in New Issue