diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java index b307538d7..871c87bc2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java @@ -92,21 +92,21 @@ public class DMPProfileController extends BaseController { @RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json") public @ResponseBody - ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException, IOException { + ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IOException { if (contentType.equals("application/xml")) { - DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(id, principal); - return this.dataManagementProfileManager.getDocument(dataManagementPlanProfileListingModel,dataManagementPlanProfileListingModel.getLabel()); + DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal); + return this.dataManagementProfileManager.getDocument(dataManagementPlanBlueprintListingModel); }else { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE")); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE")); } } @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) public ResponseEntity setDatasetProfileXml(@RequestParam("file") MultipartFile file, - @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException,IOException,Exception{ - eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile dmpProfileModel = this.dataManagementProfileManager.createDmpProfileFromXml(file); - DataManagementPlanProfileListingModel dataManagementPlan = dmpProfileModel.toDmpProfileCompositeModel(file.getOriginalFilename()); - this.dataManagementProfileManager.createOrUpdate(dataManagementPlan, principal); + @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception { + eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint dmpBlueprintModel = this.dataManagementProfileManager.createDmpProfileFromXml(file); + DataManagementPlanBlueprintListingModel dmpBlueprint = dmpBlueprintModel.toDmpProfileCompositeModel(file.getOriginalFilename()); + this.dataManagementProfileManager.createOrUpdateBlueprint(dmpBlueprint, principal); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>() .status(ApiMessageCode.SUCCESS_MESSAGE).message("")); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java index fb0427993..4b6d4dc6a 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java @@ -3,7 +3,6 @@ package eu.eudat.logic.managers; import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; import eu.eudat.data.dao.criteria.RequestItem; -import eu.eudat.data.dao.entities.DMPProfileDao; import eu.eudat.data.entities.DMPProfile; import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest; import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest; @@ -11,8 +10,8 @@ import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTable import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.utilities.builders.XmlBuilder; import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; -import eu.eudat.logic.utilities.documents.xml.dmpXml.ExportXmlBuilderDmpProfile; -import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpProfile; +import eu.eudat.logic.utilities.documents.xml.dmpXml.ExportXmlBuilderDmpBlueprint; +import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpBlueprint; import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.*; import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType; @@ -141,8 +140,8 @@ public class DataManagementProfileManager { apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile); } - public ResponseEntity getDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws IllegalAccessException, IOException, InstantiationException { - FileEnvelope envelope = getXmlDocument(dmpProfile, label); + public ResponseEntity getDocument(DataManagementPlanBlueprintListingModel dmpProfile) throws IOException { + FileEnvelope envelope = getXmlDocument(dmpProfile); InputStream resource = new FileInputStream(envelope.getFile()); logger.info("Mime Type of " + envelope.getFilename() + " is " + new MimetypesFileTypeMap().getContentType(envelope.getFile())); @@ -161,18 +160,18 @@ public class DataManagementProfileManager { HttpStatus.OK); } - public FileEnvelope getXmlDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws InstantiationException, IllegalAccessException, IOException { - ExportXmlBuilderDmpProfile xmlBuilder = new ExportXmlBuilderDmpProfile(); + public FileEnvelope getXmlDocument(DataManagementPlanBlueprintListingModel dmpProfile) throws IOException { + ExportXmlBuilderDmpBlueprint xmlBuilder = new ExportXmlBuilderDmpBlueprint(); File file = xmlBuilder.build(dmpProfile, environment); FileEnvelope fileEnvelope = new FileEnvelope(); fileEnvelope.setFile(file); - fileEnvelope.setFilename(label); + fileEnvelope.setFilename(dmpProfile.getLabel()); return fileEnvelope; } - public eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile createDmpProfileFromXml(MultipartFile multiPartFile) { - ImportXmlBuilderDmpProfile xmlBuilder = new ImportXmlBuilderDmpProfile(); + public eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint createDmpProfileFromXml(MultipartFile multiPartFile) { + ImportXmlBuilderDmpBlueprint xmlBuilder = new ImportXmlBuilderDmpBlueprint(); try { return xmlBuilder.build(convert(multiPartFile)); } catch (IOException e) { diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ExportXmlBuilderDmpBlueprint.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ExportXmlBuilderDmpBlueprint.java new file mode 100644 index 000000000..478a3127a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ExportXmlBuilderDmpBlueprint.java @@ -0,0 +1,46 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml; + +import eu.eudat.logic.utilities.builders.XmlBuilder; + +import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint; +import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section; +import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel; +import org.springframework.core.env.Environment; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.UUID; + +public class ExportXmlBuilderDmpBlueprint { + + + public File build(DataManagementPlanBlueprintListingModel dmpProfile, Environment environment) throws IOException { + + File xmlFile = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".xml"); + BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true)); + Document xmlDoc = XmlBuilder.getDocument(); + Element root = xmlDoc.createElement("root"); + Element definition = xmlDoc.createElement("definition"); +// Element root = xmlDoc.createElement(dmpProfile.getLabel()); + definition.appendChild(createDefinition(dmpProfile.getDefinition(), xmlDoc)); + root.appendChild(definition); + xmlDoc.appendChild(root); + String xml = XmlBuilder.generateXml(xmlDoc); + writer.write(xml); + writer.close(); + return xmlFile; + } + + public Element createDefinition(DataManagementPlanBlueprint dmpDefinition, Document doc) { + Element sections = doc.createElement("sections"); + for (Section section : dmpDefinition.getSections()) { + sections.appendChild(section.toXml(doc)); + } + return sections; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ExportXmlBuilderDmpProfile.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ExportXmlBuilderDmpProfile.java deleted file mode 100644 index 212facc14..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ExportXmlBuilderDmpProfile.java +++ /dev/null @@ -1,56 +0,0 @@ -package eu.eudat.logic.utilities.documents.xml.dmpXml; - -import eu.eudat.logic.utilities.builders.XmlBuilder; - -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile; -import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel; -import org.springframework.core.env.Environment; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.UUID; - -public class ExportXmlBuilderDmpProfile { - - - public File build(DataManagementPlanProfileListingModel dmpProfile, Environment environment) throws IOException { - - File xmlFile = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".xml"); - BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true)); - Document xmlDoc = XmlBuilder.getDocument(); - Element root = xmlDoc.createElement("root"); - Element definition = xmlDoc.createElement("definition"); -// Element root = xmlDoc.createElement(dmpProfile.getLabel()); - definition.appendChild(createDefinition(dmpProfile.getDefinition(), xmlDoc)); - root.appendChild(definition); - xmlDoc.appendChild(root); - String xml = XmlBuilder.generateXml(xmlDoc); - writer.write(xml); - writer.close(); - return xmlFile; - } - - public Element createDefinition(DataManagementPlanProfile dmpDefinition, Document element) { - Element fields = element.createElement("fieldSets"); - dmpDefinition.getFields().forEach(item -> { - Element field = element.createElement("field"); - field.setAttribute("id", "" + item.getId()); - field.setAttribute("type", "" + item.getType()); - field.setAttribute("dataType", "" + item.getDataType()); - field.setAttribute("required", "" + item.getRequired()); - field.setAttribute("label", "" + item.getLabel()); - if(item.getValue()!=null) { - Element value = element.createElement("value"); - value.setAttribute("value", ""+item.getValue()); - field.appendChild(value); - } - fields.appendChild(field); - }); - return fields; - } - -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ImportXmlBuilderDmpProfile.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ImportXmlBuilderDmpBlueprint.java similarity index 57% rename from dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ImportXmlBuilderDmpProfile.java rename to dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ImportXmlBuilderDmpBlueprint.java index 7962beb51..3f4628787 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ImportXmlBuilderDmpProfile.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ImportXmlBuilderDmpBlueprint.java @@ -1,6 +1,6 @@ package eu.eudat.logic.utilities.documents.xml.dmpXml; -import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile; +import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -10,16 +10,16 @@ import javax.xml.bind.Unmarshaller; import java.io.File; import java.io.IOException; -public class ImportXmlBuilderDmpProfile { - private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDmpProfile.class); +public class ImportXmlBuilderDmpBlueprint { + private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDmpBlueprint.class); - public DmpProfile build(File xmlFile) throws IOException { - DmpProfile dmpProfile = new DmpProfile(); + public DmpBlueprint build(File xmlFile) throws IOException { + DmpBlueprint dmpProfile = new DmpBlueprint(); JAXBContext jaxbContext = null; try { - jaxbContext = JAXBContext.newInstance(DmpProfile.class); + jaxbContext = JAXBContext.newInstance(DmpBlueprint.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); - dmpProfile = (DmpProfile) unmarshaller.unmarshal(xmlFile); + dmpProfile = (DmpBlueprint) unmarshaller.unmarshal(xmlFile); } catch (JAXBException e) { logger.error(e.getMessage(), e); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DescriptionTemplate.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DescriptionTemplate.java new file mode 100644 index 000000000..41d5dce25 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DescriptionTemplate.java @@ -0,0 +1,73 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; + +import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.UUID; + +@XmlRootElement(name = "descriptionTemplate") +public class DescriptionTemplate { + + private String id; + private String descriptionTemplateId; + private String label; + private int minMultiplicity; + private int maxMultiplicity; + + @XmlAttribute(name = "id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @XmlAttribute(name = "descriptionTemplateId") + public String getDescriptionTemplateId() { + return descriptionTemplateId; + } + + public void setDescriptionTemplateId(String descriptionTemplateId) { + this.descriptionTemplateId = descriptionTemplateId; + } + + @XmlAttribute(name = "label") + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @XmlAttribute(name = "minMultiplicity") + public int getMinMultiplicity() { + return minMultiplicity; + } + + public void setMinMultiplicity(int minMultiplicity) { + this.minMultiplicity = minMultiplicity; + } + + @XmlAttribute(name = "maxMultiplicity") + public int getMaxMultiplicity() { + return maxMultiplicity; + } + + public void setMaxMultiplicity(int maxMultiplicity) { + this.maxMultiplicity = maxMultiplicity; + } + + public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate toDmpBlueprintCompositeModel() { + eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate descriptionTemplate = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate(); + descriptionTemplate.setId(UUID.fromString(this.id)); + descriptionTemplate.setDescriptionTemplateId(UUID.fromString(this.descriptionTemplateId)); + descriptionTemplate.setLabel(this.label); + descriptionTemplate.setMinMultiplicity(this.minMultiplicity); + descriptionTemplate.setMaxMultiplicity(this.maxMultiplicity); + return descriptionTemplate; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DescriptionTemplates.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DescriptionTemplates.java new file mode 100644 index 000000000..e4f9390d3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DescriptionTemplates.java @@ -0,0 +1,20 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement(name = "descriptionTemplates") +public class DescriptionTemplates { + + private List descriptionTemplates; + + @XmlElement(name = "descriptionTemplate") + public List getDescriptionTemplates() { + return descriptionTemplates; + } + public void setDescriptionTemplates(List descriptionTemplates) { + this.descriptionTemplates = descriptionTemplates; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprint.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprint.java new file mode 100644 index 000000000..ecb06cb71 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprint.java @@ -0,0 +1,35 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; + +import eu.eudat.data.entities.DMPProfile; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.Date; + +@XmlRootElement(name = "root") +public class DmpBlueprint { + + private DmpBlueprintDefinition dmpBlueprintDefinition; + + @XmlElement(name = "definition") + public DmpBlueprintDefinition getDmpBlueprintDefinition() { + return dmpBlueprintDefinition; + } + + public void setDmpBlueprintDefinition(DmpBlueprintDefinition dmpBlueprintDefinition) { + this.dmpBlueprintDefinition = dmpBlueprintDefinition; + } + + public eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel toDmpProfileCompositeModel(String label) { + eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel dmpProfileModel = new eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel(); + dmpProfileModel.setLabel(label); + dmpProfileModel.setStatus(DMPProfile.Status.SAVED.getValue()); + dmpProfileModel.setCreated(new Date()); + dmpProfileModel.setModified(new Date()); + if (this.dmpBlueprintDefinition != null) { + dmpProfileModel.setDefinition(this.dmpBlueprintDefinition.toDmpBlueprintCompositeModel()); + } + return dmpProfileModel; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprintDefinition.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprintDefinition.java new file mode 100644 index 000000000..d3e8218a2 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprintDefinition.java @@ -0,0 +1,34 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.LinkedList; +import java.util.List; + +@XmlRootElement(name = "definition") +public class DmpBlueprintDefinition { + + private Sections sections; + + @XmlElement(name = "sections") + public Sections getSections() { + return sections; + } + public void setSections(Sections sections) { + this.sections = sections; + } + + + public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint toDmpBlueprintCompositeModel() { + eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint dmpBlueprint = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint(); + List dmpBlueprintSections = new LinkedList<>(); + if (this.sections != null && this.sections.getSections() != null) { + for (Section section : this.sections.getSections()) { + dmpBlueprintSections.add(section.toDmpBlueprintCompositeModel()); + } + } + dmpBlueprint.setSections(dmpBlueprintSections); + return dmpBlueprint; + } + +} \ No newline at end of file diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/ExtraField.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/ExtraField.java new file mode 100644 index 000000000..004b3c74d --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/ExtraField.java @@ -0,0 +1,96 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; + +import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.UUID; + +@XmlRootElement(name = "extraField") +public class ExtraField { + + private String id; + private int type; + private String label; + private String placeholder; + private String description; + private int ordinal; + private boolean required; + + @XmlAttribute(name = "id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @XmlAttribute(name = "type") + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + @XmlAttribute(name = "label") + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @XmlAttribute(name = "placeholder") + public String getPlaceholder() { + return placeholder; + } + + public void setPlaceholder(String placeholder) { + this.placeholder = placeholder; + } + + @XmlAttribute(name = "description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @XmlAttribute(name = "ordinal") + public int getOrdinal() { + return ordinal; + } + + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } + + @XmlAttribute(name = "required") + public boolean isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } + + public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel toDmpBlueprintCompositeModel() { + eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel systemField = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel(); + systemField.setId(UUID.fromString(this.id)); + systemField.setCategory(FieldCategory.EXTRA); + systemField.setType(this.type); + systemField.setLabel(this.label); + systemField.setPlaceholder(this.placeholder); + systemField.setDescription(this.description); + systemField.setOrdinal(this.ordinal); + systemField.setRequired(this.required); + return systemField; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/ExtraFields.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/ExtraFields.java new file mode 100644 index 000000000..2a3d12d6f --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/ExtraFields.java @@ -0,0 +1,20 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement(name = "extraFields") +public class ExtraFields { + + private List extraFields; + + @XmlElement(name = "extraField") + public List getExtraFields() { + return extraFields; + } + public void setExtraFields(List extraFields) { + this.extraFields = extraFields; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/Section.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/Section.java new file mode 100644 index 000000000..551302325 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/Section.java @@ -0,0 +1,123 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +@XmlRootElement(name = "section") +public class Section { + + private String id; + private String label; + private String description; + private int ordinal; + private SystemFields systemFields; + private ExtraFields extraFields; + private boolean hasTemplates; + private DescriptionTemplates descriptionTemplates; + + @XmlAttribute(name = "id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @XmlAttribute(name = "label") + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @XmlAttribute(name = "description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @XmlAttribute(name = "ordinal") + public int getOrdinal() { + return ordinal; + } + + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } + + @XmlElement(name = "systemFields") + public SystemFields getSystemFields() { + return systemFields; + } + + public void setSystemFields(SystemFields systemFields) { + this.systemFields = systemFields; + } + + @XmlElement(name = "extraFields") + public ExtraFields getExtraFields() { + return extraFields; + } + + public void setExtraFields(ExtraFields extraFields) { + this.extraFields = extraFields; + } + + @XmlAttribute(name = "hasTemplates") + public boolean isHasTemplates() { + return hasTemplates; + } + + public void setHasTemplates(boolean hasTemplates) { + this.hasTemplates = hasTemplates; + } + + @XmlElement(name = "descriptionTemplates") + public DescriptionTemplates getDescriptionTemplates() { + return descriptionTemplates; + } + + public void setDescriptionTemplates(DescriptionTemplates descriptionTemplates) { + this.descriptionTemplates = descriptionTemplates; + } + + public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section toDmpBlueprintCompositeModel() { + eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section section = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section(); + section.setId(UUID.fromString(this.id)); + section.setLabel(this.label); + section.setDescription(this.description); + section.setOrdinal(this.ordinal); + section.setHasTemplates(this.hasTemplates); + List dmpBlueprintFieldModels = new LinkedList<>(); + if (this.systemFields != null && this.systemFields.getSystemFields() != null) { + for (SystemField systemField : this.systemFields.getSystemFields()) { + dmpBlueprintFieldModels.add(systemField.toDmpBlueprintCompositeModel()); + } + } + if (this.extraFields != null&& this.extraFields.getExtraFields() != null) { + for (ExtraField extraField : this.extraFields.getExtraFields()) { + dmpBlueprintFieldModels.add(extraField.toDmpBlueprintCompositeModel()); + } + } + section.setFields(dmpBlueprintFieldModels); + List dmpBlueprintDescriptionTemplates = new LinkedList<>(); + if (this.descriptionTemplates != null && this.descriptionTemplates.getDescriptionTemplates() != null) { + for (DescriptionTemplate descriptionTemplate : this.descriptionTemplates.getDescriptionTemplates()) { + dmpBlueprintDescriptionTemplates.add(descriptionTemplate.toDmpBlueprintCompositeModel()); + } + } + section.setDescriptionTemplates(dmpBlueprintDescriptionTemplates); + return section; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/Sections.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/Sections.java new file mode 100644 index 000000000..3dd99293c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/Sections.java @@ -0,0 +1,19 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement(name = "sections") +public class Sections { + + private List
sections; + + @XmlElement(name = "section") + public List
getSections() { + return sections; + } + public void setSections(List
sections) { + this.sections = sections; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/SystemField.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/SystemField.java new file mode 100644 index 000000000..eded49aa0 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/SystemField.java @@ -0,0 +1,96 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; + +import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.UUID; + +@XmlRootElement(name = "systemField") +public class SystemField { + + private String id; + private int type; + private String label; + private String placeholder; + private String description; + private int ordinal; + private boolean required; + + @XmlAttribute(name = "id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @XmlAttribute(name = "type") + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + @XmlAttribute(name = "label") + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @XmlAttribute(name = "placeholder") + public String getPlaceholder() { + return placeholder; + } + + public void setPlaceholder(String placeholder) { + this.placeholder = placeholder; + } + + @XmlAttribute(name = "description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @XmlAttribute(name = "ordinal") + public int getOrdinal() { + return ordinal; + } + + public void setOrdinal(int ordinal) { + this.ordinal = ordinal; + } + + @XmlAttribute(name = "required") + public boolean isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } + + public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel toDmpBlueprintCompositeModel() { + eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel systemField = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel(); + systemField.setId(UUID.fromString(this.id)); + systemField.setCategory(FieldCategory.SYSTEM); + systemField.setType(this.type); + systemField.setLabel(this.label); + systemField.setPlaceholder(this.placeholder); + systemField.setDescription(this.description); + systemField.setOrdinal(this.ordinal); + systemField.setRequired(this.required); + return systemField; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/SystemFields.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/SystemFields.java new file mode 100644 index 000000000..7ad5a27a3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/SystemFields.java @@ -0,0 +1,20 @@ +package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement(name = "systemFields") +public class SystemFields { + + private List systemFields; + + @XmlElement(name = "systemField") + public List getSystemFields() { + return systemFields; + } + public void setSystemFields(List systemFields) { + this.systemFields = systemFields; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DMPProfileFieldDataType.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DMPProfileFieldDataType.java deleted file mode 100644 index e5d685162..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DMPProfileFieldDataType.java +++ /dev/null @@ -1,23 +0,0 @@ -package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "datatype") -public class DMPProfileFieldDataType { - - private int datatype; - - @XmlAttribute(name = "datatype") - public int getDatatype() { - return datatype; - } - - public void setDatatype(int datatype) { - this.datatype = datatype; - } - - public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileFieldDataType toDmpProfileCompositeModel() { - return eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileFieldDataType.fromInteger(datatype); - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DMPProfileType.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DMPProfileType.java deleted file mode 100644 index a13117dce..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DMPProfileType.java +++ /dev/null @@ -1,26 +0,0 @@ -package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel; - - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "type") -public class DMPProfileType { - - private int type; - - @XmlAttribute(name = "type") - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileType toDmpProfileCompositeModel() { - return eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileType.fromInteger(type); - } - - -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DmpProfile.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DmpProfile.java deleted file mode 100644 index 3e9138a46..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DmpProfile.java +++ /dev/null @@ -1,33 +0,0 @@ -package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel; - -import eu.eudat.data.entities.DMPProfile; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.Date; -import java.util.UUID; - -@XmlRootElement(name = "root") -public class DmpProfile { - - private DmpProfileDefinition dmpProfileDefinition; - - @XmlElement(name = "definition") - public DmpProfileDefinition getDmpProfileDefinition() { - return dmpProfileDefinition; - } - - public void setDmpProfileDefinition(DmpProfileDefinition dmpProfileDefinition) { - this.dmpProfileDefinition = dmpProfileDefinition; - } - - public eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel toDmpProfileCompositeModel(String label) { - eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel dmpProfileModel = new eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel(); - dmpProfileModel.setLabel(label); - dmpProfileModel.setStatus(DMPProfile.Status.SAVED.getValue()); - dmpProfileModel.setCreated(new Date()); - dmpProfileModel.setModified(new Date()); - dmpProfileModel.setDefinition(this.dmpProfileDefinition.toDmpProfileCompositeModel()); - return dmpProfileModel; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DmpProfileDefinition.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DmpProfileDefinition.java deleted file mode 100644 index 4cc4977e4..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/DmpProfileDefinition.java +++ /dev/null @@ -1,36 +0,0 @@ -package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel; - - -import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.FieldSets; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.LinkedList; -import java.util.List; - -@XmlRootElement(name = "definition") -public class DmpProfileDefinition { - - private FieldSets fieldSets; - - @XmlElement(name = "fieldSets") - public FieldSets getFieldSets() { - return fieldSets; - } - - public void setFieldSets(FieldSets fieldSets) { - this.fieldSets = fieldSets; - } - - public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile toDmpProfileCompositeModel() { - eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile dmpProfileDefinitionModel = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile(); - List dmpProfileDefinitionFields = new LinkedList<>(); - for (Field field:this.fieldSets.fields) { - dmpProfileDefinitionFields.add(field.toDmpProfileCompositeModel()); - } - dmpProfileDefinitionModel.setFields(dmpProfileDefinitionFields); - return dmpProfileDefinitionModel; - } - - -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/Field.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/Field.java deleted file mode 100644 index 28ca0a0f6..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/Field.java +++ /dev/null @@ -1,90 +0,0 @@ -package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel; - - - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; -import java.util.UUID; - -@XmlRootElement(name = "field") -public class Field { - - private String id; - - private String label; - - private int dataType; - - private boolean required; - - private int type; - -// private Object value; - - @XmlAttribute(name = "id") - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - @XmlAttribute(name = "label") - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - @XmlAttribute(name = "dataType") - public int getDataType() { - return dataType; - } - - public void setDataType(int dataType) { - this.dataType = dataType; - } - - @XmlAttribute(name = "required") - public boolean isRequired() { - return required; - } - - public void setRequired(boolean required) { - this.required = required; - } - - @XmlAttribute(name = "type") - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - -// @XmlValue -// public Object getValue() { -// return value; -// } -// -// public void setValue(Object value) { -// this.value = value; -// } - - public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field toDmpProfileCompositeModel() { - eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field field = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field(); - field.setId(UUID.fromString(this.id)); - field.setDataType(eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileFieldDataType.fromInteger(this.dataType)); - field.setLabel(this.label); - field.setRequired(this.required); - field.setType(eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileType.fromInteger(this.type)); - // field.setValue(this.value); - return field; - } - -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/FieldSets.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/FieldSets.java deleted file mode 100644 index b8f56fd70..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpProfileModel/FieldSets.java +++ /dev/null @@ -1,22 +0,0 @@ -package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.LinkedList; -import java.util.List; - -@XmlRootElement(name = "fieldSets") -public class FieldSets { - - List fields; - - @XmlElement(name = "field") - public List getField() { - return fields; - } - - public void setField(List fields) { - this.fields = fields; - } - -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/SystemFieldType.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/SystemFieldType.java index d7c36023a..306c999e8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/SystemFieldType.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/SystemFieldType.java @@ -49,7 +49,7 @@ public enum SystemFieldType { case 10: return ACCESS_RIGHTS; default: - throw new RuntimeException("Unsupported System Field Type"); + throw new RuntimeException("Unsupported System Section Type"); } } } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html index 197d737b6..f30781fdc 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html @@ -12,10 +12,10 @@ {{'DMP-PROFILE-EDITOR.ACTIONS.DELETE' | translate}} - +
diff --git a/dmp-frontend/src/app/ui/admin/dmp-profile/listing/dmp-profile-listing.component.html b/dmp-frontend/src/app/ui/admin/dmp-profile/listing/dmp-profile-listing.component.html index 767e8dba1..582bb35ce 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-profile/listing/dmp-profile-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-profile/listing/dmp-profile-listing.component.html @@ -6,11 +6,11 @@
- +