diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateFieldSetImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateFieldSetImportExport.java index 880929e52..daa00b07c 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateFieldSetImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateFieldSetImportExport.java @@ -2,6 +2,7 @@ package org.opencdmp.commons.types.descriptiontemplate.importexport; import jakarta.xml.bind.annotation.*; +import java.util.ArrayList; import java.util.List; @XmlAccessorType(XmlAccessType.FIELD) @@ -109,4 +110,12 @@ public class DescriptionTemplateFieldSetImportExport { public void setHasMultiplicity(boolean hasMultiplicity) { this.hasMultiplicity = hasMultiplicity; } + + public List getAllField() { + return this.getFields() == null ? new ArrayList<>() : this.getFields(); + } + + public List getFieldById(String id) { + return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList(); + } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java index 82c61d937..6ba455227 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateImportExport.java @@ -3,6 +3,7 @@ package org.opencdmp.commons.types.descriptiontemplate.importexport; import jakarta.xml.bind.annotation.*; +import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -18,6 +19,10 @@ public class DescriptionTemplateImportExport { private String language; @XmlAttribute(name = "type") private UUID type; + @XmlAttribute(name = "version") + private Short version; + @XmlElement(name = "groupId") + private UUID groupId; @XmlElementWrapper(name = "pages") @XmlElement(name = "page") private List pages; @@ -64,4 +69,48 @@ public class DescriptionTemplateImportExport { public void setType(UUID type) { this.type = type; } + + public Short getVersion() { + return version; + } + + public void setVersion(Short version) { + this.version = version; + } + + public UUID getGroupId() { + return groupId; + } + + public void setGroupId(UUID groupId) { + this.groupId = groupId; + } + + public List getAllFieldSets(){ + List fieldSets = new ArrayList<>(); + if (this.getPages() != null){ + for (DescriptionTemplatePageImportExport page: this.getPages()) { + fieldSets.addAll(page.getAllFieldSets()); + } + } + return fieldSets; + } + + public List getAllField(){ + List fields = new ArrayList<>(); + if (this.getPages() != null){ + for (DescriptionTemplatePageImportExport page: this.getPages()) { + fields.addAll(page.getAllField()); + } + } + return fields; + } + + public List getFieldSetById(String id) { + return this.getAllFieldSets().stream().filter(x-> id.equals(x.getId())).toList(); + } + + public List getFieldById(String id) { + return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList(); + } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplatePageImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplatePageImportExport.java index 4833eb7d7..c48fdc230 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplatePageImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplatePageImportExport.java @@ -2,6 +2,7 @@ package org.opencdmp.commons.types.descriptiontemplate.importexport; import jakarta.xml.bind.annotation.*; +import java.util.ArrayList; import java.util.List; @XmlAccessorType(XmlAccessType.FIELD) @@ -49,4 +50,23 @@ public class DescriptionTemplatePageImportExport { this.sections = sections; } + public List getAllField(){ + List fields = new ArrayList<>(); + if (this.getSections() != null){ + for (DescriptionTemplateSectionImportExport section: this.getSections()) { + fields.addAll(section.getAllField()); + } + } + return fields; + } + + public List getAllFieldSets(){ + List fieldSets = new ArrayList<>(); + if (this.getSections() != null){ + for (DescriptionTemplateSectionImportExport section: this.getSections()) { + fieldSets.addAll(section.getAllFieldSets()); + } + } + return fieldSets; + } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateSectionImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateSectionImportExport.java index a66f76f59..3e227474d 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateSectionImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/descriptiontemplate/importexport/DescriptionTemplateSectionImportExport.java @@ -2,6 +2,7 @@ package org.opencdmp.commons.types.descriptiontemplate.importexport; import jakarta.xml.bind.annotation.*; +import java.util.ArrayList; import java.util.List; @XmlAccessorType(XmlAccessType.FIELD) @@ -69,4 +70,32 @@ public class DescriptionTemplateSectionImportExport { this.sections = sections; } + + public List getAllField(){ + List fields = new ArrayList<>(); + if (this.getFieldSets() != null){ + for (DescriptionTemplateFieldSetImportExport fieldSet: this.getFieldSets()) { + fields.addAll(fieldSet.getAllField()); + } + } + if (this.getSections() != null){ + for (DescriptionTemplateSectionImportExport section: this.getSections()) { + fields.addAll(section.getAllField()); + } + } + return fields; + } + + public List getAllFieldSets(){ + List fieldSets = new ArrayList<>(); + if (this.getFieldSets() != null){ + fieldSets.addAll(this.getFieldSets()); + } + if (this.getSections() != null){ + for (DescriptionTemplateSectionImportExport section: this.getSections()) { + fieldSets.addAll(section.getAllFieldSets()); + } + } + return fieldSets; + } } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpImportExport.java index 2c007cca5..3a6bc7302 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/dmp/importexport/DmpImportExport.java @@ -28,6 +28,9 @@ public class DmpImportExport { @XmlElement(name = "access") private DmpAccessType access; + @XmlElement(name = "version") + private Short version; + @XmlElementWrapper(name = "contacts") @XmlElement(name = "contact") private List contacts; @@ -173,5 +176,13 @@ public class DmpImportExport { public void setDescriptions(List descriptions) { this.descriptions = descriptions; } + + public Short getVersion() { + return version; + } + + public void setVersion(Short version) { + this.version = version; + } } diff --git a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java index 23e5e027b..9fd6abf17 100644 --- a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java +++ b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java @@ -7,6 +7,7 @@ import gr.cite.tools.exception.MyValidationException; import gr.cite.tools.fieldset.FieldSet; import jakarta.xml.bind.JAXBException; import org.opencdmp.commons.types.description.importexport.DescriptionImportExport; +import org.opencdmp.data.DmpDescriptionTemplateEntity; import org.opencdmp.data.StorageFileEntity; import org.opencdmp.model.DescriptionValidationResult; import org.opencdmp.model.StorageFile; @@ -21,6 +22,7 @@ import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.management.InvalidApplicationException; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; import java.io.IOException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; @@ -49,4 +51,7 @@ public interface DescriptionService { DescriptionImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException; ResponseEntity exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException; + + Description importXml(DescriptionImportExport descriptionXml, UUID dmpId, List dmpDescriptionTemplates, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException; + } diff --git a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java index e52c2c0ff..e6ab79222 100644 --- a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java @@ -30,6 +30,8 @@ import org.opencdmp.commons.types.descriptionreference.DescriptionReferenceDataE import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity; import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity; import org.opencdmp.commons.types.descriptiontemplate.fielddata.UploadDataEntity; +import org.opencdmp.commons.types.descriptiontemplate.importexport.*; +import org.opencdmp.commons.types.descriptiontemplate.importexport.fielddata.ReferenceTypeDataImportExport; import org.opencdmp.commons.types.notification.*; import org.opencdmp.commons.types.reference.DefinitionEntity; import org.opencdmp.convention.ConventionService; @@ -86,6 +88,7 @@ import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.management.InvalidApplicationException; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; import java.io.IOException; import java.net.URLConnection; import java.security.InvalidAlgorithmParameterException; @@ -1096,9 +1099,12 @@ public class DescriptionServiceImpl implements DescriptionService { xml.setLabel(data.getLabel()); xml.setFinalizedAt(data.getFinalizedAt()); - DescriptionTemplateEntity blueprintEntity = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().ids(data.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first(); - if (blueprintEntity != null) { - xml.setDescriptionTemplate(this.descriptionTemplateService.exportXmlEntity(blueprintEntity.getId(), true)); + DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking().ids(data.getDmpDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first(); + if (dmpDescriptionTemplateEntity != null) xml.setSectionId(dmpDescriptionTemplateEntity.getSectionId()); + + DescriptionTemplateEntity descriptionTemplateEntity = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().ids(data.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).first(); + if (descriptionTemplateEntity != null) { + xml.setDescriptionTemplate(this.descriptionTemplateService.exportXmlEntity(descriptionTemplateEntity.getId(), true)); } if (propertiesEntity != null) { @@ -1112,8 +1118,8 @@ public class DescriptionServiceImpl implements DescriptionService { List referenceTypes = references == null ? new ArrayList<>() : this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(references.stream().map(ReferenceEntity::getTypeId).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).collect(); Map referenceTypeEntityMap = referenceTypes == null ? new HashMap<>() : referenceTypes.stream().collect(Collectors.toMap(ReferenceTypeEntity::getId, x-> x)); List dmpReferenceImportExports = new LinkedList<>(); - for (DescriptionReferenceEntity descriptionTemplateEntity : dmpReferences) { - dmpReferenceImportExports.add(this.descriptionReferenceToExport(descriptionTemplateEntity, referenceEntityMap, referenceTypeEntityMap)); + for (DescriptionReferenceEntity descriptionReferenceEntity : dmpReferences) { + dmpReferenceImportExports.add(this.descriptionReferenceToExport(descriptionReferenceEntity, referenceEntityMap, referenceTypeEntityMap)); } xml.setReferences(dmpReferenceImportExports); } @@ -1224,4 +1230,165 @@ public class DescriptionServiceImpl implements DescriptionService { } //endregion + + + //region Import + + public Description importXml(DescriptionImportExport descriptionXml, UUID dmpId, List dmpDescriptionTemplates, FieldSet fields) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, TransformerException, InvalidApplicationException, IOException, InstantiationException, IllegalAccessException, SAXException{ + + if (descriptionXml == null) throw new MyNotFoundException("Description xml not found"); + + logger.debug(new MapLogEntry("import description").And("dmpId", dmpId).And("fields", fields)); + + DescriptionPersist persist = new DescriptionPersist(); + persist.setLabel(descriptionXml.getLabel()); + persist.setDescription(descriptionXml.getDescription()); + persist.setStatus(DescriptionStatus.Draft); + persist.setDmpId(dmpId); + if (descriptionXml.getDescriptionTemplate() != null) { + persist.setDescriptionTemplateId(descriptionXml.getDescriptionTemplate().getId()); + if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplates) && descriptionXml.getSectionId() != null && descriptionXml.getDescriptionTemplate().getGroupId() != null){ + DmpDescriptionTemplateEntity dmpDescriptionTemplate = dmpDescriptionTemplates.stream().filter(x -> x.getDmpId().equals(dmpId) && + x.getDescriptionTemplateGroupId().equals(descriptionXml.getDescriptionTemplate().getGroupId()) && + x.getSectionId().equals(descriptionXml.getSectionId())).findFirst().orElse(null); + if (dmpDescriptionTemplate != null) persist.setDmpDescriptionTemplateId(dmpDescriptionTemplate.getId()); + } + } + + persist.setProperties(this.xmlToPropertyDefinitionToPersist(descriptionXml)); + + this.validatorFactory.validator(DescriptionPersist.DescriptionPersistValidator.class).validateForce(persist); + + return this.persist(persist, fields); + } + + private PropertyDefinitionPersist xmlToPropertyDefinitionToPersist(DescriptionImportExport descriptionXml) { + if (descriptionXml == null) + return null; + + PropertyDefinitionPersist persist = new PropertyDefinitionPersist(); + + Map fieldSetsMap = new HashMap<>(); + if (!this.conventionService.isListNullOrEmpty(descriptionXml.getDescriptionTemplate().getPages())) { + if (descriptionXml.getProperties() != null && !this.conventionService.isListNullOrEmpty(descriptionXml.getProperties().getFieldSets())){ + for (DescriptionPropertyDefinitionFieldSetImportExport fieldSet: descriptionXml.getProperties().getFieldSets()){ + fieldSetsMap.put(fieldSet.getFieldSetId(), this.xmlPropertyDefinitionFieldSetToPersist(fieldSet, descriptionXml.getReferences(), descriptionXml.getDescriptionTemplate())); + } + } + } + + persist.setFieldSets(fieldSetsMap); + + return persist; + } + + private PropertyDefinitionFieldSetPersist xmlPropertyDefinitionFieldSetToPersist(DescriptionPropertyDefinitionFieldSetImportExport importXml, List references, DescriptionTemplateImportExport descriptionTemplate) { + + if (importXml == null) + return null; + + PropertyDefinitionFieldSetPersist persist = new PropertyDefinitionFieldSetPersist(); + + if (!this.conventionService.isListNullOrEmpty(importXml.getItems())){ + List items = new ArrayList<>(); + for (DescriptionPropertyDefinitionFieldSetItemImportExport fieldSetItem: importXml.getItems()) { + items.add(this.xmlPropertyDefinitionFieldSetItemToPersist(fieldSetItem, references, descriptionTemplate)); + } + persist.setItems(items); + return persist; + + } + return null; + } + + private PropertyDefinitionFieldSetItemPersist xmlPropertyDefinitionFieldSetItemToPersist(DescriptionPropertyDefinitionFieldSetItemImportExport importXml, List references, DescriptionTemplateImportExport descriptionTemplate) { + if (importXml == null) + return null; + + PropertyDefinitionFieldSetItemPersist persist = new PropertyDefinitionFieldSetItemPersist(); + + persist.setComment(importXml.getComment()); + persist.setOrdinal(importXml.getOrdinal()); + + Map fields = new HashMap<>(); + + if (!this.conventionService.isListNullOrEmpty(importXml.getFields())){ + for (DescriptionFieldImportExport field: importXml.getFields()) { + fields.put(field.getFieldId(), this.xmlFieldToPersist(field, references, descriptionTemplate)); + } + } + + persist.setFields(fields); + + return persist; + } + + private FieldPersist xmlFieldToPersist(DescriptionFieldImportExport importXml, List references, DescriptionTemplateImportExport descriptionTemplate) { + if (importXml == null || descriptionTemplate == null) + return null; + + DescriptionTemplateFieldImportExport descriptionTemplateField = descriptionTemplate.getFieldById(importXml.getFieldId()).stream().findFirst().orElse(null); + if (descriptionTemplateField == null){ + return null; + } + + FieldPersist persist = new FieldPersist(); + + if (!this.conventionService.isListNullOrEmpty(references) && descriptionTemplateField.getData().getFieldType().equals(FieldType.REFERENCE_TYPES)){ + ReferenceTypeDataImportExport referenceTypeDataImportExport = (ReferenceTypeDataImportExport) descriptionTemplateField.getData(); + if (referenceTypeDataImportExport != null){ + List referencesByField = references.stream().filter(x -> x.getFieldId().equals(importXml.getFieldId())).collect(Collectors.toList()); + if (!this.conventionService.isListNullOrEmpty(referencesByField)){ + if (referenceTypeDataImportExport.getMultipleSelect()){ + List referencePersists = new ArrayList<>(); + for (DescriptionReferenceImportExport referenceImportExport: referencesByField) { + referencePersists.add(this.xmlDescriptionReferenceToPersist(referenceImportExport)); + } + persist.setReferences(referencePersists); + }else { + persist.setReference(this.xmlDescriptionReferenceToPersist(referencesByField.stream().findFirst().orElse(null))); + } + } + } + }else { + persist.setBooleanValue(importXml.getBooleanValue()); + persist.setDateValue(importXml.getDateValue()); + persist.setTextValue(importXml.getTextValue()); + persist.setTextListValue(importXml.getTextListValue()); + + if (importXml.getExternalIdentifier() != null){ + persist.setExternalIdentifier(this.xmlExternalIdentifierToPersist(importXml.getExternalIdentifier())); + } + } + + return persist; + } + + private ReferencePersist xmlDescriptionReferenceToPersist(DescriptionReferenceImportExport importXml) { + if (importXml == null) + return null; + + ReferencePersist persist = new ReferencePersist(); + + persist.setId(importXml.getId()); + persist.setLabel(importXml.getLabel()); + persist.setReference(importXml.getReference()); + + return persist; + } + + private ExternalIdentifierPersist xmlExternalIdentifierToPersist(DescriptionExternalIdentifierImportExport importXml) { + if (importXml == null) + return null; + + ExternalIdentifierPersist persist = new ExternalIdentifierPersist(); + + persist.setType(importXml.getType()); + persist.setIdentifier(importXml.getIdentifier()); + + return persist; + } + + //endregion + } diff --git a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java index 593d08005..f31f880c7 100644 --- a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java @@ -926,6 +926,9 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic xml.setType(data.getTypeId()); xml.setLanguage(data.getLanguage()); xml.setDescription(data.getDescription()); + xml.setGroupId(data.getGroupId()); + xml.setVersion(data.getVersion()); + List pagesDatasetEntity = new LinkedList<>(); for (PageEntity xmlPage : entity.getPages()) { pagesDatasetEntity.add(this.pageXmlToExport(xmlPage)); diff --git a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java index cb6a00058..2e299b056 100644 --- a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java @@ -1477,7 +1477,8 @@ public class DmpServiceImpl implements DmpService { xml.setAccess(data.getAccessType()); xml.setFinalizedAt(data.getFinalizedAt()); xml.setPublicAfter(data.getPublicAfter()); - + xml.setVersion(data.getVersion()); + if (propertiesEntity != null && !this.conventionService.isListNullOrEmpty(propertiesEntity.getContacts())) { List dmpContactImportExports = new LinkedList<>(); List users = this.queryFactory.query(UserQuery.class).disableTracking().ids(propertiesEntity.getContacts().stream().map(DmpContactEntity::getUserId).filter(Objects::nonNull).distinct().toList()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).isActive(IsActive.Active).collect(); @@ -1668,7 +1669,22 @@ public class DmpServiceImpl implements DmpService { this.validatorFactory.validator(DmpPersist.DmpPersistValidator.class).validateForce(persist); - return this.persist(persist, fields); + Dmp dmp = this.persist(persist, fields); + + if (!this.conventionService.isListNullOrEmpty(dmpXml.getDescriptions())){ + if (dmp == null || dmp.getId() == null) throw new MyApplicationException("Error creating dmp"); + + List dmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).disableTracking() + .isActive(IsActive.Active) + .dmpIds(dmp.getId()) + .collect(); + + for (DescriptionImportExport description: dmpXml.getDescriptions()){ + this.descriptionService.importXml(description, dmp.getId(), dmpDescriptionTemplates, fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Dmp._description)) : null); + } + } + + return dmp; } private DmpPropertiesPersist xmlToDmpPropertiesPersist(DmpImportExport importXml) { diff --git a/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java b/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java index 0a9244486..b50f254ee 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java @@ -340,7 +340,7 @@ public class DmpController { @RequestMapping(method = RequestMethod.GET, value = "/xml/export/{id}", produces = "application/xml") public @ResponseBody ResponseEntity getXml(@PathVariable UUID id) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { - logger.debug(new MapLogEntry("export" + DmpBlueprint.class.getSimpleName()).And("id", id)); + logger.debug(new MapLogEntry("export" + Dmp.class.getSimpleName()).And("id", id)); ResponseEntity response = this.dmpService.exportXml(id); diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts index 730ec4052..1457a3677 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts @@ -197,6 +197,12 @@ export class DmpService { const formData = new FormData(); formData.append('file', file); formData.append('label', label); + if (reqFields.length > 0){ + for (var i = 0; i < reqFields.length; i++) { + formData.append('field[]', reqFields[i]); + } + } + return this.http.post(url, formData, { params: params }).pipe( catchError((error: any) => throwError(error)));; }