diff --git a/backend/core/pom.xml b/backend/core/pom.xml
index 754a12321..6f168c8a7 100644
--- a/backend/core/pom.xml
+++ b/backend/core/pom.xml
@@ -52,17 +52,17 @@
gr.cite
oidc-authz
- 2.1.0
+ 2.2.0
org.opencdmp
repositorydepositbase
- 2.0.16
+ 2.0.17
org.opencdmp
common-models
- 0.0.19
+ 0.0.20
gr.cite
@@ -72,7 +72,7 @@
org.opencdmp
file-transformer-base
- 0.0.24
+ 0.0.25
gr.cite
diff --git a/backend/core/src/main/java/org/opencdmp/audit/AuditableAction.java b/backend/core/src/main/java/org/opencdmp/audit/AuditableAction.java
index 73325a616..c8d18b37d 100644
--- a/backend/core/src/main/java/org/opencdmp/audit/AuditableAction.java
+++ b/backend/core/src/main/java/org/opencdmp/audit/AuditableAction.java
@@ -50,6 +50,7 @@ public class AuditableAction {
public static final EventId Plan_GetPublicXml = new EventId(5017, "Plan_GetPublicXml");
public static final EventId Plan_ExportPublic = new EventId(5018, "Plan_ExportPublic");
public static final EventId Plan_PublicClone = new EventId(5019, "Plan_PublicClone");
+ public static final EventId Plan_SetStatus = new EventId(5020, "Plan_SetStatus");
public static final EventId Description_Query = new EventId(6000, "Description_Query");
diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/DescriptionStatusAvailableActionType.java b/backend/core/src/main/java/org/opencdmp/commons/enums/DescriptionStatusAvailableActionType.java
new file mode 100644
index 000000000..a1b37cc66
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/commons/enums/DescriptionStatusAvailableActionType.java
@@ -0,0 +1,30 @@
+package org.opencdmp.commons.enums;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+import org.opencdmp.data.converters.enums.DatabaseEnum;
+
+import java.util.Map;
+
+public enum DescriptionStatusAvailableActionType implements DatabaseEnum {
+
+ Export((short) 0);
+
+ private final Short value;
+
+ DescriptionStatusAvailableActionType(Short value) {
+ this.value = value;
+ }
+
+ @Override
+ @JsonValue
+ public Short getValue() {
+ return this.value;
+ }
+
+ private static final Map map = EnumUtils.getEnumValueMap(DescriptionStatusAvailableActionType.class);
+
+ public static DescriptionStatusAvailableActionType of(Short i) {
+ return map.get(i);
+ }
+
+}
diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/PlanStatusAvailableActionType.java b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanStatusAvailableActionType.java
new file mode 100644
index 000000000..5dd7d7aba
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/commons/enums/PlanStatusAvailableActionType.java
@@ -0,0 +1,31 @@
+package org.opencdmp.commons.enums;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+import org.opencdmp.data.converters.enums.DatabaseEnum;
+
+import java.util.Map;
+
+public enum PlanStatusAvailableActionType implements DatabaseEnum {
+
+ Deposit((short) 0),
+ Export((short) 1);
+
+ private final Short value;
+
+ PlanStatusAvailableActionType(Short value) {
+ this.value = value;
+ }
+
+ @Override
+ @JsonValue
+ public Short getValue() {
+ return this.value;
+ }
+
+ private static final Map map = EnumUtils.getEnumValueMap(PlanStatusAvailableActionType.class);
+
+ public static PlanStatusAvailableActionType of(Short i) {
+ return map.get(i);
+ }
+
+}
diff --git a/backend/core/src/main/java/org/opencdmp/commons/notification/NotificationProperties.java b/backend/core/src/main/java/org/opencdmp/commons/notification/NotificationProperties.java
index 8df77a337..c5e549c9a 100644
--- a/backend/core/src/main/java/org/opencdmp/commons/notification/NotificationProperties.java
+++ b/backend/core/src/main/java/org/opencdmp/commons/notification/NotificationProperties.java
@@ -11,11 +11,13 @@ public class NotificationProperties {
private UUID planInvitationExistingUserType;
private UUID planModifiedType;
private UUID planFinalisedType;
+ private UUID planStatusChangedType;
private UUID planAnnotationCreatedType;
private UUID planAnnotationStatusChangedType;
private UUID descriptionCreatedType;
private UUID descriptionModifiedType;
private UUID descriptionFinalisedType;
+ private UUID descriptionStatusChangedType;
private UUID descriptionAnnotationCreatedType;
private UUID descriptionAnnotationStatusChangedType;
private UUID mergeAccountConfirmationType;
@@ -61,6 +63,14 @@ public class NotificationProperties {
this.planFinalisedType = planFinalisedType;
}
+ public UUID getPlanStatusChangedType() {
+ return planStatusChangedType;
+ }
+
+ public void setPlanStatusChangedType(UUID planStatusChangedType) {
+ this.planStatusChangedType = planStatusChangedType;
+ }
+
public UUID getPlanAnnotationCreatedType() {
return planAnnotationCreatedType;
}
@@ -101,6 +111,14 @@ public class NotificationProperties {
this.descriptionFinalisedType = descriptionFinalisedType;
}
+ public UUID getDescriptionStatusChangedType() {
+ return descriptionStatusChangedType;
+ }
+
+ public void setDescriptionStatusChangedType(UUID descriptionStatusChangedType) {
+ this.descriptionStatusChangedType = descriptionStatusChangedType;
+ }
+
public UUID getMergeAccountConfirmationType() {
return this.mergeAccountConfirmationType;
}
diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/dashborad/RecentActivityItemEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/dashborad/RecentActivityItemEntity.java
index 8e7b23592..5fd70fdd4 100644
--- a/backend/core/src/main/java/org/opencdmp/commons/types/dashborad/RecentActivityItemEntity.java
+++ b/backend/core/src/main/java/org/opencdmp/commons/types/dashborad/RecentActivityItemEntity.java
@@ -10,14 +10,14 @@ public class RecentActivityItemEntity {
private UUID id;
private Instant updatedAt;
private String label;
- private Short statusValue;
+ private UUID statusId;
- public RecentActivityItemEntity(RecentActivityItemType type, UUID id, Instant updatedAt, String label, Short statusValue) {
+ public RecentActivityItemEntity(RecentActivityItemType type, UUID id, Instant updatedAt, String label, UUID statusId) {
this.type = type;
this.id = id;
this.updatedAt = updatedAt;
this.label = label;
- this.statusValue = statusValue;
+ this.statusId = statusId;
}
public RecentActivityItemType getType() {
@@ -52,11 +52,11 @@ public class RecentActivityItemEntity {
this.label = label;
}
- public Short getStatusValue() {
- return statusValue;
+ public UUID getStatusId() {
+ return statusId;
}
- public void setStatusValue(Short statusValue) {
- this.statusValue = statusValue;
+ public void setStatusId(UUID statusId) {
+ this.statusId = statusId;
}
}
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/descriptionstatus/DescriptionStatusDefinitionEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/descriptionstatus/DescriptionStatusDefinitionEntity.java
index f7a4a4f84..e2a5d4d0a 100644
--- a/backend/core/src/main/java/org/opencdmp/commons/types/descriptionstatus/DescriptionStatusDefinitionEntity.java
+++ b/backend/core/src/main/java/org/opencdmp/commons/types/descriptionstatus/DescriptionStatusDefinitionEntity.java
@@ -1,9 +1,9 @@
package org.opencdmp.commons.types.descriptionstatus;
-import jakarta.xml.bind.annotation.XmlAccessType;
-import jakarta.xml.bind.annotation.XmlAccessorType;
-import jakarta.xml.bind.annotation.XmlElement;
-import jakarta.xml.bind.annotation.XmlRootElement;
+import jakarta.xml.bind.annotation.*;
+import org.opencdmp.commons.enums.DescriptionStatusAvailableActionType;
+
+import java.util.List;
@XmlRootElement(name = "definition")
@XmlAccessorType(XmlAccessType.FIELD)
@@ -12,7 +12,19 @@ public class DescriptionStatusDefinitionEntity {
@XmlElement(name = "authorization")
private DescriptionStatusDefinitionAuthorizationEntity authorization;
+ @XmlElementWrapper(name = "availableActions")
+ @XmlElement(name = "action")
+ private List availableActions;
+
public DescriptionStatusDefinitionAuthorizationEntity getAuthorization() { return this.authorization; }
public void setAuthorization(DescriptionStatusDefinitionAuthorizationEntity authorization) { this.authorization = authorization; }
+
+ public List getAvailableActions() {
+ return availableActions;
+ }
+
+ public void setAvailableActions(List availableActions) {
+ this.availableActions = availableActions;
+ }
}
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/commons/types/planstatus/PlanStatusDefinitionEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/planstatus/PlanStatusDefinitionEntity.java
index 1d8e1d171..6892612b6 100644
--- a/backend/core/src/main/java/org/opencdmp/commons/types/planstatus/PlanStatusDefinitionEntity.java
+++ b/backend/core/src/main/java/org/opencdmp/commons/types/planstatus/PlanStatusDefinitionEntity.java
@@ -1,6 +1,9 @@
package org.opencdmp.commons.types.planstatus;
import jakarta.xml.bind.annotation.*;
+import org.opencdmp.commons.enums.PlanStatusAvailableActionType;
+
+import java.util.List;
@XmlRootElement(name = "definition")
@XmlAccessorType(XmlAccessType.FIELD)
@@ -9,9 +12,21 @@ public class PlanStatusDefinitionEntity {
@XmlElement(name = "authorization")
private PlanStatusDefinitionAuthorizationEntity authorization;
+ @XmlElementWrapper(name = "availableActions")
+ @XmlElement(name = "action")
+ private List availableActions;
+
public PlanStatusDefinitionAuthorizationEntity getAuthorization() {
return this.authorization;
}
public void setAuthorization(PlanStatusDefinitionAuthorizationEntity authorization) { this.authorization = authorization; }
+
+ public List getAvailableActions() {
+ return availableActions;
+ }
+
+ public void setAvailableActions(List availableActions) {
+ this.availableActions = availableActions;
+ }
}
diff --git a/backend/core/src/main/java/org/opencdmp/data/DescriptionEntity.java b/backend/core/src/main/java/org/opencdmp/data/DescriptionEntity.java
index 987d6e4fe..8741b899f 100644
--- a/backend/core/src/main/java/org/opencdmp/data/DescriptionEntity.java
+++ b/backend/core/src/main/java/org/opencdmp/data/DescriptionEntity.java
@@ -39,6 +39,10 @@ public class DescriptionEntity extends TenantScopedBaseEntity {
private DescriptionStatus status;
public static final String _status = "status";
+ @Column(name = "status_id", nullable = true)
+ private UUID statusId;
+ public static final String _statusId = "statusId";
+
@Column(name = "description")
private String description;
@@ -187,5 +191,13 @@ public class DescriptionEntity extends TenantScopedBaseEntity {
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
}
+
+ public UUID getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(UUID statusId) {
+ this.statusId = statusId;
+ }
}
diff --git a/backend/core/src/main/java/org/opencdmp/data/DescriptionStatusEntity.java b/backend/core/src/main/java/org/opencdmp/data/DescriptionStatusEntity.java
index 290500fce..14aad3de9 100644
--- a/backend/core/src/main/java/org/opencdmp/data/DescriptionStatusEntity.java
+++ b/backend/core/src/main/java/org/opencdmp/data/DescriptionStatusEntity.java
@@ -29,6 +29,11 @@ public class DescriptionStatusEntity extends TenantScopedBaseEntity {
private String description;
public static final String _description = "description";
+ @Column(name = "action", length = DescriptionStatusEntity._nameLength, nullable = true)
+ private String action;
+ public static final String _action = "action";
+ public static final int _actionLength = 250;
+
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public static final String _createdAt = "createdAt";
@@ -74,6 +79,14 @@ public class DescriptionStatusEntity extends TenantScopedBaseEntity {
this.createdAt = createdAt;
}
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
public Instant getUpdatedAt() {
return this.updatedAt;
}
diff --git a/backend/core/src/main/java/org/opencdmp/data/PlanEntity.java b/backend/core/src/main/java/org/opencdmp/data/PlanEntity.java
index f3e6d072d..cd92a36c3 100644
--- a/backend/core/src/main/java/org/opencdmp/data/PlanEntity.java
+++ b/backend/core/src/main/java/org/opencdmp/data/PlanEntity.java
@@ -47,6 +47,10 @@ public class PlanEntity extends TenantScopedBaseEntity {
public static final String _status = "status";
+ @Column(name = "status_id", nullable = true)
+ private UUID statusId;
+ public static final String _statusId = "statusId";
+
@Column(name = "properties", nullable = true)
private String properties;
@@ -141,6 +145,14 @@ public class PlanEntity extends TenantScopedBaseEntity {
this.status = status;
}
+ public UUID getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(UUID statusId) {
+ this.statusId = statusId;
+ }
+
public String getProperties() {
return this.properties;
}
diff --git a/backend/core/src/main/java/org/opencdmp/data/PlanStatusEntity.java b/backend/core/src/main/java/org/opencdmp/data/PlanStatusEntity.java
index 6837d381d..39e3529e2 100644
--- a/backend/core/src/main/java/org/opencdmp/data/PlanStatusEntity.java
+++ b/backend/core/src/main/java/org/opencdmp/data/PlanStatusEntity.java
@@ -29,6 +29,11 @@ public class PlanStatusEntity extends TenantScopedBaseEntity {
private String description;
public static final String _description = "description";
+ @Column(name = "action", length = PlanStatusEntity._actionLength, nullable = true)
+ private String action;
+ public static final String _action = "action";
+ public static final int _actionLength = 250;
+
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public static final String _createdAt = "createdAt";
@@ -67,6 +72,14 @@ public class PlanStatusEntity extends TenantScopedBaseEntity {
public String getDescription() { return this.description; }
public void setDescription(String description) { this.description = description;}
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
public Instant getCreatedAt() {
return this.createdAt;
}
diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java
index 5b0d8cc8f..15f38125e 100644
--- a/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java
+++ b/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java
@@ -33,9 +33,9 @@ public class DescriptionElasticEntity {
private String description;
public final static String _description = "description";
- @Field(value = DescriptionElasticEntity._status, type = FieldType.Short)
- private DescriptionStatus status;
- public final static String _status = "status";
+ @Field(value = DescriptionElasticEntity._statusId, type = FieldType.Keyword)
+ private UUID statusId;
+ public final static String _statusId = "statusId";
@Field(value = DescriptionElasticEntity._finalizedAt, type = FieldType.Date)
private Date finalizedAt;
@@ -97,12 +97,12 @@ public class DescriptionElasticEntity {
this.description = description;
}
- public DescriptionStatus getStatus() {
- return this.status;
+ public UUID getStatusId() {
+ return statusId;
}
- public void setStatus(DescriptionStatus status) {
- this.status = status;
+ public void setStatusId(UUID statusId) {
+ this.statusId = statusId;
}
public Date getFinalizedAt() {
diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/PlanElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/PlanElasticEntity.java
index 3d8e3e8b5..9a2350443 100644
--- a/backend/core/src/main/java/org/opencdmp/elastic/data/PlanElasticEntity.java
+++ b/backend/core/src/main/java/org/opencdmp/elastic/data/PlanElasticEntity.java
@@ -35,9 +35,9 @@ public class PlanElasticEntity {
private Short version;
public final static String _version = "version";
- @Field(value = PlanElasticEntity._status, type = FieldType.Short)
- private PlanStatus status;
- public final static String _status = "status";
+ @Field(value = PlanElasticEntity._statusId, type = FieldType.Keyword)
+ private UUID statusId;
+ public final static String _statusId = "statusId";
@Field(value = PlanElasticEntity._accessType, type = FieldType.Short)
private PlanAccessType accessType;
@@ -130,12 +130,12 @@ public class PlanElasticEntity {
this.version = version;
}
- public PlanStatus getStatus() {
- return this.status;
+ public UUID getStatusId() {
+ return statusId;
}
- public void setStatus(PlanStatus status) {
- this.status = status;
+ public void setStatusId(UUID statusId) {
+ this.statusId = statusId;
}
public PlanAccessType getAccessType() {
diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedPlanElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedPlanElasticEntity.java
index cd9d84e06..1b1a717eb 100644
--- a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedPlanElasticEntity.java
+++ b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedPlanElasticEntity.java
@@ -35,9 +35,9 @@ public class NestedPlanElasticEntity {
private PlanVersionStatus versionStatus;
public final static String _versionStatus = "versionStatus";
- @Field(value = NestedPlanElasticEntity._status, type = FieldType.Short)
- private PlanStatus status;
- public final static String _status = "status";
+ @Field(value = NestedPlanElasticEntity._statusId, type = FieldType.Keyword)
+ private UUID statusId;
+ public final static String _statusId = "statusId";
@Field(value = NestedPlanElasticEntity._accessType, type = FieldType.Short)
private PlanAccessType accessType;
@@ -103,12 +103,12 @@ public class NestedPlanElasticEntity {
this.version = version;
}
- public PlanStatus getStatus() {
- return status;
+ public UUID getStatusId() {
+ return statusId;
}
- public void setStatus(PlanStatus status) {
- this.status = status;
+ public void setStatusId(UUID statusId) {
+ this.statusId = statusId;
}
public PlanAccessType getAccessType() {
diff --git a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java
index 6cc4f11a8..6b8aa3ba4 100644
--- a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java
+++ b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java
@@ -63,7 +63,7 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder excludedIds;
private Collection tenantIds;
- private Collection statuses;
+ private Collection statusIds;
private NestedDescriptionTemplateElasticQuery descriptionTemplateSubQuery;
private NestedReferenceElasticQuery referenceSubQuery;
private NestedTagElasticQuery tagSubQuery;
@@ -133,18 +133,18 @@ public class DescriptionElasticQuery extends ElasticQuery values) {
- this.statuses = values;
+ public DescriptionElasticQuery statusIds(Collection values) {
+ this.statusIds = values;
return this;
}
@@ -189,7 +189,7 @@ public class DescriptionElasticQuery extends ElasticQuery predicates = new ArrayList<>();
if (usePublic ) {
predicates.add(this.and(
- this.equals(new ElasticField(DescriptionElasticEntity._plan + "." + PlanElasticEntity._status, this.entityClass()).disableInfer(true), PlanStatus.Finalized.getValue()),
+ this.equals(new ElasticField(DescriptionElasticEntity._plan + "." + PlanElasticEntity._statusId, this.entityClass()).disableInfer(true), PlanStatus.Finalized.getValue()),
this.equals(new ElasticField(DescriptionElasticEntity._plan + "." + PlanElasticEntity._accessType, this.entityClass()).disableInfer(true), PlanAccessType.Public.getValue())
));
}
@@ -284,8 +284,8 @@ public class DescriptionElasticQuery extends ElasticQuery ids;
private Collection excludedIds;
- private Collection statuses;
+ private Collection statusIds;
private Collection versionStatuses;
private Collection accessTypes;
private Collection versions;
@@ -108,18 +108,18 @@ public class InnerObjectPlanElasticQuery extends ElasticInnerObjectQuery values) {
- this.statuses = values;
+ public InnerObjectPlanElasticQuery statusIds(Collection values) {
+ this.statusIds = values;
return this;
}
@@ -203,8 +203,8 @@ public class InnerObjectPlanElasticQuery extends ElasticInnerObjectQuery x.getValue()).collect(Collectors.toList()).toArray(new Short[this.statuses.size()]))._toQuery());
+ if (this.statusIds != null) {
+ predicates.add(this.containsUUID(this.elasticFieldOf(NestedPlanElasticEntity._id).disableInfer(true), this.statusIds)._toQuery());
}
if (this.versionStatuses != null) {
predicates.add(this.contains(this.elasticFieldOf(NestedPlanElasticEntity._versionStatus).disableInfer(true), this.versionStatuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[this.versionStatuses.size()]))._toQuery());
@@ -229,7 +229,7 @@ public class InnerObjectPlanElasticQuery extends ElasticInnerObjectQuery {
private String like;
private Collection ids;
private Collection excludedIds;
- private Collection statuses;
+ private Collection statusIds;
private Collection versionStatuses;
private Collection accessTypes;
private Collection versions;
@@ -140,18 +140,18 @@ public class PlanElasticQuery extends ElasticQuery {
return this;
}
- public PlanElasticQuery statuses(PlanStatus value) {
- this.statuses = List.of(value);
+ public PlanElasticQuery statuses(UUID value) {
+ this.statusIds = List.of(value);
return this;
}
- public PlanElasticQuery statuses(PlanStatus... value) {
- this.statuses = Arrays.asList(value);
+ public PlanElasticQuery statuses(UUID... value) {
+ this.statusIds = Arrays.asList(value);
return this;
}
- public PlanElasticQuery statuses(Collection values) {
- this.statuses = values;
+ public PlanElasticQuery statuses(Collection values) {
+ this.statusIds = values;
return this;
}
@@ -224,7 +224,7 @@ public class PlanElasticQuery extends ElasticQuery {
@Override
protected Boolean isFalseQuery() {
- return this.isEmpty(this.ids) || this.isEmpty(this.versionStatuses) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes)|| this.isEmpty(this.statuses);
+ return this.isEmpty(this.ids) || this.isEmpty(this.versionStatuses) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes)|| this.isEmpty(this.statusIds);
}
@Override
@@ -265,7 +265,7 @@ public class PlanElasticQuery extends ElasticQuery {
List predicates = new ArrayList<>();
if (usePublic) {
predicates.add(this.and(
- this.equals(this.elasticFieldOf(PlanElasticEntity._status), PlanStatus.Finalized.getValue()),
+ this.equals(this.elasticFieldOf(PlanElasticEntity._statusId), PlanStatus.Finalized.getValue()),
this.equals(this.elasticFieldOf(PlanElasticEntity._accessType), PlanAccessType.Public.getValue())
));
}
@@ -328,8 +328,8 @@ public class PlanElasticQuery extends ElasticQuery {
if (this.excludedIds != null) {
predicates.add(this.not(this.containsUUID(this.elasticFieldOf(PlanElasticEntity._id), this.excludedIds)._toQuery())._toQuery());
}
- if (this.statuses != null) {
- predicates.add(this.contains(this.elasticFieldOf(PlanElasticEntity._status), this.statuses.stream().map(PlanStatus::getValue).toList().toArray(new Short[this.statuses.size()]))._toQuery());
+ if (this.statusIds != null) {
+ predicates.add(this.containsUUID(this.elasticFieldOf(PlanElasticEntity._statusId), this.statusIds)._toQuery());
}
if (this.versionStatuses != null) {
predicates.add(this.contains(this.elasticFieldOf(PlanElasticEntity._versionStatus), this.versionStatuses.stream().map(PlanVersionStatus::getValue).toList().toArray(new Short[this.versionStatuses.size()]))._toQuery());
@@ -363,7 +363,7 @@ public class PlanElasticQuery extends ElasticQuery {
if (columns.contains(PlanElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._id), UUID.class));
if (columns.contains(PlanElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._label), String.class));
if (columns.contains(PlanElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._description), String.class));
- if (columns.contains(PlanElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._status), PlanStatus.class));
+ if (columns.contains(PlanElasticEntity._statusId)) mocDoc.setStatusId(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._statusId), UUID.class));
if (columns.contains(PlanElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._versionStatus), PlanVersionStatus.class));
if (columns.contains(PlanElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._version), Short.class));
if (columns.contains(PlanElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(PlanElasticEntity._groupId), UUID.class));
@@ -383,7 +383,7 @@ public class PlanElasticQuery extends ElasticQuery {
if (item.match(PlanElasticEntity._id)) return this.elasticFieldOf(PlanElasticEntity._id);
else if (item.match(PlanElasticEntity._label)) return item instanceof OrderingFieldResolver ? this.elasticFieldOf(PlanElasticEntity._label).subfield(ElasticConstants.SubFields.keyword) : this.elasticFieldOf(PlanElasticEntity._label);
else if (item.match(PlanElasticEntity._description)) return this.elasticFieldOf(PlanElasticEntity._description);
- else if (item.match(PlanElasticEntity._status)) return this.elasticFieldOf(PlanElasticEntity._status);
+ else if (item.match(PlanElasticEntity._statusId)) return this.elasticFieldOf(PlanElasticEntity._statusId);
else if (item.match(PlanElasticEntity._version)) return this.elasticFieldOf(PlanElasticEntity._version);
else if (item.match(PlanElasticEntity._versionStatus)) return this.elasticFieldOf(PlanElasticEntity._versionStatus);
else if (item.match(PlanElasticEntity._groupId)) return this.elasticFieldOf(PlanElasticEntity._groupId);
diff --git a/backend/core/src/main/java/org/opencdmp/event/DescriptionStatusTouchedEvent.java b/backend/core/src/main/java/org/opencdmp/event/DescriptionStatusTouchedEvent.java
new file mode 100644
index 000000000..17c793a5d
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/event/DescriptionStatusTouchedEvent.java
@@ -0,0 +1,35 @@
+package org.opencdmp.event;
+
+import java.util.UUID;
+
+public class DescriptionStatusTouchedEvent {
+
+ public DescriptionStatusTouchedEvent() {
+ }
+
+ public DescriptionStatusTouchedEvent(UUID id, String tenantCode) {
+ this.id = id;
+ this.tenantCode = tenantCode;
+ }
+
+ private UUID id;
+
+ private String tenantCode;
+
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getTenantCode() {
+ return tenantCode;
+ }
+
+ public void setTenantCode(String tenantCode) {
+ this.tenantCode = tenantCode;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/event/EventBroker.java b/backend/core/src/main/java/org/opencdmp/event/EventBroker.java
index defc5be38..4d08202dd 100644
--- a/backend/core/src/main/java/org/opencdmp/event/EventBroker.java
+++ b/backend/core/src/main/java/org/opencdmp/event/EventBroker.java
@@ -53,6 +53,14 @@ public class EventBroker {
this.applicationEventPublisher.publishEvent(event);
}
+ public void emit(PlanStatusTouchedEvent event) {
+ this.applicationEventPublisher.publishEvent(event);
+ }
+
+ public void emit(DescriptionStatusTouchedEvent event) {
+ this.applicationEventPublisher.publishEvent(event);
+ }
+
public void emit(TagTouchedEvent event) {
this.applicationEventPublisher.publishEvent(event);
}
diff --git a/backend/core/src/main/java/org/opencdmp/event/PlanStatusTouchedEvent.java b/backend/core/src/main/java/org/opencdmp/event/PlanStatusTouchedEvent.java
new file mode 100644
index 000000000..dee289cfc
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/event/PlanStatusTouchedEvent.java
@@ -0,0 +1,34 @@
+package org.opencdmp.event;
+
+import java.util.UUID;
+
+public class PlanStatusTouchedEvent {
+
+ public PlanStatusTouchedEvent() {
+ }
+
+ public PlanStatusTouchedEvent(UUID id, String tenantCode) {
+ this.id = id;
+ this.tenantCode = tenantCode;
+ }
+
+ private UUID id;
+
+ private String tenantCode;
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getTenantCode() {
+ return tenantCode;
+ }
+
+ public void setTenantCode(String tenantCode) {
+ this.tenantCode = tenantCode;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/event/PlanTouchedEvent.java b/backend/core/src/main/java/org/opencdmp/event/PlanTouchedEvent.java
index 13f362c3a..edc4feab7 100644
--- a/backend/core/src/main/java/org/opencdmp/event/PlanTouchedEvent.java
+++ b/backend/core/src/main/java/org/opencdmp/event/PlanTouchedEvent.java
@@ -22,3 +22,4 @@ public class PlanTouchedEvent {
}
}
+
diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicDescription.java b/backend/core/src/main/java/org/opencdmp/model/PublicDescription.java
index 778d1df97..260007157 100644
--- a/backend/core/src/main/java/org/opencdmp/model/PublicDescription.java
+++ b/backend/core/src/main/java/org/opencdmp/model/PublicDescription.java
@@ -1,6 +1,5 @@
package org.opencdmp.model;
-import org.opencdmp.commons.enums.DescriptionStatus;
import java.time.Instant;
import java.util.UUID;
@@ -15,7 +14,7 @@ public class PublicDescription {
public static final String _label = "label";
- private DescriptionStatus status;
+ private PublicDescriptionStatus status;
public static final String _status = "status";
@@ -65,11 +64,11 @@ public class PublicDescription {
}
- public DescriptionStatus getStatus() {
+ public PublicDescriptionStatus getStatus() {
return status;
}
- public void setStatus(DescriptionStatus status) {
+ public void setStatus(PublicDescriptionStatus status) {
this.status = status;
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatus.java b/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatus.java
new file mode 100644
index 000000000..5c89d1c2d
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatus.java
@@ -0,0 +1,36 @@
+package org.opencdmp.model;
+
+
+import java.util.UUID;
+
+public class PublicDescriptionStatus {
+
+ public final static String _id = "id";
+ private UUID id;
+
+ public final static String _name = "name";
+ private String name;
+
+ public final static String _internalStatus = "internalStatus";
+ private org.opencdmp.commons.enums.DescriptionStatus internalStatus;
+
+ public final static String _definition = "definition";
+ private PublicDescriptionStatusDefinition definition;
+
+ public UUID getId() { return this.id; }
+ public void setId(UUID id) { this.id = id; }
+
+ public String getName() { return this.name; }
+ public void setName(String name) { this.name = name; }
+
+ public org.opencdmp.commons.enums.DescriptionStatus getInternalStatus() { return this.internalStatus; }
+ public void setInternalStatus(org.opencdmp.commons.enums.DescriptionStatus internalStatus) { this.internalStatus = internalStatus; }
+
+ public PublicDescriptionStatusDefinition getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(PublicDescriptionStatusDefinition definition) {
+ this.definition = definition;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatusDefinition.java b/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatusDefinition.java
new file mode 100644
index 000000000..6a0e26f82
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatusDefinition.java
@@ -0,0 +1,20 @@
+package org.opencdmp.model;
+
+import org.opencdmp.commons.enums.DescriptionStatusAvailableActionType;
+
+import java.util.List;
+
+public class PublicDescriptionStatusDefinition {
+
+
+ public final static String _availableActions = "availableActions";
+ private List availableActions;
+
+ public List getAvailableActions() {
+ return availableActions;
+ }
+
+ public void setAvailableActions(List availableActions) {
+ this.availableActions = availableActions;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicPlan.java b/backend/core/src/main/java/org/opencdmp/model/PublicPlan.java
index b95aded25..1415cc27a 100644
--- a/backend/core/src/main/java/org/opencdmp/model/PublicPlan.java
+++ b/backend/core/src/main/java/org/opencdmp/model/PublicPlan.java
@@ -1,7 +1,6 @@
package org.opencdmp.model;
import org.opencdmp.commons.enums.PlanAccessType;
-import org.opencdmp.commons.enums.PlanStatus;
import java.time.Instant;
import java.util.List;
@@ -36,7 +35,7 @@ public class PublicPlan {
public static final String _publishedAt = "publishedAt";
- private PlanStatus status;
+ private PublicPlanStatus status;
public static final String _status = "status";
private UUID groupId;
@@ -118,11 +117,11 @@ public class PublicPlan {
this.publishedAt = publishedAt;
}
- public PlanStatus getStatus() {
+ public PublicPlanStatus getStatus() {
return status;
}
- public void setStatus(PlanStatus status) {
+ public void setStatus(PublicPlanStatus status) {
this.status = status;
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatus.java b/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatus.java
new file mode 100644
index 000000000..dc80f6816
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatus.java
@@ -0,0 +1,43 @@
+package org.opencdmp.model;
+
+
+import org.opencdmp.commons.enums.PlanStatus;
+
+import java.util.UUID;
+
+public class PublicPlanStatus {
+
+ public final static String _id = "id";
+ private UUID id;
+
+ public final static String _name = "name";
+ private String name;
+
+ public final static String _internalStatus = "internalStatus";
+ private PlanStatus internalStatus;
+
+ public final static String _definition = "definition";
+ private PublicPlanStatusDefinition definition;
+
+ public UUID getId() { return this.id; }
+ public void setId(UUID id) { this.id = id; }
+
+ public String getName() { return this.name; }
+ public void setName(String name) { this.name = name; }
+
+ public PlanStatus getInternalStatus() {
+ return internalStatus;
+ }
+
+ public void setInternalStatus(PlanStatus internalStatus) {
+ this.internalStatus = internalStatus;
+ }
+
+ public PublicPlanStatusDefinition getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(PublicPlanStatusDefinition definition) {
+ this.definition = definition;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatusDefinition.java b/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatusDefinition.java
new file mode 100644
index 000000000..ad38047bb
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatusDefinition.java
@@ -0,0 +1,21 @@
+package org.opencdmp.model;
+
+import org.opencdmp.commons.enums.PlanStatusAvailableActionType;
+
+import java.util.List;
+
+public class PublicPlanStatusDefinition {
+
+
+ public final static String _availableActions = "availableActions";
+ private List availableActions;
+
+
+ public List getAvailableActions() {
+ return availableActions;
+ }
+
+ public void setAvailableActions(List availableActions) {
+ this.availableActions = availableActions;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/model/RecentActivityItemLookup.java b/backend/core/src/main/java/org/opencdmp/model/RecentActivityItemLookup.java
index 028a96153..7b1d6b499 100644
--- a/backend/core/src/main/java/org/opencdmp/model/RecentActivityItemLookup.java
+++ b/backend/core/src/main/java/org/opencdmp/model/RecentActivityItemLookup.java
@@ -6,9 +6,7 @@ import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.enums.RecentActivityOrder;
import org.opencdmp.model.description.Description;
import org.opencdmp.model.plan.Plan;
-import org.opencdmp.query.lookup.DescriptionLookup;
-import org.opencdmp.query.lookup.PlanLookup;
-import org.opencdmp.query.lookup.PlanUserLookup;
+import org.opencdmp.query.lookup.*;
import gr.cite.tools.data.query.Ordering;
import gr.cite.tools.data.query.Paging;
import gr.cite.tools.fieldset.BaseFieldSet;
@@ -97,8 +95,12 @@ public class RecentActivityItemLookup{
DescriptionLookup lookup = new DescriptionLookup();
lookup.setIsActive(List.of(IsActive.Active));
if (this.like != null) lookup.setLike(this.like);
- if (this.onlyDraft != null) lookup.setStatuses(List.of(DescriptionStatus.Draft));
- else lookup.setStatuses(List.of(DescriptionStatus.Draft, DescriptionStatus.Finalized));
+ if (this.onlyDraft != null) {
+ DescriptionStatusLookup descriptionStatusLookup = new DescriptionStatusLookup();
+ descriptionStatusLookup.setInternalStatuses(List.of(DescriptionStatus.Draft));
+ descriptionStatusLookup.setIsActive(List.of(IsActive.Active));
+ lookup.setDescriptionStatusSubQuery(descriptionStatusLookup);
+ }
if (this.userIds != null) {
PlanLookup planLookup = new PlanLookup();
PlanUserLookup planUserLookup = new PlanUserLookup();
@@ -131,7 +133,12 @@ public class RecentActivityItemLookup{
PlanLookup lookup = new PlanLookup();
lookup.setIsActive(List.of(IsActive.Active));
if (this.like != null) lookup.setLike(this.like);
- if (this.onlyDraft != null) lookup.setStatuses(List.of(PlanStatus.Draft));
+ if (this.onlyDraft != null) {
+ PlanStatusLookup planStatusLookup = new PlanStatusLookup();
+ planStatusLookup.setInternalStatuses(List.of(PlanStatus.Draft));
+ planStatusLookup.setIsActive(List.of(IsActive.Active));
+ lookup.setPlanStatusSubQuery(planStatusLookup);
+ }
if (this.userIds != null) {
PlanUserLookup planUserLookup = new PlanUserLookup();
planUserLookup.setUserIds(this.userIds);
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionBuilder.java
index 0984191d4..6b8989995 100644
--- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionBuilder.java
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionBuilder.java
@@ -10,10 +10,8 @@ import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.DescriptionEntity;
-import org.opencdmp.model.PublicDescription;
-import org.opencdmp.model.PublicDescriptionTemplate;
-import org.opencdmp.model.PublicPlan;
-import org.opencdmp.model.PublicPlanDescriptionTemplate;
+import org.opencdmp.model.*;
+import org.opencdmp.query.DescriptionStatusQuery;
import org.opencdmp.query.DescriptionTemplateQuery;
import org.opencdmp.query.PlanDescriptionTemplateQuery;
import org.opencdmp.query.PlanQuery;
@@ -66,12 +64,15 @@ public class PublicDescriptionBuilder extends BaseBuilder planItemsMap = this.collectPlans(planFields, data);
+ FieldSet descriptionStatusFields = fields.extractPrefixed(this.asPrefix(PublicDescription._status));
+ Map descriptionStatusItemsMap = this.collectDescriptionStatuses(descriptionStatusFields, data);
+
List models = new ArrayList<>();
for (DescriptionEntity d : data) {
PublicDescription m = new PublicDescription();
if (fields.hasField(this.asIndexer(PublicDescription._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(PublicDescription._label))) m.setLabel(d.getLabel());
- if (fields.hasField(this.asIndexer(PublicDescription._status))) m.setStatus(d.getStatus());
+ if (!descriptionStatusFields.isEmpty() && descriptionStatusItemsMap != null && descriptionStatusItemsMap.containsKey(d.getStatusId())) m.setStatus(descriptionStatusItemsMap.get(d.getStatusId()));
if (fields.hasField(this.asIndexer(PublicDescription._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(PublicDescription._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(PublicDescription._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
@@ -177,4 +178,34 @@ public class PublicDescriptionBuilder extends BaseBuilder collectDescriptionStatuses(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", PublicDescriptionStatus.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(PublicDescriptionStatus._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(DescriptionEntity::getStatusId).distinct().collect(Collectors.toList()),
+ x -> {
+ PublicDescriptionStatus item = new PublicDescriptionStatus();
+ item.setId(x);
+ return item;
+ },
+ PublicDescriptionStatus::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDescriptionStatus._id);
+ DescriptionStatusQuery q = this.queryFactory.query(DescriptionStatusQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getStatusId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(PublicDescriptionStatusBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicDescriptionStatus::getId);
+ }
+ if (!fields.hasField(PublicDescriptionStatus._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
+
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusBuilder.java
new file mode 100644
index 000000000..099d2406b
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusBuilder.java
@@ -0,0 +1,68 @@
+package org.opencdmp.model.builder;
+
+import gr.cite.tools.data.builder.BuilderFactory;
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.fieldset.FieldSet;
+import gr.cite.tools.logging.DataLogEntry;
+import gr.cite.tools.logging.LoggerService;
+import org.opencdmp.authorization.AuthorizationFlags;
+import org.opencdmp.commons.XmlHandlingService;
+import org.opencdmp.commons.types.descriptionstatus.DescriptionStatusDefinitionEntity;
+import org.opencdmp.convention.ConventionService;
+
+
+import org.opencdmp.data.DescriptionStatusEntity;
+import org.opencdmp.model.PublicDescriptionStatus;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class PublicDescriptionStatusBuilder extends BaseBuilder {
+
+ private final XmlHandlingService xmlHandlingService;
+ private final BuilderFactory builderFactory;
+
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+ @Autowired
+ public PublicDescriptionStatusBuilder(
+ ConventionService conventionService, XmlHandlingService xmlHandlingService, BuilderFactory builderFactory) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDescriptionStatusBuilder.class)));
+ this.xmlHandlingService = xmlHandlingService;
+ this.builderFactory = builderFactory;
+ }
+
+ public PublicDescriptionStatusBuilder authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+ @Override
+ public List build(FieldSet fields, List data) throws MyApplicationException {
+ this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
+ this.logger.trace(new DataLogEntry("requested fields", fields));
+ if (fields == null || data == null || fields.isEmpty())
+ return new ArrayList<>();
+ List models = new ArrayList<>();
+ FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(PublicDescriptionStatus._definition));
+
+ for (DescriptionStatusEntity d : data) {
+ PublicDescriptionStatus m = new PublicDescriptionStatus();
+ if (fields.hasField(this.asIndexer(PublicDescriptionStatus._id))) m.setId(d.getId());
+ if (fields.hasField(this.asIndexer(PublicDescriptionStatus._name))) m.setName(d.getName());
+ if (fields.hasField(this.asIndexer(PublicDescriptionStatus._internalStatus))) m.setInternalStatus(d.getInternalStatus());
+ if (!definitionFields.isEmpty() && d.getDefinition() != null) {
+ DescriptionStatusDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DescriptionStatusDefinitionEntity.class, d.getDefinition());
+ m.setDefinition(this.builderFactory.builder(PublicDescriptionStatusDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
+ }
+ models.add(m);
+ }
+ this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
+ return models;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusDefinitionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusDefinitionBuilder.java
new file mode 100644
index 000000000..3445595d7
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusDefinitionBuilder.java
@@ -0,0 +1,51 @@
+package org.opencdmp.model.builder;
+
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.fieldset.FieldSet;
+import gr.cite.tools.logging.DataLogEntry;
+import gr.cite.tools.logging.LoggerService;
+import org.opencdmp.authorization.AuthorizationFlags;
+import org.opencdmp.commons.types.descriptionstatus.DescriptionStatusDefinitionEntity;
+import org.opencdmp.convention.ConventionService;
+
+import org.opencdmp.model.PublicDescriptionStatusDefinition;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class PublicDescriptionStatusDefinitionBuilder extends BaseBuilder {
+
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+ @Autowired
+ public PublicDescriptionStatusDefinitionBuilder(
+ ConventionService conventionService) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDescriptionStatusDefinitionBuilder.class)));
+ }
+
+ public PublicDescriptionStatusDefinitionBuilder authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+ @Override
+ public List build(FieldSet fields, List data) throws MyApplicationException {
+ this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
+ this.logger.trace(new DataLogEntry("requested fields", fields));
+ if (fields == null || data == null || fields.isEmpty())
+ return new ArrayList<>();
+ List models = new ArrayList<>();
+ for (DescriptionStatusDefinitionEntity d : data) {
+ PublicDescriptionStatusDefinition m = new PublicDescriptionStatusDefinition();
+ if (fields.hasField(this.asIndexer(PublicDescriptionStatusDefinition._availableActions))) m.setAvailableActions(d.getAvailableActions());
+ models.add(m);
+ }
+ this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
+ return models;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanBuilder.java
index 560305ba5..e63666b61 100644
--- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanBuilder.java
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanBuilder.java
@@ -71,6 +71,9 @@ public class PublicPlanBuilder extends BaseBuilder {
FieldSet otherPlanVersionsFields = fields.extractPrefixed(this.asPrefix(PublicPlan._otherPlanVersions));
Map> otherPlanVersionsMap = this.collectOtherPlanVersions(otherPlanVersionsFields, data);
+ FieldSet planStatusFields = fields.extractPrefixed(this.asPrefix(PublicPlan._status));
+ Map planStatusItemsMap = this.collectPlanStatuses(planStatusFields, data);
+
for (PlanEntity d : data) {
PublicPlan m = new PublicPlan();
if (fields.hasField(this.asIndexer(PublicPlan._id))) m.setId(d.getId());
@@ -80,7 +83,7 @@ public class PublicPlanBuilder extends BaseBuilder {
if (fields.hasField(this.asIndexer(PublicPlan._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
if (fields.hasField(this.asIndexer(PublicPlan._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(PublicPlan._accessType))) m.setAccessType(d.getAccessType());
- if (fields.hasField(this.asIndexer(PublicPlan._status))) m.setStatus(d.getStatus());
+ if (!planStatusFields.isEmpty() && planStatusItemsMap != null && planStatusItemsMap.containsKey(d.getStatusId())) m.setStatus(planStatusItemsMap.get(d.getStatusId()));
if (fields.hasField(this.asIndexer(PublicPlan._groupId))) m.setGroupId(d.getGroupId());
if (fields.hasField(this.asIndexer(PublicPlan._accessType))) m.setAccessType(d.getAccessType());
@@ -190,4 +193,34 @@ public class PublicPlanBuilder extends BaseBuilder {
return itemMap;
}
+ private Map collectPlanStatuses(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", PublicPlanStatus.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(PublicPlanStatus._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(PlanEntity::getStatusId).distinct().collect(Collectors.toList()),
+ x -> {
+ PublicPlanStatus item = new PublicPlanStatus();
+ item.setId(x);
+ return item;
+ },
+ PublicPlanStatus::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicPlanStatus._id);
+ PlanStatusQuery q = this.queryFactory.query(PlanStatusQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(PlanEntity::getStatusId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(PublicPlanStatusBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PublicPlanStatus::getId);
+ }
+ if (!fields.hasField(PublicPlanStatus._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
+
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusBuilder.java
new file mode 100644
index 000000000..e1c5a31f6
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusBuilder.java
@@ -0,0 +1,68 @@
+package org.opencdmp.model.builder;
+
+import gr.cite.tools.data.builder.BuilderFactory;
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.fieldset.FieldSet;
+import gr.cite.tools.logging.DataLogEntry;
+import gr.cite.tools.logging.LoggerService;
+import org.opencdmp.authorization.AuthorizationFlags;
+import org.opencdmp.commons.XmlHandlingService;
+import org.opencdmp.commons.types.planstatus.PlanStatusDefinitionEntity;
+import org.opencdmp.convention.ConventionService;
+import org.opencdmp.data.PlanStatusEntity;
+import org.opencdmp.model.PublicPlanStatus;
+import org.opencdmp.model.builder.planstatus.PlanStatusDefinitionBuilder;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class PublicPlanStatusBuilder extends BaseBuilder {
+
+ private final XmlHandlingService xmlHandlingService;
+ private final BuilderFactory builderFactory;
+
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+ @Autowired
+ public PublicPlanStatusBuilder(
+ ConventionService conventionService, XmlHandlingService xmlHandlingService, BuilderFactory builderFactory) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicPlanStatusBuilder.class)));
+ this.xmlHandlingService = xmlHandlingService;
+ this.builderFactory = builderFactory;
+ }
+
+ public PublicPlanStatusBuilder authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+ @Override
+ public List build(FieldSet fields, List data) throws MyApplicationException {
+ this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
+ this.logger.trace(new DataLogEntry("requested fields", fields));
+ if (fields == null || data == null || fields.isEmpty())
+ return new ArrayList<>();
+
+ FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(PublicPlanStatus._definition));
+ List models = new ArrayList<>();
+
+ for (PlanStatusEntity d : data) {
+ PublicPlanStatus m = new PublicPlanStatus();
+ if (fields.hasField(this.asIndexer(PublicPlanStatus._id))) m.setId(d.getId());
+ if (fields.hasField(this.asIndexer(PublicPlanStatus._name))) m.setName(d.getName());
+ if (fields.hasField(this.asIndexer(PublicPlanStatus._internalStatus))) m.setInternalStatus(d.getInternalStatus());
+ if (!definitionFields.isEmpty() && d.getDefinition() != null) {
+ PlanStatusDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(PlanStatusDefinitionEntity.class, d.getDefinition());
+ m.setDefinition(this.builderFactory.builder(PublicPlanStatusDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
+ }
+ models.add(m);
+ }
+ this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
+ return models;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusDefinitionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusDefinitionBuilder.java
new file mode 100644
index 000000000..6ba1fcfdb
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusDefinitionBuilder.java
@@ -0,0 +1,50 @@
+package org.opencdmp.model.builder;
+
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.fieldset.FieldSet;
+import gr.cite.tools.logging.DataLogEntry;
+import gr.cite.tools.logging.LoggerService;
+import org.opencdmp.authorization.AuthorizationFlags;
+import org.opencdmp.commons.types.planstatus.PlanStatusDefinitionEntity;
+import org.opencdmp.convention.ConventionService;
+import org.opencdmp.model.PublicPlanStatusDefinition;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class PublicPlanStatusDefinitionBuilder extends BaseBuilder {
+
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+ @Autowired
+ public PublicPlanStatusDefinitionBuilder(
+ ConventionService conventionService) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicPlanStatusDefinitionBuilder.class)));
+ }
+
+ public PublicPlanStatusDefinitionBuilder authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+ @Override
+ public List build(FieldSet fields, List data) throws MyApplicationException {
+ this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
+ this.logger.trace(new DataLogEntry("requested fields", fields));
+ if (fields == null || data == null || fields.isEmpty())
+ return new ArrayList<>();
+ List models = new ArrayList<>();
+ for (PlanStatusDefinitionEntity d : data) {
+ PublicPlanStatusDefinition m = new PublicPlanStatusDefinition();
+ if (fields.hasField(this.asIndexer(PublicPlanStatusDefinition._availableActions))) m.setAvailableActions(d.getAvailableActions());
+ models.add(m);
+ }
+ this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
+ return models;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/PlanUserCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/PlanUserCommonModelBuilder.java
index 27d945528..457278ab4 100644
--- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/PlanUserCommonModelBuilder.java
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/PlanUserCommonModelBuilder.java
@@ -78,7 +78,7 @@ public class PlanUserCommonModelBuilder extends BaseCommonModelBuilder itemMap;
- UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(PlanUserEntity::getUserId).distinct().collect(Collectors.toList()));
+ UserQuery q = this.queryFactory.query(UserQuery.class).disableTracking().isActive(IsActive.Active).ids(data.stream().map(PlanUserEntity::getUserId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(UserCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, UserEntity::getId);
return itemMap;
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java
index f8fbb106b..edb4349f8 100644
--- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionCommonModelBuilder.java
@@ -8,6 +8,7 @@ import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commonmodels.enums.DescriptionStatus;
import org.opencdmp.commonmodels.models.description.DescriptionModel;
+import org.opencdmp.commonmodels.models.description.DescriptionStatusModel;
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
import org.opencdmp.commonmodels.models.plan.PlanModel;
import org.opencdmp.commons.JsonHandlingService;
@@ -25,9 +26,7 @@ import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse;
import org.opencdmp.model.builder.commonmodels.descriptiontemplate.DescriptionTemplateCommonModelBuilder;
import org.opencdmp.model.builder.commonmodels.plan.PlanCommonModelBuilder;
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
-import org.opencdmp.query.DescriptionTemplateQuery;
-import org.opencdmp.query.PlanDescriptionTemplateQuery;
-import org.opencdmp.query.PlanQuery;
+import org.opencdmp.query.*;
import org.opencdmp.service.visibility.VisibilityService;
import org.opencdmp.service.visibility.VisibilityServiceImpl;
import org.slf4j.LoggerFactory;
@@ -103,18 +102,15 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder definitionEntityMap = this.collectDescriptionTemplateDefinitions(data);
Map planDescriptionTemplateSections = this.collectPlanDescriptionTemplateSections(data);
+ Map descriptionStatuses = this.collectDescriptionStatuses(data);
+
List> models = new ArrayList<>();
for (DescriptionEntity d : data) {
DescriptionModel m = new DescriptionModel();
m.setId(d.getId());
m.setLabel(d.getLabel());
m.setDescription(d.getDescription());
- switch (d.getStatus()){
- case Finalized -> m.setStatus(DescriptionStatus.Finalized);
- case Draft -> m.setStatus(DescriptionStatus.Draft);
- case Canceled -> m.setStatus(DescriptionStatus.Canceled);
- default -> throw new MyApplicationException("unrecognized type " + d.getStatus());
- }
+ if (descriptionStatuses != null && d.getStatusId() != null && descriptionStatuses.containsKey(d.getStatusId())) m.setStatus(descriptionStatuses.get(d.getStatusId()));
m.setCreatedAt(d.getCreatedAt());
m.setDescription(d.getDescription());
if (plans != null && d.getPlanId() != null && plans.containsKey(d.getPlanId())) m.setPlan(plans.get(d.getPlanId()));
@@ -197,7 +193,8 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder collectDescriptionStatuses(List data) throws MyApplicationException {
+ if (data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", DescriptionStatusModel.class.getSimpleName());
+
+ Map itemMap;
+ DescriptionStatusQuery q = this.queryFactory.query(DescriptionStatusQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getStatusId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(DescriptionStatusCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, DescriptionStatusEntity::getId);
+
+ return itemMap;
+ }
+
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionStatusCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionStatusCommonModelBuilder.java
new file mode 100644
index 000000000..48a055f80
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/description/DescriptionStatusCommonModelBuilder.java
@@ -0,0 +1,67 @@
+package org.opencdmp.model.builder.commonmodels.description;
+
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.logging.LoggerService;
+import org.opencdmp.authorization.AuthorizationFlags;
+import org.opencdmp.commonmodels.models.description.DescriptionStatusModel;
+import org.opencdmp.convention.ConventionService;
+import org.opencdmp.data.DescriptionStatusEntity;
+import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
+import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse;
+
+
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Optional;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class DescriptionStatusCommonModelBuilder extends BaseCommonModelBuilder {
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+ @Autowired
+ public DescriptionStatusCommonModelBuilder(
+ ConventionService conventionService
+ ) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionStatusCommonModelBuilder.class)));
+ }
+
+ public DescriptionStatusCommonModelBuilder authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+
+ @Override
+ protected List> buildInternal(List data) throws MyApplicationException {
+ this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
+ if (data == null || data.isEmpty()) return new ArrayList<>();
+
+ List> models = new ArrayList<>();
+ for (DescriptionStatusEntity d : data) {
+ DescriptionStatusModel m = new DescriptionStatusModel();
+ m.setId(d.getId());
+ m.setName(d.getName());
+ if (d.getInternalStatus() != null) {
+ switch (d.getInternalStatus()){
+ case Finalized -> m.setInternalStatus(org.opencdmp.commonmodels.enums.DescriptionStatus.Finalized);
+ case Draft -> m.setInternalStatus(org.opencdmp.commonmodels.enums.DescriptionStatus.Draft);
+ case Canceled -> m.setInternalStatus(org.opencdmp.commonmodels.enums.DescriptionStatus.Canceled);
+ default -> throw new MyApplicationException("unrecognized type " + d.getInternalStatus());
+ }
+ }
+
+ models.add(new CommonModelBuilderItemResponse<>(m, d));
+ }
+
+ this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
+
+ return models;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanCommonModelBuilder.java
index d99bb0f88..1a4ace692 100644
--- a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanCommonModelBuilder.java
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanCommonModelBuilder.java
@@ -15,6 +15,7 @@ import org.opencdmp.commonmodels.models.FileEnvelopeModel;
import org.opencdmp.commonmodels.models.UserModel;
import org.opencdmp.commonmodels.models.description.DescriptionModel;
import org.opencdmp.commonmodels.models.plan.PlanModel;
+import org.opencdmp.commonmodels.models.plan.PlanStatusModel;
import org.opencdmp.commonmodels.models.planblueprint.PlanBlueprintModel;
import org.opencdmp.commonmodels.models.planreference.PlanReferenceModel;
import org.opencdmp.commons.JsonHandlingService;
@@ -127,6 +128,7 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder creators = this.collectCreators(data);
Map planBlueprints = this.collectPlanBlueprints(data);
Map definitionEntityMap = this.collectPlanBlueprintDefinitions(data);
+ Map planStatuses = this.collectPlanStatuses(data);
for (PlanEntity d : data) {
PlanModel m = new PlanModel();
@@ -137,11 +139,7 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder m.setStatus(PlanStatus.Finalized);
- case Draft -> m.setStatus(PlanStatus.Draft);
- default -> throw new MyApplicationException("unrecognized type " + d.getStatus());
- }
+ if (planStatuses != null && !planStatuses.isEmpty() && d.getStatusId() != null && planStatuses.containsKey(d.getStatusId())) m.setStatus(planStatuses.get(d.getStatusId()));
if (entityDois != null && !entityDois.isEmpty() && entityDois.containsKey(d.getId())) m.setEntityDois(entityDois.get(d.getId()));
if (creators != null && !creators.isEmpty() && d.getCreatorId() != null && creators.containsKey(d.getCreatorId())) m.setCreator(creators.get(d.getCreatorId()));
if (planBlueprints != null && !planBlueprints.isEmpty() && d.getBlueprintId() != null && planBlueprints.containsKey(d.getBlueprintId())) m.setPlanBlueprint(planBlueprints.get(d.getBlueprintId()));
@@ -194,8 +192,8 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder> itemMap;
- PlanUserQuery query = this.queryFactory.query(PlanUserQuery.class).disableTracking().isActives(IsActive.Active).authorize(this.authorize).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList()));
- itemMap = this.builderFactory.builder(PlanUserCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, PlanUserEntity::getPlanId);
+ PlanUserQuery query = this.queryFactory.query(PlanUserQuery.class).disableTracking().isActives(IsActive.Active).planIds(data.stream().map(PlanEntity::getId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(PlanUserCommonModelBuilder.class).asMasterKey(query, PlanUserEntity::getPlanId);
return itemMap;
}
@@ -219,7 +217,8 @@ public class PlanCommonModelBuilder extends BaseCommonModelBuilder collectPlanStatuses(List data) throws MyApplicationException {
+ if (data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", PlanStatusModel.class.getSimpleName());
+
+ Map itemMap;
+ PlanStatusQuery q = this.queryFactory.query(PlanStatusQuery.class).isActives(IsActive.Active).authorize(this.authorize).ids(data.stream().filter(x-> x.getStatusId() != null).map(PlanEntity::getStatusId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(PlanStatusCommonModelBuilder.class).authorize(this.authorize).asForeignKey(q, PlanStatusEntity::getId);
+ return itemMap;
+ }
+
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanStatusCommonModelBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanStatusCommonModelBuilder.java
new file mode 100644
index 000000000..eb8628c6e
--- /dev/null
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/commonmodels/plan/PlanStatusCommonModelBuilder.java
@@ -0,0 +1,64 @@
+package org.opencdmp.model.builder.commonmodels.plan;
+
+import gr.cite.tools.exception.MyApplicationException;
+import gr.cite.tools.logging.LoggerService;
+import org.opencdmp.authorization.AuthorizationFlags;
+import org.opencdmp.commonmodels.models.plan.PlanStatusModel;
+import org.opencdmp.convention.ConventionService;
+import org.opencdmp.data.PlanStatusEntity;
+import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
+import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Optional;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class PlanStatusCommonModelBuilder extends BaseCommonModelBuilder {
+ private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+ @Autowired
+ public PlanStatusCommonModelBuilder(
+ ConventionService conventionService
+ ) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanStatusCommonModelBuilder.class)));
+ }
+
+ public PlanStatusCommonModelBuilder authorize(EnumSet values) {
+ this.authorize = values;
+ return this;
+ }
+
+
+ @Override
+ protected List> buildInternal(List data) throws MyApplicationException {
+ this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
+ if (data == null || data.isEmpty()) return new ArrayList<>();
+
+ List> models = new ArrayList<>();
+ for (PlanStatusEntity d : data) {
+ PlanStatusModel m = new PlanStatusModel();
+ m.setId(d.getId());
+ m.setName(d.getName());
+ if (d.getInternalStatus() != null) {
+ switch (d.getInternalStatus()){
+ case Finalized -> m.setInternalStatus(org.opencdmp.commonmodels.enums.PlanStatus.Finalized);
+ case Draft -> m.setInternalStatus(org.opencdmp.commonmodels.enums.PlanStatus.Draft);
+ default -> throw new MyApplicationException("unrecognized type " + d.getInternalStatus());
+ }
+ }
+
+ models.add(new CommonModelBuilderItemResponse<>(m, d));
+ }
+
+ this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
+
+ return models;
+ }
+}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java
index 374f74996..c2e209f43 100644
--- a/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java
@@ -13,12 +13,12 @@ import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.authorization.authorizationcontentresolver.AuthorizationContentResolver;
import org.opencdmp.commons.JsonHandlingService;
import org.opencdmp.commons.XmlHandlingService;
+import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.commons.types.description.PropertyDefinitionEntity;
import org.opencdmp.commons.types.descriptiontemplate.DefinitionEntity;
import org.opencdmp.convention.ConventionService;
-import org.opencdmp.data.DescriptionEntity;
-import org.opencdmp.data.DescriptionTemplateEntity;
+import org.opencdmp.data.*;
import org.opencdmp.model.DescriptionTag;
import org.opencdmp.model.PlanDescriptionTemplate;
import org.opencdmp.model.builder.BaseBuilder;
@@ -26,14 +26,19 @@ import org.opencdmp.model.builder.DescriptionTagBuilder;
import org.opencdmp.model.builder.PlanDescriptionTemplateBuilder;
import org.opencdmp.model.builder.UserBuilder;
import org.opencdmp.model.builder.descriptionreference.DescriptionReferenceBuilder;
+import org.opencdmp.model.builder.descriptionstatus.DescriptionStatusBuilder;
import org.opencdmp.model.builder.descriptiontemplate.DescriptionTemplateBuilder;
import org.opencdmp.model.builder.plan.PlanBuilder;
import org.opencdmp.model.description.Description;
import org.opencdmp.model.descriptionreference.DescriptionReference;
+import org.opencdmp.model.descriptionstatus.DescriptionStatus;
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
import org.opencdmp.model.plan.Plan;
+import org.opencdmp.model.planstatus.PlanStatusDefinitionAuthorization;
import org.opencdmp.model.user.User;
import org.opencdmp.query.*;
+import org.opencdmp.service.custompolicy.CustomPolicyService;
+import org.opencdmp.service.descriptionstatus.DescriptionStatusService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@@ -55,14 +60,16 @@ public class DescriptionBuilder extends BaseBuilder authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public DescriptionBuilder(
- ConventionService conventionService,
- QueryFactory queryFactory,
- BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService, AuthorizationService authorizationService, AuthorizationContentResolver authorizationContentResolver, TenantScope tenantScope) {
+ ConventionService conventionService,
+ QueryFactory queryFactory,
+ BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService, AuthorizationService authorizationService, AuthorizationContentResolver authorizationContentResolver, TenantScope tenantScope, CustomPolicyService customPolicyService, DescriptionStatusService descriptionStatusService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
@@ -71,6 +78,8 @@ public class DescriptionBuilder extends BaseBuilder values) {
@@ -85,6 +94,12 @@ public class DescriptionBuilder extends BaseBuilder();
+ FieldSet statusFields = fields.extractPrefixed(this.asPrefix(Description._status));
+ Map statusItemsMap = this.collectDescriptionStatuses(statusFields, data);
+
+ FieldSet availableStatusesFields = fields.extractPrefixed(this.asPrefix(Description._availableStatuses));
+ Map> avaialbleStatusesItemsMap = this.collectAvailableDescriptionStatuses(availableStatusesFields, data);
+
FieldSet planDescriptionTemplateFields = fields.extractPrefixed(this.asPrefix(Description._planDescriptionTemplate));
Map planDescriptionTemplateItemsMap = this.collectPlanDescriptionTemplates(planDescriptionTemplateFields, data);
@@ -110,13 +125,15 @@ public class DescriptionBuilder extends BaseBuilder authorizationFlags = this.extractAuthorizationFlags(fields, Description._authorizationFlags, this.authorizationContentResolver.getPermissionNames());
Map affiliatedResourceMap = authorizationFlags == null || authorizationFlags.isEmpty() ? null : this.authorizationContentResolver.descriptionsAffiliation(data.stream().map(DescriptionEntity::getId).collect(Collectors.toList()));
+ FieldSet statusAuthorizationFlags = fields.extractPrefixed(this.asPrefix(Description._statusAuthorizationFlags));
List models = new ArrayList<>();
for (DescriptionEntity d : data) {
Description m = new Description();
if (fields.hasField(this.asIndexer(Description._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(Description._tenantId))) m.setTenantId(d.getTenantId());
if (fields.hasField(this.asIndexer(Description._label))) m.setLabel(d.getLabel());
- if (fields.hasField(this.asIndexer(Description._status))) m.setStatus(d.getStatus());
+ if (!statusFields.isEmpty() && statusItemsMap != null && statusItemsMap.containsKey(d.getStatusId())) m.setStatus(statusItemsMap.get(d.getStatusId()));
+ if (avaialbleStatusesItemsMap != null && !avaialbleStatusesItemsMap.isEmpty() && avaialbleStatusesItemsMap.containsKey(d.getId())) m.setAvailableStatuses(avaialbleStatusesItemsMap.get(d.getId()));
if (fields.hasField(this.asIndexer(Description._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(Description._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(Description._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
@@ -135,6 +152,9 @@ public class DescriptionBuilder extends BaseBuilder collectDescriptionStatuses(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", DescriptionStatus.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(DescriptionStatus._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(DescriptionEntity::getStatusId).distinct().collect(Collectors.toList()),
+ x -> {
+ DescriptionStatus item = new DescriptionStatus();
+ item.setId(x);
+ return item;
+ },
+ DescriptionStatus::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(DescriptionStatus._id);
+ DescriptionStatusQuery q = this.queryFactory.query(DescriptionStatusQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getStatusId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(DescriptionStatusBuilder.class).authorize(this.authorize).asForeignKey(q, clone, DescriptionStatus::getId);
+ }
+ if (!fields.hasField(DescriptionStatus._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
+
+ private Map> collectAvailableDescriptionStatuses(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty()) return null;
+ this.logger.debug("checking related - {}", DescriptionStatus.class.getSimpleName());
+
+ Map> itemMap = new HashMap<>();
+ FieldSet fieldSet = new BaseFieldSet(fields.getFields()).ensure(DescriptionStatus._id);
+ Map> itemStatusIdsMap = this.descriptionStatusService.getAuthorizedAvailableStatusIds(data.stream().map(DescriptionEntity::getId).collect(Collectors.toList()));
+
+ List statusEntities = this.queryFactory.query(DescriptionStatusQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(itemStatusIdsMap.values().stream().flatMap(List::stream).distinct().collect(Collectors.toList())).collectAs(fieldSet);
+ List descriptionStatuses = this.builderFactory.builder(DescriptionStatusBuilder.class).authorize(this.authorize).build(fieldSet, statusEntities);
+
+ for (DescriptionEntity entity: data) {
+ itemMap.put(entity.getId(), new ArrayList<>());
+ List statusIds = itemStatusIdsMap.getOrDefault(entity.getId(), new ArrayList<>());
+ for (UUID statusId: statusIds) {
+ itemMap.get(entity.getId()).addAll(descriptionStatuses.stream().filter(x -> x.getId().equals(statusId)).collect(Collectors.toList()));
+ }
+ }
+
+ return itemMap;
+ }
+
private Map collectUsers(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty())
return null;
@@ -315,4 +387,22 @@ public class DescriptionBuilder extends BaseBuilder evaluateStatusAuthorizationFlags(AuthorizationService authorizationService, FieldSet statusAuthorizationFlags, DescriptionEntity description) {
+ List allowed = new ArrayList<>();
+ if (statusAuthorizationFlags == null) return allowed;
+ if (authorizationService == null) return allowed;
+ if (description == null) return allowed;
+
+ String editPermission = this.customPolicyService.getDescriptionStatusCanEditStatusPermission(description.getStatusId());
+ AffiliatedResource affiliatedResource = this.authorizationContentResolver.planAffiliation(description.getPlanId());
+ for (String permission : statusAuthorizationFlags.getFields()) {
+ if (statusAuthorizationFlags.hasField(this.asIndexer(PlanStatusDefinitionAuthorization._edit))) {
+ Boolean isAllowed = affiliatedResource == null ? this.authorizationService.authorize(editPermission) : this.authorizationService.authorizeAtLeastOne(List.of(affiliatedResource), editPermission);
+ if (isAllowed) allowed.add(permission);
+ }
+ }
+
+ return allowed;
+ }
+
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/descriptionstatus/DescriptionStatusBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/descriptionstatus/DescriptionStatusBuilder.java
index fea2d62ed..cf01a84d1 100644
--- a/backend/core/src/main/java/org/opencdmp/model/builder/descriptionstatus/DescriptionStatusBuilder.java
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/descriptionstatus/DescriptionStatusBuilder.java
@@ -56,6 +56,7 @@ public class DescriptionStatusBuilder extends BaseBuilder {
private final AuthorizationService authorizationService;
private final AuthorizationContentResolver authorizationContentResolver;
private final TenantScope tenantScope;
+ private final CustomPolicyService customPolicyService;
+ private final PlanStatusService planStatusService;
private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public PlanBuilder(ConventionService conventionService,
QueryFactory queryFactory,
- BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService, AuthorizationService authorizationService, AuthorizationContentResolver authorizationContentResolver, TenantScope tenantScope) {
+ BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService, AuthorizationService authorizationService, AuthorizationContentResolver authorizationContentResolver, TenantScope tenantScope, CustomPolicyService customPolicyService, PlanStatusService planStatusService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
@@ -69,6 +78,8 @@ public class PlanBuilder extends BaseBuilder {
this.authorizationService = authorizationService;
this.authorizationContentResolver = authorizationContentResolver;
this.tenantScope = tenantScope;
+ this.customPolicyService = customPolicyService;
+ this.planStatusService = planStatusService;
}
public PlanBuilder authorize(EnumSet values) {
@@ -85,6 +96,12 @@ public class PlanBuilder extends BaseBuilder {
List models = new ArrayList<>();
+ FieldSet statusFields = fields.extractPrefixed(this.asPrefix(Plan._status));
+ Map statusItemsMap = this.collectPlanStatuses(statusFields, data);
+
+ FieldSet availableStatusesFields = fields.extractPrefixed(this.asPrefix(Plan._availableStatuses));
+ Map> avaialbleStatusesItemsMap = this.collectAvailablePlanStatuses(availableStatusesFields, data);
+
FieldSet entityDoisFields = fields.extractPrefixed(this.asPrefix(Plan._entityDois));
Map> entityDoisMap = this.collectEntityDois(entityDoisFields, data);
@@ -114,14 +131,16 @@ public class PlanBuilder extends BaseBuilder {
Set authorizationFlags = this.extractAuthorizationFlags(fields, Plan._authorizationFlags, this.authorizationContentResolver.getPermissionNames());
Map affiliatedResourceMap = authorizationFlags == null || authorizationFlags.isEmpty() ? null : this.authorizationContentResolver.plansAffiliation(data.stream().map(PlanEntity::getId).collect(Collectors.toList()));
-
+
+ FieldSet statusAuthorizationFlags = fields.extractPrefixed(this.asPrefix(Plan._statusAuthorizationFlags));
for (PlanEntity d : data) {
Plan m = new Plan();
if (fields.hasField(this.asIndexer(Plan._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(Plan._tenantId))) m.setTenantId(d.getTenantId());
if (fields.hasField(this.asIndexer(Plan._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(Plan._version))) m.setVersion(d.getVersion());
- if (fields.hasField(this.asIndexer(Plan._status))) m.setStatus(d.getStatus());
+ if (!statusFields.isEmpty() && statusItemsMap != null && statusItemsMap.containsKey(d.getStatusId())) m.setStatus(statusItemsMap.get(d.getStatusId()));
+ if (avaialbleStatusesItemsMap != null && !avaialbleStatusesItemsMap.isEmpty() && avaialbleStatusesItemsMap.containsKey(d.getId())) m.setAvailableStatuses(avaialbleStatusesItemsMap.get(d.getId()));
if (fields.hasField(this.asIndexer(Plan._groupId))) m.setGroupId(d.getGroupId());
if (fields.hasField(this.asIndexer(Plan._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(Plan._createdAt))) m.setCreatedAt(d.getCreatedAt());
@@ -150,6 +169,9 @@ public class PlanBuilder extends BaseBuilder {
m.setProperties(this.builderFactory.builder(PlanPropertiesBuilder.class).withDefinition(definitionEntityMap != null ? definitionEntityMap.getOrDefault(d.getBlueprintId(), null) : null).authorize(this.authorize).build(planPropertiesFields, propertyDefinition));
}
if (affiliatedResourceMap != null && !authorizationFlags.isEmpty()) m.setAuthorizationFlags(this.evaluateAuthorizationFlags(this.authorizationService, authorizationFlags, affiliatedResourceMap.getOrDefault(d.getId(), null)));
+ if (!statusAuthorizationFlags.isEmpty() && !this.conventionService.isListNullOrEmpty(m.getAvailableStatuses())) {
+ m.setStatusAuthorizationFlags(this.evaluateStatusAuthorizationFlags(this.authorizationService, statusAuthorizationFlags, d));
+ }
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
@@ -157,6 +179,58 @@ public class PlanBuilder extends BaseBuilder {
return models;
}
+ private Map collectPlanStatuses(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty())
+ return null;
+ this.logger.debug("checking related - {}", PlanStatus.class.getSimpleName());
+
+ Map itemMap;
+ if (!fields.hasOtherField(this.asIndexer(PlanStatus._id))) {
+ itemMap = this.asEmpty(
+ data.stream().map(PlanEntity::getStatusId).distinct().collect(Collectors.toList()),
+ x -> {
+ PlanStatus item = new PlanStatus();
+ item.setId(x);
+ return item;
+ },
+ PlanStatus::getId);
+ } else {
+ FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PlanStatus._id);
+ PlanStatusQuery q = this.queryFactory.query(PlanStatusQuery.class).disableTracking().authorize(this.authorize).ids(data.stream().map(PlanEntity::getStatusId).distinct().collect(Collectors.toList()));
+ itemMap = this.builderFactory.builder(PlanStatusBuilder.class).authorize(this.authorize).asForeignKey(q, clone, PlanStatus::getId);
+ }
+ if (!fields.hasField(PlanStatus._id)) {
+ itemMap.forEach((id, item) -> {
+ if (item != null)
+ item.setId(null);
+ });
+ }
+
+ return itemMap;
+ }
+
+ private Map> collectAvailablePlanStatuses(FieldSet fields, List data) throws MyApplicationException {
+ if (fields.isEmpty() || data.isEmpty()) return null;
+ this.logger.debug("checking related - {}", PlanStatus.class.getSimpleName());
+
+ Map> itemMap = new HashMap<>();
+ FieldSet fieldSet = new BaseFieldSet(fields.getFields()).ensure(PlanStatus._id);
+ Map> itemStatusIdsMap = this.planStatusService.getAuthorizedAvailableStatusIds(data.stream().map(PlanEntity::getId).collect(Collectors.toList()));
+
+ List statusEntities = this.queryFactory.query(PlanStatusQuery.class).authorize(this.authorize).isActives(IsActive.Active).ids(itemStatusIdsMap.values().stream().flatMap(List::stream).distinct().collect(Collectors.toList())).collectAs(fieldSet);
+ List planStatuses = this.builderFactory.builder(PlanStatusBuilder.class).authorize(this.authorize).build(fieldSet, statusEntities);
+
+ for (PlanEntity entity: data) {
+ itemMap.put(entity.getId(), new ArrayList<>());
+ List statusIds = itemStatusIdsMap.getOrDefault(entity.getId(), new ArrayList<>());
+ for (UUID statusId: statusIds) {
+ itemMap.get(entity.getId()).addAll(planStatuses.stream().filter(x -> x.getId().equals(statusId)).collect(Collectors.toList()));
+ }
+ }
+
+ return itemMap;
+ }
+
private Map> collectPlanReferences(FieldSet fields, List data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty()) return null;
this.logger.debug("checking related - {}", PlanReference.class.getSimpleName());
@@ -342,4 +416,22 @@ public class PlanBuilder extends BaseBuilder {
return itemMap;
}
+ private List evaluateStatusAuthorizationFlags(AuthorizationService authorizationService, FieldSet statusAuthorizationFlags, PlanEntity plan) {
+ List allowed = new ArrayList<>();
+ if (statusAuthorizationFlags == null) return allowed;
+ if (authorizationService == null) return allowed;
+ if (plan == null) return allowed;
+
+ String editPermission = this.customPolicyService.getPlanStatusCanEditStatusPermission(plan.getStatusId());
+ AffiliatedResource affiliatedResource = this.authorizationContentResolver.planAffiliation(plan.getId());
+ for (String permission : statusAuthorizationFlags.getFields()) {
+ if (statusAuthorizationFlags.hasField(this.asIndexer(PlanStatusDefinitionAuthorization._edit))) {
+ Boolean isAllowed = affiliatedResource == null ? this.authorizationService.authorize(editPermission) : this.authorizationService.authorizeAtLeastOne(List.of(affiliatedResource), editPermission);
+ if (isAllowed) allowed.add(permission);
+ }
+ }
+
+ return allowed;
+ }
+
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusBuilder.java
index 71a23b6a6..7bfe20829 100644
--- a/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusBuilder.java
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusBuilder.java
@@ -68,6 +68,8 @@ public class PlanStatusBuilder extends BaseBuilder
m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(PlanStatus._description)))
m.setDescription(d.getDescription());
+ if (fields.hasField(this.asIndexer(PlanStatus._action)))
+ m.setAction(d.getAction());
if (fields.hasField(this.asIndexer(PlanStatus._internalStatus)))
m.setInternalStatus(d.getInternalStatus());
if (fields.hasField(this.asIndexer(PlanStatus._hash)))
diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusDefinitionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusDefinitionBuilder.java
index b4d6c8181..b342b2b9b 100644
--- a/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusDefinitionBuilder.java
+++ b/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusDefinitionBuilder.java
@@ -53,6 +53,8 @@ public class PlanStatusDefinitionBuilder extends BaseBuilder availableStatuses;
+ public static final String _availableStatuses = "availableStatuses";
+
+ private List statusAuthorizationFlags;
+ public static final String _statusAuthorizationFlags = "statusAuthorizationFlags";
+
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
@@ -231,6 +237,22 @@ public class Description {
this.authorizationFlags = authorizationFlags;
}
+ public List getAvailableStatuses() {
+ return availableStatuses;
+ }
+
+ public void setAvailableStatuses(List availableStatuses) {
+ this.availableStatuses = availableStatuses;
+ }
+
+ public List getStatusAuthorizationFlags() {
+ return statusAuthorizationFlags;
+ }
+
+ public void setStatusAuthorizationFlags(List statusAuthorizationFlags) {
+ this.statusAuthorizationFlags = statusAuthorizationFlags;
+ }
+
public Boolean getBelongsToCurrentTenant() {
return belongsToCurrentTenant;
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/descriptionstatus/DescriptionStatus.java b/backend/core/src/main/java/org/opencdmp/model/descriptionstatus/DescriptionStatus.java
index 3279b5a86..45c7094d8 100644
--- a/backend/core/src/main/java/org/opencdmp/model/descriptionstatus/DescriptionStatus.java
+++ b/backend/core/src/main/java/org/opencdmp/model/descriptionstatus/DescriptionStatus.java
@@ -16,6 +16,9 @@ public class DescriptionStatus {
public final static String _description = "description";
private String description;
+ public static final String _action = "action";
+ private String action;
+
public final static String _createdAt = "createdAt";
private Instant createdAt;
@@ -46,6 +49,14 @@ public class DescriptionStatus {
public String getDescription() { return this.description; }
public void setDescription(String description) { this.description = description; }
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
public Instant getCreatedAt() { return this.createdAt; }
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
diff --git a/backend/core/src/main/java/org/opencdmp/model/descriptionstatus/DescriptionStatusDefinition.java b/backend/core/src/main/java/org/opencdmp/model/descriptionstatus/DescriptionStatusDefinition.java
index 340f8f499..403049942 100644
--- a/backend/core/src/main/java/org/opencdmp/model/descriptionstatus/DescriptionStatusDefinition.java
+++ b/backend/core/src/main/java/org/opencdmp/model/descriptionstatus/DescriptionStatusDefinition.java
@@ -1,11 +1,26 @@
package org.opencdmp.model.descriptionstatus;
+import org.opencdmp.commons.enums.DescriptionStatusAvailableActionType;
+
+import java.util.List;
+
public class DescriptionStatusDefinition {
public final static String _authorization = "authorization";
private DescriptionStatusDefinitionAuthorization authorization;
+ public final static String _availableActions = "availableActions";
+ private List availableActions;
+
public DescriptionStatusDefinitionAuthorization getAuthorization() { return this.authorization; }
public void setAuthorization(DescriptionStatusDefinitionAuthorization authorization) { this.authorization = authorization; }
+
+ public List getAvailableActions() {
+ return availableActions;
+ }
+
+ public void setAvailableActions(List availableActions) {
+ this.availableActions = availableActions;
+ }
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionToPublicApiDatasetMapper.java b/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionToPublicApiDatasetMapper.java
index 1cbf7d4f5..d3ee28796 100644
--- a/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionToPublicApiDatasetMapper.java
+++ b/backend/core/src/main/java/org/opencdmp/model/mapper/publicapi/DescriptionToPublicApiDatasetMapper.java
@@ -30,7 +30,7 @@ public class DescriptionToPublicApiDatasetMapper {
model.setDescription(description.getDescription());
model.setReference("");
model.setUri("");
- model.setStatus(description.getStatus());
+// TODO status model.setStatus(description.getStatus());
model.setDmp(dmp);
model.setDatasetProfileDefinition(descriptionTemplateToPublicApiDatasetProfileMapper.toPublicModel(description.getDescriptionTemplate()));
diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java
index dd81a9404..14b1b6ea9 100644
--- a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java
+++ b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionPersist.java
@@ -46,9 +46,9 @@ public class DescriptionPersist {
public static final String _descriptionTemplateId = "descriptionTemplateId";
- private DescriptionStatus status;
+ private UUID statusId;
- public static final String _status = "status";
+ public static final String _statusId = "statusId";
private String description;
@@ -97,12 +97,12 @@ public class DescriptionPersist {
this.planDescriptionTemplateId = planDescriptionTemplateId;
}
- public DescriptionStatus getStatus() {
- return this.status;
+ public UUID getStatusId() {
+ return statusId;
}
- public void setStatus(DescriptionStatus status) {
- this.status = status;
+ public void setStatusId(UUID statusId) {
+ this.statusId = statusId;
}
public String getDescription() {
@@ -178,16 +178,19 @@ public class DescriptionPersist {
DescriptionTemplateEntity descriptionTemplate = null;
PlanEntity planEntity = null;
PlanBlueprintEntity planBlueprintEntity = null;
+ DescriptionStatusEntity statusEntity = null;
try {
descriptionTemplate = this.isValidGuid(item.getDescriptionTemplateId()) ? this.entityManager.find(DescriptionTemplateEntity.class, item.getDescriptionTemplateId(), true) : null;
planEntity = this.isValidGuid(item.getPlanId()) ? this.entityManager.find(PlanEntity.class, item.getPlanId(), true) : null;
planBlueprintEntity = planEntity == null ? null : this.entityManager.find(PlanBlueprintEntity.class, planEntity.getBlueprintId());
+ statusEntity = this.isValidGuid(item.getStatusId()) ? this.entityManager.find(DescriptionStatusEntity.class, item.getStatusId(), true) : null;
} catch (InvalidApplicationException e) {
throw new RuntimeException(e);
}
DefinitionEntity definition = descriptionTemplate == null ? null : this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, descriptionTemplate.getDefinition());
PlanBlueprintEntity finalPlanBlueprintEntity = planBlueprintEntity;
+ DescriptionStatusEntity finalStatusEntity = statusEntity;
return Arrays.asList(
this.spec()
.iff(() -> this.isValidGuid(item.getId()))
@@ -214,21 +217,22 @@ public class DescriptionPersist {
.must(() -> this.isValidGuid(item.getPlanDescriptionTemplateId()))
.failOn(DescriptionPersist._planDescriptionTemplateId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._planDescriptionTemplateId}, LocaleContextHolder.getLocale())),
this.spec()
- .must(() -> !this.isNull(item.getStatus()))
- .failOn(DescriptionPersist._status).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._status}, LocaleContextHolder.getLocale())),
+ .iff(() -> this.isValidGuid(item.getId()))
+ .must(() -> this.isValidGuid(item.getStatusId()))
+ .failOn(DescriptionPersist._statusId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._statusId}, LocaleContextHolder.getLocale())),
this.spec()
- .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
+ .iff(() -> finalStatusEntity != null && finalStatusEntity.getInternalStatus() != null && finalStatusEntity.getInternalStatus() == DescriptionStatus.Finalized)
.must(() -> !this.isNull(item.getProperties()))
.failOn(DescriptionPersist._properties).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._properties}, LocaleContextHolder.getLocale())),
this.spec()
- .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
+ .iff(() -> finalStatusEntity != null && finalStatusEntity.getInternalStatus() != null && finalStatusEntity.getInternalStatus() == DescriptionStatus.Finalized)
.must(() -> this.isDescriptionTemplateMaxMultiplicityValid(finalPlanBlueprintEntity, item.getPlanId(), item.getPlanDescriptionTemplateId(), this.isValidGuid(item.getId())))
.failOn(DescriptionPersist._descriptionTemplateId).failWith(this.messageSource.getMessage("Validation.InvalidDescriptionTemplateMultiplicity", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())),
this.refSpec()
- .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
+ .iff(() -> finalStatusEntity != null && finalStatusEntity.getInternalStatus() != null && finalStatusEntity.getInternalStatus() == DescriptionStatus.Finalized)
.on(DescriptionPersist._properties)
.over(item.getProperties())
- .using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition).setVisibilityService(definition, item.getProperties()))
+ .using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(finalStatusEntity.getInternalStatus()).withDefinition(definition).setVisibilityService(definition, item.getProperties()))
// this.navSpec()
// .iff(() -> !this.isNull(item.getTags()))
// .on(DescriptionPersist._tags)
diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionStatusPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionStatusPersist.java
index 259afc084..84669208b 100644
--- a/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionStatusPersist.java
+++ b/backend/core/src/main/java/org/opencdmp/model/persist/DescriptionStatusPersist.java
@@ -1,6 +1,5 @@
package org.opencdmp.model.persist;
-import org.opencdmp.commons.enums.DescriptionStatus;
import org.opencdmp.commons.validation.BaseValidator;
import gr.cite.tools.validation.specification.Specification;
import org.opencdmp.convention.ConventionService;
@@ -21,7 +20,7 @@ public class DescriptionStatusPersist {
public static final String _id = "id";
- private DescriptionStatus status;
+ private UUID statusId;
public static final String _status = "status";
@@ -37,12 +36,12 @@ public class DescriptionStatusPersist {
this.id = id;
}
- public DescriptionStatus getStatus() {
- return status;
+ public UUID getStatusId() {
+ return statusId;
}
- public void setStatus(DescriptionStatus status) {
- this.status = status;
+ public void setStatusId(UUID statusId) {
+ this.statusId = statusId;
}
public String getHash() {
@@ -82,7 +81,7 @@ public class DescriptionStatusPersist {
.must(() -> this.isValidHash(item.getHash()))
.failOn(DescriptionStatusPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._hash}, LocaleContextHolder.getLocale())),
this.spec()
- .must(() -> !this.isNull(item.getStatus()))
+ .must(() -> this.isValidGuid(item.getStatusId()))
.failOn(DescriptionStatusPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._status}, LocaleContextHolder.getLocale()))
);
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/PlanPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/PlanPersist.java
index 4173d902b..225bc8b80 100644
--- a/backend/core/src/main/java/org/opencdmp/model/persist/PlanPersist.java
+++ b/backend/core/src/main/java/org/opencdmp/model/persist/PlanPersist.java
@@ -36,9 +36,9 @@ public class PlanPersist {
public static final String _label = "label";
- private PlanStatus status;
+ private UUID statusId;
- public static final String _status = "status";
+ public static final String _statusId = "statusId";
private PlanPropertiesPersist properties;
@@ -84,12 +84,12 @@ public class PlanPersist {
this.label = label;
}
- public PlanStatus getStatus() {
- return this.status;
+ public UUID getStatusId() {
+ return statusId;
}
- public void setStatus(PlanStatus status) {
- this.status = status;
+ public void setStatusId(UUID statusId) {
+ this.statusId = statusId;
}
public PlanPropertiesPersist getProperties() {
@@ -186,9 +186,10 @@ public class PlanPersist {
@Override
protected List specifications(PlanPersist item) {
PlanBlueprintEntity planBlueprintEntity = null;
+ PlanStatusEntity statusEntity = null;
try {
planBlueprintEntity = this.isValidGuid(item.getBlueprint()) ? this.entityManager.find(PlanBlueprintEntity.class, item.getBlueprint(), true) : null;
-
+ statusEntity = this.isValidGuid(item.getStatusId()) ? this.entityManager.find(PlanStatusEntity.class, item.getStatusId(), true) : null;
} catch (InvalidApplicationException e) {
throw new RuntimeException(e);
}
@@ -203,6 +204,7 @@ public class PlanPersist {
accessFieldLabel = this.getSystemFieldLabel(definition, PlanBlueprintSystemFieldType.AccessRights);
}
+ PlanStatusEntity finalStatusEntity = statusEntity;
return Arrays.asList(
this.spec()
.iff(() -> this.isValidGuid(item.getId()))
@@ -220,40 +222,41 @@ public class PlanPersist {
.must(() -> this.lessEqualLength(item.getLabel(), PlanEntity._labelLength))
.failOn(PlanPersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{PlanPersist._label}, LocaleContextHolder.getLocale())),
this.spec()
- .iff(() -> item.getStatus() == PlanStatus.Finalized)
+ .iff(() -> finalStatusEntity != null && finalStatusEntity.getInternalStatus() != null && finalStatusEntity.getInternalStatus() == PlanStatus.Finalized)
.must(() -> !this.isEmpty(item.getDescription()))
.failOn(PlanPersist._description).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._description}, LocaleContextHolder.getLocale())),
this.spec()
- .must(() -> !this.isNull(item.getStatus()))
- .failOn(PlanPersist._status).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._status}, LocaleContextHolder.getLocale())),
+ .iff(() -> this.isValidGuid(item.getId()))
+ .must(() -> !this.isNull(item.getStatusId()))
+ .failOn(PlanPersist._statusId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._statusId}, LocaleContextHolder.getLocale())),
this.spec()
- .iff(() -> item.getStatus() == PlanStatus.Finalized)
+ .iff(() -> finalStatusEntity != null && finalStatusEntity.getInternalStatus() != null && finalStatusEntity.getInternalStatus() == PlanStatus.Finalized)
.must(() -> this.isValidGuid(item.getBlueprint()))
.failOn(PlanPersist._blueprint).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._blueprint}, LocaleContextHolder.getLocale())),
this.spec()
- .iff(() -> item.getStatus() == PlanStatus.Finalized)
+ .iff(() -> finalStatusEntity != null && finalStatusEntity.getInternalStatus() != null && finalStatusEntity.getInternalStatus() == PlanStatus.Finalized)
.must(() -> !this.isNull(item.getProperties()))
.failOn(PlanPersist._properties).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._properties}, LocaleContextHolder.getLocale())),
this.spec()
- .iff(() -> item.getStatus() == PlanStatus.Finalized)
+ .iff(() -> finalStatusEntity != null && finalStatusEntity.getInternalStatus() != null && finalStatusEntity.getInternalStatus() == PlanStatus.Finalized)
.must(() -> this.isDescriptionTemplateMultiplicityValid(finalPlanBlueprintEntity, item.getId()))
.failOn(PlanPersist._descriptionTemplates).failWith(this.messageSource.getMessage("Validation.InvalidDescriptionTemplateMultiplicityOnPlan", new Object[]{PlanPersist._descriptionTemplates}, LocaleContextHolder.getLocale())),
this.refSpec()
- .iff(() -> !this.isNull(item.getProperties()))
+ .iff(() -> !this.isNull(item.getProperties()) && finalStatusEntity != null)
.on(PlanPersist._properties)
.over(item.getProperties())
- .using(() -> this.validatorFactory.validator(PlanPropertiesPersist.PlanPropertiesPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition)),
+ .using(() -> this.validatorFactory.validator(PlanPropertiesPersist.PlanPropertiesPersistValidator.class).setStatus(finalStatusEntity.getInternalStatus()).withDefinition(definition)),
this.spec()
- .iff(() -> item.getStatus() == PlanStatus.Finalized)
+ .iff(() -> finalStatusEntity != null && finalStatusEntity.getInternalStatus() != null && finalStatusEntity.getInternalStatus() == PlanStatus.Finalized)
.must(() -> !this.isNull(item.getLanguage()))
.failOn(PlanPersist._language).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{languageFieldLabel != null ? languageFieldLabel : PlanBlueprintSystemFieldType.Language.name()}, LocaleContextHolder.getLocale())),
this.spec()
- .iff(() -> item.getStatus() == PlanStatus.Finalized)
+ .iff(() -> finalStatusEntity != null && finalStatusEntity.getInternalStatus() != null && finalStatusEntity.getInternalStatus() == PlanStatus.Finalized)
.must(() -> !this.isNull(item.getAccessType()))
.failOn(PlanPersist._accessType).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{accessFieldLabel != null ? accessFieldLabel : PlanBlueprintSystemFieldType.AccessRights.name()}, LocaleContextHolder.getLocale())),
this.spec()
- .iff(() -> item.getStatus() == PlanStatus.Finalized)
+ .iff(() -> finalStatusEntity != null && finalStatusEntity.getInternalStatus() != null && finalStatusEntity.getInternalStatus() == PlanStatus.Finalized)
.must(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates()))
.failOn(PlanPersist._descriptionTemplates).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{PlanPersist._descriptionTemplates}, LocaleContextHolder.getLocale())),
this.navSpec()
diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusDefinitionAuthorizationItemPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusDefinitionAuthorizationItemPersist.java
index f402d41b3..2fda7fca8 100644
--- a/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusDefinitionAuthorizationItemPersist.java
+++ b/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusDefinitionAuthorizationItemPersist.java
@@ -62,11 +62,6 @@ public class DescriptionStatusDefinitionAuthorizationItemPersist {
@Override
protected List specifications(DescriptionStatusDefinitionAuthorizationItemPersist item) {
return Arrays.asList(
- this.spec()
- .must(() -> !this.isListNullOrEmpty(item.getRoles()))
- .failOn(PlanStatusDefinitionAuthorizationItemPersist._roles).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanStatusDefinitionAuthorizationItemPersist._roles}, LocaleContextHolder.getLocale())), this.spec()
- .must(() -> !this.isListNullOrEmpty(item.getPlanRoles()))
- .failOn(PlanStatusDefinitionAuthorizationItemPersist._planRoles).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanStatusDefinitionAuthorizationItemPersist._planRoles}, LocaleContextHolder.getLocale()))
);
}
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusDefinitionPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusDefinitionPersist.java
index 6e2121027..7f406d40f 100644
--- a/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusDefinitionPersist.java
+++ b/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusDefinitionPersist.java
@@ -2,10 +2,10 @@ package org.opencdmp.model.persist.descriptionstatus;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
+import org.opencdmp.commons.enums.DescriptionStatusAvailableActionType;
import org.opencdmp.commons.validation.BaseValidator;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
-import org.opencdmp.model.descriptionstatus.DescriptionStatusDefinitionAuthorization;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
@@ -20,9 +20,19 @@ public class DescriptionStatusDefinitionPersist {
private DescriptionStatusDefinitionAuthorizationPersist authorization;
public final static String _authorization = "authorization";
+ private List availableActions;
+ public final static String _availableActions = "availableActions";
+
public DescriptionStatusDefinitionAuthorizationPersist getAuthorization() { return authorization; }
public void setAuthorization(DescriptionStatusDefinitionAuthorizationPersist authorization) { this.authorization = authorization; }
+ public List getAvailableActions() {
+ return availableActions;
+ }
+
+ public void setAvailableActions(List availableActions) {
+ this.availableActions = availableActions;
+ }
@Component(DescriptionStatusDefinitionPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusPersist.java
index db27eb606..e7ac7deb0 100644
--- a/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusPersist.java
+++ b/backend/core/src/main/java/org/opencdmp/model/persist/descriptionstatus/DescriptionStatusPersist.java
@@ -27,6 +27,9 @@ public class DescriptionStatusPersist {
private String description;
public final static String _description = "description";
+ private String action;
+ public static final String _action = "action";
+
private org.opencdmp.commons.enums.DescriptionStatus internalStatus;
public final static String _internalStatus = "internalStatus";
@@ -46,6 +49,14 @@ public class DescriptionStatusPersist {
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
public org.opencdmp.commons.enums.DescriptionStatus getInternalStatus() { return internalStatus; }
public void setInternalStatus(org.opencdmp.commons.enums.DescriptionStatus internalStatus) { this.internalStatus = internalStatus; }
@@ -93,6 +104,10 @@ public class DescriptionStatusPersist {
.iff(() -> !this.isEmpty(item.getName()))
.must(() -> this.lessEqualLength(item.getName(), DescriptionStatusEntity._nameLength))
.failOn(DescriptionStatusPersist._name).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._name}, LocaleContextHolder.getLocale())),
+ this.spec()
+ .iff(() -> !this.isEmpty(item.getAction()))
+ .must(() -> this.lessEqualLength(item.getAction(), DescriptionStatusEntity._actionLength))
+ .failOn(DescriptionStatusPersist._action).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._action}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> item.getInternalStatus() == org.opencdmp.commons.enums.DescriptionStatus.Finalized)
.must(() -> !this.isNull(item.getDefinition()))
diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionAuthorizationItemPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionAuthorizationItemPersist.java
index 10e4c5df8..1c30f022c 100644
--- a/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionAuthorizationItemPersist.java
+++ b/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionAuthorizationItemPersist.java
@@ -66,11 +66,6 @@ public class PlanStatusDefinitionAuthorizationItemPersist {
@Override
protected List specifications(PlanStatusDefinitionAuthorizationItemPersist item) {
return Arrays.asList(
- this.spec()
- .must(() -> !this.isListNullOrEmpty(item.getRoles()))
- .failOn(PlanStatusDefinitionAuthorizationItemPersist._roles).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanStatusDefinitionAuthorizationItemPersist._roles}, LocaleContextHolder.getLocale())), this.spec()
- .must(() -> !this.isListNullOrEmpty(item.getPlanRoles()))
- .failOn(PlanStatusDefinitionAuthorizationItemPersist._planRoles).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanStatusDefinitionAuthorizationItemPersist._planRoles}, LocaleContextHolder.getLocale()))
);
}
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionPersist.java
index 646f2ad46..ba5cbd03f 100644
--- a/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionPersist.java
+++ b/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionPersist.java
@@ -2,6 +2,7 @@ package org.opencdmp.model.persist.planstatus;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
+import org.opencdmp.commons.enums.PlanStatusAvailableActionType;
import org.opencdmp.commons.validation.BaseValidator;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
@@ -19,11 +20,21 @@ public class PlanStatusDefinitionPersist {
public final static String _authorization = "authorization";
private PlanStatusDefinitionAuthorizationPersist authorization = null;
+ public final static String _availableActions = "availableActions";
+ private List availableActions;
public PlanStatusDefinitionAuthorizationPersist getAuthorization() { return authorization; }
public void setAuthorization(PlanStatusDefinitionAuthorizationPersist authorization) { this.authorization = authorization; }
+ public List getAvailableActions() {
+ return availableActions;
+ }
+
+ public void setAvailableActions(List availableActions) {
+ this.availableActions = availableActions;
+ }
+
@Component(PlanStatusDefinitionPersist.PlanStatusDefinitionPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class PlanStatusDefinitionPersistValidator extends BaseValidator {
diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusPersist.java
index 65f6781f1..e20b8dea0 100644
--- a/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusPersist.java
+++ b/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusPersist.java
@@ -26,6 +26,9 @@ public class PlanStatusPersist {
private String description;
public static final String _description = "description";
+ private String action;
+ public static final String _action = "action";
+
private org.opencdmp.commons.enums.PlanStatus internalStatus;
public static final String _internalStatus = "internalStatus";
@@ -53,6 +56,14 @@ public class PlanStatusPersist {
public void setDescription(String description) { this.description = description; }
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
public org.opencdmp.commons.enums.PlanStatus getInternalStatus() { return this.internalStatus; }
public void setInternalStatus(org.opencdmp.commons.enums.PlanStatus internalStatus) { this.internalStatus = internalStatus; }
@@ -105,6 +116,10 @@ public class PlanStatusPersist {
.iff(() -> !this.isEmpty(item.getName()))
.must(() -> this.lessEqualLength(item.getName(), PlanStatusEntity._nameLength))
.failOn(org.opencdmp.model.persist.planstatus.PlanStatusPersist._name).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{org.opencdmp.model.persist.planstatus.PlanStatusPersist._name}, LocaleContextHolder.getLocale())),
+ this.spec()
+ .iff(() -> !this.isEmpty(item.getAction()))
+ .must(() -> this.lessEqualLength(item.getAction(), PlanStatusEntity._actionLength))
+ .failOn(PlanStatusPersist._action).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{org.opencdmp.model.persist.planstatus.PlanStatusPersist._action}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> item.getInternalStatus() == org.opencdmp.commons.enums.PlanStatus.Finalized)
.must(() -> !this.isNull(item.getDefinition()))
diff --git a/backend/core/src/main/java/org/opencdmp/model/plan/Plan.java b/backend/core/src/main/java/org/opencdmp/model/plan/Plan.java
index 750b59cee..842840edd 100644
--- a/backend/core/src/main/java/org/opencdmp/model/plan/Plan.java
+++ b/backend/core/src/main/java/org/opencdmp/model/plan/Plan.java
@@ -1,13 +1,13 @@
package org.opencdmp.model.plan;
import org.opencdmp.commons.enums.PlanAccessType;
-import org.opencdmp.commons.enums.PlanStatus;
import org.opencdmp.commons.enums.PlanVersionStatus;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.model.*;
import org.opencdmp.model.description.Description;
import org.opencdmp.model.planblueprint.PlanBlueprint;
import org.opencdmp.model.planreference.PlanReference;
+import org.opencdmp.model.planstatus.PlanStatus;
import org.opencdmp.model.user.User;
import java.time.Instant;
@@ -97,6 +97,11 @@ public class Plan {
private List otherPlanVersions;
public static final String _otherPlanVersions = "otherPlanVersions";
+ private List availableStatuses;
+ public static final String _availableStatuses = "availableStatuses";
+
+ private List statusAuthorizationFlags;
+ public static final String _statusAuthorizationFlags = "statusAuthorizationFlags";
private Boolean belongsToCurrentTenant;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
@@ -318,4 +323,20 @@ public class Plan {
public void setOtherPlanVersions(List otherPlanVersions) {
this.otherPlanVersions = otherPlanVersions;
}
+
+ public List getAvailableStatuses() {
+ return availableStatuses;
+ }
+
+ public void setAvailableStatuses(List availableStatuses) {
+ this.availableStatuses = availableStatuses;
+ }
+
+ public List getStatusAuthorizationFlags() {
+ return statusAuthorizationFlags;
+ }
+
+ public void setStatusAuthorizationFlags(List statusAuthorizationFlags) {
+ this.statusAuthorizationFlags = statusAuthorizationFlags;
+ }
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatus.java b/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatus.java
index b5be3d177..606fd2613 100644
--- a/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatus.java
+++ b/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatus.java
@@ -16,6 +16,9 @@ public class PlanStatus {
public final static String _description = "description";
private String description;
+ public static final String _action = "action";
+ private String action;
+
public final static String _createdAt = "createdAt";
private Instant createdAt;
@@ -61,6 +64,14 @@ public class PlanStatus {
public void setDescription(String description) { this.description = description; }
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
public PlanStatusDefinition getDefinition() {
return this.definition;
}
diff --git a/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinition.java b/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinition.java
index f310f5bc6..c49049dac 100644
--- a/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinition.java
+++ b/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinition.java
@@ -1,12 +1,27 @@
package org.opencdmp.model.planstatus;
+import org.opencdmp.commons.enums.PlanStatusAvailableActionType;
+
+import java.util.List;
+
public class PlanStatusDefinition {
public final static String _authorization = "authorization";
private PlanStatusDefinitionAuthorization authorization;
+ public final static String _availableActions = "availableActions";
+ private List availableActions;
+
public PlanStatusDefinitionAuthorization getAuthorization() { return this.authorization; }
public void setAuthorization(PlanStatusDefinitionAuthorization authorization) { this.authorization = authorization; }
+
+ public List getAvailableActions() {
+ return availableActions;
+ }
+
+ public void setAvailableActions(List availableActions) {
+ this.availableActions = availableActions;
+ }
}
diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java
index 0521c6165..b6d666199 100644
--- a/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java
+++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java
@@ -58,7 +58,7 @@ public class DescriptionQuery extends QueryBase {
private Collection isActives;
- private Collection statuses;
+ private Collection statusIds;
private Collection planIds;
@@ -72,6 +72,8 @@ public class DescriptionQuery extends QueryBase {
private Collection planDescriptionTemplateIds;
+ private DescriptionStatusQuery descriptionStatusQuery;
+
private final TenantEntityManager tenantEntityManager;
public DescriptionQuery(UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager) {
this.userScope = userScope;
@@ -210,18 +212,18 @@ public class DescriptionQuery extends QueryBase {
return this;
}
- public DescriptionQuery statuses(DescriptionStatus value) {
- this.statuses = List.of(value);
+ public DescriptionQuery statusIds(UUID value) {
+ this.statusIds = List.of(value);
return this;
}
- public DescriptionQuery statuses(DescriptionStatus... value) {
- this.statuses = Arrays.asList(value);
+ public DescriptionQuery statusIds(UUID... value) {
+ this.statusIds = Arrays.asList(value);
return this;
}
- public DescriptionQuery statuses(Collection values) {
- this.statuses = values;
+ public DescriptionQuery statusIds(Collection values) {
+ this.statusIds = values;
return this;
}
@@ -250,6 +252,11 @@ public class DescriptionQuery extends QueryBase {
return this;
}
+ public DescriptionQuery descriptionStatusSubQuery(DescriptionStatusQuery subQuery) {
+ this.descriptionStatusQuery = subQuery;
+ return this;
+ }
+
@Override
protected EntityManager entityManager(){
return this.tenantEntityManager.getEntityManager();
@@ -261,7 +268,7 @@ public class DescriptionQuery extends QueryBase {
this.isEmpty(this.ids) ||
this.isEmpty(this.isActives) || this.isEmpty(this.createdByIds) ||
this.isEmpty(this.excludedIds) || this.isFalseQuery(this.planQuery) ||
- this.isEmpty(this.statuses) || this.isFalseQuery(this.planDescriptionTemplateQuery);
+ this.isEmpty(this.statusIds) || this.isFalseQuery(this.planDescriptionTemplateQuery);
}
@Override
@@ -349,9 +356,9 @@ public class DescriptionQuery extends QueryBase {
inClause.value(item);
predicates.add(inClause);
}
- if (this.statuses != null) {
- CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._status));
- for (DescriptionStatus item : this.statuses)
+ if (this.statusIds != null) {
+ CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._statusId));
+ for (UUID item : this.statusIds)
inClause.value(item);
predicates.add(inClause);
}
@@ -381,6 +388,10 @@ public class DescriptionQuery extends QueryBase {
inClause.value(item);
predicates.add(inClause);
}
+ if (this.descriptionStatusQuery != null) {
+ QueryContext subQuery = this.applySubQuery(this.descriptionStatusQuery, queryContext, UUID.class, descriptionStatusEntityRoot -> descriptionStatusEntityRoot.get(DescriptionStatusEntity._id));
+ predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._statusId)).value(subQuery.Query));
+ }
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
@@ -399,7 +410,9 @@ public class DescriptionQuery extends QueryBase {
else if (item.prefix(Description._properties))
return DescriptionEntity._properties;
else if (item.match(Description._status) || item.match(PublicDescription._status))
- return DescriptionEntity._status;
+ return DescriptionEntity._statusId;
+ else if (item.prefix(Description._status) || item.prefix(PublicDescription._status))
+ return DescriptionEntity._statusId;
else if (item.match(Description._description) || item.match(PublicDescription._description))
return DescriptionEntity._description;
else if (item.match(Description._createdBy))
@@ -444,6 +457,7 @@ public class DescriptionQuery extends QueryBase {
item.setLabel(QueryBase.convertSafe(tuple, columns, DescriptionEntity._label, String.class));
item.setProperties(QueryBase.convertSafe(tuple, columns, DescriptionEntity._properties, String.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, DescriptionEntity._status, DescriptionStatus.class));
+ item.setStatusId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._statusId, UUID.class));
item.setDescription(QueryBase.convertSafe(tuple, columns, DescriptionEntity._description, String.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._updatedAt, Instant.class));
diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionStatusQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionStatusQuery.java
index 486bc155c..4818a4842 100644
--- a/backend/core/src/main/java/org/opencdmp/query/DescriptionStatusQuery.java
+++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionStatusQuery.java
@@ -188,6 +188,8 @@ public class DescriptionStatusQuery extends QueryBase {
return DescriptionStatusEntity._name;
else if (item.match(DescriptionStatus._description))
return DescriptionStatusEntity._description;
+ else if (item.match(DescriptionStatus._action))
+ return DescriptionStatusEntity._action;
else if (item.match(DescriptionStatus._createdAt))
return DescriptionStatusEntity._createdAt;
else if (item.match(DescriptionStatus._updatedAt))
@@ -200,6 +202,8 @@ public class DescriptionStatusQuery extends QueryBase {
return DescriptionStatusEntity._internalStatus;
else if (item.match(DescriptionStatusEntity._definition))
return DescriptionStatusEntity._definition;
+ else if (item.prefix(DescriptionStatusEntity._definition))
+ return DescriptionStatusEntity._definition;
else
return null;
}
@@ -210,6 +214,7 @@ public class DescriptionStatusQuery extends QueryBase {
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._id, UUID.class));
item.setName(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._name, String.class));
item.setDescription(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._description, String.class));
+ item.setAction(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._action, String.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._tenantId, UUID.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._updatedAt, Instant.class));
diff --git a/backend/core/src/main/java/org/opencdmp/query/PlanQuery.java b/backend/core/src/main/java/org/opencdmp/query/PlanQuery.java
index 6b195c891..25fe42e6e 100644
--- a/backend/core/src/main/java/org/opencdmp/query/PlanQuery.java
+++ b/backend/core/src/main/java/org/opencdmp/query/PlanQuery.java
@@ -39,7 +39,7 @@ public class PlanQuery extends QueryBase {
private Collection isActives;
- private Collection statuses;
+ private Collection statusIds;
private Collection versionStatuses;
@@ -61,6 +61,8 @@ public class PlanQuery extends QueryBase {
private EntityDoiQuery entityDoiQuery;
+ private PlanStatusQuery planStatusQuery;
+
private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
private final UserScope userScope;
@@ -177,18 +179,18 @@ public class PlanQuery extends QueryBase {
return this;
}
- public PlanQuery statuses(PlanStatus value) {
- this.statuses = List.of(value);
+ public PlanQuery statusIds(UUID value) {
+ this.statusIds = List.of(value);
return this;
}
- public PlanQuery statuses(PlanStatus... value) {
- this.statuses = Arrays.asList(value);
+ public PlanQuery statusIds(UUID... value) {
+ this.statusIds = Arrays.asList(value);
return this;
}
- public PlanQuery statuses(Collection values) {
- this.statuses = values;
+ public PlanQuery statusIds(Collection values) {
+ this.statusIds = values;
return this;
}
@@ -253,6 +255,11 @@ public class PlanQuery extends QueryBase {
return this;
}
+ public PlanQuery planStatusSubQuery(PlanStatusQuery subQuery) {
+ this.planStatusQuery = subQuery;
+ return this;
+ }
+
public PlanQuery authorize(EnumSet values) {
this.authorize = values;
return this;
@@ -275,7 +282,7 @@ public class PlanQuery extends QueryBase {
@Override
protected Boolean isFalseQuery() {
- return this.isEmpty(this.ids) || this.isEmpty(this.creatorIds) || this.isEmpty(this.isActives) || this.isEmpty(this.versionStatuses) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes) || this.isEmpty(this.statuses) || this.isFalseQuery(this.planDescriptionTemplateQuery) || this.isFalseQuery(this.planUserQuery);
+ return this.isEmpty(this.ids) || this.isEmpty(this.creatorIds) || this.isEmpty(this.isActives) || this.isEmpty(this.versionStatuses) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes) || this.isEmpty(this.statusIds) || this.isFalseQuery(this.planDescriptionTemplateQuery) || this.isFalseQuery(this.planUserQuery);
}
@Override
@@ -347,9 +354,9 @@ public class PlanQuery extends QueryBase {
inClause.value(item);
predicates.add(inClause);
}
- if (this.statuses != null) {
- CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._status));
- for (PlanStatus item : this.statuses)
+ if (this.statusIds != null) {
+ CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._statusId));
+ for (UUID item : this.statusIds)
inClause.value(item);
predicates.add(inClause);
}
@@ -407,6 +414,11 @@ public class PlanQuery extends QueryBase {
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._id)).value(subQuery.Query));
}
+ if (this.planStatusQuery != null) {
+ QueryContext subQuery = this.applySubQuery(this.planStatusQuery, queryContext, UUID.class, planStatusEntityRoot -> planStatusEntityRoot.get(PlanStatusEntity._id));
+ predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanEntity._statusId)).value(subQuery.Query));
+ }
+
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
@@ -424,7 +436,9 @@ public class PlanQuery extends QueryBase {
else if (item.match(Plan._version) || item.match(PublicPlan._version))
return PlanEntity._version;
else if (item.match(Plan._status))
- return PlanEntity._status;
+ return PlanEntity._statusId;
+ else if (item.prefix(Plan._status))
+ return PlanEntity._statusId;
else if (item.match(Plan._properties))
return PlanEntity._properties;
else if (item.prefix(Plan._properties))
@@ -475,6 +489,7 @@ public class PlanQuery extends QueryBase {
item.setLabel(QueryBase.convertSafe(tuple, columns, PlanEntity._label, String.class));
item.setVersion(QueryBase.convertSafe(tuple, columns, PlanEntity._version, Short.class));
item.setStatus(QueryBase.convertSafe(tuple, columns, PlanEntity._status, PlanStatus.class));
+ item.setStatusId(QueryBase.convertSafe(tuple, columns, PlanEntity._statusId, UUID.class));
item.setVersionStatus(QueryBase.convertSafe(tuple, columns, PlanEntity._versionStatus, PlanVersionStatus.class));
item.setProperties(QueryBase.convertSafe(tuple, columns, PlanEntity._properties, String.class));
item.setGroupId(QueryBase.convertSafe(tuple, columns, PlanEntity._groupId, UUID.class));
diff --git a/backend/core/src/main/java/org/opencdmp/query/PlanStatusQuery.java b/backend/core/src/main/java/org/opencdmp/query/PlanStatusQuery.java
index 4670f010f..a4125d121 100644
--- a/backend/core/src/main/java/org/opencdmp/query/PlanStatusQuery.java
+++ b/backend/core/src/main/java/org/opencdmp/query/PlanStatusQuery.java
@@ -36,6 +36,7 @@ public class PlanStatusQuery extends QueryBase {
private EnumSet authorize = EnumSet.of(AuthorizationFlags.None);
+
public PlanStatusQuery like(String value) {
this.like = value;
return this;
@@ -187,8 +188,12 @@ public class PlanStatusQuery extends QueryBase {
return PlanStatusEntity._description;
else if (item.match(PlanStatus._name))
return PlanStatusEntity._name;
+ else if (item.match(PlanStatus._action))
+ return PlanStatusEntity._action;
else if (item.match(PlanStatus._internalStatus))
return PlanStatusEntity._internalStatus;
+ else if (item.prefix(PlanStatus._definition))
+ return PlanStatusEntity._definition;
else if (item.match(PlanStatus._definition))
return PlanStatusEntity._definition;
else if (item.match(PlanStatus._createdAt))
@@ -211,6 +216,7 @@ public class PlanStatusQuery extends QueryBase {
item.setDescription(QueryBase.convertSafe(tuple, columns, PlanStatusEntity._description, String.class));
item.setDefinition(QueryBase.convertSafe(tuple, columns, PlanStatusEntity._definition, String.class));
item.setName(QueryBase.convertSafe(tuple, columns, PlanStatusEntity._name, String.class));
+ item.setAction(QueryBase.convertSafe(tuple, columns, PlanStatusEntity._action, String.class));
item.setInternalStatus(QueryBase.convertSafe(tuple, columns, PlanStatusEntity._internalStatus, org.opencdmp.commons.enums.PlanStatus.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, PlanStatusEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, PlanStatusEntity._updatedAt, Instant.class));
diff --git a/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java b/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java
index 94502c3b3..02efe005e 100644
--- a/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java
+++ b/backend/core/src/main/java/org/opencdmp/query/lookup/DescriptionLookup.java
@@ -3,7 +3,6 @@ package org.opencdmp.query.lookup;
import gr.cite.tools.data.query.Lookup;
import gr.cite.tools.data.query.QueryFactory;
import org.apache.commons.lang3.StringUtils;
-import org.opencdmp.commons.enums.DescriptionStatus;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.elastic.query.DescriptionElasticQuery;
import org.opencdmp.query.DescriptionQuery;
@@ -31,7 +30,8 @@ public class DescriptionLookup extends Lookup {
private List isActive;
- private List statuses;
+ private List statusIds;
+ private DescriptionStatusLookup descriptionStatusSubQuery;
public String getLike() {
return this.like;
@@ -65,12 +65,12 @@ public class DescriptionLookup extends Lookup {
this.isActive = isActive;
}
- public List getStatuses() {
- return this.statuses;
+ public List getStatusIds() {
+ return statusIds;
}
- public void setStatuses(List