This commit is contained in:
CITE\spapacharalampous 2024-08-22 14:11:56 +03:00
parent a0d9568375
commit da1c603a8a
13 changed files with 53 additions and 53 deletions

View File

@ -251,5 +251,6 @@ public final class Permission {
public static String ViewTenantConfigurationPage = "ViewTenantConfigurationPage"; public static String ViewTenantConfigurationPage = "ViewTenantConfigurationPage";
public static String ViewStatusPage = "ViewStatusPage"; public static String ViewStatusPage = "ViewStatusPage";
public static String ViewPlanStatusPage = "ViewPlanStatusPage"; public static String ViewPlanStatusPage = "ViewPlanStatusPage";
public static String ViewDescriptionStatusPage = "ViewPlanStatusPage";
} }

View File

@ -3,19 +3,19 @@ package org.opencdmp.commons.types.planstatus;
import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.List; @XmlRootElement(name = "authorization")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class PlanStatusDefinitionAuthorizationEntity { public class PlanStatusDefinitionAuthorizationEntity {
@XmlElement(name = "edit") @XmlElement(name = "edit")
private List<PlanStatusDefinitionAuthorizationItemEntity> edit; private PlanStatusDefinitionAuthorizationItemEntity edit;
public List<PlanStatusDefinitionAuthorizationItemEntity> getEdit() { public PlanStatusDefinitionAuthorizationItemEntity getEdit() {
return edit; return edit;
} }
public void setEdit(List<PlanStatusDefinitionAuthorizationItemEntity> edit) { public void setEdit(PlanStatusDefinitionAuthorizationItemEntity edit) {
this.edit = edit; this.edit = edit;
} }
} }

View File

@ -1,6 +1,5 @@
package org.opencdmp.model.builder.planstatus; package org.opencdmp.model.builder.planstatus;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
@ -21,14 +20,10 @@ import java.util.*;
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanStatusDefinitionAuthorizationItemBuilder extends BaseBuilder<PlanStatusDefinitionAuthorizationItem, PlanStatusDefinitionAuthorizationItemEntity> { public class PlanStatusDefinitionAuthorizationItemBuilder extends BaseBuilder<PlanStatusDefinitionAuthorizationItem, PlanStatusDefinitionAuthorizationItemEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public PlanStatusDefinitionAuthorizationItemBuilder(ConventionService conventionService) {
public PlanStatusDefinitionAuthorizationItemBuilder(ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanStatusDefinitionAuthorizationItemBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanStatusDefinitionAuthorizationItemBuilder.class)));
this.builderFactory = builderFactory;
} }
public PlanStatusDefinitionAuthorizationItemBuilder authorize(EnumSet<AuthorizationFlags> values) { public PlanStatusDefinitionAuthorizationItemBuilder authorize(EnumSet<AuthorizationFlags> values) {

View File

@ -70,9 +70,7 @@ public class PlanStatusDeleter implements Deleter {
return; return;
Instant now = Instant.now(); Instant now = Instant.now();
for (PlanStatusEntity item : data) { for (PlanStatusEntity item : data) {
logger.trace("deleting item {}", item.getId()); logger.trace("deleting item {}", item.getId());
item.setIsActive(IsActive.Inactive); item.setIsActive(IsActive.Inactive);
item.setUpdatedAt(now); item.setUpdatedAt(now);

View File

@ -16,16 +16,16 @@ import java.util.List;
public class PlanStatusDefinitionAuthorizationItemPersist { public class PlanStatusDefinitionAuthorizationItemPersist {
public List<String> roles = null; private List<String> roles = null;
public final static String _roles = "roles"; public final static String _roles = "roles";
public List<String> planRoles = null; private List<String> planRoles = null;
public final static String _planRoles = "planRoles"; public final static String _planRoles = "planRoles";
public Boolean allowAuthenticated; private Boolean allowAuthenticated;
public final static String _allowAuthenticated = "allowAuthenticated"; public final static String _allowAuthenticated = "allowAuthenticated";
public Boolean allowAnonymous; private Boolean allowAnonymous;
public final static String _allowAnonymous = "allowAuthenticated"; public final static String _allowAnonymous = "allowAuthenticated";

View File

@ -17,14 +17,14 @@ import java.util.List;
public class PlanStatusDefinitionAuthorizationPersist { public class PlanStatusDefinitionAuthorizationPersist {
public final static String _edit = "edit"; public final static String _edit = "edit";
private List<PlanStatusDefinitionAuthorizationItemPersist> edit = null; private PlanStatusDefinitionAuthorizationItemPersist edit = null;
public List<PlanStatusDefinitionAuthorizationItemPersist> getEdit() { public PlanStatusDefinitionAuthorizationItemPersist getEdit() {
return this.edit; return this.edit;
} }
public void setEdit(List<PlanStatusDefinitionAuthorizationItemPersist> edit) { public void setEdit(PlanStatusDefinitionAuthorizationItemPersist edit) {
this.edit = edit; this.edit = edit;
} }
@ -50,13 +50,13 @@ public class PlanStatusDefinitionAuthorizationPersist {
protected List<Specification> specifications(PlanStatusDefinitionAuthorizationPersist item) { protected List<Specification> specifications(PlanStatusDefinitionAuthorizationPersist item) {
return Arrays.asList( return Arrays.asList(
this.spec() 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())), .failOn(PlanStatusDefinitionAuthorizationPersist._edit).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanStatusDefinitionAuthorizationPersist._edit}, LocaleContextHolder.getLocale())),
this.navSpec() this.refSpec()
.iff(() -> !this.isListNullOrEmpty(item.getEdit())) .iff(() -> !this.isNull(item.getEdit()))
.on(PlanStatusDefinitionAuthorizationPersist._edit) .on(PlanStatusDefinitionAuthorizationPersist._edit)
.over(item.getEdit()) .over(item.getEdit())
.using((itm) -> this.validatorFactory.validator(PlanStatusDefinitionAuthorizationItemPersist.PlanStatusDefinitionAuthorizationItemPersistValidator.class)) .using(() -> this.validatorFactory.validator(PlanStatusDefinitionAuthorizationItemPersist.PlanStatusDefinitionAuthorizationItemPersistValidator.class))
); );
} }
} }

View File

@ -97,7 +97,7 @@ public class PlanStatusPersist {
this.spec() this.spec()
.iff(() -> !this.isValidGuid(item.getId())) .iff(() -> !this.isValidGuid(item.getId()))
.must(() -> !this.isValidHash(item.getHash())) .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() this.spec()
.must(() -> !this.isEmpty(item.getName())) .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())), .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())) .iff(() -> !this.isEmpty(item.getName()))
.must(() -> this.lessEqualLength(item.getName(), PlanStatusEntity._nameLength)) .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())), .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() this.spec()
.iff(() -> item.getInternalStatus() == org.opencdmp.commons.enums.PlanStatus.Finalized) .iff(() -> item.getInternalStatus() == org.opencdmp.commons.enums.PlanStatus.Finalized)
.must(() -> !this.isNull(item.getDefinition())) .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())), .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() this.refSpec()
.iff(() -> !this.isNull(item.getDefinition())) .iff(() -> !this.isNull(item.getDefinition()))
.on(org.opencdmp.model.persist.planstatus.PlanStatusPersist._definition) .on(org.opencdmp.model.persist.planstatus.PlanStatusPersist._definition)

