From da1c603a8a4f21b5670b7022d561d452cc6547b6 Mon Sep 17 00:00:00 2001 From: "CITE\\spapacharalampous" Date: Thu, 22 Aug 2024 14:11:56 +0300 Subject: [PATCH] fixes --- .../opencdmp/authorization/Permission.java | 1 + ...anStatusDefinitionAuthorizationEntity.java | 10 ++++----- ...tusDefinitionAuthorizationItemBuilder.java | 7 +----- .../model/deleter/PlanStatusDeleter.java | 2 -- ...tusDefinitionAuthorizationItemPersist.java | 8 +++---- ...nStatusDefinitionAuthorizationPersist.java | 14 ++++++------ .../persist/planstatus/PlanStatusPersist.java | 9 ++++---- .../PlanStatusDefinitionAuthorization.java | 8 +++---- ...PlanStatusDefinitionAuthorizationItem.java | 9 ++++---- .../org/opencdmp/query/PlanStatusQuery.java | 12 +++++----- .../query/lookup/PlanStatusLookup.java | 2 +- .../DescriptionStatusServiceImpl.java | 2 ++ .../planstatus/PlanStatusServiceImpl.java | 22 ++++++++++++------- 13 files changed, 53 insertions(+), 53 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/authorization/Permission.java b/backend/core/src/main/java/org/opencdmp/authorization/Permission.java index 2cff235c5..8937fd780 100644 --- a/backend/core/src/main/java/org/opencdmp/authorization/Permission.java +++ b/backend/core/src/main/java/org/opencdmp/authorization/Permission.java @@ -251,5 +251,6 @@ public final class Permission { public static String ViewTenantConfigurationPage = "ViewTenantConfigurationPage"; public static String ViewStatusPage = "ViewStatusPage"; public static String ViewPlanStatusPage = "ViewPlanStatusPage"; + public static String ViewDescriptionStatusPage = "ViewPlanStatusPage"; } diff --git a/backend/core/src/main/java/org/opencdmp/commons/types/planstatus/PlanStatusDefinitionAuthorizationEntity.java b/backend/core/src/main/java/org/opencdmp/commons/types/planstatus/PlanStatusDefinitionAuthorizationEntity.java index 533bf6931..af7a7f41d 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/types/planstatus/PlanStatusDefinitionAuthorizationEntity.java +++ b/backend/core/src/main/java/org/opencdmp/commons/types/planstatus/PlanStatusDefinitionAuthorizationEntity.java @@ -3,19 +3,19 @@ package org.opencdmp.commons.types.planstatus; 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 java.util.List; - +@XmlRootElement(name = "authorization") @XmlAccessorType(XmlAccessType.FIELD) public class PlanStatusDefinitionAuthorizationEntity { @XmlElement(name = "edit") - private List edit; + private PlanStatusDefinitionAuthorizationItemEntity edit; - public List getEdit() { + public PlanStatusDefinitionAuthorizationItemEntity getEdit() { return edit; } - public void setEdit(List edit) { + public void setEdit(PlanStatusDefinitionAuthorizationItemEntity edit) { this.edit = edit; } } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusDefinitionAuthorizationItemBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusDefinitionAuthorizationItemBuilder.java index 1a100c947..f6a2c4f1e 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusDefinitionAuthorizationItemBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/planstatus/PlanStatusDefinitionAuthorizationItemBuilder.java @@ -1,6 +1,5 @@ package org.opencdmp.model.builder.planstatus; -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; @@ -21,14 +20,10 @@ import java.util.*; @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class PlanStatusDefinitionAuthorizationItemBuilder extends BaseBuilder { - private final BuilderFactory builderFactory; - private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - - public PlanStatusDefinitionAuthorizationItemBuilder(ConventionService conventionService, BuilderFactory builderFactory) { + public PlanStatusDefinitionAuthorizationItemBuilder(ConventionService conventionService) { super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanStatusDefinitionAuthorizationItemBuilder.class))); - this.builderFactory = builderFactory; } public PlanStatusDefinitionAuthorizationItemBuilder authorize(EnumSet values) { diff --git a/backend/core/src/main/java/org/opencdmp/model/deleter/PlanStatusDeleter.java b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanStatusDeleter.java index 7fb638f8e..a1c54f3c8 100644 --- a/backend/core/src/main/java/org/opencdmp/model/deleter/PlanStatusDeleter.java +++ b/backend/core/src/main/java/org/opencdmp/model/deleter/PlanStatusDeleter.java @@ -70,9 +70,7 @@ public class PlanStatusDeleter implements Deleter { return; Instant now = Instant.now(); - for (PlanStatusEntity item : data) { - logger.trace("deleting item {}", item.getId()); item.setIsActive(IsActive.Inactive); item.setUpdatedAt(now); 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 69b846e52..07a13e353 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 @@ -16,16 +16,16 @@ import java.util.List; public class PlanStatusDefinitionAuthorizationItemPersist { - public List roles = null; + private List roles = null; public final static String _roles = "roles"; - public List planRoles = null; + private List planRoles = null; public final static String _planRoles = "planRoles"; - public Boolean allowAuthenticated; + private Boolean allowAuthenticated; public final static String _allowAuthenticated = "allowAuthenticated"; - public Boolean allowAnonymous; + private Boolean allowAnonymous; public final static String _allowAnonymous = "allowAuthenticated"; diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionAuthorizationPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionAuthorizationPersist.java index 62af5787d..424ecf65c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionAuthorizationPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/planstatus/PlanStatusDefinitionAuthorizationPersist.java @@ -17,14 +17,14 @@ import java.util.List; public class PlanStatusDefinitionAuthorizationPersist { public final static String _edit = "edit"; - private List edit = null; + private PlanStatusDefinitionAuthorizationItemPersist edit = null; - public List getEdit() { + public PlanStatusDefinitionAuthorizationItemPersist getEdit() { return this.edit; } - public void setEdit(List edit) { + public void setEdit(PlanStatusDefinitionAuthorizationItemPersist edit) { this.edit = edit; } @@ -50,13 +50,13 @@ public class PlanStatusDefinitionAuthorizationPersist { protected List specifications(PlanStatusDefinitionAuthorizationPersist item) { return Arrays.asList( this.spec() - .must(() -> !this.isListNullOrEmpty(item.getEdit())) + .must(() -> !this.isNull(item.getEdit())) .failOn(PlanStatusDefinitionAuthorizationPersist._edit).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanStatusDefinitionAuthorizationPersist._edit}, LocaleContextHolder.getLocale())), - this.navSpec() - .iff(() -> !this.isListNullOrEmpty(item.getEdit())) + this.refSpec() + .iff(() -> !this.isNull(item.getEdit())) .on(PlanStatusDefinitionAuthorizationPersist._edit) .over(item.getEdit()) - .using((itm) -> this.validatorFactory.validator(PlanStatusDefinitionAuthorizationItemPersist.PlanStatusDefinitionAuthorizationItemPersistValidator.class)) + .using(() -> this.validatorFactory.validator(PlanStatusDefinitionAuthorizationItemPersist.PlanStatusDefinitionAuthorizationItemPersistValidator.class)) ); } } 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 edc98ff33..c8fbf7567 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 @@ -97,7 +97,7 @@ public class PlanStatusPersist { this.spec() .iff(() -> !this.isValidGuid(item.getId())) .must(() -> !this.isValidHash(item.getHash())) - .failOn(org.opencdmp.model.persist.planstatus.PlanStatusPersist._hash).failWith(this.messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), + .failOn(org.opencdmp.model.persist.planstatus.PlanStatusPersist._hash).failWith(this.messageSource.getMessage("Validation_OverPosting", new Object[]{org.opencdmp.model.persist.planstatus.PlanStatusPersist._hash}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getName())) .failOn(org.opencdmp.model.persist.planstatus.PlanStatusPersist._name).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{org.opencdmp.model.persist.planstatus.PlanStatusPersist._name}, LocaleContextHolder.getLocale())), @@ -105,14 +105,13 @@ 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() + .must(() -> !this.isNull(item.getInternalStatus())) + .failOn(org.opencdmp.model.persist.planstatus.PlanStatusPersist._internalStatus).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{org.opencdmp.model.persist.planstatus.PlanStatusPersist._internalStatus}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> item.getInternalStatus() == org.opencdmp.commons.enums.PlanStatus.Finalized) .must(() -> !this.isNull(item.getDefinition())) .failOn(org.opencdmp.model.persist.planstatus.PlanStatusPersist._definition).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{org.opencdmp.model.persist.planstatus.PlanStatusPersist._definition}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> !this.isNull(item.getInternalStatus())) - .failOn(org.opencdmp.model.persist.planstatus.PlanStatusPersist._internalStatus).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{org.opencdmp.model.persist.planstatus.PlanStatusPersist._internalStatus}, LocaleContextHolder.getLocale())), - this.refSpec() .iff(() -> !this.isNull(item.getDefinition())) .on(org.opencdmp.model.persist.planstatus.PlanStatusPersist._definition) diff --git a/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinitionAuthorization.java b/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinitionAuthorization.java index 9a46e48e9..0dad74d8c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinitionAuthorization.java +++ b/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinitionAuthorization.java @@ -1,17 +1,15 @@ package org.opencdmp.model.planstatus; -import java.util.List; - public class PlanStatusDefinitionAuthorization { public final static String _edit = "edit"; - private List edit; + private PlanStatusDefinitionAuthorizationItem edit; - public List getEdit() { + public PlanStatusDefinitionAuthorizationItem getEdit() { return edit; } - public void setEdit(List edit) { + public void setEdit(PlanStatusDefinitionAuthorizationItem edit) { this.edit = edit; } diff --git a/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinitionAuthorizationItem.java b/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinitionAuthorizationItem.java index 574f496e9..a16eb2ad3 100644 --- a/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinitionAuthorizationItem.java +++ b/backend/core/src/main/java/org/opencdmp/model/planstatus/PlanStatusDefinitionAuthorizationItem.java @@ -5,16 +5,17 @@ import java.util.List; public class PlanStatusDefinitionAuthorizationItem { public final static String _roles = "roles"; - public List roles; + private List roles; public final static String _planRoles = "planRoles"; - public List planRoles; + private List planRoles; public final static String _allowAuthenticated = "allowAuthenticated"; - public Boolean allowAuthenticated; + private Boolean allowAuthenticated; + public final static String _allowAnonymous = "allowAnonymous"; - public Boolean allowAnonymous; + private Boolean allowAnonymous; public List getRoles() { return this.roles; } public void setRoles(List roles) { this.roles = roles; } 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 4c9603f31..63565b2a0 100644 --- a/backend/core/src/main/java/org/opencdmp/query/PlanStatusQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/PlanStatusQuery.java @@ -71,17 +71,17 @@ public class PlanStatusQuery extends QueryBase { return this; } - public PlanStatusQuery isActive(IsActive value) { + public PlanStatusQuery isActives(IsActive value) { this.isActives = List.of(value); return this; } - public PlanStatusQuery isActive(IsActive... value) { + public PlanStatusQuery isActives(IsActive... value) { this.isActives = Arrays.asList(value); return this; } - public PlanStatusQuery isActive(Collection values) { + public PlanStatusQuery isActives(Collection values) { this.isActives = values; return this; } @@ -117,17 +117,17 @@ public class PlanStatusQuery extends QueryBase { } private final QueryUtilsService queryUtilsService; - private final TenantEntityManager tenantEntityManager; + private final TenantEntityManager entityManager; public PlanStatusQuery( QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager) { this.queryUtilsService = queryUtilsService; - this.tenantEntityManager = tenantEntityManager; + this.entityManager = tenantEntityManager; } @Override protected EntityManager entityManager(){ - return this.tenantEntityManager.getEntityManager(); + return this.entityManager.getEntityManager(); } @Override diff --git a/backend/core/src/main/java/org/opencdmp/query/lookup/PlanStatusLookup.java b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanStatusLookup.java index b0e9db833..e947d2234 100644 --- a/backend/core/src/main/java/org/opencdmp/query/lookup/PlanStatusLookup.java +++ b/backend/core/src/main/java/org/opencdmp/query/lookup/PlanStatusLookup.java @@ -55,7 +55,7 @@ public class PlanStatusLookup extends Lookup { if (this.like != null) query.like(this.like); if (this.ids != null) query.ids(this.ids); if (this.excludedIds != null) query.excludedIds(this.excludedIds); - if (this.isActive != null) query.isActive(this.isActive); + if (this.isActive != null) query.isActives(this.isActive); this.enrichCommon(query); diff --git a/backend/core/src/main/java/org/opencdmp/service/descriptionstatus/DescriptionStatusServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/descriptionstatus/DescriptionStatusServiceImpl.java index a0d812929..13f6f235c 100644 --- a/backend/core/src/main/java/org/opencdmp/service/descriptionstatus/DescriptionStatusServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/descriptionstatus/DescriptionStatusServiceImpl.java @@ -31,12 +31,14 @@ import org.opencdmp.model.persist.descriptionstatus.DescriptionStatusPersist; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Service; import javax.management.InvalidApplicationException; import java.time.Instant; import java.util.List; import java.util.UUID; +@Service public class DescriptionStatusServiceImpl implements DescriptionStatusService { private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionStatusServiceImpl.class)); diff --git a/backend/core/src/main/java/org/opencdmp/service/planstatus/PlanStatusServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/planstatus/PlanStatusServiceImpl.java index e95e4fdee..9c53fb457 100644 --- a/backend/core/src/main/java/org/opencdmp/service/planstatus/PlanStatusServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/planstatus/PlanStatusServiceImpl.java @@ -27,10 +27,10 @@ import org.opencdmp.event.EventBroker; import org.opencdmp.model.builder.planstatus.PlanStatusBuilder; import org.opencdmp.model.deleter.PlanStatusDeleter; import org.opencdmp.model.persist.planstatus.PlanStatusDefinitionAuthorizationItemPersist; +import org.opencdmp.model.persist.planstatus.PlanStatusDefinitionAuthorizationPersist; import org.opencdmp.model.persist.planstatus.PlanStatusDefinitionPersist; import org.opencdmp.model.persist.planstatus.PlanStatusPersist; import org.opencdmp.model.planstatus.PlanStatus; -import org.opencdmp.service.tag.TagServiceImpl; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -91,6 +91,7 @@ public class PlanStatusServiceImpl implements PlanStatusService { data.setName(model.getName()); data.setDescription(model.getDescription()); + data.setInternalStatus(model.getInternalStatus()); data.setDefinition(this.xmlHandlingService.toXml(this.buildPlanStatusDefinitionEntity(model.getDefinition()))); data.setUpdatedAt(Instant.now()); @@ -119,15 +120,20 @@ public class PlanStatusServiceImpl implements PlanStatusService { return data; if (persist.getAuthorization() != null) { - PlanStatusDefinitionAuthorizationEntity definitionAuthorizationData = new PlanStatusDefinitionAuthorizationEntity(); + PlanStatusDefinitionAuthorizationEntity definitionAuthorizationData = this.buildPlanStatusDefinitionAuthorizationEntity(persist.getAuthorization()); data.setAuthorization(definitionAuthorizationData); - if (!this.conventionService.isListNullOrEmpty(persist.getAuthorization().getEdit())) { - definitionAuthorizationData.setEdit(new ArrayList<>()); + } + return data; + } - for (PlanStatusDefinitionAuthorizationItemPersist p : persist.getAuthorization().getEdit()) { - definitionAuthorizationData.getEdit().add(this.buildPlanStatusDefinitionAuthorizationItemEntity(p)); - } - } + private @NotNull PlanStatusDefinitionAuthorizationEntity buildPlanStatusDefinitionAuthorizationEntity(PlanStatusDefinitionAuthorizationPersist persist) { + PlanStatusDefinitionAuthorizationEntity data = new PlanStatusDefinitionAuthorizationEntity(); + if (persist == null) + return data; + + if (persist.getEdit() != null) { + PlanStatusDefinitionAuthorizationItemEntity definitionAuthorizationData = this.buildPlanStatusDefinitionAuthorizationItemEntity(persist.getEdit()); + data.setEdit(definitionAuthorizationData); } return data; }