added description status entity

This commit is contained in:
CITE\spapacharalampous 2024-08-22 13:55:38 +03:00
parent c3d5120d37
commit a0d9568375
30 changed files with 1754 additions and 0 deletions

View File

@ -202,6 +202,11 @@ public class AuditableAction {
public static final EventId PlanStatus_Persist = new EventId(300002, "PlanStatus_Persist"); public static final EventId PlanStatus_Persist = new EventId(300002, "PlanStatus_Persist");
public static final EventId PlanStatus_Delete = new EventId(300003, "PlanStatus_Delete"); public static final EventId PlanStatus_Delete = new EventId(300003, "PlanStatus_Delete");
public static final EventId DescriptionStatus_Query = new EventId(400000, "DescriptionStatus_Query");
public static final EventId DescriptionStatus_Lookup = new EventId(400001, "DescriptionStatus_Lookup");
public static final EventId DescriptionStatus_Persist = new EventId(400002, "DescriptionStatus_Persist");
public static final EventId DescriptionStatus_Delete = new EventId(400003, "DescriptionStatus_Delete");
} }

View File

@ -95,6 +95,11 @@ public final class Permission {
public static String EditPlanStatus = "EditPlanStatus"; public static String EditPlanStatus = "EditPlanStatus";
public static String DeletePlanStatus = "DeletePlanStatus"; public static String DeletePlanStatus = "DeletePlanStatus";
//DescriptionStatus
public static String BrowseDescriptionStatus = "BrowseDescriptionStatus";
public static String EditDescriptionStatus = "EditDescriptionStatus";
public static String DeleteDescriptionStatus = "DeleteDescriptionStatus";
//PlanBlueprint //PlanBlueprint
public static String BrowsePlanBlueprint = "BrowsePlanBlueprint"; public static String BrowsePlanBlueprint = "BrowsePlanBlueprint";
public static String EditPlanBlueprint = "EditPlanBlueprint"; public static String EditPlanBlueprint = "EditPlanBlueprint";

View File

@ -11,6 +11,7 @@ public enum UsageLimitTargetMetric implements DatabaseEnum<String> {
PLAN_STATUS_COUNT(TargetMetrics.PlanStatusCount), PLAN_STATUS_COUNT(TargetMetrics.PlanStatusCount),
BLUEPRINT_COUNT(TargetMetrics.BlueprintCount), BLUEPRINT_COUNT(TargetMetrics.BlueprintCount),
DESCRIPTION_COUNT(TargetMetrics.DescriptionCount), DESCRIPTION_COUNT(TargetMetrics.DescriptionCount),
DESCRIPTION_STATUS_COUNT(TargetMetrics.DescriptionStatusCount),
DESCRIPTION_TEMPLATE_COUNT(TargetMetrics.DescriptionTemplateCount), DESCRIPTION_TEMPLATE_COUNT(TargetMetrics.DescriptionTemplateCount),
DESCRIPTION_TEMPLATE_TYPE_COUNT(TargetMetrics.DescriptionTemplateTypeCount), DESCRIPTION_TEMPLATE_TYPE_COUNT(TargetMetrics.DescriptionTemplateTypeCount),
PREFILLING_SOURCES_COUNT(TargetMetrics.PrefillingSourcesCount), PREFILLING_SOURCES_COUNT(TargetMetrics.PrefillingSourcesCount),
@ -38,6 +39,7 @@ public enum UsageLimitTargetMetric implements DatabaseEnum<String> {
public static final String PlanStatusCount = "plan_status_count"; public static final String PlanStatusCount = "plan_status_count";
public static final String BlueprintCount = "blueprint_count"; public static final String BlueprintCount = "blueprint_count";
public static final String DescriptionCount = "description_count"; public static final String DescriptionCount = "description_count";
public static final String DescriptionStatusCount = "description_status_count";
public static final String DescriptionTemplateCount = "description_template_count"; public static final String DescriptionTemplateCount = "description_template_count";
public static final String DescriptionTemplateTypeCount = "description_template_type_count"; public static final String DescriptionTemplateTypeCount = "description_template_type_count";
public static final String PrefillingSourcesCount = "prefilling_sources_count"; public static final String PrefillingSourcesCount = "prefilling_sources_count";

View File

@ -0,0 +1,18 @@
package org.opencdmp.commons.types.descriptionstatus;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "authorization")
@XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionStatusDefinitionAuthorizationEntity {
@XmlElement(name = "edit")
private DescriptionStatusDefinitionAuthorizationItemEntity edit;
public DescriptionStatusDefinitionAuthorizationItemEntity getEdit() { return edit; }
public void setEdit(DescriptionStatusDefinitionAuthorizationItemEntity edit) { this.edit = edit; }
}

View File

@ -0,0 +1,36 @@
package org.opencdmp.commons.types.descriptionstatus;
import jakarta.xml.bind.annotation.*;
import java.util.List;
@XmlRootElement(name = "edit")
@XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionStatusDefinitionAuthorizationItemEntity {
@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,18 @@
package org.opencdmp.commons.types.descriptionstatus;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "definition")
@XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionStatusDefinitionEntity {
@XmlElement(name = "authorization")
private DescriptionStatusDefinitionAuthorizationEntity authorization;
public DescriptionStatusDefinitionAuthorizationEntity getAuthorization() { return authorization; }
public void setAuthorization(DescriptionStatusDefinitionAuthorizationEntity authorization) { this.authorization = authorization; }
}

View File

@ -0,0 +1,100 @@
package org.opencdmp.data;
import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import org.opencdmp.commons.enums.DescriptionStatus;
import org.opencdmp.commons.enums.IsActive;
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 = "\"DescriptionStatus\"")
public class DescriptionStatusEntity 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 = DescriptionStatusEntity._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 DescriptionStatus 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 DescriptionStatus getInternalStatus() { return internalStatus; }
public void setInternalStatus(DescriptionStatus internalStatus) { this.internalStatus = internalStatus; }
public String getDefinition() {
return this.definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
}

View File

@ -0,0 +1,70 @@
package org.opencdmp.model.builder.descriptionstatus;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commons.XmlHandlingService;
import org.opencdmp.commons.types.descriptionstatus.DescriptionStatusDefinitionEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.DescriptionStatusEntity;
import org.opencdmp.model.builder.BaseBuilder;
import org.opencdmp.model.descriptionstatus.DescriptionStatus;
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 DescriptionStatusBuilder extends BaseBuilder<DescriptionStatus, DescriptionStatusEntity> {
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final BuilderFactory builderFactory;
private final XmlHandlingService xmlHandlingService;
public DescriptionStatusBuilder(ConventionService conventionService, BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionStatusBuilder.class)));
this.builderFactory = builderFactory;
this.xmlHandlingService = xmlHandlingService;
}
public DescriptionStatusBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<DescriptionStatus> build(FieldSet fields, List<DescriptionStatusEntity> 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<DescriptionStatus> models = new ArrayList<>();
FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(DescriptionStatus._definition));
for (DescriptionStatusEntity d : data) {
DescriptionStatus m = new DescriptionStatus();
if (fields.hasField(this.asIndexer(DescriptionStatus._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(DescriptionStatus._name))) m.setName(d.getName());
if (fields.hasField(this.asIndexer(DescriptionStatus._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(DescriptionStatus._updatedAt))) m.setUpdateAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(DescriptionStatus._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(DescriptionStatus._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(DescriptionStatus._internalStatus))) m.setInternalStatus(d.getInternalStatus());
if (!definitionFields.isEmpty() && d.getDefinition() != null) {
DescriptionStatusDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DescriptionStatusDefinitionEntity.class, d.getDefinition());
m.setDefinition(this.builderFactory.builder(DescriptionStatusDefinitionBuilder.class).authorize(authorize).build(definitionFields, definition));
}
models.add(m);
}
return models;
}
}

