#8998 - implement import/export functionality for dmp blueprints

This commit is contained in:
Bernaldo Mihasi 2023-09-26 09:35:59 +03:00
parent 32c45520b4
commit c99267d6cc
24 changed files with 611 additions and 316 deletions

View File

@ -92,21 +92,21 @@ public class DMPProfileController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json") @RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
public @ResponseBody 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")) { if (contentType.equals("application/xml")) {
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(id, principal); DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
return this.dataManagementProfileManager.getDocument(dataManagementPlanProfileListingModel,dataManagementPlanProfileListingModel.getLabel()); return this.dataManagementProfileManager.getDocument(dataManagementPlanBlueprintListingModel);
}else { }else {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE")); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
} }
} }
@RequestMapping(method = RequestMethod.POST, value = {"/upload"}) @RequestMapping(method = RequestMethod.POST, value = {"/upload"})
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file, public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException,IOException,Exception{ @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile dmpProfileModel = this.dataManagementProfileManager.createDmpProfileFromXml(file); eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint dmpBlueprintModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
DataManagementPlanProfileListingModel dataManagementPlan = dmpProfileModel.toDmpProfileCompositeModel(file.getOriginalFilename()); DataManagementPlanBlueprintListingModel dmpBlueprint = dmpBlueprintModel.toDmpProfileCompositeModel(file.getOriginalFilename());
this.dataManagementProfileManager.createOrUpdate(dataManagementPlan, principal); this.dataManagementProfileManager.createOrUpdateBlueprint(dmpBlueprint, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplate>>() return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplate>>()
.status(ApiMessageCode.SUCCESS_MESSAGE).message("")); .status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
} }

View File

@ -3,7 +3,6 @@ package eu.eudat.logic.managers;
import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import eu.eudat.data.dao.criteria.RequestItem; import eu.eudat.data.dao.criteria.RequestItem;
import eu.eudat.data.dao.entities.DMPProfileDao;
import eu.eudat.data.entities.DMPProfile; import eu.eudat.data.entities.DMPProfile;
import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest; import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest;
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest; 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.services.operations.DatabaseRepository;
import eu.eudat.logic.utilities.builders.XmlBuilder; import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; 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.ExportXmlBuilderDmpBlueprint;
import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpProfile; 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.*;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType; import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType;
@ -141,8 +140,8 @@ public class DataManagementProfileManager {
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile); apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
} }
public ResponseEntity<byte[]> getDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws IllegalAccessException, IOException, InstantiationException { public ResponseEntity<byte[]> getDocument(DataManagementPlanBlueprintListingModel dmpProfile) throws IOException {
FileEnvelope envelope = getXmlDocument(dmpProfile, label); FileEnvelope envelope = getXmlDocument(dmpProfile);
InputStream resource = new FileInputStream(envelope.getFile()); InputStream resource = new FileInputStream(envelope.getFile());
logger.info("Mime Type of " + envelope.getFilename() + " is " + logger.info("Mime Type of " + envelope.getFilename() + " is " +
new MimetypesFileTypeMap().getContentType(envelope.getFile())); new MimetypesFileTypeMap().getContentType(envelope.getFile()));
@ -161,18 +160,18 @@ public class DataManagementProfileManager {
HttpStatus.OK); HttpStatus.OK);
} }
public FileEnvelope getXmlDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws InstantiationException, IllegalAccessException, IOException { public FileEnvelope getXmlDocument(DataManagementPlanBlueprintListingModel dmpProfile) throws IOException {
ExportXmlBuilderDmpProfile xmlBuilder = new ExportXmlBuilderDmpProfile(); ExportXmlBuilderDmpBlueprint xmlBuilder = new ExportXmlBuilderDmpBlueprint();
File file = xmlBuilder.build(dmpProfile, environment); File file = xmlBuilder.build(dmpProfile, environment);
FileEnvelope fileEnvelope = new FileEnvelope(); FileEnvelope fileEnvelope = new FileEnvelope();
fileEnvelope.setFile(file); fileEnvelope.setFile(file);
fileEnvelope.setFilename(label); fileEnvelope.setFilename(dmpProfile.getLabel());
return fileEnvelope; return fileEnvelope;
} }
public eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile createDmpProfileFromXml(MultipartFile multiPartFile) { public eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint createDmpProfileFromXml(MultipartFile multiPartFile) {
ImportXmlBuilderDmpProfile xmlBuilder = new ImportXmlBuilderDmpProfile(); ImportXmlBuilderDmpBlueprint xmlBuilder = new ImportXmlBuilderDmpBlueprint();
try { try {
return xmlBuilder.build(convert(multiPartFile)); return xmlBuilder.build(convert(multiPartFile));
} catch (IOException e) { } catch (IOException e) {

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -1,6 +1,6 @@
package eu.eudat.logic.utilities.documents.xml.dmpXml; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -10,16 +10,16 @@ import javax.xml.bind.Unmarshaller;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
public class ImportXmlBuilderDmpProfile { public class ImportXmlBuilderDmpBlueprint {
private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDmpProfile.class); private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDmpBlueprint.class);
public DmpProfile build(File xmlFile) throws IOException { public DmpBlueprint build(File xmlFile) throws IOException {
DmpProfile dmpProfile = new DmpProfile(); DmpBlueprint dmpProfile = new DmpBlueprint();
JAXBContext jaxbContext = null; JAXBContext jaxbContext = null;
try { try {
jaxbContext = JAXBContext.newInstance(DmpProfile.class); jaxbContext = JAXBContext.newInstance(DmpBlueprint.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
dmpProfile = (DmpProfile) unmarshaller.unmarshal(xmlFile); dmpProfile = (DmpBlueprint) unmarshaller.unmarshal(xmlFile);
} catch (JAXBException e) { } catch (JAXBException e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} }

View File

@ -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;
}
}

View File

@ -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<DescriptionTemplate> descriptionTemplates;
@XmlElement(name = "descriptionTemplate")
public List<DescriptionTemplate> getDescriptionTemplates() {
return descriptionTemplates;
}
public void setDescriptionTemplates(List<DescriptionTemplate> descriptionTemplates) {
this.descriptionTemplates = descriptionTemplates;
}
}

View File

@ -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;
}
}

View File

@ -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<eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section> 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;
}
}

