Skip to content

Commit

Permalink
Refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
EmanueleValentini1 committed Oct 26, 2023
1 parent fe3aebe commit 8c5059e
Show file tree
Hide file tree
Showing 23 changed files with 273 additions and 107 deletions.
2 changes: 0 additions & 2 deletions src/main/java/it/gov/pagopa/atmlayer/service/model/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.quarkus.runtime.Startup;
import it.gov.pagopa.atmlayer.service.model.model.ErrorResponse;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.openapi.annotations.Components;
Expand Down Expand Up @@ -36,7 +35,6 @@

}),
info = @Info(title = "ATM Layer - MIL Integration service", version = "0.0.1-SNAPSHOT"))
@ApplicationPath("/api")
@Startup
public class App extends Application {
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

@Retention(RUNTIME)
@Constraint(validatedBy = BankKeyValidator.class)
@Target({ElementType.TYPE_USE, FIELD, METHOD, PARAMETER, ANNOTATION_TYPE })
@Target({ElementType.TYPE_USE, FIELD, METHOD, PARAMETER, ANNOTATION_TYPE})
@SupportedValidationTarget(ANNOTATED_ELEMENT)
@Documented
public @interface BankKeyConstraint {
String message() default "{the BankKey is invalid}";

Class<?>[] groups() default { };
Class<?>[] groups() default {};

Class<? extends Payload>[] payload() default { };
Class<? extends Payload>[] payload() default {};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package it.gov.pagopa.atmlayer.service.model.model;
package it.gov.pagopa.atmlayer.service.model.dto;

import jakarta.validation.constraints.NotNull;
import lombok.Data;
Expand All @@ -8,12 +8,10 @@

@Data
@NoArgsConstructor
public class BankKey {
public class BankKeyDto {

@NotNull(message = "The acquirerId cannot be null")
private String acquirerId;

private String branchId;

private List<String> terminalId;
private List<BranchDto> branches;
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
package it.gov.pagopa.atmlayer.service.model.dto;

import it.gov.pagopa.atmlayer.service.model.model.AssociationMetadata;
import it.gov.pagopa.atmlayer.service.model.constraint.BankKeyConstraint;
import jakarta.validation.Valid;
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.List;

@Data
@NoArgsConstructor
public class BpmnAssociationDto {
@FormParam("file")
@PartType(MediaType.APPLICATION_XML)
private File file;

@FormParam("metadata")
@PartType(MediaType.APPLICATION_JSON)
@Valid
private AssociationMetadata associationMetadata;
private List<@BankKeyConstraint @Valid BankKeyDto> bankKeyDtoList;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package it.gov.pagopa.atmlayer.service.model.dto;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class BranchDto {

private String branchId;

private List<String> terminalId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package it.gov.pagopa.atmlayer.service.model.entity;

import io.quarkus.hibernate.reactive.panache.PanacheEntityBase;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionEnum;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.io.Serial;
import java.io.Serializable;
import java.sql.Timestamp;

@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class BpmnBankConfig extends PanacheEntityBase implements Serializable {

@Serial
private static final long serialVersionUID = 2192727048075093200L;
@EmbeddedId
private BpmnBankConfigPK bpmnBankConfigPK;

@Column(name = "function_type")
private FunctionEnum functionType;

@Column(name = "enabled", columnDefinition = "boolean default true")
private Boolean enabled;

@CreationTimestamp
@Column(name = "created_at")
private Timestamp createdAt;

@UpdateTimestamp
@Column(name = "last_updated_at")
private Timestamp lastUpdatedAt;

@Column(name = "created_by")
private String createdBy;

@Column(name = "last_updated_by")
private String lastUpdatedBy;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package it.gov.pagopa.atmlayer.service.model.entity;

import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.io.Serial;
import java.io.Serializable;
import java.util.UUID;

@Embeddable
@Getter
@Setter
@AllArgsConstructor
public class BpmnBankConfigPK implements Serializable {
@Serial
private static final long serialVersionUID = -9140657073094910845L;

@NotNull(message = "bpmn id cannot be null")
private UUID bpmnId;

@NotNull(message = "bpmn model version cannot be null")
private int bpmnModelVersion;

@NotNull(message = "acquirer id cannot be null")
private String acquirerId;

private String branchId;

private String terminalId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,74 @@
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.io.Serial;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.UUID;

@Entity
@Setter
@Getter
@NoArgsConstructor
public class BpmnVersion extends PanacheEntityBase {
@AllArgsConstructor
public class BpmnVersion extends PanacheEntityBase implements Serializable {

@Serial
private static final long serialVersionUID = 3353950790095221978L;
@EmbeddedId
private BpmnVersionPK bpmnVersionPK;

@Column(name = "deployed_file_name")
private String deployedFileName;

@Column(name = "definition_key")
private String definitionKey;

@Column(name = "function_type")
private FunctionEnum functionType;

@Column(name = "status")
private StatusEnum status;

@Column(name = "sha256")
private String sha256;

@Column(columnDefinition = "boolean default true")
@Column(name = "enabled", columnDefinition = "boolean default true")
private Boolean enabled;

@Column(name = "definition_version_camunda")
private Integer definitionVersionCamunda;

@Column(name = "camunda_definition_id")
private String camundaDefinitionId;

@Column(name = "description")
private String description;

@Column(name = "resource")
private String resource;

@Column(name = "deployement_id")
private UUID deploymentId;

@CreationTimestamp
@Column(name = "created_at")
private Timestamp createdAt;

@UpdateTimestamp
@Column(name = "last_updated_at")
private Timestamp lastUpdatedAt;

@Column(name = "created_by")
private String createdBy;

@Column(name = "last_updated_by")
private String lastUpdatedBy;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package it.gov.pagopa.atmlayer.service.model.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serial;
Expand All @@ -11,11 +14,14 @@
@Embeddable
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class BpmnVersionPK implements Serializable {

@Serial
private static final long serialVersionUID = -6327455979830016850L;
private UUID bpmnId;

@Column(columnDefinition = "int default 1")
private int modelVersion;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
@Getter
public class AtmLayerException extends Exception {

/** Error code of this exception
/**
* Error code of this exception
* -- GETTER --
* Returns error code
* Returns error code
*
* @return Error code of this exception
*/
Expand All @@ -23,7 +24,7 @@ public class AtmLayerException extends Exception {
* Constructs new exception with provided error code and message
*
* @param errorCode Error code
* @param message Detail message
* @param message Detail message
*/
public AtmLayerException(AppErrorCodeEnum errorCode, String message) {
super(message);
Expand All @@ -34,8 +35,8 @@ public AtmLayerException(AppErrorCodeEnum errorCode, String message) {
* Constructs new exception with provided error code, message and cause
*
* @param errorCode Error code
* @param message Detail message
* @param cause Exception causing the constructed one
* @param message Detail message
* @param cause Exception causing the constructed one
*/
public AtmLayerException(AppErrorCodeEnum errorCode, String message, Throwable cause) {
super(message, cause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AtmLayerRestException(String message, Response.Status statusCode, String
this.statusCode = statusCode.getStatusCode();

}

public AtmLayerRestException(String message, Response.Status status, Throwable cause, String type, List<String> errors) {
super(message, status, cause);
this.message = message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import io.quarkus.arc.properties.IfBuildProperty;
import it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum;
import it.gov.pagopa.atmlayer.service.model.utils.ConstraintViolationMappingUtils;
import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerRestException;
import it.gov.pagopa.atmlayer.service.model.model.ATMLayerErrorResponse;
import it.gov.pagopa.atmlayer.service.model.model.ATMLayerValidationErrorResponse;
import it.gov.pagopa.atmlayer.service.model.utils.ConstraintViolationMappingUtils;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import jakarta.validation.ConstraintViolation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package it.gov.pagopa.atmlayer.service.model.mapper;

import it.gov.pagopa.atmlayer.service.model.dto.BpmnCreationDto;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersion;
import it.gov.pagopa.atmlayer.service.model.model.CreationMetadata;
import it.gov.pagopa.atmlayer.service.model.dto.BpmnCreationDto;
import org.mapstruct.Mapper;

@Mapper
public interface BpmnVersionMapper {

BpmnCreationDto toDto (BpmnVersion bpmnVersion);
BpmnCreationDto toDto(BpmnVersion bpmnVersion);

CreationMetadata toEntity (BpmnCreationDto bpmnCreationDto);
CreationMetadata toEntity(BpmnCreationDto bpmnCreationDto);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.gov.pagopa.atmlayer.service.model.model;

import it.gov.pagopa.atmlayer.service.model.constraint.BankKeyConstraint;
import it.gov.pagopa.atmlayer.service.model.dto.BankKeyDto;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionEnum;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
Expand All @@ -19,5 +20,5 @@ public class AssociationMetadata {
@NotNull(message = "The BPMN key cannot be null")
private String bpmnKey;
@NotNull(message = "The Bank Key list cannot be null")
private List<@BankKeyConstraint @Valid BankKey> bankKeyList;
private List<@BankKeyConstraint @Valid BankKeyDto> bankKeyDtoList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.UUID;

@Data
@NoArgsConstructor
public class CreationMetadata {
@NotNull(message = "bpmn id cannot be null")
private UUID bpmnId;
@NotNull(message = "model version cannot be null")
private int modelVersion;
@NotNull(message = "deployed file name cannot be null")
Expand Down
Loading

0 comments on commit 8c5059e

Please sign in to comment.