Skip to content

Commit

Permalink
Merge branch 'sprint4_workflow_resource' into Main_sprint4_integration
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/it/gov/pagopa/atmlayer/service/model/entity/ResourceEntity.java
#	src/main/java/it/gov/pagopa/atmlayer/service/model/model/ResourceEntityDTO.java
#	src/test/resources/application.properties
  • Loading branch information
asioleLab committed Nov 10, 2023
2 parents 9fafed2 + 794f69f commit aba37f3
Show file tree
Hide file tree
Showing 33 changed files with 176 additions and 120 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package it.gov.pagopa.atmlayer.service.model.dto;

import it.gov.pagopa.atmlayer.service.model.enumeration.ResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.WorkflowResourceTypeEnum;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.ws.rs.FormParam;
Expand All @@ -21,5 +21,5 @@ public class ResourceCreationDto {
private String filename;
@FormParam("resourceType")
@NotNull(message = "resource type is required")
private ResourceTypeEnum resourceType;
private WorkflowResourceTypeEnum resourceType;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package it.gov.pagopa.atmlayer.service.model.dto;

import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.ResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.WorkflowResourceTypeEnum;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.ws.rs.FormParam;
Expand All @@ -25,11 +24,7 @@ public class WorkflowResourceCreationDto {
@Pattern(regexp = "^[a-zA-Z0-9_-]+$", message = "deve essere della forma ${regexp} e non contenere l'estensione del file")
private String filename;

@FormParam("functionType")
@NotNull(message = "function type is required")
private FunctionTypeEnum functionType;

@FormParam("resourceType")
@NotNull(message = "resource type is required")
private ResourceTypeEnum resourceType;
private WorkflowResourceTypeEnum resourceType;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package it.gov.pagopa.atmlayer.service.model.entity;

import io.quarkus.hibernate.reactive.panache.PanacheEntityBase;
import it.gov.pagopa.atmlayer.service.model.enumeration.ResourceTypeEnum;
import jakarta.persistence.CascadeType;
import it.gov.pagopa.atmlayer.service.model.enumeration.WorkflowResourceTypeEnum;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -30,13 +28,11 @@ public class ResourceEntity extends PanacheEntityBase implements Serializable {
@GeneratedValue(strategy = GenerationType.UUID)
@Id
private UUID resourceId;
@OneToOne(mappedBy = "resourceEntity", cascade = CascadeType.ALL)
ResourceFile resourceFile;
@Column(name = "sha256", unique = true)
private String sha256;
@Column(name = "resourceType")
ResourceTypeEnum resourceTypeEnum;
@Column(name = "file_name")
@Column(name="resourceType")
WorkflowResourceTypeEnum workflowResourceTypeEnum;
@Column(name="file_name")
String fileName;
@CreationTimestamp
@Column(name = "created_at")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.quarkus.hibernate.reactive.panache.PanacheEntityBase;
import it.gov.pagopa.atmlayer.service.model.enumeration.ResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.WorkflowResourceTypeEnum;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
Expand Down Expand Up @@ -45,8 +45,7 @@ public class ResourceFile extends PanacheEntityBase implements Serializable {

@Column(name = "resource_type")
@Enumerated(EnumType.STRING)
@NotNull
private ResourceTypeEnum resourceType;
private WorkflowResourceTypeEnum resourceType;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumns({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package it.gov.pagopa.atmlayer.service.model.entity;

import io.quarkus.hibernate.reactive.panache.PanacheEntityBase;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.ResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.WorkflowResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
Expand All @@ -12,7 +11,6 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.PrePersist;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -45,13 +43,9 @@ public class WorkflowResource extends PanacheEntityBase implements Serializable
@Column(name = "definition_key")
private String definitionKey;

@Column(name = "function_type")
@Enumerated(EnumType.STRING)
private FunctionTypeEnum functionType;

@Column(name = "resource_type")
@Enumerated(EnumType.STRING)
private ResourceTypeEnum resourceType;
private WorkflowResourceTypeEnum resourceType;

@Column(name = "status")
@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorType.NOT_DEPLOYED_STATUS;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorType.NOT_EXISTING_REFERENCED_ENTITY;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorType.ID_NOT_FOUND;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorType.NOT_UPDATABLE;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorType.NOT_UPGRADABLE;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorType.NOT_VALID_FILE;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorType.NOT_VALID_REFERENCED_ENTITY;
Expand Down Expand Up @@ -46,7 +47,9 @@ public enum AppErrorCodeEnum {
WORKFLOW_RESOURCE_FILE_WITH_SAME_CONTENT_ALREADY_EXIST("ATMLM_4000021","A Workflow Resource file with the same content already exists", CONSTRAINT_VIOLATION),
WORKFLOW_RESOURCE_FILE_WITH_SAME_CAMUNDA_DEFINITION_KEY_ALREADY_EXISTS("ATMLM_4000022","A Workflow Resource file with the same Camunda definition key already exists", CONSTRAINT_VIOLATION),
WORKFLOW_FILE_DOES_NOT_EXIST("ATMLM_4000023", "The referenced Workflow Resource file does not exist", NOT_EXISTING_REFERENCED_ENTITY),
WORKFLOW_RESOURCE_CANNOT_BE_DELETED_FOR_STATUS("ATMLM_4000024", "The referenced Workflow Resource file can not be deleted in the actual state", NOT_DELETABLE);
WORKFLOW_RESOURCE_CANNOT_BE_DELETED_FOR_STATUS("ATMLM_4000024", "The referenced Workflow Resource file can not be deleted in the actual state", NOT_DELETABLE),
WORKFLOW_RESOURCE_CANNOT_BE_UPDATED_FOR_STATUS("ATMLM_4000025", "The referenced Workflow Resource file can not be updated in the actual state", NOT_UPDATABLE),
WORKFLOW_RESOURCE_FILE_CANNOT_BE_DEPLOYED("ATMLM_4000026", "The referenced Workflow Resource file can not be deployed", NOT_DEPLOYABLE_STATUS);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public enum AppErrorType {
NOT_VALID_FILE,
INVALID_DEPLOY,
ID_NOT_FOUND,
INVALID_ARGUMENT
INVALID_ARGUMENT,
NOT_UPDATABLE
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public enum StatusEnum {
@JsonValue
private String value;

public static Set<StatusEnum> getDeletableStatuses() {
public static Set<StatusEnum> getUpdatableAndDeletableStatuses() {
return new HashSet<>(Arrays.asList(CREATED, DEPLOY_ERROR));
}

public static boolean isDeletable(StatusEnum status) {
return getDeletableStatuses().contains(status);
public static boolean isEditable(StatusEnum status) {
return getUpdatableAndDeletableStatuses().contains(status);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

@AllArgsConstructor
@Getter
public enum ResourceTypeEnum {
public enum WorkflowResourceTypeEnum {
BPMN("bpmn","application/bpmn", "bpmn:process", "id"),
HTML("html","application/html", "NULL", "NULL"),
DMN("dmn", "application/dmn", "decision", "id");

String extension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import it.gov.pagopa.atmlayer.service.model.dto.BpmnCreationDto;
import it.gov.pagopa.atmlayer.service.model.dto.BpmnUpgradeDto;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersion;
import it.gov.pagopa.atmlayer.service.model.enumeration.ResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.WorkflowResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum;
import it.gov.pagopa.atmlayer.service.model.model.BpmnDTO;
import it.gov.pagopa.atmlayer.service.model.utils.BpmnUtils;
Expand All @@ -27,7 +27,7 @@ public BpmnVersion toEntityCreation(BpmnCreationDto bpmnCreationDto) throws NoSu
bpmnVersion.setFunctionType(bpmnCreationDto.getFunctionType());
bpmnVersion.setStatus(StatusEnum.CREATED);
bpmnVersion.setSha256(BpmnUtils.calculateSha256(bpmnCreationDto.getFile()));
bpmnVersion.setDeployedFileName(bpmnCreationDto.getFilename().concat(".").concat(ResourceTypeEnum.BPMN.getExtension()));
bpmnVersion.setDeployedFileName(bpmnCreationDto.getFilename().concat(".").concat(WorkflowResourceTypeEnum.BPMN.getExtension()));
bpmnVersion.setEnabled(true);
return bpmnVersion;
}
Expand All @@ -47,7 +47,7 @@ public BpmnVersion toEntityUpgrade(BpmnUpgradeDto bpmnUpgradeDto, Long version,
bpmnVersion.setFunctionType(bpmnUpgradeDto.getFunctionType());
bpmnVersion.setStatus(StatusEnum.CREATED);
bpmnVersion.setSha256(BpmnUtils.calculateSha256(bpmnUpgradeDto.getFile()));
bpmnVersion.setDeployedFileName(bpmnUpgradeDto.getFilename().concat(".").concat(ResourceTypeEnum.BPMN.getExtension()));
bpmnVersion.setDeployedFileName(bpmnUpgradeDto.getFilename().concat(".").concat(WorkflowResourceTypeEnum.BPMN.getExtension()));
bpmnVersion.setEnabled(true);
bpmnVersion.setModelVersion(version);
bpmnVersion.setDefinitionKey(definitionKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import it.gov.pagopa.atmlayer.service.model.dto.ResourceCreationDto;
import it.gov.pagopa.atmlayer.service.model.entity.ResourceEntity;
import it.gov.pagopa.atmlayer.service.model.model.ResourceEntityDTO;
import it.gov.pagopa.atmlayer.service.model.utils.BpmnUtils;
import org.mapstruct.Mapper;

Expand All @@ -14,7 +13,7 @@ public abstract class ResourceEntityMapper {
public ResourceEntity toEntityCreation(ResourceCreationDto resourceCreationDto) throws NoSuchAlgorithmException, IOException {
ResourceEntity resourceEntity = new ResourceEntity();
resourceEntity.setSha256(BpmnUtils.calculateSha256(resourceCreationDto.getFile()));
resourceEntity.setResourceTypeEnum(resourceCreationDto.getResourceType());
resourceEntity.setWorkflowResourceTypeEnum(resourceCreationDto.getResourceType());
resourceEntity.setFileName(resourceCreationDto.getFilename());
return resourceEntity;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package it.gov.pagopa.atmlayer.service.model.mapper;

import it.gov.pagopa.atmlayer.service.model.dto.WorkflowResourceCreationDto;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersion;
import it.gov.pagopa.atmlayer.service.model.entity.WorkflowResource;
import it.gov.pagopa.atmlayer.service.model.enumeration.ResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum;
import it.gov.pagopa.atmlayer.service.model.model.BpmnDTO;
import it.gov.pagopa.atmlayer.service.model.model.WorkflowResourceDTO;
import it.gov.pagopa.atmlayer.service.model.utils.BpmnUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.stream.Collectors;

@Mapper(componentModel = "cdi")
public abstract class WorkflowResourceMapper {
Expand All @@ -21,7 +24,6 @@ public abstract class WorkflowResourceMapper {

public WorkflowResource toEntityCreation(WorkflowResourceCreationDto workflowCreationDto) throws NoSuchAlgorithmException, IOException {
WorkflowResource workflowResource = new WorkflowResource();
workflowResource.setFunctionType(workflowCreationDto.getFunctionType());
workflowResource.setStatus(StatusEnum.CREATED);
workflowResource.setSha256(BpmnUtils.calculateSha256(workflowCreationDto.getFile()));
workflowResource.setDeployedFileName(workflowCreationDto.getFilename().concat(".").concat(workflowCreationDto.getResourceType().toString()));
Expand All @@ -31,6 +33,10 @@ public WorkflowResource toEntityCreation(WorkflowResourceCreationDto workflowCre

public abstract WorkflowResourceDTO toDTO(WorkflowResource workflowResource);

public List<WorkflowResourceDTO> toDTOList(List<WorkflowResource> list){
return list.stream().map(this::toDTO).collect(Collectors.toList());
}

// @Mapping(ignore = true, target = "enabled")
// @Mapping(target = "resourceFile.dmn",ignore = true)
// public abstract WorkflowResource toEntity(WorkflowResourceDTO workflowResourceDTO);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package it.gov.pagopa.atmlayer.service.model.model;

import it.gov.pagopa.atmlayer.service.model.enumeration.ResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.WorkflowResourceTypeEnum;

import java.sql.Timestamp;
import java.util.UUID;

public class ResourceEntityDTO {
private UUID resourceId;
private String sha256;
ResourceTypeEnum resourceTypeEnum;
WorkflowResourceTypeEnum workflowResourceTypeEnum;
private Timestamp createdAt;
private Timestamp lastUpdatedAt;
private String createdBy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package it.gov.pagopa.atmlayer.service.model.model;

import it.gov.pagopa.atmlayer.service.model.enumeration.ResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.WorkflowResourceTypeEnum;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -20,7 +20,7 @@
@EqualsAndHashCode
public class ResourceFileDTO {
private UUID id;
private ResourceTypeEnum resourceType;
private WorkflowResourceTypeEnum resourceType;
private String storageKey;
private String fileName;
private String extension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface ObjectStoreProperties {

Bpmn bpmn();

Dmn dmn();
WorkflowResource workflowResource();

interface Bucket {
String name();
Expand All @@ -33,7 +33,7 @@ interface Bpmn {
String pathTemplate();
}

interface Dmn {
interface WorkflowResource {
String pathTemplate();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Uni<List<BpmnBankConfig>> findByAcquirerIdAndFunctionType(String acquirer
return list("select b from BpmnBankConfig b where b.bpmnBankConfigPK.acquirerId = :acquirerId and b.functionType= :functionType", params);
}

public Uni<List<BpmnBankConfig>> findByTriadAndFunctionType(String acquirerId, String branchId, String terminalId, FunctionTypeEnum functionType) {
public Uni<List<BpmnBankConfig>> findByConfigAndFunctionType(String acquirerId, String branchId, String terminalId, FunctionTypeEnum functionType) {
Map<String, Object> params = new HashMap<>();
params.put("acquirerId", acquirerId);
params.put("branchId", branchId);
Expand Down
Loading

0 comments on commit aba37f3

Please sign in to comment.