View File

@ -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;
}
}

View File

@ -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<ExtraField> extraFields;
@XmlElement(name = "extraField")
public List<ExtraField> getExtraFields() {
return extraFields;
}
public void setExtraFields(List<ExtraField> extraFields) {
this.extraFields = extraFields;
}
}

View File

@ -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<eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel> 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<eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate> 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;
}
}

View File

@ -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<Section> sections;
@XmlElement(name = "section")
public List<Section> getSections() {
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
}

View File

@ -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;
}
}

View File

@ -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<SystemField> systemFields;
@XmlElement(name = "systemField")
public List<SystemField> getSystemFields() {
return systemFields;
}
public void setSystemFields(List<SystemField> systemFields) {
this.systemFields = systemFields;
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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<eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field> dmpProfileDefinitionFields = new LinkedList<>();
for (Field field:this.fieldSets.fields) {
dmpProfileDefinitionFields.add(field.toDmpProfileCompositeModel());
}
dmpProfileDefinitionModel.setFields(dmpProfileDefinitionFields);
return dmpProfileDefinitionModel;
}
}

View File

@ -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;
}
}

View File

@ -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<Field> fields;
@XmlElement(name = "field")
public List<Field> getField() {
return fields;
}
public void setField(List<Field> fields) {
this.fields = fields;
}
}

View File

@ -49,7 +49,7 @@ public enum SystemFieldType {
case 10: case 10:
return ACCESS_RIGHTS; return ACCESS_RIGHTS;
default: default:
throw new RuntimeException("Unsupported System Field Type"); throw new RuntimeException("Unsupported System Section Type");
} }
} }
} }

View File

@ -12,10 +12,10 @@
{{'DMP-PROFILE-EDITOR.ACTIONS.DELETE' | translate}} {{'DMP-PROFILE-EDITOR.ACTIONS.DELETE' | translate}}
</button> </button>
</div> </div>
<!-- <div class="col-auto" *ngIf="formGroup.get('status').value==1"> <div class="col-auto" *ngIf="formGroup.get('status').value==1">
<button mat-button class="finalize-btn" (click)="downloadXML()" <button mat-button class="finalize-btn" (click)="downloadXML()"
type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.DOWNLOAD-XML' | translate }}</button> type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.DOWNLOAD-XML' | translate }}</button>
</div> --> </div>
<div *ngIf="formGroup.get('status').value!=1" class="col-auto"> <div *ngIf="formGroup.get('status').value!=1" class="col-auto">
<button mat-button class="finalize-btn" (click)="finalize()" <button mat-button class="finalize-btn" (click)="finalize()"
[disabled]="!this.isFormValid()" type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.FINALIZE' | translate }}</button> [disabled]="!this.isFormValid()" type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.FINALIZE' | translate }}</button>

View File

@ -6,11 +6,11 @@
</div> </div>
<div class="col"></div> <div class="col"></div>
<div class="col-auto"> <div class="col-auto">
<!-- <button mat-raised-button class="import-btn" (click)="openDialog()"> <button mat-raised-button class="import-btn" (click)="openDialog()">
<span class="button-text"> <span class="button-text">
{{'DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML' | translate}} {{'DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML' | translate}}
</span> </span>
</button> --> </button>
<button mat-raised-button class="create-btn ml-md-3" [routerLink]="['/dmp-profiles/new'] "> <button mat-raised-button class="create-btn ml-md-3" [routerLink]="['/dmp-profiles/new'] ">
<span class="button-text"> <span class="button-text">
{{'DMP-PROFILE-LISTING.CREATE-DMP-BLUEPRINT' | translate}} {{'DMP-PROFILE-LISTING.CREATE-DMP-BLUEPRINT' | translate}}