Skip to content

Commit

Permalink
Object store (#7)
Browse files Browse the repository at this point in the history
* Initial commit

* First Example Version

* added tracing

* Aggiunto profilo native

* First try to decode

* Decode working

* Sha 256 calculation working in post.

* First draft of model entities

* Creato enum per function

* Adding utils to validate BankKey

* Scritte util

* Fix

* First implementation of BankKey Custom Validation

* Change @NotNull in @nonnull

* Custom Validator fixed

* Added Status Enum, ModelEntity creation

* Rename Status enum

* ModelService refactor

* decodebase64 refactor

* Enum for function

* Update application-local.properties

Removed unused local property

* adding helm and pipe

* Refactoring

* Rename root packager

* Fix pom.xml

* Refinement

* reformat properties

* removed useless files

* Column annotation added

* Renaming

* Find working

* add Notation

* Fixing params, sha unique

* BankConfig persistence

* BankConfig persistence

* Bpmn dto mapper

* Fix general props

* BOMN associations service created

* BPMN associations service created

* fixed Bpmn Resource endpoints logic

* in BPMN creation, now Upload with S3 is done

* removed unused import

* fixed unit tests

* fixed properties

* fixed properties

---------

Co-authored-by: Escarsel <[email protected]>
Co-authored-by: USERSAD\evalenti <[email protected]>
Co-authored-by: Simone Munao <[email protected]>
  • Loading branch information
4 people authored Oct 31, 2023
1 parent c64db93 commit 3f6d716
Show file tree
Hide file tree
Showing 57 changed files with 1,574 additions and 192 deletions.
16 changes: 13 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>it.gov.pagopa</groupId>
<artifactId>atm-layer-mil-model</artifactId>
<artifactId>atm-layer-model</artifactId>
<version>0.0.1</version>
<name>atm-layer-mil-model</name>
<name>atm-layer-model</name>
<properties>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<jacoco.version>0.8.7</jacoco.version>
Expand All @@ -21,6 +21,7 @@
<quarkus.openapi.generator.version>2.2.10</quarkus.openapi.generator.version>
<quarkus-amazon-services.version>2.4.5</quarkus-amazon-services.version>
<quarkus.logging.logback.version>1.1.1</quarkus.logging.logback.version>
<apache.common.text.version>1.11.0</apache.common.text.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.0.0</surefire-plugin.version>
<mockito.core.version>5.4.0</mockito.core.version>
Expand Down Expand Up @@ -84,6 +85,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-reactive-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-context-propagation</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.amazonservices</groupId>
<artifactId>quarkus-amazon-s3</artifactId>
Expand All @@ -100,7 +105,7 @@
<groupId>software.amazon.awssdk</groupId>
<artifactId>netty-nio-client</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>io.quarkiverse.amazonservices</groupId>
<artifactId>quarkus-amazon-sts</artifactId>
</dependency>
Expand All @@ -114,6 +119,11 @@
<artifactId>quarkus-openapi-generator</artifactId>
<version>${quarkus.openapi.generator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>${apache.common.text.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
6 changes: 2 additions & 4 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 @@ -31,12 +30,11 @@
"title": "Internal Server Error",
"status": 500,
"detail": "An unexpected error has occurred. Please contact support.",
"instance": "ATML_MI_500"
"instance": "ATMLM_500"
}""")),

}),
info = @Info(title = "ATM Layer - MIL Integration service", version = "0.0.1-SNAPSHOT"))
@ApplicationPath("/api/v1/model")
info = @Info(title = "ATM Layer - Model service", version = "0.0.1-SNAPSHOT"))
@Startup
public class App extends Application {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package it.gov.pagopa.atmlayer.service.model.constraint;

import it.gov.pagopa.atmlayer.service.model.validators.BankKeyValidator;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;
import jakarta.validation.constraintvalidation.SupportedValidationTarget;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static jakarta.validation.constraintvalidation.ValidationTarget.ANNOTATED_ELEMENT;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Retention(RUNTIME)
@Constraint(validatedBy = BankKeyValidator.class)
@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<? extends Payload>[] payload() default {};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package it.gov.pagopa.atmlayer.service.model.dto;

import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class BankKeyDto {

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

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

import it.gov.pagopa.atmlayer.service.model.constraint.BankKeyConstraint;
import jakarta.validation.Valid;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class BpmnAssociationDto {

private List<@BankKeyConstraint @Valid BankKeyDto> bankKeyDtoList;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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;

@Data
@NoArgsConstructor
public class BpmnCreationDto {
@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("functionType")
@NotNull(message = "function type is required")
private functionTypeEnum functionType;
}
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,58 @@
package it.gov.pagopa.atmlayer.service.model.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import io.quarkus.hibernate.reactive.panache.PanacheEntityBase;
import it.gov.pagopa.atmlayer.service.model.enumeration.functionTypeEnum;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinColumns;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
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.Serializable;
import java.sql.Timestamp;

@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "bpmn_bank_config")
public class BpmnBankConfig extends PanacheEntityBase implements Serializable {

@EmbeddedId
private BpmnBankConfigPK bpmnBankConfigPK;

@Column(name = "function_type")
@Enumerated(EnumType.STRING)
private functionTypeEnum 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,36 @@
package it.gov.pagopa.atmlayer.service.model.entity;

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

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

@Embeddable
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class BpmnBankConfigPK implements Serializable {

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

@NotNull(message = "bpmn model version cannot be null")
@Column(name = "bpmn_model_version")
private Long bpmnModelVersion;

@NotNull(message = "acquirer id cannot be null")
@Column(name = "acquirer_id")
private String acquirerId;
@Column(name = "branch_id")
private String branchId;
@Column(name = "terminal_id")
private String terminalId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package it.gov.pagopa.atmlayer.service.model.entity;

import io.quarkus.hibernate.reactive.panache.PanacheEntityBase;
import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.functionTypeEnum;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

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

@Entity
@Setter
@Getter
@NoArgsConstructor
@Table(name = "bpmn_version")
@IdClass(BpmnVersionPK.class)
public class BpmnVersion extends PanacheEntityBase implements Serializable {

@GeneratedValue(strategy = GenerationType.UUID)
@Column(name = "bpmn_id", nullable = false, updatable = false)
@Id
private UUID bpmnId;

@Column(name = "model_version", nullable = false)
@Id
private Long modelVersion = 1L;

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

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

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

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

@Column(name = "sha256", unique = true)
private String sha256;

@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;
}
Loading

0 comments on commit 3f6d716

Please sign in to comment.