View File

@ -0,0 +1,57 @@
package org.opencdmp.model.builder.descriptionstatus;
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.descriptionstatus.DescriptionStatusDefinitionAuthorizationEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.builder.BaseBuilder;
import org.opencdmp.model.descriptionstatus.DescriptionStatusDefinitionAuthorization;
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 DescriptionStatusDefinitionAuthorizationBuilder extends BaseBuilder<DescriptionStatusDefinitionAuthorization, DescriptionStatusDefinitionAuthorizationEntity> {
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final BuilderFactory builderFactory;
public DescriptionStatusDefinitionAuthorizationBuilder(ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionStatusDefinitionAuthorizationBuilder.class)));
this.builderFactory = builderFactory;
}
public DescriptionStatusDefinitionAuthorizationBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<DescriptionStatusDefinitionAuthorization> build(FieldSet fields, List<DescriptionStatusDefinitionAuthorizationEntity> 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<DescriptionStatusDefinitionAuthorization> models = new ArrayList<>();
FieldSet editFields = fields.extractPrefixed(this.asPrefix(DescriptionStatusDefinitionAuthorization._edit));
for (DescriptionStatusDefinitionAuthorizationEntity d : data) {
DescriptionStatusDefinitionAuthorization m = new DescriptionStatusDefinitionAuthorization();
if (!editFields.isEmpty() && d.getEdit() != null) {
m.setEdit(this.builderFactory.builder(DescriptionStatusDefinitionAuthorizationItemBuilder.class).authorize(this.authorize).build(editFields, d.getEdit()));
}
models.add(m);
}
return models;
}
}

View File

@ -0,0 +1,53 @@
package org.opencdmp.model.builder.descriptionstatus;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commons.types.descriptionstatus.DescriptionStatusDefinitionAuthorizationItemEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.builder.BaseBuilder;
import org.opencdmp.model.descriptionstatus.DescriptionStatusDefinitionAuthorizationItem;
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 DescriptionStatusDefinitionAuthorizationItemBuilder extends BaseBuilder<DescriptionStatusDefinitionAuthorizationItem, DescriptionStatusDefinitionAuthorizationItemEntity> {
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public DescriptionStatusDefinitionAuthorizationItemBuilder(ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionStatusDefinitionAuthorizationItemBuilder.class)));
}
public DescriptionStatusDefinitionAuthorizationItemBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<DescriptionStatusDefinitionAuthorizationItem> build(FieldSet fields, List<DescriptionStatusDefinitionAuthorizationItemEntity> 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<DescriptionStatusDefinitionAuthorizationItem> models = new ArrayList<>();
for (DescriptionStatusDefinitionAuthorizationItemEntity d : data) {
DescriptionStatusDefinitionAuthorizationItem m = new DescriptionStatusDefinitionAuthorizationItem();
if (fields.hasField(this.asIndexer(DescriptionStatusDefinitionAuthorizationItem._planRoles))) m.setPlanRoles(d.getPlanRoles());
if (fields.hasField(this.asIndexer(DescriptionStatusDefinitionAuthorizationItem._roles))) m.setRoles(d.getRoles());
if (fields.hasField(this.asIndexer(DescriptionStatusDefinitionAuthorizationItem._allowAnonymous))) m.setAllowAnonymous(d.getAllowAnonymous());
if (fields.hasField(this.asIndexer(DescriptionStatusDefinitionAuthorizationItem._allowAuthenticated))) m.setAllowAuthenticated(d.getAllowAuthenticated());
models.add(m);
}
return models;
}
}

