added plan status entity

This commit is contained in:
CITE\spapacharalampous 2024-08-21 12:41:36 +03:00
parent 0e05a8a97c
commit f9c3f8a64b
29 changed files with 1848 additions and 1 deletions

View File

@ -197,6 +197,11 @@ public class AuditableAction {
public static final EventId UsageLimit_Persist = new EventId(290002, "UsageLimit_Persist");
public static final EventId UsageLimit_Delete = new EventId(290003, "UsageLimit_Delete");
public static final EventId PlanStatus_Query = new EventId(300000, "PlanStatus_Query");
public static final EventId PlanStatus_Lookup = new EventId(300001, "PlanStatus_Lookup");
public static final EventId PlanStatus_Persist = new EventId(300002, "PlanStatus_Persist");
public static final EventId PlanStatus_Delete = new EventId(300003, "PlanStatus_Delete");
}

View File

@ -90,6 +90,10 @@ public final class Permission {
public static String InvitePlanUsers = "InvitePlanUsers";
public static String AnnotatePlan = "AnnotatePlan";
//PlanStatus
public static String BrowsePlanStatus = "BrowsePlanStatus";
public static String EditPlanStatus = "EditPlanStatus";
public static String DeletePlanStatus = "DeletePlanStatus";
//PlanBlueprint
public static String BrowsePlanBlueprint = "BrowsePlanBlueprint";

View File

@ -8,6 +8,7 @@ import java.util.Map;
public enum UsageLimitTargetMetric implements DatabaseEnum<String> {
USER_COUNT(TargetMetrics.UserCount),
PLAN_COUNT(TargetMetrics.PlanCount),
PLAN_STATUS_COUNT(TargetMetrics.PlanStatusCount),
BLUEPRINT_COUNT(TargetMetrics.BlueprintCount),
DESCRIPTION_COUNT(TargetMetrics.DescriptionCount),
DESCRIPTION_TEMPLATE_COUNT(TargetMetrics.DescriptionTemplateCount),
@ -34,6 +35,7 @@ public enum UsageLimitTargetMetric implements DatabaseEnum<String> {
public static class TargetMetrics {
public static final String UserCount = "user_count";
public static final String PlanCount = "plan_count";
public static final String PlanStatusCount = "plan_status_count";
public static final String BlueprintCount = "blueprint_count";
public static final String DescriptionCount = "description_count";
public static final String DescriptionTemplateCount = "description_template_count";

View File

@ -0,0 +1,21 @@
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 java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class PlanStatusDefinitionAuthorizationEntity {
@XmlElement(name = "edit")
private List<PlanStatusDefinitionAuthorizationItemEntity> edit;
public List<PlanStatusDefinitionAuthorizationItemEntity> getEdit() {
return edit;
}
public void setEdit(List<PlanStatusDefinitionAuthorizationItemEntity> edit) {
this.edit = edit;
}
}

View File

@ -0,0 +1,36 @@
package org.opencdmp.commons.types.planstatus;
import jakarta.xml.bind.annotation.*;
import java.util.List;
@XmlRootElement(name = "edit")
@XmlAccessorType(XmlAccessType.FIELD)
public class PlanStatusDefinitionAuthorizationItemEntity {
@XmlElementWrapper(name = "roles")
@XmlElement(name = "roles")
public List<String> roles;
@XmlElementWrapper(name = "plan_roles")
@XmlElement(name = "plan_roles")
public List<String> planRoles;
@XmlElement(name = "allowAuthenticated")
public Boolean allowAuthenticated;
@XmlElement(name = "allowAnonymous")
public Boolean allowAnonymous;
public List<String> getRoles() { return this.roles; }
public void setRoles(List<String> roles) { this.roles = roles; }
public List<String> getPlanRoles() { return this.planRoles; }
public void setPlanRoles(List<String> planRoles) { this.planRoles = planRoles; }
public Boolean getAllowAuthenticated() { return this.allowAuthenticated; }
public void setAllowAuthenticated(Boolean allowAuthenticated) { this.allowAuthenticated = allowAuthenticated; }
public Boolean getAllowAnonymous() { return this.allowAnonymous; }
public void setAllowAnonymous(Boolean allowAnonymous) { this.allowAnonymous = allowAnonymous; }
}

View File

@ -0,0 +1,17 @@
package org.opencdmp.commons.types.planstatus;
import jakarta.xml.bind.annotation.*;
@XmlRootElement(name = "definition")
@XmlAccessorType(XmlAccessType.FIELD)
public class PlanStatusDefinitionEntity {
@XmlElement(name = "authorization")
private PlanStatusDefinitionAuthorizationEntity authorization;
public PlanStatusDefinitionAuthorizationEntity getAuthorization() {
return authorization;
}
public void setAuthorization(PlanStatusDefinitionAuthorizationEntity authorization) { this.authorization = authorization; }
}

View File

@ -0,0 +1,104 @@
package org.opencdmp.data;
import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.enums.PlanStatus;
import org.opencdmp.data.converters.enums.DescriptionTemplateStatusConverter;
import org.opencdmp.data.converters.enums.IsActiveConverter;
import org.opencdmp.data.tenant.TenantScopedBaseEntity;
import org.opencdmp.data.types.SQLXMLType;
import java.time.Instant;
import java.util.UUID;
@Entity
@Table(name = "\"PlanStatus\"")
public class PlanStatusEntity extends TenantScopedBaseEntity {
@Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id;
public static final String _id = "id";
@Column(name = "name", length = PlanStatusEntity._nameLength, nullable = false)
private String name;
public static final String _name = "name";
public static final int _nameLength = 250;
@Column(name = "description", nullable = true)
private String description;
public static final String _description = "description";
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public static final String _createdAt = "createdAt";
@Column(name = "updated_at", nullable = false)
private Instant updatedAt;
public static final String _updatedAt = "updatedAt";
@Column(name = "is_active", nullable = false)
@Convert(converter = IsActiveConverter.class)
private IsActive isActive;
public static final String _isActive = "isActive";
@Column(name = "internal_status", nullable = false)
@Convert(converter = DescriptionTemplateStatusConverter.class)
private PlanStatus internalStatus;
public static final String _internalStatus = "internalStatus";
@Type(SQLXMLType.class)
@Column(name = "definition", nullable = false, columnDefinition = "xml")
private String definition;
public static final String _definition = "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 String getDescription() { return this.description; }
public void setDescription(String description) { this.description = description;}
public Instant getCreatedAt() {
return this.createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getUpdatedAt() {
return this.updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
public IsActive getIsActive() {
return this.isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
public PlanStatus getInternalStatus() {
return this.internalStatus;
}
public void setInternalStatus(PlanStatus internalStatus) {
this.internalStatus = internalStatus;
}
public String getDefinition() {
return this.definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
}

View File

@ -0,0 +1,76 @@
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;
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.builder.BaseBuilder;
import org.opencdmp.model.planstatus.PlanStatus;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanStatusBuilder extends BaseBuilder<PlanStatus, PlanStatusEntity> {
private final XmlHandlingService xmlHandlingService;
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public PlanStatusBuilder(ConventionService conventionService, XmlHandlingService xmlHandlingService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanStatusDefinitionAuthorizationItemBuilder.class)));
this.xmlHandlingService = xmlHandlingService;
this.builderFactory = builderFactory;
}
public PlanStatusBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PlanStatus> build(FieldSet fields, List<PlanStatusEntity> 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(PlanStatus._definition));
List<PlanStatus> models = new ArrayList<>();
for (PlanStatusEntity d : data) {
PlanStatus m = new PlanStatus();
if (fields.hasField(this.asIndexer(PlanStatus._id)))
m.setId(d.getId());
if (fields.hasField(this.asIndexer(PlanStatus._name)))
m.setName(d.getName());
if (fields.hasField(this.asIndexer(PlanStatus._description)))
m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(PlanStatus._internalStatus)))
m.setInternalStatus(d.getInternalStatus());
if (fields.hasField(this.asIndexer(PlanStatus._hash)))
m.setHash(this.hashValue(d.getUpdatedAt()));
if (!definitionFields.isEmpty() && d.getDefinition() != null) {
PlanStatusDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(PlanStatusDefinitionEntity.class, d.getDefinition());
m.setDefinition(this.builderFactory.builder(PlanStatusDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
}
models.add(m);
}
return models;
}
}

View File

@ -0,0 +1,56 @@
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;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commons.types.planstatus.PlanStatusDefinitionAuthorizationEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.builder.BaseBuilder;
import org.opencdmp.model.planstatus.PlanStatusDefinitionAuthorization;
import org.slf4j.LoggerFactory;
import java.util.*;
public class PlanStatusDefinitionAuthorizationBuilder extends BaseBuilder<PlanStatusDefinitionAuthorization, PlanStatusDefinitionAuthorizationEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public PlanStatusDefinitionAuthorizationBuilder(ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanStatusDefinitionAuthorizationItemBuilder.class)));
this.builderFactory = builderFactory;
}
public PlanStatusDefinitionAuthorizationBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PlanStatusDefinitionAuthorization> build(FieldSet fields, List<PlanStatusDefinitionAuthorizationEntity> 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<PlanStatusDefinitionAuthorization> models = new ArrayList<>();
FieldSet editFields = fields.extractPrefixed(this.asPrefix(PlanStatusDefinitionAuthorization._edit));
for (PlanStatusDefinitionAuthorizationEntity d : data) {
PlanStatusDefinitionAuthorization m = new PlanStatusDefinitionAuthorization();
if (!editFields.isEmpty() && d.getEdit() != null) {
m.setEdit(this.builderFactory.builder(PlanStatusDefinitionAuthorizationItemBuilder.class).authorize(this.authorize).build(editFields, d.getEdit()));
}
models.add(m);
}
return models;
}
}

