Skip to content

Commit

Permalink
created new endpoint to acquire the right bpmn model for the processS…
Browse files Browse the repository at this point in the history
…ervice (#25)
  • Loading branch information
candreac authored Nov 15, 2023
1 parent 3b242d7 commit b30301c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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.model.BpmnDTO;
import it.gov.pagopa.atmlayer.service.model.utils.BpmnUtils;
import it.gov.pagopa.atmlayer.service.model.model.BpmnProcessDTO;
import it.gov.pagopa.atmlayer.service.model.utils.FileUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
Expand Down Expand Up @@ -35,24 +35,26 @@ public BpmnVersion toEntityCreation(BpmnCreationDto bpmnCreationDto) throws NoSu

public abstract BpmnDTO toDTO(BpmnVersion bpmnVersion);

public List<BpmnDTO> toDTOList(List<BpmnVersion> list){
public abstract BpmnProcessDTO toProcessDTO(BpmnDTO bpmnProcessDTO);

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

@Mapping(ignore = true, target = "enabled")
@Mapping(target = "resourceFile.bpmn",ignore = true)
@Mapping(target = "resourceFile.bpmn", ignore = true)
public abstract BpmnVersion toEntity(BpmnDTO bpmnDTO);

public BpmnVersion toEntityUpgrade(BpmnUpgradeDto bpmnUpgradeDto, Long version, String definitionKey) throws NoSuchAlgorithmException, IOException {
BpmnVersion bpmnVersion = new BpmnVersion();
bpmnVersion.setFunctionType(bpmnUpgradeDto.getFunctionType());
bpmnVersion.setStatus(StatusEnum.CREATED);
bpmnVersion.setSha256(FileUtils.calculateSha256(bpmnUpgradeDto.getFile()));
bpmnVersion.setDeployedFileName(bpmnUpgradeDto.getFilename().concat(".").concat(S3ResourceTypeEnum.BPMN.getExtension()));
bpmnVersion.setEnabled(true);
bpmnVersion.setModelVersion(version);
bpmnVersion.setDefinitionKey(definitionKey);
bpmnVersion.setBpmnId(bpmnUpgradeDto.getUuid());
return bpmnVersion;
}
public BpmnVersion toEntityUpgrade(BpmnUpgradeDto bpmnUpgradeDto, Long version, String definitionKey) throws NoSuchAlgorithmException, IOException {
BpmnVersion bpmnVersion = new BpmnVersion();
bpmnVersion.setFunctionType(bpmnUpgradeDto.getFunctionType());
bpmnVersion.setStatus(StatusEnum.CREATED);
bpmnVersion.setSha256(FileUtils.calculateSha256(bpmnUpgradeDto.getFile()));
bpmnVersion.setDeployedFileName(bpmnUpgradeDto.getFilename().concat(".").concat(S3ResourceTypeEnum.BPMN.getExtension()));
bpmnVersion.setEnabled(true);
bpmnVersion.setModelVersion(version);
bpmnVersion.setDefinitionKey(definitionKey);
bpmnVersion.setBpmnId(bpmnUpgradeDto.getUuid());
return bpmnVersion;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package it.gov.pagopa.atmlayer.service.model.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
@EqualsAndHashCode
public class BpmnProcessDTO {

private String camundaDefinitionId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import it.gov.pagopa.atmlayer.service.model.mapper.BpmnVersionMapper;
import it.gov.pagopa.atmlayer.service.model.model.BpmnBankConfigDTO;
import it.gov.pagopa.atmlayer.service.model.model.BpmnDTO;
import it.gov.pagopa.atmlayer.service.model.model.BpmnProcessDTO;
import it.gov.pagopa.atmlayer.service.model.service.BpmnFileStorageService;
import it.gov.pagopa.atmlayer.service.model.service.BpmnVersionService;
import it.gov.pagopa.atmlayer.service.model.service.impl.BpmnBankConfigService;
Expand Down Expand Up @@ -217,6 +218,17 @@ public Uni<BpmnDTO> findBPMNByTriad(@PathParam("functionType") String functionTy
});
}

@GET
@Path("/process/function/{functionType}/bank/{acquirerId}/branch/{branchId}/terminal/{terminalId}")
@Produces(MediaType.APPLICATION_JSON)
public Uni<BpmnProcessDTO> findBPMNByTriadForProcessService(@PathParam("functionType") String functionType,
@PathParam("acquirerId") String acquirerId,
@PathParam("branchId") String branchId,
@PathParam("terminalId") String terminalId) {
return this.findBPMNByTriad(functionType, acquirerId, branchId, terminalId)
.onItem().transformToUni(bpmn -> Uni.createFrom().item(bpmnVersionMapper.toProcessDTO(bpmn)));
}

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
Expand Down

0 comments on commit b30301c

Please sign in to comment.