View File

@ -0,0 +1,59 @@
package org.opencdmp.model.builder.descriptionstatus;
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.descriptionstatus.DescriptionStatusDefinitionEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.builder.BaseBuilder;
import org.opencdmp.model.descriptionstatus.DescriptionStatusDefinition;
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 DescriptionStatusDefinitionBuilder extends BaseBuilder<DescriptionStatusDefinition, DescriptionStatusDefinitionEntity> {
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final BuilderFactory builderFactory;
public DescriptionStatusDefinitionBuilder(ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionStatusDefinitionBuilder.class)));
this.builderFactory = builderFactory;
}
public DescriptionStatusDefinitionBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<DescriptionStatusDefinition> build(FieldSet fields, List<DescriptionStatusDefinitionEntity> 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<DescriptionStatusDefinition> models = new ArrayList<>();
FieldSet authorizationFields = fields.extractPrefixed(this.asPrefix(DescriptionStatusDefinition._authorization));
for (DescriptionStatusDefinitionEntity d : data) {
DescriptionStatusDefinition m = new DescriptionStatusDefinition();
if (!authorizationFields.isEmpty() && d.getAuthorization() != null) {
this.builderFactory.builder(DescriptionStatusDefinitionAuthorizationBuilder.class).authorize(authorize).build(authorizationFields, d.getAuthorization());
}
models.add(m);
}
return models;
}
}

View File

@ -0,0 +1,43 @@
package org.opencdmp.model.censorship.descriptionstatus;
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.descriptionstatus.DescriptionStatus;
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 DescriptionStatusCensor extends BaseCensor {
protected final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionStatusCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public DescriptionStatusCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
this.logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowseDescriptionStatus);
FieldSet definitionFields = fields.extractPrefixed(this.asIndexerPrefix(DescriptionStatus._definition));
this.censorFactory.censor(DescriptionStatusDefinitionCensor.class).censor(definitionFields, userId);
}
}

View File

@ -0,0 +1,44 @@
package org.opencdmp.model.censorship.descriptionstatus;
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.descriptionstatus.DescriptionStatusDefinitionAuthorization;
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 DescriptionStatusDefinitionAuthorizationCensor extends BaseCensor {
protected final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionStatusDefinitionAuthorizationCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public DescriptionStatusDefinitionAuthorizationCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
this.logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowsePlanStatus);
FieldSet editFields = fields.extractPrefixed(this.asIndexerPrefix(DescriptionStatusDefinitionAuthorization._edit));
this.censorFactory.censor(DescriptionStatusDefinitionAuthorizationItemCensor.class).censor(editFields, userId);
}
}

View File

@ -0,0 +1,41 @@
package org.opencdmp.model.censorship.descriptionstatus;
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 DescriptionStatusDefinitionAuthorizationItemCensor extends BaseCensor {
private static LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionStatusDefinitionAuthorizationItemCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public DescriptionStatusDefinitionAuthorizationItemCensor(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.BrowseDescriptionStatus);
}
}

View File

@ -0,0 +1,43 @@
package org.opencdmp.model.censorship.descriptionstatus;
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.descriptionstatus.DescriptionStatusDefinition;
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 DescriptionStatusDefinitionCensor extends BaseCensor {
protected final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionStatusDefinitionCensor.class));
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
public DescriptionStatusDefinitionCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields, UUID userId) {
this.logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowseDescriptionStatus);
FieldSet authorizationFields = fields.extractPrefixed(this.asIndexerPrefix(DescriptionStatusDefinition._authorization));
this.censorFactory.censor(DescriptionStatusDefinitionAuthorizationCensor.class).censor(authorizationFields, userId);
}
}

View File

@ -0,0 +1,78 @@
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.DescriptionStatusEntity;
import org.opencdmp.data.TenantEntityManager;
import org.opencdmp.query.DescriptionStatusQuery;
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(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DescriptionStatusDeleter implements Deleter {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionStatusDeleter.class));
private final TenantEntityManager entityManager;
private final DeleterFactory deleterFactory;
private final QueryFactory queryFactory;
private final AccountingService accountingService;
@Autowired
public DescriptionStatusDeleter(
TenantEntityManager entityManager,
DeleterFactory deleterFactory,
QueryFactory queryFactory,
AccountingService accountingService) {
this.entityManager = entityManager;
this.deleterFactory = deleterFactory;
this.queryFactory = queryFactory;
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<DescriptionStatusEntity> data = this.queryFactory.query(DescriptionStatusQuery.class).ids(ids).collect();
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
this.deleteAndSave(data);
}
public void deleteAndSave(List<DescriptionStatusEntity> 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<DescriptionStatusEntity> 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 (DescriptionStatusEntity 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.DESCRIPTION_STATUS_COUNT.getValue());
}
}
}

View File