View File

@ -0,0 +1,59 @@
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;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commons.types.planstatus.PlanStatusDefinitionAuthorizationItemEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.builder.BaseBuilder;
import org.opencdmp.model.planstatus.PlanStatusDefinitionAuthorizationItem;
import org.slf4j.LoggerFactory;
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 PlanStatusDefinitionAuthorizationItemBuilder extends BaseBuilder<PlanStatusDefinitionAuthorizationItem, PlanStatusDefinitionAuthorizationItemEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public PlanStatusDefinitionAuthorizationItemBuilder(ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanStatusDefinitionAuthorizationItemBuilder.class)));
this.builderFactory = builderFactory;
}
public PlanStatusDefinitionAuthorizationItemBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PlanStatusDefinitionAuthorizationItem> build(FieldSet fields, List<PlanStatusDefinitionAuthorizationItemEntity> 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<PlanStatusDefinitionAuthorizationItem> models = new ArrayList<>();
for (PlanStatusDefinitionAuthorizationItemEntity d : data) {
PlanStatusDefinitionAuthorizationItem m = new PlanStatusDefinitionAuthorizationItem();
if (fields.hasField(this.asIndexer(PlanStatusDefinitionAuthorizationItem._planRoles))) m.setPlanRoles(d.getPlanRoles());
if (fields.hasField(this.asIndexer(PlanStatusDefinitionAuthorizationItem._roles))) m.setRoles(d.getRoles());
if (fields.hasField(this.asIndexer(PlanStatusDefinitionAuthorizationItem._allowAuthenticated))) m.setAllowAuthenticated(d.getAllowAuthenticated());
if (fields.hasField(this.asIndexer(PlanStatusDefinitionAuthorizationItem._allowAnonymous))) m.setAllowAnonymous(d.getAllowAnonymous());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -0,0 +1,56 @@
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;
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.builder.BaseBuilder;
import org.opencdmp.model.planstatus.PlanStatusDefinition;
import org.slf4j.LoggerFactory;
import java.util.*;
public class PlanStatusDefinitionBuilder extends BaseBuilder<PlanStatusDefinition, PlanStatusDefinitionEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public PlanStatusDefinitionBuilder(ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PlanStatusDefinitionAuthorizationItemBuilder.class)));
this.builderFactory = builderFactory;
}
public PlanStatusDefinitionBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PlanStatusDefinition> build(FieldSet fields, List<PlanStatusDefinitionEntity> 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<PlanStatusDefinition> models = new ArrayList<>();
FieldSet authorizationFields = fields.extractPrefixed(this.asPrefix(PlanStatusDefinition._authorization));
for (PlanStatusDefinitionEntity d : data) {
PlanStatusDefinition m = new PlanStatusDefinition();
if (!authorizationFields.isEmpty() && d.getAuthorization() != null) {
m.setAuthorization(this.builderFactory.builder(PlanStatusDefinitionAuthorizationBuilder.class).authorize(this.authorize).build(authorizationFields, d.getAuthorization()));
}
models.add(m);
}
return models;
}
}

