From 87324797697153188ec1447d4a213363fece8bb8 Mon Sep 17 00:00:00 2001 From: "CITE\\amentis" Date: Mon, 23 Sep 2024 17:41:27 +0300 Subject: [PATCH] export plan, description status --- .../importexport/DescriptionImportExport.java | 11 ++++++++ .../DescriptionStatusImportExport.java | 26 +++++++++++++++++++ .../plan/importexport/PlanImportExport.java | 11 ++++++++ .../importexport/PlanStatusImportExport.java | 26 +++++++++++++++++++ .../description/DescriptionServiceImpl.java | 12 +++++++++ .../service/plan/PlanServiceImpl.java | 12 +++++++++ 6 files changed, 98 insertions(+) create mode 100644 backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionStatusImportExport.java create mode 100644 backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanStatusImportExport.java diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionImportExport.java index 8da1d9d6c..7bf4ee965 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionImportExport.java @@ -22,6 +22,9 @@ public class DescriptionImportExport { @XmlElement(name = "label") private String label; + @XmlElement(name = "status") + private DescriptionStatusImportExport status; + @XmlElement(name = "finalizedAt") @XmlJavaTypeAdapter(InstantXmlAdapter.class) private Instant finalizedAt; @@ -67,6 +70,14 @@ public class DescriptionImportExport { this.label = label; } + public DescriptionStatusImportExport getStatus() { + return status; + } + + public void setStatus(DescriptionStatusImportExport status) { + this.status = status; + } + public Instant getFinalizedAt() { return this.finalizedAt; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionStatusImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionStatusImportExport.java new file mode 100644 index 000000000..00d4398c9 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/commons/types/description/importexport/DescriptionStatusImportExport.java @@ -0,0 +1,26 @@ +package org.opencdmp.commons.types.description.importexport; + +import java.util.UUID; + +public class DescriptionStatusImportExport { + + private UUID id; + + private String name; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanImportExport.java index 13eccf64b..1b0fdf210 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanImportExport.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanImportExport.java @@ -30,6 +30,9 @@ public class PlanImportExport { @XmlElement(name = "access") private PlanAccessType access; + @XmlElement(name = "status") + private PlanStatusImportExport status; + @XmlElement(name = "version") private Short version; @@ -109,6 +112,14 @@ public class PlanImportExport { this.access = access; } + public PlanStatusImportExport getStatus() { + return status; + } + + public void setStatus(PlanStatusImportExport status) { + this.status = status; + } + public List getContacts() { return this.contacts; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanStatusImportExport.java b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanStatusImportExport.java new file mode 100644 index 000000000..0c7f06a9e --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/commons/types/plan/importexport/PlanStatusImportExport.java @@ -0,0 +1,26 @@ +package org.opencdmp.commons.types.plan.importexport; + +import java.util.UUID; + +public class PlanStatusImportExport { + + private UUID id; + + private String name; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} 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 5f56e6089..3feca9ba2 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 @@ -1253,6 +1253,7 @@ public class DescriptionServiceImpl implements DescriptionService { xml.setId(data.getId()); xml.setDescription(data.getDescription()); xml.setLabel(data.getLabel()); + xml.setStatus(this.descriptionStatusImportExportToExport(data.getStatusId())); xml.setFinalizedAt(data.getFinalizedAt()); PlanDescriptionTemplateEntity planDescriptionTemplateEntity = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(data.getPlanDescriptionTemplateId()).authorize(AuthorizationFlags.All).isActive(IsActive.Active).first(); @@ -1289,6 +1290,17 @@ public class DescriptionServiceImpl implements DescriptionService { return xml; } + private DescriptionStatusImportExport descriptionStatusImportExportToExport(UUID statusId) throws InvalidApplicationException { + DescriptionStatusImportExport xml = new DescriptionStatusImportExport(); + if (statusId == null) return xml; + DescriptionStatusEntity statusEntity = this.entityManager.find(DescriptionStatusEntity.class, statusId, true); + if (statusEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{statusId, DescriptionStatusEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); + + xml.setId(statusEntity.getId()); + xml.setName(statusEntity.getName()); + return xml; + } + private DescriptionReferenceImportExport descriptionReferenceToExport(DescriptionReferenceEntity entity, Map referenceEntityMap, Map referenceTypeEntityMap) { DescriptionReferenceImportExport xml = new DescriptionReferenceImportExport(); if (entity == null) return xml; diff --git a/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java index a162d4a5c..342c6f8ca 100644 --- a/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java @@ -2142,6 +2142,7 @@ public class PlanServiceImpl implements PlanService { xml.setTitle(data.getLabel()); xml.setLanguage(data.getLanguage()); xml.setAccess(data.getAccessType()); + xml.setStatus(this.planStatusImportExportToExport(data.getStatusId())); xml.setFinalizedAt(data.getFinalizedAt()); xml.setPublicAfter(data.getPublicAfter()); xml.setVersion(data.getVersion()); @@ -2155,6 +2156,17 @@ public class PlanServiceImpl implements PlanService { return xml; } + + private PlanStatusImportExport planStatusImportExportToExport(UUID statusId) throws InvalidApplicationException { + PlanStatusImportExport xml = new PlanStatusImportExport(); + if (statusId == null) return xml; + PlanStatusEntity planStatusEntity = this.entityManager.find(PlanStatusEntity.class, statusId, true); + if (planStatusEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{statusId, PlanStatusEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); + + xml.setId(planStatusEntity.getId()); + xml.setName(planStatusEntity.getName()); + return xml; + } private List descriptionsToExport(PlanEntity data, Boolean isPublic) throws JAXBException, InvalidApplicationException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { List descriptions;