@ -0,0 +1,64 @@
package org.opencdmp.model.descriptionstatus;
import org.opencdmp.commons.enums.IsActive;
import java.time.Instant;
import java.util.UUID;
public class DescriptionStatus {
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 updateAt;
public final static String _isActive = "isActive";
private IsActive isActive;
public final static String _belongsToCurrentTenant = "belongsToCurrentTenant";
private Boolean belongsToCurrentTenant;
public final static String _internalStatus = "internalStatus";
private org.opencdmp.commons.enums.DescriptionStatus internalStatus;
public final static String _definition = "definition";
private DescriptionStatusDefinition definition;
public UUID getId() { return id; }
public void setId(UUID id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public Instant getCreatedAt() { return createdAt; }
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
public Instant getUpdateAt() { return updateAt; }
public void setUpdateAt(Instant updateAt) { this.updateAt = updateAt; }
public IsActive getIsActive() { return isActive; }
public void setIsActive(IsActive isActive) { this.isActive = isActive; }
public org.opencdmp.commons.enums.DescriptionStatus getInternalStatus() { return internalStatus; }
public void setInternalStatus(org.opencdmp.commons.enums.DescriptionStatus internalStatus) { this.internalStatus = internalStatus; }
public DescriptionStatusDefinition getDefinition() { return definition; }
public void setDefinition(DescriptionStatusDefinition definition) { this.definition = definition; }
public Boolean getBelongsToCurrentTenant() { return belongsToCurrentTenant; }
public void setBelongsToCurrentTenant(Boolean belongsToCurrentTenant) { this.belongsToCurrentTenant = belongsToCurrentTenant; }
}

View File

@ -0,0 +1,11 @@
package org.opencdmp.model.descriptionstatus;
public class DescriptionStatusDefinition {
public final static String _authorization = "authorization";
private DescriptionStatusDefinitionAuthorization authorization;
public DescriptionStatusDefinitionAuthorization getAuthorization() { return authorization; }
public void setAuthorization(DescriptionStatusDefinitionAuthorization authorization) { this.authorization = authorization; }
}

View File

@ -0,0 +1,11 @@
package org.opencdmp.model.descriptionstatus;
public class DescriptionStatusDefinitionAuthorization {
public final static String _edit = "edit";
private DescriptionStatusDefinitionAuthorizationItem edit;
public DescriptionStatusDefinitionAuthorizationItem getEdit() { return edit; }
public void setEdit(DescriptionStatusDefinitionAuthorizationItem edit) { this.edit = edit; }
}

View File

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

View File

@ -0,0 +1,72 @@
package org.opencdmp.model.persist.descriptionstatus;
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.opencdmp.model.persist.planstatus.PlanStatusDefinitionAuthorizationItemPersist;
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 DescriptionStatusDefinitionAuthorizationItemPersist {
private List<String> roles = null;
public final static String _roles = "roles";
private List<String> planRoles = null;
public final static String _planRoles = "planRoles";
private Boolean allowAuthenticated;
public final static String _allowAuthenticated = "allowAuthenticated";
private Boolean allowAnonymous;
public final static String _allowAnonymous = "allowAnonymous";
public List<String> getRoles() { return roles; }
public void setRoles(List<String> roles) { this.roles = roles; }
public List<String> getPlanRoles() { return planRoles; }
public void setPlanRoles(List<String> planRoles) { this.planRoles = planRoles; }
public Boolean getAllowAuthenticated() { return allowAuthenticated; }
public void setAllowAuthenticated(Boolean allowAuthenticated) { this.allowAuthenticated = allowAuthenticated; }
public Boolean getAllowAnonymous() { return allowAnonymous; }
public void setAllowAnonymous(Boolean allowAnonymous) { this.allowAnonymous = allowAnonymous; }
@Component(DescriptionStatusDefinitionAuthorizationItemPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DescriptionStatusDefinitionAuthorizationItemPersistValidator extends BaseValidator<DescriptionStatusDefinitionAuthorizationItemPersist> {
public static final String ValidatorName = "DescriptionStatusPersistValidation.DescriptionStatusDefinitionPersistValidator.DescriptionStatusDefinitionAuthorizationPersistValidator.DescriptionStatusDefinitionAuthorizationItemPersistValidator";
private final MessageSource messageSource;
protected DescriptionStatusDefinitionAuthorizationItemPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<DescriptionStatusDefinitionAuthorizationItemPersist> modelClass() {
return DescriptionStatusDefinitionAuthorizationItemPersist.class;
}
@Override
protected List<Specification> specifications(DescriptionStatusDefinitionAuthorizationItemPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isListNullOrEmpty(item.getRoles()))
.failOn(PlanStatusDefinitionAuthorizationItemPersist._roles).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanStatusDefinitionAuthorizationItemPersist._roles}, LocaleContextHolder.getLocale())), this.spec()
.must(() -> !this.isListNullOrEmpty(item.getPlanRoles()))
.failOn(PlanStatusDefinitionAuthorizationItemPersist._planRoles).failWith(messageSource.getMessage("Validation_Required", new Object[]{PlanStatusDefinitionAuthorizationItemPersist._planRoles}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -0,0 +1,61 @@
package org.opencdmp.model.persist.descriptionstatus;
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.opencdmp.model.descriptionstatus.DescriptionStatusDefinitionAuthorization;
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 DescriptionStatusDefinitionAuthorizationPersist {
private DescriptionStatusDefinitionAuthorizationItemPersist edit;
public final static String _edit = "edit";
public DescriptionStatusDefinitionAuthorizationItemPersist getEdit() { return edit; }
public void setEdit(DescriptionStatusDefinitionAuthorizationItemPersist edit) { this.edit = edit; }
@Component(DescriptionStatusDefinitionAuthorizationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DescriptionStatusDefinitionAuthorizationPersistValidator extends BaseValidator<DescriptionStatusDefinitionAuthorizationPersist> {
public static final String ValidatorName = "DescriptionStatusPersistValidation.DescriptionStatusDefinitionPersistValidator.DescriptionStatusDefinitionAuthorizationPersistValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected DescriptionStatusDefinitionAuthorizationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<DescriptionStatusDefinitionAuthorizationPersist> modelClass() {
return DescriptionStatusDefinitionAuthorizationPersist.class;
}
@Override
protected List<Specification> specifications(DescriptionStatusDefinitionAuthorizationPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isNull(item.getEdit()))
.failOn(DescriptionStatusDefinitionAuthorizationPersist._edit).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusDefinitionAuthorizationPersist._edit}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getEdit()))
.on(DescriptionStatusDefinitionAuthorization._edit)
.over(item.getEdit())
.using(() -> this.validatorFactory.validator(DescriptionStatusDefinitionAuthorizationItemPersist.DescriptionStatusDefinitionAuthorizationItemPersistValidator.class))
);
}
}
}