View File

@ -0,0 +1,44 @@
package org.opencdmp.model.censorship.planstatus;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.opencdmp.model.planstatus.PlanStatus;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanStatusCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanStatusCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PlanStatusCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowsePlanStatus);
FieldSet definitionFields = fields.extractPrefixed(this.asIndexerPrefix(PlanStatus._definition));
this.censorFactory.censor(PlanStatusDefinitionCensor.class).censor(definitionFields, userId);
}
}

View File

@ -0,0 +1,45 @@
package org.opencdmp.model.censorship.planstatus;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.opencdmp.model.planstatus.PlanStatusDefinitionAuthorization;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanStatusDefinitionAuthorizationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanStatusDefinitionAuthorizationCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PlanStatusDefinitionAuthorizationCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowsePlanStatus);
FieldSet editFields = fields.extractPrefixed(this.asIndexerPrefix(PlanStatusDefinitionAuthorization._edit));
this.censorFactory.censor(PlanStatusDefinitionAuthorizationItemCensor.class).censor(editFields, userId);
}
}

View File

@ -0,0 +1,40 @@
package org.opencdmp.model.censorship.planstatus;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanStatusDefinitionAuthorizationItemCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanStatusCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PlanStatusDefinitionAuthorizationItemCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowsePlanStatus);
}
}

View File

@ -0,0 +1,41 @@
package org.opencdmp.model.censorship.planstatus;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.censorship.BaseCensor;
import org.opencdmp.model.planstatus.PlanStatusDefinition;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanStatusDefinitionCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanStatusDefinitionCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public PlanStatusDefinitionCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowsePlanStatus);
FieldSet authotizationFields = fields.extractPrefixed(this.asIndexerPrefix(PlanStatusDefinition._authorization));
this.censorFactory.censor(PlanStatusDefinitionAuthorizationCensor.class).censor(authotizationFields, userId);
}
}

View File

@ -0,0 +1,85 @@
package org.opencdmp.model.deleter;
import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.enums.UsageLimitTargetMetric;
import org.opencdmp.data.PlanStatusEntity;
import org.opencdmp.data.TenantEntityManager;
import org.opencdmp.query.PlanStatusQuery;
import org.opencdmp.service.accounting.AccountingService;
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 javax.management.InvalidApplicationException;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanStatusDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplateDeleter.class));
private final TenantEntityManager entityManager;
protected final QueryFactory queryFactory;
protected final DeleterFactory deleterFactory;
protected final AccountingService accountingService;
@Autowired
public PlanStatusDeleter(
TenantEntityManager entityManager,
QueryFactory queryFactory,
DeleterFactory deleterFactory,
AccountingService accountingService) {
this.entityManager = entityManager;
this.queryFactory = queryFactory;
this.deleterFactory = deleterFactory;
this.accountingService = accountingService;
}
public void deleteAndSaveByIds(List<UUID> ids) throws InvalidApplicationException {
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
List<PlanStatusEntity> data = this.queryFactory.query(PlanStatusQuery.class).ids(ids).collect();
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.deleteAndSave(data);
}
public void deleteAndSave(List<PlanStatusEntity> data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.delete(data);
logger.trace("saving changes");
this.entityManager.flush();
logger.trace("changes saved");
}
public void delete(List<PlanStatusEntity> data) throws InvalidApplicationException {
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
if (data == null || data.isEmpty())
return;
Instant now = Instant.now();
for (PlanStatusEntity item : data) {
logger.trace("deleting item {}", item.getId());
item.setIsActive(IsActive.Inactive);
item.setUpdatedAt(now);
logger.trace("updating item");
this.entityManager.merge(item);
logger.trace("updated item");
this.accountingService.decrease(UsageLimitTargetMetric.PLAN_STATUS_COUNT.getValue());
}
}
}

View File