View File

@ -1,17 +1,15 @@
package org.opencdmp.model.planstatus; package org.opencdmp.model.planstatus;
import java.util.List;
public class PlanStatusDefinitionAuthorization { public class PlanStatusDefinitionAuthorization {
public final static String _edit = "edit"; public final static String _edit = "edit";
private List<PlanStatusDefinitionAuthorizationItem> edit; private PlanStatusDefinitionAuthorizationItem edit;
public List<PlanStatusDefinitionAuthorizationItem> getEdit() { public PlanStatusDefinitionAuthorizationItem getEdit() {
return edit; return edit;
} }
public void setEdit(List<PlanStatusDefinitionAuthorizationItem> edit) { public void setEdit(PlanStatusDefinitionAuthorizationItem edit) {
this.edit = edit; this.edit = edit;
} }

View File

@ -5,16 +5,17 @@ import java.util.List;
public class PlanStatusDefinitionAuthorizationItem { public class PlanStatusDefinitionAuthorizationItem {
public final static String _roles = "roles"; public final static String _roles = "roles";
public List<String> roles; private List<String> roles;
public final static String _planRoles = "planRoles"; public final static String _planRoles = "planRoles";
public List<String> planRoles; private List<String> planRoles;
public final static String _allowAuthenticated = "allowAuthenticated"; public final static String _allowAuthenticated = "allowAuthenticated";
public Boolean allowAuthenticated; private Boolean allowAuthenticated;
public final static String _allowAnonymous = "allowAnonymous"; public final static String _allowAnonymous = "allowAnonymous";
public Boolean allowAnonymous; private Boolean allowAnonymous;
public List<String> getRoles() { return this.roles; } public List<String> getRoles() { return this.roles; }
public void setRoles(List<String> roles) { this.roles = roles; } public void setRoles(List<String> roles) { this.roles = roles; }

View File

@ -71,17 +71,17 @@ public class PlanStatusQuery extends QueryBase<PlanStatusEntity> {
return this; return this;
} }
public PlanStatusQuery isActive(IsActive value) { public PlanStatusQuery isActives(IsActive value) {
this.isActives = List.of(value); this.isActives = List.of(value);
return this; return this;
} }
public PlanStatusQuery isActive(IsActive... value) { public PlanStatusQuery isActives(IsActive... value) {
this.isActives = Arrays.asList(value); this.isActives = Arrays.asList(value);
return this; return this;
} }
public PlanStatusQuery isActive(Collection<IsActive> values) { public PlanStatusQuery isActives(Collection<IsActive> values) {
this.isActives = values; this.isActives = values;
return this; return this;
} }
@ -117,17 +117,17 @@ public class PlanStatusQuery extends QueryBase<PlanStatusEntity> {
} }
private final QueryUtilsService queryUtilsService; private final QueryUtilsService queryUtilsService;
private final TenantEntityManager tenantEntityManager; private final TenantEntityManager entityManager;
public PlanStatusQuery( public PlanStatusQuery(
QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager) { QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager) {
this.queryUtilsService = queryUtilsService; this.queryUtilsService = queryUtilsService;
this.tenantEntityManager = tenantEntityManager; this.entityManager = tenantEntityManager;
} }
@Override @Override
protected EntityManager entityManager(){ protected EntityManager entityManager(){
return this.tenantEntityManager.getEntityManager(); return this.entityManager.getEntityManager();
} }
@Override @Override

View File

@ -55,7 +55,7 @@ public class PlanStatusLookup extends Lookup {
if (this.like != null) query.like(this.like); if (this.like != null) query.like(this.like);
if (this.ids != null) query.ids(this.ids); if (this.ids != null) query.ids(this.ids);
if (this.excludedIds != null) query.excludedIds(this.excludedIds); 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); this.enrichCommon(query);

View File

@ -31,12 +31,14 @@ import org.opencdmp.model.persist.descriptionstatus.DescriptionStatusPersist;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.time.Instant; import java.time.Instant;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@Service
public class DescriptionStatusServiceImpl implements DescriptionStatusService { public class DescriptionStatusServiceImpl implements DescriptionStatusService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionStatusServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionStatusServiceImpl.class));

View File

@ -27,10 +27,10 @@ import org.opencdmp.event.EventBroker;
import org.opencdmp.model.builder.planstatus.PlanStatusBuilder; import org.opencdmp.model.builder.planstatus.PlanStatusBuilder;
import org.opencdmp.model.deleter.PlanStatusDeleter; import org.opencdmp.model.deleter.PlanStatusDeleter;
import org.opencdmp.model.persist.planstatus.PlanStatusDefinitionAuthorizationItemPersist; 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.PlanStatusDefinitionPersist;
import org.opencdmp.model.persist.planstatus.PlanStatusPersist; import org.opencdmp.model.persist.planstatus.PlanStatusPersist;
import org.opencdmp.model.planstatus.PlanStatus; import org.opencdmp.model.planstatus.PlanStatus;
import org.opencdmp.service.tag.TagServiceImpl;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
@ -91,6 +91,7 @@ public class PlanStatusServiceImpl implements PlanStatusService {
data.setName(model.getName()); data.setName(model.getName());
data.setDescription(model.getDescription()); data.setDescription(model.getDescription());
data.setInternalStatus(model.getInternalStatus());
data.setDefinition(this.xmlHandlingService.toXml(this.buildPlanStatusDefinitionEntity(model.getDefinition()))); data.setDefinition(this.xmlHandlingService.toXml(this.buildPlanStatusDefinitionEntity(model.getDefinition())));
data.setUpdatedAt(Instant.now()); data.setUpdatedAt(Instant.now());
@ -119,15 +120,20 @@ public class PlanStatusServiceImpl implements PlanStatusService {
return data; return data;
if (persist.getAuthorization() != null) { if (persist.getAuthorization() != null) {
PlanStatusDefinitionAuthorizationEntity definitionAuthorizationData = new PlanStatusDefinitionAuthorizationEntity(); PlanStatusDefinitionAuthorizationEntity definitionAuthorizationData = this.buildPlanStatusDefinitionAuthorizationEntity(persist.getAuthorization());
data.setAuthorization(definitionAuthorizationData); data.setAuthorization(definitionAuthorizationData);
if (!this.conventionService.isListNullOrEmpty(persist.getAuthorization().getEdit())) { }
definitionAuthorizationData.setEdit(new ArrayList<>()); return data;
}
for (PlanStatusDefinitionAuthorizationItemPersist p : persist.getAuthorization().getEdit()) { private @NotNull PlanStatusDefinitionAuthorizationEntity buildPlanStatusDefinitionAuthorizationEntity(PlanStatusDefinitionAuthorizationPersist persist) {
definitionAuthorizationData.getEdit().add(this.buildPlanStatusDefinitionAuthorizationItemEntity(p)); PlanStatusDefinitionAuthorizationEntity data = new PlanStatusDefinitionAuthorizationEntity();
} if (persist == null)
} return data;
if (persist.getEdit() != null) {
PlanStatusDefinitionAuthorizationItemEntity definitionAuthorizationData = this.buildPlanStatusDefinitionAuthorizationItemEntity(persist.getEdit());
data.setEdit(definitionAuthorizationData);
} }
return data; return data;
} }