View File

@ -0,0 +1,61 @@
package org.opencdmp.model.persist.descriptionstatus;
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.opencdmp.model.descriptionstatus.DescriptionStatusDefinitionAuthorization;
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 DescriptionStatusDefinitionPersist {
private DescriptionStatusDefinitionAuthorizationPersist authorization;
public final static String _authorization = "authorization";
public DescriptionStatusDefinitionAuthorizationPersist getAuthorization() { return authorization; }
public void setAuthorization(DescriptionStatusDefinitionAuthorizationPersist authorization) { this.authorization = authorization; }
@Component(DescriptionStatusDefinitionPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DescriptionStatusDefinitionPersistValidator extends BaseValidator<DescriptionStatusDefinitionPersist> {
public final static String ValidatorName = "DescriptionStatusPersistValidation.DescriptionStatusDefinitionPersistValidator";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected DescriptionStatusDefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<DescriptionStatusDefinitionPersist> modelClass() {
return DescriptionStatusDefinitionPersist.class;
}
@Override
protected List<Specification> specifications(DescriptionStatusDefinitionPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isNull(item.getAuthorization()))
.failOn(DescriptionStatusDefinitionPersist._authorization).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusDefinitionPersist._authorization}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getAuthorization()))
.on(DescriptionStatusDefinitionPersist._authorization)
.over(item.getAuthorization())
.using(() -> this.validatorFactory.validator(DescriptionStatusDefinitionAuthorizationPersist.DescriptionStatusDefinitionAuthorizationPersistValidator.class))
);
}
}
}

View File

@ -0,0 +1,116 @@
package org.opencdmp.model.persist.descriptionstatus;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
import org.opencdmp.commons.enums.PlanStatus;
import org.opencdmp.commons.validation.BaseValidator;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.DescriptionStatusEntity;
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 DescriptionStatusPersist {
private UUID id;
private String name;
public final static String _name = "name";
private String description;
public final static String _description = "description";
private org.opencdmp.commons.enums.DescriptionStatus internalStatus;
public final static String _internalStatus = "internalStatus";
private DescriptionStatusDefinitionPersist definition;
public final static String _definition = "definition";
private String hash;
public final static String _hash = "hash";
public UUID getId() { return id; }
public void setId(UUID id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public org.opencdmp.commons.enums.DescriptionStatus getInternalStatus() { return internalStatus; }
public void setInternalStatus(org.opencdmp.commons.enums.DescriptionStatus internalStatus) { this.internalStatus = internalStatus; }
public DescriptionStatusDefinitionPersist getDefinition() { return definition; }
public void setDefinition(DescriptionStatusDefinitionPersist definition) { this.definition = definition; }
public String getHash() { return hash; }
public void setHash(String hash) { this.hash = hash; }
@Component(DescriptionStatusPersist.DescriptionStatusPersistValidation.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DescriptionStatusPersistValidation extends BaseValidator<DescriptionStatusPersist> {
public final static String ValidatorName = "DescriptionStatusPersistValidation";
private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected DescriptionStatusPersistValidation(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors);
this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
}
@Override
protected Class<DescriptionStatusPersist> modelClass() {
return DescriptionStatusPersist.class;
}
@Override
protected List<Specification> specifications(DescriptionStatusPersist item) {
return Arrays.asList(
this.spec()
.iff(() -> this.isValidGuid(item.getId()))
.must(() -> this.isValidHash(item.getHash()))
.failOn(DescriptionStatusPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._hash}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isValidGuid(item.getId()))
.must(() -> !this.isValidHash(item.getHash()))
.failOn(DescriptionStatusPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._hash}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getName()))
.failOn(DescriptionStatusPersist._name).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._name}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getName()))
.must(() -> this.lessEqualLength(item.getName(), DescriptionStatusEntity._nameLength))
.failOn(DescriptionStatusPersist._name).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._name}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getInternalStatus()))
.failOn(DescriptionStatusPersist._internalStatus).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._internalStatus}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> item.getInternalStatus() == org.opencdmp.commons.enums.DescriptionStatus.Finalized)
.must(() -> !this.isNull(item.getDefinition()))
.failOn(DescriptionStatusPersist._internalStatus).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._internalStatus}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getDefinition()))
.on(DescriptionStatusPersist._definition)
.over(item.getDefinition())
.using(() -> this.validatorFactory.validator(DescriptionStatusDefinitionPersist.DescriptionStatusDefinitionPersistValidator.class)),
this.refSpec()
.iff(() -> item.getInternalStatus() == org.opencdmp.commons.enums.DescriptionStatus.Finalized)
.on(DescriptionStatusPersist._definition)
.over(item.getDefinition())
.using(() -> this.validatorFactory.validator(DescriptionStatusDefinitionPersist.DescriptionStatusDefinitionPersistValidator.class))
);
}
}
}

View File