@ -0,0 +1,76 @@
package org.opencdmp.model.persist.planstatus;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
import org.opencdmp.commons.validation.BaseValidator;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
public class PlanStatusDefinitionAuthorizationItemPersist {
public List<String> roles = null;
public final static String _roles = "roles";
public List<String> planRoles = null;
public final static String _planRoles = "planRoles";
public Boolean allowAuthenticated;
public final static String _allowAuthenticated = "allowAuthenticated";
public Boolean allowAnonymous;
public final static String _allowAnonymous = "allowAuthenticated";
public List<String> getRoles() { return this.roles; }
public void setRoles(List<String> roles) { this.roles = roles; }
public List<String> getPlanRoles() { return this.planRoles; }
public void setPlanRoles(List<String> planRoles) { this.planRoles = planRoles; }
public Boolean getAllowAuthenticated() { return this.allowAuthenticated; }
public void setAllowAuthenticated(Boolean allowAuthenticated) { this.allowAuthenticated = allowAuthenticated; }
public Boolean getAllowAnonymous() { return this.allowAnonymous; }
public void setAllowAnonymous(Boolean allowAnonymous) { this.allowAnonymous = allowAnonymous; }
@Component(PlanStatusDefinitionAuthorizationItemPersist.PlanStatusDefinitionAuthorizationItemPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class PlanStatusDefinitionAuthorizationItemPersistValidator extends BaseValidator<PlanStatusDefinitionAuthorizationItemPersist> {
public static final String ValidatorName = "PlanStatus.PlanStatusDefinitionAuthorizationItemPersistValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected PlanStatusDefinitionAuthorizationItemPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<PlanStatusDefinitionAuthorizationItemPersist> modelClass() {
return PlanStatusDefinitionAuthorizationItemPersist.class;
}
@Override
protected List<Specification> 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()))
);
}
}
}

View File

@ -0,0 +1,63 @@
package org.opencdmp.model.persist.planstatus;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
import org.opencdmp.commons.validation.BaseValidator;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
public class PlanStatusDefinitionAuthorizationPersist {
public final static String _edit = "edit";
private List<PlanStatusDefinitionAuthorizationItemPersist> edit = null;
public List<PlanStatusDefinitionAuthorizationItemPersist> getEdit() {
return this.edit;
}
public void setEdit(List<PlanStatusDefinitionAuthorizationItemPersist> edit) {
this.edit = edit;
}
@Component(PlanStatusDefinitionAuthorizationPersist.PlanStatusDefinitionAuthorizationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class PlanStatusDefinitionAuthorizationPersistValidator extends BaseValidator<PlanStatusDefinitionAuthorizationPersist> {
public static final String ValidatorName = "PlanStatus.PlanStatusDefinitionAuthorizationPersistValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
public PlanStatusDefinitionAuthorizationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<PlanStatusDefinitionAuthorizationPersist> modelClass() {
return PlanStatusDefinitionAuthorizationPersist.class;
}
@Override
protected List<Specification> specifications(PlanStatusDefinitionAuthorizationPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isListNullOrEmpty(item.getEdit()))
.failOn(PlanStatusDefinitionAuthorizationPersist._edit).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanStatusDefinitionAuthorizationPersist._edit}, LocaleContextHolder.getLocale())),
this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getEdit()))
.on(PlanStatusDefinitionAuthorizationPersist._edit)
.over(item.getEdit())
.using((itm) -> this.validatorFactory.validator(PlanStatusDefinitionAuthorizationItemPersist.PlanStatusDefinitionAuthorizationItemPersistValidator.class))
);
}
}
}

View File

@ -0,0 +1,64 @@
package org.opencdmp.model.persist.planstatus;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
import org.opencdmp.commons.validation.BaseValidator;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import java.util.Arrays;
import java.util.List;
public class PlanStatusDefinitionPersist {
public final static String _authorization = "authorization";
private PlanStatusDefinitionAuthorizationPersist authorization = null;
public PlanStatusDefinitionAuthorizationPersist getAuthorization() { return authorization; }
public void setAuthorization(PlanStatusDefinitionAuthorizationPersist authorization) { this.authorization = authorization; }
@Component(PlanStatusDefinitionPersist.PlanStatusDefinitionPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class PlanStatusDefinitionPersistValidator extends BaseValidator<PlanStatusDefinitionPersist> {
public static final String ValidatorName = "PlanStatus.PlanStatusDefinitionPersistValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
public PlanStatusDefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<PlanStatusDefinitionPersist> modelClass() {
return PlanStatusDefinitionPersist.class;
}
@Override
protected List<Specification> specifications(PlanStatusDefinitionPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isNull(item.getAuthorization()))
.failOn(PlanStatusDefinitionPersist._authorization).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanStatusDefinitionPersist._authorization}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getAuthorization()))
.on(PlanStatusDefinitionPersist._authorization)
.over(item.getAuthorization())
.using(() -> this.validatorFactory.validator(PlanStatusDefinitionAuthorizationPersist.PlanStatusDefinitionAuthorizationPersistValidator.class))
);
}
@Override
public Errors validateObject(Object target) {
return super.validateObject(target);
}
}
}

View File

