Skip to content

Commit

Permalink
functionType for bpmn operations is now a String
Browse files Browse the repository at this point in the history
  • Loading branch information
candreac committed Nov 11, 2023
1 parent da58341 commit 3914a3a
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 120 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package it.gov.pagopa.atmlayer.service.model.dto;

import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.ws.rs.FormParam;
Expand All @@ -26,5 +25,5 @@ public class BpmnCreationDto {

@FormParam("functionType")
@NotNull(message = "function type is required")
private FunctionTypeEnum functionType;
private String functionType;
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package it.gov.pagopa.atmlayer.service.model.dto;

import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.ws.rs.FormParam;
import jakarta.ws.rs.core.MediaType;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jboss.resteasy.reactive.PartType;

import java.io.File;
import java.util.UUID;

@Data
@NoArgsConstructor
public class BpmnUpgradeDto {

@FormParam("uuid")
@NotNull(message = "uuid is required")
private UUID uuid;
@FormParam("uuid")
@NotNull(message = "uuid is required")
private UUID uuid;

@FormParam("file")
@PartType(MediaType.APPLICATION_XML)
@NotNull(message = "bpmn file is required")
private File file;
@FormParam("file")
@PartType(MediaType.APPLICATION_XML)
@NotNull(message = "bpmn file is required")
private File file;

@FormParam("filename")
@NotNull(message = "filename is required")
@Pattern(regexp = "^[a-zA-Z0-9_-]+$", message = "deve essere della forma ${regexp} e non contenere l'estensione del file")
private String filename;
@FormParam("filename")
@NotNull(message = "filename is required")
@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("functionType")
@NotNull(message = "function type is required")
private String functionType;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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 jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
Expand Down Expand Up @@ -30,8 +29,7 @@ public class BpmnBankConfig extends PanacheEntityBase implements Serializable {
private BpmnBankConfigPK bpmnBankConfigPK;

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

@CreationTimestamp
@Column(name = "created_at")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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.StatusEnum;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
Expand Down Expand Up @@ -49,8 +48,7 @@ public class BpmnVersion extends PanacheEntityBase implements Serializable {
private String definitionKey;

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

@Column(name = "status")
@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package it.gov.pagopa.atmlayer.service.model.model;

import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
Expand All @@ -26,7 +25,7 @@ public class BpmnBankConfigDTO {
private String acquirerId;
private String branchId;
private String terminalId;
private FunctionTypeEnum functionType;
private String functionType;
@Schema(description = "Creation Timestamp", format = "date-time", pattern = "DD/MM/YYYY", example = "2023-11-03T14:18:36.635+00:00")
private Timestamp createdAt;
@Schema(description = "Last Update Timestamp", format = "date-time", pattern = "DD/MM/YYYY", example = "2023-11-03T14:18:36.635+00:00")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package it.gov.pagopa.atmlayer.service.model.model;

import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -27,7 +26,7 @@ public class BpmnDTO {
private Long modelVersion;
private String deployedFileName;
private String definitionKey;
private FunctionTypeEnum functionType;
private String functionType;
private StatusEnum status;
private String sha256;
private Integer definitionVersionCamunda;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package it.gov.pagopa.atmlayer.service.model.model;

import it.gov.pagopa.atmlayer.service.model.enumeration.DeployableResourceType;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -26,7 +25,7 @@ public class WorkflowResourceDTO {
private UUID workflowResourceId;
private String deployedFileName;
private String definitionKey;
private FunctionTypeEnum functionType;
private String functionType;
private StatusEnum status;
private String sha256;
private Integer definitionVersionCamunda;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.smallrye.mutiny.Uni;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnBankConfig;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnBankConfigPK;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import jakarta.enterprise.context.ApplicationScoped;

import java.util.HashMap;
Expand All @@ -14,22 +13,22 @@
@ApplicationScoped
public class BpmnBankConfigRepository implements PanacheRepositoryBase<BpmnBankConfig, BpmnBankConfigPK> {

public Uni<Long> deleteByAcquirerIdAndFunctionType(String acquirerId, FunctionTypeEnum functionType) {
public Uni<Long> deleteByAcquirerIdAndFunctionType(String acquirerId, String functionType) {
Map<String, Object> params = new HashMap<>();
params.put("acquirerId", acquirerId);
params.put("functionType", functionType);
return delete(
"delete from BpmnBankConfig b where b.bpmnBankConfigPK.acquirerId = :acquirerId and b.functionType= :functionType", params);
}

public Uni<List<BpmnBankConfig>> findByAcquirerIdAndFunctionType(String acquirerId, FunctionTypeEnum functionType) {
public Uni<List<BpmnBankConfig>> findByAcquirerIdAndFunctionType(String acquirerId, String functionType) {
Map<String, Object> params = new HashMap<>();
params.put("acquirerId", acquirerId);
params.put("functionType", functionType);
return list("select b from BpmnBankConfig b where b.bpmnBankConfigPK.acquirerId = :acquirerId and b.functionType= :functionType", params);
}

public Uni<List<BpmnBankConfig>> findByConfigAndFunctionType(String acquirerId, String branchId, String terminalId, FunctionTypeEnum functionType) {
public Uni<List<BpmnBankConfig>> findByConfigAndFunctionType(String acquirerId, String branchId, String terminalId, String functionType) {
Map<String, Object> params = new HashMap<>();
params.put("acquirerId", acquirerId);
params.put("branchId", branchId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.smallrye.mutiny.Uni;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersion;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersionPK;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import jakarta.enterprise.context.ApplicationScoped;

import java.util.List;
Expand All @@ -26,7 +25,7 @@ public Uni<List<BpmnVersion>> findByIds(Set<BpmnVersionPK> ids) {
return find("where concat(bpmnId,'_',modelVersion) in ?1", bpmnIdVersion).list();
}

public Uni<List<BpmnVersion>> findByIdAndFunction(UUID uuid, FunctionTypeEnum functionType) {
public Uni<List<BpmnVersion>> findByIdAndFunction(UUID uuid, String functionType) {
return find(
"select b from BpmnVersion b where b.bpmnId = :bpmnId and b.functionType = :functionType order by b.modelVersion DESC",
Parameters.with("bpmnId", uuid).and("functionType", functionType)).list();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import it.gov.pagopa.atmlayer.service.model.entity.ResourceFile;
import it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.BankConfigUtilityValues;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerException;
import it.gov.pagopa.atmlayer.service.model.mapper.BpmnConfigMapper;
import it.gov.pagopa.atmlayer.service.model.mapper.BpmnVersionMapper;
Expand Down Expand Up @@ -80,7 +79,7 @@ public class BpmnResource {

@GET
@Produces(MediaType.APPLICATION_JSON)
public Uni<List<BpmnDTO>> getAllBpmn(){
public Uni<List<BpmnDTO>> getAllBpmn() {
return this.bpmnVersionService.getAll()
.onItem()
.transform(Unchecked.function(list -> {
Expand Down Expand Up @@ -116,15 +115,15 @@ public Uni<BpmnDTO> getEncodedFile(@PathParam("bpmnId") UUID bpmnId,
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Uni<Collection<BpmnBankConfigDTO>> associateBPMN(@PathParam("acquirerId") String acquirerId,
@PathParam("functionType") FunctionTypeEnum functionTypeEnum,
@PathParam("functionType") String functionType,
@RequestBody(required = true) @Valid BpmnAssociationDto bpmnAssociationDto)
throws NoSuchAlgorithmException, IOException {
List<BpmnBankConfig> configs = getAcquirerConfigs(bpmnAssociationDto, acquirerId,
functionTypeEnum);
functionType);
Set<BpmnVersionPK> bpmnIds = BpmnUtils.extractBpmnUUIDFromAssociations(configs);
return bpmnEntityValidator.validateExistenceStatusAndFunctionType(bpmnIds, functionTypeEnum)
return bpmnEntityValidator.validateExistenceStatusAndFunctionType(bpmnIds, functionType)
.onItem().transformToUni(
x -> this.bpmnVersionService.putAssociations(acquirerId, functionTypeEnum, configs))
x -> this.bpmnVersionService.putAssociations(acquirerId, functionType, configs))
.onItem()
.transformToUni(list -> Uni.createFrom().item(this.bpmnConfigMapper.toDTOList(list)));
}
Expand Down Expand Up @@ -189,24 +188,24 @@ public Multi<Buffer> downloadBpmn(@PathParam("uuid") UUID bpmnId,
@GET
@Path("/function/{functionType}/bank/{acquirerId}/branch/{branchId}/terminal/{terminalId}")
@Produces(MediaType.APPLICATION_JSON)
public Uni<BpmnDTO> findBPMNByTriad(@PathParam("functionType") FunctionTypeEnum functionTypeEnum,
public Uni<BpmnDTO> findBPMNByTriad(@PathParam("functionType") String functionType,
@PathParam("acquirerId") String acquirerId,
@PathParam("branchId") String branchId,
@PathParam("terminalId") String terminalId) {
return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, terminalId, functionTypeEnum)
return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, terminalId, functionType)
.onItem()
.transformToUni(x1 -> {
if (x1.isPresent()) {
return bpmnVersionService.findByPk(new BpmnVersionPK(x1.get().getBpmnBankConfigPK().getBpmnId(), x1.get().getBpmnBankConfigPK().getBpmnModelVersion()))
.onItem().transformToUni(bpmn1 -> Uni.createFrom().item(this.bpmnVersionMapper.toDTO(bpmn1.get())));
}
return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, BankConfigUtilityValues.NULL_VALUE.getValue(), functionTypeEnum)
return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, BankConfigUtilityValues.NULL_VALUE.getValue(), functionType)
.onItem().transformToUni(x2 -> {
if (x2.isPresent()) {
return bpmnVersionService.findByPk(new BpmnVersionPK(x2.get().getBpmnBankConfigPK().getBpmnId(), x2.get().getBpmnBankConfigPK().getBpmnModelVersion()))
.onItem().transformToUni(bpmn2 -> Uni.createFrom().item(this.bpmnVersionMapper.toDTO(bpmn2.get())));
}
return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, BankConfigUtilityValues.NULL_VALUE.getValue(), BankConfigUtilityValues.NULL_VALUE.getValue(), functionTypeEnum)
return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, BankConfigUtilityValues.NULL_VALUE.getValue(), BankConfigUtilityValues.NULL_VALUE.getValue(), functionType)
.onItem().transformToUni(Unchecked.function(x3 -> {
if (x3.isPresent()) {
return bpmnVersionService.findByPk(new BpmnVersionPK(x3.get().getBpmnBankConfigPK().getBpmnId(), x3.get().getBpmnBankConfigPK().getBpmnModelVersion()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import it.gov.pagopa.atmlayer.service.model.entity.BpmnBankConfig;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersion;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersionPK;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum;
import it.gov.pagopa.atmlayer.service.model.model.BpmnDTO;

Expand All @@ -22,6 +21,7 @@ public interface BpmnVersionService {
Uni<List<BpmnVersion>> findByPKSet(Set<BpmnVersionPK> bpmnVersionPKSet);

Uni<BpmnVersion> setBpmnVersionStatus(BpmnVersionPK key, StatusEnum status);

Uni<BpmnVersion> save(BpmnVersion bpmnVersion);

Uni<Boolean> delete(BpmnVersionPK bpmnVersionPK);
Expand All @@ -32,7 +32,7 @@ public interface BpmnVersionService {

Uni<Optional<BpmnVersion>> findByPk(BpmnVersionPK bpmnVersionPK);

Uni<List<BpmnBankConfig>> putAssociations(String acquirerId, FunctionTypeEnum functionTypeEnum, List<BpmnBankConfig> bpmnBankConfigs);
Uni<List<BpmnBankConfig>> putAssociations(String acquirerId, String functionTypeEnum, List<BpmnBankConfig> bpmnBankConfigs);

Uni<BpmnVersion> deploy(BpmnVersionPK bpmnVersionPK);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.smallrye.mutiny.unchecked.Unchecked;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnBankConfig;
import it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerException;
import it.gov.pagopa.atmlayer.service.model.mapper.BpmnConfigMapper;
import it.gov.pagopa.atmlayer.service.model.model.BpmnBankConfigDTO;
Expand All @@ -31,16 +30,16 @@ public Uni<Void> saveList(List<BpmnBankConfig> bpmnBankConfigs) {
return bankConfigRepository.persist(bpmnBankConfigs);
}

public Uni<List<BpmnBankConfig>> findByAcquirerIdAndFunctionType(String acquirerId, FunctionTypeEnum functionType) {
public Uni<List<BpmnBankConfig>> findByAcquirerIdAndFunctionType(String acquirerId, String functionType) {
return this.bankConfigRepository.findByAcquirerIdAndFunctionType(acquirerId, functionType);
}

@WithTransaction
public Uni<Long> deleteByAcquirerIdAndFunctionType(String acquirerId, FunctionTypeEnum functionTypeEnum) {
public Uni<Long> deleteByAcquirerIdAndFunctionType(String acquirerId, String functionTypeEnum) {
return this.bankConfigRepository.deleteByAcquirerIdAndFunctionType(acquirerId, functionTypeEnum);
}

public Uni<Optional<BpmnBankConfig>> findByConfigurationsAndFunction(String acquirerId, String branchId, String terminalId, FunctionTypeEnum functionTypeEnum) {
public Uni<Optional<BpmnBankConfig>> findByConfigurationsAndFunction(String acquirerId, String branchId, String terminalId, String functionTypeEnum) {
return this.bankConfigRepository.findByConfigAndFunctionType(acquirerId, branchId, terminalId, functionTypeEnum)
.onItem().transformToUni(Unchecked.function(x -> {
if (!x.isEmpty() && x.size() > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import it.gov.pagopa.atmlayer.service.model.entity.ResourceFile;
import it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.DeployableResourceType;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.S3ResourceTypeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum;
import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerException;
import it.gov.pagopa.atmlayer.service.model.mapper.BpmnVersionMapper;
Expand Down Expand Up @@ -131,7 +129,7 @@ public Uni<Optional<BpmnVersion>> findByPk(BpmnVersionPK bpmnVersionPK) {

@Override
@WithTransaction
public Uni<List<BpmnBankConfig>> putAssociations(String acquirerId, FunctionTypeEnum functionType, List<BpmnBankConfig> bpmnBankConfigs) {
public Uni<List<BpmnBankConfig>> putAssociations(String acquirerId, String functionType, List<BpmnBankConfig> bpmnBankConfigs) {
Uni<Long> deleteExistingUni = this.bpmnBankConfigService.deleteByAcquirerIdAndFunctionType(acquirerId, functionType);
return deleteExistingUni
.onItem()
Expand Down Expand Up @@ -241,7 +239,7 @@ public Uni<BpmnVersion> deploy(BpmnVersionPK bpmnVersionPK) {
.onItem().transformToUni(x -> Uni.createFrom().failure(new AtmLayerException("Error in BPMN deploy. Fail to generate presigned URL", Response.Status.INTERNAL_SERVER_ERROR, ATMLM_500)));
});
})
.onItem().transformToUni(presignedUrl -> processClient.deploy(presignedUrl.toString(),DeployableResourceType.BPMN.name())
.onItem().transformToUni(presignedUrl -> processClient.deploy(presignedUrl.toString(), DeployableResourceType.BPMN.name())
.onFailure().recoverWithUni(failure -> {
log.error(failure.getMessage());
return this.setBpmnVersionStatus(bpmnVersionPK, StatusEnum.DEPLOY_ERROR)
Expand Down Expand Up @@ -282,7 +280,7 @@ public Uni<BpmnVersion> setDeployInfo(BpmnVersionPK key, DeployResponseDto respo
}));
}

public Uni<BpmnVersion> getLatestVersion(UUID uuid, FunctionTypeEnum functionType) {
public Uni<BpmnVersion> getLatestVersion(UUID uuid, String functionType) {
return this.bpmnVersionRepository.findByIdAndFunction(uuid, functionType)
.onItem()
.transform(list -> list.get(0))
Expand Down
Loading

0 comments on commit 3914a3a

Please sign in to comment.