@ -0,0 +1,221 @@
package org.opencdmp.query;
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.data.DescriptionStatusEntity;
import org.opencdmp.data.TenantEntityManager;
import org.opencdmp.model.descriptionstatus.DescriptionStatus;
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 DescriptionStatusQuery extends QueryBase<DescriptionStatusEntity> {
private String like;
private Collection<UUID> ids;
private Collection<IsActive> isActives;
private Collection<org.opencdmp.commons.enums.DescriptionStatus> internalStatuses;
private Collection<UUID> excludeIds;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public DescriptionStatusQuery like(String value) {
this.like = value;
return this;
}
public DescriptionStatusQuery ids(UUID value) {
this.ids = List.of(value);
return this;
}
public DescriptionStatusQuery ids(UUID... value) {
this.ids = Arrays.asList(value);
return this;
}
public DescriptionStatusQuery ids(Collection<UUID> values) {
this.ids = values;
return this;
}
public DescriptionStatusQuery excludeIds(UUID value) {
this.excludeIds = List.of(value);
return this;
}
public DescriptionStatusQuery excludeIds(UUID... value) {
this.excludeIds = Arrays.asList(value);
return this;
}
public DescriptionStatusQuery excludeIds(Collection<UUID> values) {
this.excludeIds = values;
return this;
}
public DescriptionStatusQuery isActive(IsActive value) {
this.isActives = List.of(value);
return this;
}
public DescriptionStatusQuery isActive(IsActive... value) {
this.isActives = Arrays.asList(value);
return this;
}
public DescriptionStatusQuery isActive(Collection<IsActive> values) {
this.isActives = values;
return this;
}
public DescriptionStatusQuery internalStatuses(org.opencdmp.commons.enums.DescriptionStatus value) {
this.internalStatuses = List.of(value);
return this;
}
public DescriptionStatusQuery internalStatuses(org.opencdmp.commons.enums.DescriptionStatus... value) {
this.internalStatuses = Arrays.asList(value);
return this;
}
public DescriptionStatusQuery internalStatuses(Collection<org.opencdmp.commons.enums.DescriptionStatus> values) {
this.internalStatuses = values;
return this;
}
public DescriptionStatusQuery enableTracking() {
this.noTracking = false;
return this;
}
public DescriptionStatusQuery disableTracking() {
this.noTracking = true;
return this;
}
public DescriptionStatusQuery authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
private final QueryUtilsService queryUtilsService;
private final TenantEntityManager entityManager;
public DescriptionStatusQuery(
QueryUtilsService queryUtilsService, TenantEntityManager entityManager) {
this.queryUtilsService = queryUtilsService;
this.entityManager = entityManager;
}
@Override
protected EntityManager entityManager(){
return this.entityManager.getEntityManager();
}
@Override
protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.internalStatuses);
}
@Override
protected Class<DescriptionStatusEntity> entityClass() { return DescriptionStatusEntity.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(DescriptionStatusEntity._id));
for (UUID id : this.ids)
inClause.value(id);
predicates.add(inClause);
}
if (this.like != null && !this.like.isBlank()) {
predicates.add(queryContext.CriteriaBuilder.or(
this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionStatusEntity._name), this.like),
this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionStatusEntity._description), this.like)));
}
if (this.isActives != null) {
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionStatusEntity._isActive));
for (IsActive isActive : this.isActives)
inClause.value(isActive);
predicates.add(inClause);
}
if (this.internalStatuses != null) {
CriteriaBuilder.In<org.opencdmp.commons.enums.DescriptionStatus> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionStatusEntity._internalStatus));
for (org.opencdmp.commons.enums.DescriptionStatus internalStatus : this.internalStatuses)
inClause.value(internalStatus);
predicates.add(inClause);
}
if (this.excludeIds != null) {
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionStatusEntity._id));
for (UUID id : this.excludeIds) {
notInClause.value(id);
}
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(DescriptionStatus._id))
return DescriptionStatusEntity._id;
else if (item.match(DescriptionStatus._name))
return DescriptionStatusEntity._name;
else if (item.match(DescriptionStatus._description))
return DescriptionStatusEntity._description;
else if (item.match(DescriptionStatus._createdAt))
return DescriptionStatusEntity._createdAt;
else if (item.match(DescriptionStatus._updatedAt))
return DescriptionStatusEntity._updatedAt;
else if (item.match(DescriptionStatus._isActive))
return DescriptionStatusEntity._isActive;
else if (item.match(DescriptionStatus._belongsToCurrentTenant))
return DescriptionStatusEntity._tenantId;
else if (item.match(DescriptionStatus._internalStatus))
return DescriptionStatusEntity._internalStatus;
else if (item.match(DescriptionStatusEntity._definition))
return DescriptionStatusEntity._definition;
else
return null;
}
@Override
protected DescriptionStatusEntity convert(Tuple tuple, Set<String> columns) {
DescriptionStatusEntity item = new DescriptionStatusEntity();
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._id, UUID.class));
item.setName(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._name, String.class));
item.setDescription(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._description, String.class));
item.setTenantId(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._tenantId, UUID.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._updatedAt, Instant.class));
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._isActive, IsActive.class));
item.setInternalStatus(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._internalStatus, org.opencdmp.commons.enums.DescriptionStatus.class));
item.setDefinition(QueryBase.convertSafe(tuple, columns, DescriptionStatusEntity._definition, String.class));
return item;
}
}

View File

@ -0,0 +1,48 @@
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.DescriptionStatusQuery;
import java.util.List;
import java.util.UUID;
public class DescriptionStatusLookup 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 DescriptionStatusQuery enrich(QueryFactory queryFactory) {
DescriptionStatusQuery query = queryFactory.query(DescriptionStatusQuery.class);
if (this.like != null) query.like(this.like);
if (this.ids != null) query.ids(this.ids);
if (this.excludedIds != null) query.excludeIds(this.excludedIds);
if (this.isActive != null) query.isActive(this.isActive);
this.enrichCommon(query);
return query;
}
}