@ -0,0 +1,129 @@
package org.opencdmp.model.persist.planstatus;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
import org.opencdmp.commons.validation.BaseValidator;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.PlanStatusEntity;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class PlanStatusPersist {
private UUID id;
private String name;
public static final String _name = "name";
private String description;
public static final String _description = "description";
private org.opencdmp.commons.enums.PlanStatus internalStatus;
public static final String _internalStatus = "internalStatus";
private PlanStatusDefinitionPersist definition;
public static final String _definition = "definition";
private String hash;
public static final String _hash = "hash";
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 String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public org.opencdmp.commons.enums.PlanStatus getInternalStatus() { return this.internalStatus; }
public void setInternalStatus(org.opencdmp.commons.enums.PlanStatus internalStatus) { this.internalStatus = internalStatus; }
public PlanStatusDefinitionPersist getDefinition() { return this.definition; }
public void setDefinition(PlanStatusDefinitionPersist definition) { this.definition = definition; }
public String getHash() {
return this.hash;
}
public void setHash(String hash) {
this.hash = hash;
}
@Component(org.opencdmp.model.persist.planstatus.PlanStatusPersist.PlanStatusPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class PlanStatusPersistValidator extends BaseValidator<org.opencdmp.model.persist.planstatus.PlanStatusPersist> {
public static final String ValidatorName = "PlanStatusPersistValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected PlanStatusPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<org.opencdmp.model.persist.planstatus.PlanStatusPersist> modelClass() {
return org.opencdmp.model.persist.planstatus.PlanStatusPersist.class;
}
@Override
protected List<Specification> specifications(org.opencdmp.model.persist.planstatus.PlanStatusPersist item) {
return Arrays.asList(
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_Required", new Object[]{org.opencdmp.model.persist.planstatus.PlanStatusPersist._hash}, LocaleContextHolder.getLocale())),
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())),
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())),
this.spec()
.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(() -> 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)
.over(item.getDefinition())
.using(() -> this.validatorFactory.validator(PlanStatusDefinitionPersist.PlanStatusDefinitionPersistValidator.class)),
this.refSpec()
.iff(() -> item.getInternalStatus() == org.opencdmp.commons.enums.PlanStatus.Finalized)
.on(org.opencdmp.model.persist.planstatus.PlanStatusPersist._definition)
.over(item.getDefinition())
.using(() -> this.validatorFactory.validator(PlanStatusDefinitionPersist.PlanStatusDefinitionPersistValidator.class))
);
}
}
}

View File

@ -0,0 +1,124 @@
package org.opencdmp.model.planstatus;
import org.opencdmp.commons.enums.IsActive;
import java.time.Instant;
import java.util.List;
import java.util.UUID;
public class PlanStatus {
public final static String _id = "id";
private UUID id;
public final static String _name = "name";
private String name;
public final static String _description = "description";
private String description;
public final static String _createdAt = "createdAt";
private Instant createdAt;
public final static String _updatedAt = "updatedAt";
private Instant updatedAt;
public final static String _isActive = "isActive";
private IsActive isActive;
public final static String _internalStatus = "internalStatus";
private org.opencdmp.commons.enums.PlanStatus internalStatus;
public final static String _definition = "definition";
private PlanStatusDefinition definition;
public final static String _hash = "hash";
private String hash;
public static final String _authorizationFlags = "authorizationFlags";
private List<String> authorizationFlags;
public static final String _belongsToCurrentTenant = "belongsToCurrentTenant";
private Boolean belongsToCurrentTenant;
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 String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public PlanStatusDefinition getDefinition() {
return this.definition;
}
public void setDefinition(PlanStatusDefinition definition) {
this.definition = definition;
}
public Instant getCreatedAt() {
return this.createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getUpdatedAt() {
return this.updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
public IsActive getIsActive() {
return this.isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
public org.opencdmp.commons.enums.PlanStatus getInternalStatus() {
return this.internalStatus;
}
public void setInternalStatus(org.opencdmp.commons.enums.PlanStatus internalStatus) { this.internalStatus = internalStatus; }
public String getHash() {
return this.hash;
}
public void setHash(String hash) {
this.hash = hash;
}
public List<String> getAuthorizationFlags() {
return this.authorizationFlags;
}
public void setAuthorizationFlags(List<String> authorizationFlags) {
this.authorizationFlags = authorizationFlags;
}
public Boolean getBelongsToCurrentTenant() {
return this.belongsToCurrentTenant;
}
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) {
this.belongsToCurrentTenant = belongsToCurrentTenant;
}
}

View File

@ -0,0 +1,12 @@
package org.opencdmp.model.planstatus;
public class PlanStatusDefinition {
public final static String _authorization = "authorization";
private PlanStatusDefinitionAuthorization authorization;
public PlanStatusDefinitionAuthorization getAuthorization() { return authorization; }
public void setAuthorization(PlanStatusDefinitionAuthorization authorization) { this.authorization = authorization; }
}

View File

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

View File

@ -0,0 +1,30 @@
package org.opencdmp.model.planstatus;
import java.util.List;
public class PlanStatusDefinitionAuthorizationItem {
public final static String _roles = "roles";
public List<String> roles;
public final static String _planRoles = "planRoles";
public List<String> planRoles;
public final static String _allowAuthenticated = "allowAuthenticated";
public Boolean allowAuthenticated;
public final static String _allowAnonymous = "allowAnonymous";
public Boolean allowAnonymous;
public List<String> getRoles() { return this.roles; }
public void setRoles(List<String> roles) { this.roles = roles; }
public List<String> getPlanRoles() { return this.planRoles; }
public void setPlanRoles(List<String> planRoles) { this.planRoles = planRoles; }
public Boolean getAllowAuthenticated() { return this.allowAuthenticated; }
public void setAllowAuthenticated(Boolean allowAuthenticated) { this.allowAuthenticated = allowAuthenticated; }
public Boolean getAllowAnonymous() { return this.allowAnonymous; }
public void setAllowAnonymous(Boolean allowAnonymous) { this.allowAnonymous = allowAnonymous; }
}

View File

@ -0,0 +1,224 @@
package org.opencdmp.query;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase;
import gr.cite.tools.data.query.QueryContext;
import jakarta.persistence.EntityManager;
import jakarta.persistence.Tuple;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Predicate;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.data.PlanEntity;
import org.opencdmp.data.PlanStatusEntity;
import org.opencdmp.data.TenantEntityManager;
import org.opencdmp.model.planstatus.PlanStatus;
import org.opencdmp.query.utils.QueryUtilsService;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.time.Instant;
import java.util.*;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlanStatusQuery extends QueryBase<PlanStatusEntity> {
private String like;
private Collection<UUID> ids;
private Collection<IsActive> isActives;
private Collection<org.opencdmp.commons.enums.PlanStatus> internalStatuses;
private Collection<UUID> excludedIds;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public PlanStatusQuery like(String value) {
this.like = value;
return this;
}
public PlanStatusQuery ids(UUID value) {
this.ids = List.of(value);
return this;
}
public PlanStatusQuery ids(UUID... value) {
this.ids = Arrays.asList(value);
return this;
}
public PlanStatusQuery ids(Collection<UUID> values) {
this.ids = values;
return this;
}
public PlanStatusQuery excludedIds(UUID value) {
this.excludedIds = List.of(value);
return this;
}
public PlanStatusQuery excludedIds(UUID... value) {
this.excludedIds = Arrays.asList(value);
return this;
}
public PlanStatusQuery excludedIds(Collection<UUID> values) {
this.excludedIds = values;
return this;
}
public PlanStatusQuery isActive(IsActive value) {
this.isActives = List.of(value);
return this;
}
public PlanStatusQuery isActive(IsActive... value) {
this.isActives = Arrays.asList(value);
return this;
}
public PlanStatusQuery isActive(Collection<IsActive> values) {
this.isActives = values;
return this;
}
public PlanStatusQuery statuses(org.opencdmp.commons.enums.PlanStatus value) {
this.internalStatuses = List.of(value);
return this;
}
public PlanStatusQuery statuses(org.opencdmp.commons.enums.PlanStatus... value) {
this.internalStatuses = Arrays.asList(value);
return this;
}
public PlanStatusQuery statuses(Collection<org.opencdmp.commons.enums.PlanStatus> values) {
this.internalStatuses = values;
return this;
}
public PlanStatusQuery enableTracking() {
this.noTracking = false;
return this;
}
public PlanStatusQuery disableTracking() {
this.noTracking = true;
return this;
}
public PlanStatusQuery authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
private final QueryUtilsService queryUtilsService;
private final TenantEntityManager tenantEntityManager;
public PlanStatusQuery(
QueryUtilsService queryUtilsService, TenantEntityManager tenantEntityManager) {
this.queryUtilsService = queryUtilsService;
this.tenantEntityManager = tenantEntityManager;
}
@Override
protected EntityManager entityManager(){
return this.tenantEntityManager.getEntityManager();
}
@Override
protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.internalStatuses);
}
@Override
protected Class<PlanStatusEntity> entityClass() { return PlanStatusEntity.class; }
@Override
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>();
if (this.ids != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanStatusEntity._id));
for (UUID item : this.ids)
inClause.value(item);
predicates.add(inClause);
}
if (this.like != null && !this.like.isBlank()) {
predicates.add(queryContext.CriteriaBuilder.or(
this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(PlanStatusEntity._name), this.like),
this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(PlanStatusEntity._description), this.like)));
}
if (this.isActives != null) {
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanStatusEntity._isActive));
for (IsActive item : this.isActives)
inClause.value(item);
predicates.add(inClause);
}
if (this.internalStatuses != null) {
CriteriaBuilder.In<org.opencdmp.commons.enums.PlanStatus> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanStatusEntity._internalStatus));
for (org.opencdmp.commons.enums.PlanStatus item : this.internalStatuses)
inClause.value(item);
predicates.add(inClause);
}
if (this.excludedIds != null) {
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PlanStatusEntity._id));
for (UUID item : this.excludedIds)
notInClause.value(item);
predicates.add(notInClause.not());
}
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
return null;
}
}
@Override
protected String fieldNameOf(FieldResolver item) {
if (item.match(PlanStatus._id))
return PlanStatus._id;
else if (item.match(PlanStatus._description))
return PlanStatus._description;
else if (item.match(PlanStatus._name))
return PlanStatus._name;
else if (item.match(PlanStatus._internalStatus))
return PlanStatus._internalStatus;
else if (item.match(PlanStatus._definition))
return PlanStatus._definition;
else if (item.prefix(PlanStatus._definition))
return PlanStatus._definition;
else if (item.match(PlanStatus._createdAt))
return PlanStatus._createdAt;
else if (item.match(PlanStatus._updatedAt))
return PlanStatus._updatedAt;
else if (item.match(PlanStatus._isActive))
return PlanStatus._isActive;
else if (item.match(PlanStatus._belongsToCurrentTenant))
return PlanStatus._belongsToCurrentTenant;
else
return null;
}
@Override
protected PlanStatusEntity convert(Tuple tuple, Set<String> columns) {
PlanStatusEntity item = new PlanStatusEntity();
item.setId(QueryBase.convertSafe(tuple, columns, PlanStatusEntity._id, UUID.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, PlanStatusEntity._tenantId, UUID.class));
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.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));
return item;
}
}

View File

@ -0,0 +1,65 @@
package org.opencdmp.query.lookup;
import gr.cite.tools.data.query.Lookup;
import gr.cite.tools.data.query.QueryFactory;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.query.PlanStatusQuery;
import java.util.List;
import java.util.UUID;
public class PlanStatusLookup extends Lookup {
private String like;
private List<UUID> ids;
private List<UUID> excludedIds;
private List<IsActive> isActive;
public String getLike() {
return like;
}
public void setLike(String like) {
this.like = like;
}
public List<UUID> getIds() {
return ids;
}
public void setIds(List<UUID> ids) {
this.ids = ids;
}
public List<UUID> getExcludedIds() {
return excludedIds;
}
public void setExcludedIds(List<UUID> excludedIds) {
this.excludedIds = excludedIds;
}
public List<IsActive> getIsActive() {
return isActive;
}
public void setIsActive(List<IsActive> isActive) {
this.isActive = isActive;
}
public PlanStatusQuery enrich(QueryFactory queryFactory) {
PlanStatusQuery query = queryFactory.query(PlanStatusQuery.class);
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);
this.enrichCommon(query);
return query;
}
}