View File

@ -0,0 +1,20 @@
package org.opencdmp.service.descriptionstatus;
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.descriptionstatus.DescriptionStatus;
import org.opencdmp.model.persist.descriptionstatus.DescriptionStatusPersist;
import javax.management.InvalidApplicationException;
import java.util.UUID;
public interface DescriptionStatusService {
DescriptionStatus persist(DescriptionStatusPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException;
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
}

View File

@ -0,0 +1,142 @@
package org.opencdmp.service.descriptionstatus;
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.opencdmp.authorization.Permission;
import org.opencdmp.commons.XmlHandlingService;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.types.descriptionstatus.DescriptionStatusDefinitionAuthorizationEntity;
import org.opencdmp.commons.types.descriptionstatus.DescriptionStatusDefinitionAuthorizationItemEntity;
import org.opencdmp.commons.types.descriptionstatus.DescriptionStatusDefinitionEntity;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.DescriptionStatusEntity;
import org.opencdmp.data.TenantEntityManager;
import org.opencdmp.model.builder.descriptionstatus.DescriptionStatusBuilder;
import org.opencdmp.model.deleter.DescriptionStatusDeleter;
import org.opencdmp.model.descriptionstatus.DescriptionStatus;
import org.opencdmp.model.persist.descriptionstatus.DescriptionStatusDefinitionAuthorizationItemPersist;
import org.opencdmp.model.persist.descriptionstatus.DescriptionStatusDefinitionAuthorizationPersist;
import org.opencdmp.model.persist.descriptionstatus.DescriptionStatusDefinitionPersist;
import org.opencdmp.model.persist.descriptionstatus.DescriptionStatusPersist;
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.List;
import java.util.UUID;
public class DescriptionStatusServiceImpl implements DescriptionStatusService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionStatusServiceImpl.class));
private final BuilderFactory builderFactory;
private final DeleterFactory deleterFactory;
private final AuthorizationService authService;
private final TenantEntityManager entityManager;
private final ConventionService conventionService;
private final MessageSource messageSource;
private final XmlHandlingService xmlHandlingService;
public DescriptionStatusServiceImpl(BuilderFactory builderFactory, DeleterFactory deleterFactory, AuthorizationService authService, TenantEntityManager entityManager, ConventionService conventionService, MessageSource messageSource, XmlHandlingService xmlHandlingService) {
this.builderFactory = builderFactory;
this.deleterFactory = deleterFactory;
this.authService = authService;
this.entityManager = entityManager;
this.conventionService = conventionService;
this.messageSource = messageSource;
this.xmlHandlingService = xmlHandlingService;
}
@Override
public DescriptionStatus persist(DescriptionStatusPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException {
logger.debug(new MapLogEntry("persisting data description status").And("model", model).And("fields", fields));
this.authService.authorizeForce(Permission.EditDescriptionStatus);
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
DescriptionStatusEntity data;
if (isUpdate) {
data = this.entityManager.find(DescriptionStatusEntity.class, model.getId());
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionStatus.class.getSimpleName()}, LocaleContextHolder.getLocale()));
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DescriptionStatus.class.getSimpleName()}, LocaleContextHolder.getLocale()));
} else {
data = new DescriptionStatusEntity();
data.setId(UUID.randomUUID());
data.setIsActive(IsActive.Active);
data.setCreatedAt(Instant.now());
}
data.setName(model.getName());
data.setDescription(model.getDescription());
data.setInternalStatus(model.getInternalStatus());
data.setDefinition(this.xmlHandlingService.toXml(this.buildDescriptionStatusDefinitionEntity(model.getDefinition())));
data.setUpdatedAt(Instant.now());
if (isUpdate)
this.entityManager.merge(data);
else
this.entityManager.persist(data);
this.entityManager.flush();
return this.builderFactory.builder(DescriptionStatusBuilder.class).build(BaseFieldSet.build(fields, DescriptionStatus._id), data);
}
@Override
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug("deleting description status: {}", id);
this.authService.authorizeForce(Permission.DeleteDescriptionStatus);
this.deleterFactory.deleter(DescriptionStatusDeleter.class).deleteAndSaveByIds(List.of(id));
}
private DescriptionStatusDefinitionEntity buildDescriptionStatusDefinitionEntity(DescriptionStatusDefinitionPersist persist) {
DescriptionStatusDefinitionEntity data = new DescriptionStatusDefinitionEntity();
if (persist == null)
return data;
data.setAuthorization(this.buildDescriptionStatusDefinitionAuthorizationEntity(persist.getAuthorization()));
return data;
}
private DescriptionStatusDefinitionAuthorizationEntity buildDescriptionStatusDefinitionAuthorizationEntity(DescriptionStatusDefinitionAuthorizationPersist persist) {
DescriptionStatusDefinitionAuthorizationEntity data = new DescriptionStatusDefinitionAuthorizationEntity();
if (persist == null)
return data;
data.setEdit(this.buildDescriptionStatusDefinitionAuthorizationItemEntity(persist.getEdit()));
return data;
}
private DescriptionStatusDefinitionAuthorizationItemEntity buildDescriptionStatusDefinitionAuthorizationItemEntity(DescriptionStatusDefinitionAuthorizationItemPersist persist) {
DescriptionStatusDefinitionAuthorizationItemEntity data = new DescriptionStatusDefinitionAuthorizationItemEntity();
if (persist == null)
return data;
data.setPlanRoles(persist.getPlanRoles());
data.setRoles(persist.getRoles());
data.setAllowAnonymous(persist.getAllowAnonymous());
data.setAllowAuthenticated(persist.getAllowAuthenticated());
return data;
}
}