View File

@ -0,0 +1,19 @@
package org.opencdmp.service.planstatus;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.FieldSet;
import jakarta.xml.bind.JAXBException;
import org.opencdmp.model.persist.planstatus.PlanStatusPersist;
import org.opencdmp.model.planstatus.PlanStatus;
import javax.management.InvalidApplicationException;
import java.util.UUID;
public interface PlanStatusService {
PlanStatus persist(PlanStatusPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException;
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
}

View File

@ -0,0 +1,145 @@
package org.opencdmp.service.planstatus;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import jakarta.xml.bind.JAXBException;
import org.jetbrains.annotations.NotNull;
import org.opencdmp.authorization.Permission;
import org.opencdmp.commons.XmlHandlingService;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.types.planstatus.PlanStatusDefinitionAuthorizationEntity;
import org.opencdmp.commons.types.planstatus.PlanStatusDefinitionAuthorizationItemEntity;
import org.opencdmp.commons.types.planstatus.PlanStatusDefinitionEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.PlanStatusEntity;
import org.opencdmp.data.TenantEntityManager;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
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.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;
import javax.management.InvalidApplicationException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class PlanStatusServiceImpl implements PlanStatusService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanStatusServiceImpl.class));
private final BuilderFactory builderFactory;
private final DeleterFactory deleterFactory;
private final AuthorizationService authorizationService;
private final ConventionService conventionService;
private final XmlHandlingService xmlHandlingService;
private final TenantEntityManager entityManager;
private final MessageSource messageSource;
private final ErrorThesaurusProperties errors;
public PlanStatusServiceImpl(BuilderFactory builderFactory, DeleterFactory deleterFactory, AuthorizationService authorizationService, ConventionService conventionService, XmlHandlingService xmlHandlingService, TenantEntityManager entityManager, MessageSource messageSource, ErrorThesaurusProperties errors, EventBroker eventBroker) {
this.builderFactory = builderFactory;
this.deleterFactory = deleterFactory;
this.authorizationService = authorizationService;
this.conventionService = conventionService;
this.xmlHandlingService = xmlHandlingService;
this.entityManager = entityManager;
this.messageSource = messageSource;
this.errors = errors;
}
@Override
public PlanStatus persist(PlanStatusPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException {
logger.debug(new MapLogEntry("persisting data plan status").And("model", model).And("fields", fields));
this.authorizationService.authorizeForce(Permission.EditPlanStatus);
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
PlanStatusEntity data;
if (isUpdate) {
data = this.entityManager.find(PlanStatusEntity.class, model.getId());
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), PlanStatus.class.getSimpleName()}, LocaleContextHolder.getLocale()));
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
} else {
data = new PlanStatusEntity();
data.setId(UUID.randomUUID());
data.setIsActive(IsActive.Active);
data.setCreatedAt(Instant.now());
}
data.setName(model.getName());
data.setDescription(model.getDescription());
data.setDefinition(this.xmlHandlingService.toXml(this.buildPlanStatusDefinitionEntity(model.getDefinition())));
data.setUpdatedAt(Instant.now());
if (isUpdate)
this.entityManager.merge(data);
else
this.entityManager.persist(data);
this.entityManager.flush();
return this.builderFactory.builder(PlanStatusBuilder.class).build(BaseFieldSet.build(fields, PlanStatus._id), data);
}
@Override
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug("deleting plan status: {}", id);
this.authorizationService.authorizeForce(Permission.DeletePlanStatus);
this.deleterFactory.deleter(PlanStatusDeleter.class).deleteAndSaveByIds(List.of(id));
}
private @NotNull PlanStatusDefinitionEntity buildPlanStatusDefinitionEntity(PlanStatusDefinitionPersist persist) {
PlanStatusDefinitionEntity data = new PlanStatusDefinitionEntity();
if (persist == null)
return data;
if (persist.getAuthorization() != null) {
PlanStatusDefinitionAuthorizationEntity definitionAuthorizationData = new PlanStatusDefinitionAuthorizationEntity();
data.setAuthorization(definitionAuthorizationData);
if (!this.conventionService.isListNullOrEmpty(persist.getAuthorization().getEdit())) {
definitionAuthorizationData.setEdit(new ArrayList<>());
for (PlanStatusDefinitionAuthorizationItemPersist p : persist.getAuthorization().getEdit()) {
definitionAuthorizationData.getEdit().add(this.buildPlanStatusDefinitionAuthorizationItemEntity(p));
}
}
}
return data;
}
private @NotNull PlanStatusDefinitionAuthorizationItemEntity buildPlanStatusDefinitionAuthorizationItemEntity(PlanStatusDefinitionAuthorizationItemPersist persist) {
PlanStatusDefinitionAuthorizationItemEntity data = new PlanStatusDefinitionAuthorizationItemEntity();
if (persist == null)
return data;
data.setPlanRoles(persist.getPlanRoles());
data.setRoles(persist.getRoles());
data.setAllowAuthenticated(persist.getAllowAuthenticated());
data.setAllowAnonymous(persist.getAllowAnonymous());
return data;
}
}

View File

@ -0,0 +1,187 @@
package org.opencdmp.controllers;
import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.ValidationFilterAnnotation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.xml.bind.JAXBException;
import org.opencdmp.audit.AuditableAction;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.controllers.swagger.SwaggerHelpers;
import org.opencdmp.controllers.swagger.annotation.OperationWithTenantHeader;
import org.opencdmp.controllers.swagger.annotation.Swagger400;
import org.opencdmp.controllers.swagger.annotation.Swagger404;
import org.opencdmp.controllers.swagger.annotation.SwaggerCommonErrorResponses;
import org.opencdmp.data.PlanStatusEntity;
import org.opencdmp.model.builder.planstatus.PlanStatusBuilder;
import org.opencdmp.model.censorship.planstatus.PlanStatusCensor;
import org.opencdmp.model.persist.planstatus.PlanStatusPersist;
import org.opencdmp.model.planstatus.PlanStatus;
import org.opencdmp.model.result.QueryResult;
import org.opencdmp.query.PlanStatusQuery;
import org.opencdmp.query.lookup.PlanStatusLookup;
import org.opencdmp.service.planstatus.PlanStatusService;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.management.InvalidApplicationException;
import java.util.*;
@RestController
@RequestMapping(path = "api/plan-status")
@io.swagger.v3.oas.annotations.tags.Tag(name = "PlanStatuses", description = "Manage tags")
@SwaggerCommonErrorResponses
public class PlanStatusController {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanStatusController.class));
private final BuilderFactory builderFactory;
private final AuditService auditService;
private final PlanStatusService planStatusService;
private final CensorFactory censorFactory;
private final QueryFactory queryFactory;
private final MessageSource messageSource;
public PlanStatusController(
BuilderFactory builderFactory,
AuditService auditService,
PlanStatusService planStatusService,
CensorFactory censorFactory,
QueryFactory queryFactory,
MessageSource messageSource) {
this.builderFactory = builderFactory;
this.auditService = auditService;
this.planStatusService = planStatusService;
this.censorFactory = censorFactory;
this.queryFactory = queryFactory;
this.messageSource = messageSource;
}
@PostMapping("query")
@OperationWithTenantHeader(summary = "Query all planStatuses", description = SwaggerHelpers.Tag.endpoint_query, requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = SwaggerHelpers.Tag.endpoint_query_request_body, content = @Content(
examples = {
@ExampleObject(
name = SwaggerHelpers.Commons.pagination_example,
description = SwaggerHelpers.Commons.pagination_example_description,
value = SwaggerHelpers.Tag.endpoint_query_request_body_example
)
}
)), responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content(
array = @ArraySchema(
schema = @Schema(
implementation = PlanStatus.class
)
),
examples = @ExampleObject(
name = SwaggerHelpers.Commons.pagination_response_example,
description = SwaggerHelpers.Commons.pagination_response_example_description,
value = SwaggerHelpers.Tag.endpoint_query_response_example
))))
public QueryResult<PlanStatus> Query(@RequestBody PlanStatusLookup lookup) throws MyApplicationException, MyForbiddenException {
logger.debug("querying {}", PlanStatus.class.getSimpleName());
this.censorFactory.censor(PlanStatusCensor.class).censor(lookup.getProject(), null);
PlanStatusQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.AllExceptPublic);
List<PlanStatusEntity> data = query.collectAs(lookup.getProject());
List<PlanStatus> models = this.builderFactory.builder(PlanStatusBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(lookup.getProject(), data);
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
this.auditService.track(AuditableAction.PlanStatus_Query, "lookup", lookup);
return new QueryResult<>(models, count);
}
@GetMapping("{id}")
@OperationWithTenantHeader(summary = "Fetch a specific planStatus by id", description = "",
responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content(
schema = @Schema(
implementation = PlanStatus.class
))
))
@Swagger404
public PlanStatus Get(
@Parameter(name = "id", description = "The id of a planStatus to fetch", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id,
@Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet,
Locale locale
) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
logger.debug(new MapLogEntry("retrieving" + PlanStatus.class.getSimpleName()).And("id", id).And("fields", fieldSet));
this.censorFactory.censor(PlanStatusCensor.class).censor(fieldSet, null);
PlanStatusQuery query = this.queryFactory.query(PlanStatusQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(id);
PlanStatus model = this.builderFactory.builder(PlanStatusBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(fieldSet, query.firstAs(fieldSet));
if (model == null)
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, PlanStatus.class.getSimpleName()}, LocaleContextHolder.getLocale()));
this.auditService.track(AuditableAction.PlanStatus_Lookup, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("id", id),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
return model;
}
@PostMapping("persist")
@OperationWithTenantHeader(summary = "Create a new or update an existing planStatus", description = "",
responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content(
schema = @Schema(
implementation = PlanStatus.class
))
))
@Swagger400
@Swagger404
@Transactional
@ValidationFilterAnnotation(validator = PlanStatusPersist.PlanStatusPersistValidator.ValidatorName, argumentName = "model")
public PlanStatus Persist(
@RequestBody PlanStatusPersist model,
@Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet
) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException {
logger.debug(new MapLogEntry("persisting" + PlanStatus.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
PlanStatus persisted = this.planStatusService.persist(model, fieldSet);
this.auditService.track(AuditableAction.PlanStatus_Persist, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("model", model),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
return persisted;
}
@DeleteMapping("{id}")
@OperationWithTenantHeader(summary = "Delete a planStatus by id", description = "",
responses = @ApiResponse(description = "OK", responseCode = "200"))
@Swagger404
@Transactional
public void Delete(
@Parameter(name = "id", description = "The id of a planStatus to delete", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id
) throws MyForbiddenException, InvalidApplicationException {
logger.debug(new MapLogEntry("retrieving" + PlanStatus.class.getSimpleName()).And("id", id));
this.planStatusService.deleteAndSave(id);
this.auditService.track(AuditableAction.PlanStatus_Delete, "id", id);
}
}