View File

@ -0,0 +1,186 @@
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.DescriptionStatusEntity;
import org.opencdmp.model.builder.descriptionstatus.DescriptionStatusBuilder;
import org.opencdmp.model.censorship.descriptionstatus.DescriptionStatusCensor;
import org.opencdmp.model.descriptionstatus.DescriptionStatus;
import org.opencdmp.model.persist.descriptionstatus.DescriptionStatusPersist;
import org.opencdmp.model.result.QueryResult;
import org.opencdmp.query.DescriptionStatusQuery;
import org.opencdmp.query.lookup.DescriptionStatusLookup;
import org.opencdmp.service.descriptionstatus.DescriptionStatusService;
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/description-status")
@io.swagger.v3.oas.annotations.tags.Tag(name = "DescriptionStatuses", description = "Manage tags")
@SwaggerCommonErrorResponses
public class DescriptionStatusController {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionStatusController.class));
private final BuilderFactory builderFactory;
private final AuditService auditService;
private final DescriptionStatusService descriptionStatusService;
private final CensorFactory censorFactory;
private final QueryFactory queryFactory;
private final MessageSource messageSource;
public DescriptionStatusController(
BuilderFactory builderFactory,
AuditService auditService,
DescriptionStatusService descriptionStatusService,
CensorFactory censorFactory,
QueryFactory queryFactory,
MessageSource messageSource) {
this.builderFactory = builderFactory;
this.auditService = auditService;
this.descriptionStatusService = descriptionStatusService;
this.censorFactory = censorFactory;
this.queryFactory = queryFactory;
this.messageSource = messageSource;
}
@PostMapping("query")
@OperationWithTenantHeader(summary = "Query all descriptionStatuses", 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 = DescriptionStatus.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<DescriptionStatus> Query(@RequestBody DescriptionStatusLookup lookup) throws MyApplicationException, MyForbiddenException {
logger.debug("querying {}", DescriptionStatus.class.getSimpleName());
this.censorFactory.censor(DescriptionStatusCensor.class).censor(lookup.getProject(), null);
DescriptionStatusQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.AllExceptPublic);
List<DescriptionStatusEntity> data = query.collectAs(lookup.getProject());
List<DescriptionStatus> models = this.builderFactory.builder(DescriptionStatusBuilder.class).build(lookup.getProject(), data);
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
this.auditService.track(AuditableAction.DescriptionStatus_Query);
return new QueryResult<>(models, count);
}
@GetMapping("{id}")
@OperationWithTenantHeader(summary = "Fetch a specific descriptionStatus by id", description = "",
responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content(
schema = @Schema(
implementation = DescriptionStatus.class
))
))
@Swagger404
public DescriptionStatus Get(
@Parameter(name = "id", description = "The id of a descriptionStatus 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" + DescriptionStatus.class.getSimpleName()).And("id", id).And("fields", fieldSet));
this.censorFactory.censor(DescriptionStatusCensor.class).censor(fieldSet, null);
DescriptionStatusQuery query = this.queryFactory.query(DescriptionStatusQuery.class).disableTracking().authorize(AuthorizationFlags.AllExceptPublic).ids(id);
DescriptionStatus model = this.builderFactory.builder(DescriptionStatusBuilder.class).build(fieldSet, query.firstAs(fieldSet));
if (model == null)
throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionStatus.class.getSimpleName()}, LocaleContextHolder.getLocale()));
this.auditService.track(AuditableAction.DescriptionStatus_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 descriptionStatus", description = "",
responses = @ApiResponse(description = "OK", responseCode = "200", content = @Content(
schema = @Schema(
implementation = DescriptionStatus.class
))
))
@Swagger400
@Swagger404
@Transactional
@ValidationFilterAnnotation(validator = DescriptionStatusPersist.DescriptionStatusPersistValidation.ValidatorName, argumentName = "model")
public DescriptionStatus Persist(
@RequestBody DescriptionStatusPersist model,
@Parameter(name = "fieldSet",description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet
) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException {
logger.debug(new MapLogEntry("persisting"+DescriptionStatus.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
DescriptionStatus persisted = this.descriptionStatusService.persist(model, fieldSet);
this.auditService.track(AuditableAction.DescriptionStatus_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 descriptionStatus by id", description = "",
responses = @ApiResponse(description = "OK", responseCode = "200"))
@Swagger404
@Transactional
public void Delete(
@Parameter(name = "id", description = "The id of descriptionStatus to delete", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id
) throws MyForbiddenException, InvalidApplicationException {
logger.debug(new MapLogEntry("deleting"+DescriptionStatus.class.getSimpleName()).And("id", id));
this.descriptionStatusService.deleteAndSave(id);
this.auditService.track(AuditableAction.DescriptionStatus_Delete, "id", id);
}
}

View File

@ -116,6 +116,33 @@ permissions:
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
#DescriptionStatus
BrowseDescriptionStatus:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
EditDescriptionStatus:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
DeleteDescriptionStatus:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
claims: [ ]
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
#PlanStatus #PlanStatus
BrowsePlanStatus: BrowsePlanStatus:
roles: roles:
@ -1324,6 +1351,14 @@ permissions:
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
ViewPlanStatusPage: ViewPlanStatusPage:
roles:
- Admin
- TenantAdmin
- TenantConfigManager
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
ViewDescriptionStatusPage:
roles: roles:
- Admin - Admin
- TenantAdmin - TenantAdmin