Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: P4ADEV-1545 fdr ingestion actity implementation retrieval via query file validation #22

Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
615f97d
P4ADEV-1545 FdRIngestionActity added interface implementation and its…
macacia Nov 26, 2024
9e0ada7
P4ADEV-1545 FdRIngestionActity naming refactoring
macacia Nov 26, 2024
9f58e1f
P4ADEV-1545 FdRIngestionActity added service and test
macacia Nov 27, 2024
93450f8
P4ADEV-1545 FdRIngestionActity added utils and its test
macacia Nov 27, 2024
9780f00
P4ADEV-1545 FdRIngestionActity fix
macacia Nov 27, 2024
a5d451d
P4ADEV-1545 FdRIngestionActity fix
macacia Nov 27, 2024
45edff1
P4ADEV-1545 FdRIngestionActity refactored FileUtils.java and its tests
macacia Nov 27, 2024
88e6cea
P4ADEV-1545 FdRIngestionActity added missing test
macacia Nov 27, 2024
476d008
P4ADEV-1545 FdRIngestionActity added missing test
macacia Nov 27, 2024
474ea2f
P4ADEV-1545 FdRIngestionActity resolved sonar issues
macacia Nov 27, 2024
b898521
P4ADEV-1545 FdRIngestionActity fixed with sonar issues
macacia Nov 27, 2024
0789a33
P4ADEV-1545 FdRIngestionActity resolved sonar issues
macacia Nov 27, 2024
cfbdb39
P4ADEV-1545 FdRIngestionActity rename Activity
macacia Nov 28, 2024
d86cf20
P4ADEV-1545 FdRIngestionActity rename Activity
macacia Nov 28, 2024
141cc4b
P4ADEV-1545 ReportingflowIngestionActity added documentation
macacia Nov 28, 2024
7ef1f1f
Merge branch 'main' of https://github.com/pagopa/p4pa-payhub-activiti…
macacia Nov 28, 2024
71c5830
P4ADEV-1545 ReportingFlowIngestionActivity rename Activity
macacia Nov 28, 2024
c1f2cf6
P4ADEV-1545 moved packages
macacia Nov 28, 2024
af747db
feat:P4ADEV-1545-FdRIngestionActity-implementation-retrieval-via-quer…
marcomatteuccieng Nov 28, 2024
81fdcce
P4ADEV-1545 some refactor
macacia Nov 28, 2024
b7bfaef
P4ADEV-1545 fix test
macacia Nov 28, 2024
3ada04e
P4ADEV-1545 added java docs
macacia Nov 28, 2024
bd2bf69
P4ADEV-1545 resolved sonar security issues
macacia Nov 28, 2024
00c89a5
P4ADEV-1545 resolved sonar security issues
macacia Nov 28, 2024
e1ab12c
P4ADEV-1545 fixed
macacia Nov 28, 2024
cad3093
P4ADEV-1545 fixed sonar issues
macacia Nov 28, 2024
c2cbea5
P4ADEV-1545 fixed sonar issues
macacia Nov 28, 2024
cf1d135
P4ADEV-1545 fix to prevent zip bomb
macacia Nov 29, 2024
29ad416
P4ADEV-1545 fix to prevent zip bomb
macacia Nov 29, 2024
ed282f7
P4ADEV-1545 fix
macacia Nov 29, 2024
9ed8d19
Merge remote-tracking branch 'origin/main' into P4ADEV-1545-FdRIngest…
macacia Nov 29, 2024
3628a52
P4ADEV-1545 updated version
macacia Nov 29, 2024
c45eeb5
P4ADEV-1545 fixed sonar issues
macacia Nov 29, 2024
e65f935
P4ADEV-1545 fix sonar issues
macacia Nov 29, 2024
0c319ef
P4ADEV-1545 removed unused declaration
macacia Nov 29, 2024
f373eae
P4ADEV-1545 fixed javadocs
macacia Nov 29, 2024
54f9bee
P4ADEV-1545 resolved requested changes
macacia Dec 3, 2024
aed3a71
P4ADEV-1545 fix on requested changes
macacia Dec 3, 2024
9c5b6ac
P4ADEV-1545 moved variable into constructor
macacia Dec 3, 2024
19e4cd2
P4ADEV-1545 resolved requested changes
macacia Dec 3, 2024
854a661
Merge remote-tracking branch 'origin/main' into P4ADEV-1545-FdRIngest…
macacia Dec 3, 2024
653e8c8
P4ADEV-1545 fix test
macacia Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package it.gov.pagopa.payhub.activities.activity.fdr;
package it.gov.pagopa.payhub.activities.activity.ingestionflow;

/**
* Interface for the UpdateIngestionFlowStatusActivity.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package it.gov.pagopa.payhub.activities.activity.paymentsreporting;
import it.gov.pagopa.payhub.activities.dto.reportingflow.ReportingFlowIngestionActivityResult;

/**
* Interface for the ReportingFlowIngestionActivity.
* Defines methods for processing files based on an IngestionFlow ID.
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*/
public interface ReportingFlowIngestionActivity {
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Processes a file based on the provided IngestionFlow ID.
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* @param ingestionFlowId the unique identifier related to the file to process.
* @return {@link ReportingFlowIngestionActivityResult} containing the list of IUFs and status.
*/
ReportingFlowIngestionActivityResult processFile(String ingestionFlowId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package it.gov.pagopa.payhub.activities.activity.paymentsreporting;

import it.gov.pagopa.payhub.activities.service.ingestionflow.IngestionFileHandlerService;
import it.gov.pagopa.payhub.activities.service.ingestionflow.IngestionFlowRetrieverService;
import it.gov.pagopa.payhub.activities.dto.reportingflow.ReportingFlowIngestionActivityResult;
import it.gov.pagopa.payhub.activities.dto.ingestionflow.IngestionFlowDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
* Implementation of the `ReportingFlowIngestionActivity` interface.
* Manages the ingestion of reporting flow files, including validation and processing.
*/
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
@Slf4j
@Component
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
public class ReportingFlowIngestionActivityImpl implements ReportingFlowIngestionActivity {
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
private final IngestionFlowRetrieverService ingestionFlowRetrieverService;
private final IngestionFileHandlerService ingestionFileHandlerService;

/**
* Constructor for `ReportingFlowIngestionActivityImpl`.
*
* @param ingestionFlowRetrieverService service for retrieving ingestion flow details.
* @param ingestionFileHandlerService service for handling ingestion files.
*/
public ReportingFlowIngestionActivityImpl(IngestionFlowRetrieverService ingestionFlowRetrieverService,
IngestionFileHandlerService ingestionFileHandlerService) {
this.ingestionFlowRetrieverService = ingestionFlowRetrieverService;
this.ingestionFileHandlerService = ingestionFileHandlerService;
}

/**
* Processes an ingestion flow file.
*
* @param ingestionFlowId the ID of the ingestion flow to process.
* @return the result of the ingestion activity, including status and processed items.
*/
@Override
public ReportingFlowIngestionActivityResult processFile(String ingestionFlowId) {
List<String> iufList = new ArrayList<>();
boolean success = true;

try {
IngestionFlowDTO ingestionFlowDTO = ingestionFlowRetrieverService.getIngestionFlow(Long.valueOf(ingestionFlowId));
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
ingestionFileHandlerService.setUpProcess(ingestionFlowDTO.getFilePathName(), ingestionFlowDTO.getFileName());

} catch (Exception e) {
log.error("Error during IngestionActivity flowId {} due to: {}", ingestionFlowId, e.getMessage());
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
success = false;
}
return new ReportingFlowIngestionActivityResult(iufList, success);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package it.gov.pagopa.payhub.activities.activity.fdr;
package it.gov.pagopa.payhub.activities.activity.utility;

/**
* Interface for SendEmailIngestionFlowActivity.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package it.gov.pagopa.payhub.activities.dao;

import it.gov.pagopa.payhub.activities.dto.ingestionflow.IngestionFlowDTO;

import java.util.Optional;

/**
* Data Access Object (DAO) interface for managing ingestion flows.
*
* <p>
* The {@code IngestionFlowDao} provides an abstraction for accessing and manipulating
* ingestion flow data. It focuses on retrieving ingestion flow details from the underlying
* data source using defined operations.
* </p>
*
* <h2>Purpose</h2>
* The interface enables the separation of the data access layer from the business logic layer,
* promoting modularity and testability. It is commonly implemented by a class that interacts
* with a database or other persistent storage mechanism.
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* <h2>Method Details</h2>
* <ul>
* <li>
* <strong>{@code getIngestionFlow(Long ingestionFlowId)}</strong>:
* Fetches an {@link IngestionFlowDTO} entity using its unique identifier.
* <ul>
* <li>Parameter: {@code ingestionFlowId} - The unique ID of the ingestion flow to retrieve.</li>
* <li>Returns: {@code Optional<IngestionFlowDTO>} - An optional containing the ingestion flow data, or empty if not found.</li>
* </ul>
* </li>
* </ul>
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* <h2>Key Features</h2>
* <ul>
* <li>Defines a clear contract for ingestion flow data retrieval.</li>
* <li>Supports returning results in an {@link Optional} to handle absent data gracefully.</li>
* <li>Encourages a clean and maintainable design in data access operations.</li>
* </ul>
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* <h2>Usage Example</h2>
* <pre>{@code
* // Assuming IngestionFlowDao is implemented by a class IngestionFlowDaoImpl
* IngestionFlowDao ingestionFlowDao = new IngestionFlowDaoImpl();
* Long ingestionFlowId = 123L;
* Optional<IngestionFlowDTO> flow = ingestionFlowDao.getIngestionFlow(ingestionFlowId);
*
* flow.ifPresent(f -> System.out.println("Ingestion Flow Retrieved: " + f));
* }</pre>
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* @see IngestionFlowDTO
*/
public interface IngestionFlowDao {
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Retrieves the {@link IngestionFlowDTO} entity based on the provided ingestion flow ID.
*
* @param ingestionFlowId the unique identifier of the ingestion flow to be retrieved.
* @return an {@link Optional} containing the requested {@link IngestionFlowDTO} if found,
* or an empty {@link Optional} if no matching entity exists.
*/
Optional<IngestionFlowDTO> getIngestionFlow(Long ingestionFlowId);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package it.gov.pagopa.payhub.activities.dto.ingestionflow;

import it.gov.pagopa.payhub.activities.dto.OrganizationDTO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.sql.Timestamp;

/**
* Data Transfer Object (DTO) representing the details of an ingestion flow.
*
* <p>
* This class encapsulates metadata and operational details about an ingestion flow,
* serving as a structured data container for various application layers such as
* service, controller, or repository layers.
* </p>
*
* <h2>Purpose</h2>
* The {@code IngestionFlowDTO} provides a standardized way to transfer and manipulate
* information about ingestion flows, which may include details such as the flow's
* identifier, organization, type, timestamps, status, and other relevant metadata.
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* <h2>Annotations</h2>
* <ul>
* <li>{@link lombok.Data} - Generates getter, setter, equals, hashCode, and toString methods.</li>
* <li>{@link lombok.Builder} - Enables the builder pattern for object creation.</li>
* <li>{@link lombok.NoArgsConstructor} - Generates a no-arguments constructor.</li>
* <li>{@link lombok.AllArgsConstructor} - Generates an all-arguments constructor.</li>
* </ul>
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* <h2>Fields</h2>
* <ul>
* <li><strong>ingestionFlowId</strong>: Unique identifier of the ingestion flow.</li>
* <li><strong>version</strong>: Version number of the ingestion flow.</li>
* <li><strong>orgId</strong>: The {@link OrganizationDTO} associated with the ingestion flow.</li>
* <li><strong>PspIdentifier</strong>: Identifier of the Payment Service Provider (PSP) involved.</li>
* <li><strong>flowIdentifierCode</strong>: Code uniquely identifying the ingestion flow.</li>
* <li><strong>flowDateTime</strong>: Timestamp of when the ingestion flow occurred.</li>
* <li><strong>flowType</strong>: Type/category of the ingestion flow.</li>
* <li><strong>flowTypeCode</strong>: Code representing the type of the flow.</li>
* <li><strong>operatorName</strong>: Name of the operator managing the ingestion flow.</li>
* <li><strong>status</strong>: Current status of the ingestion flow (e.g., completed, pending).</li>
* <li><strong>filePathName</strong>: Full path of the file associated with the ingestion flow.</li>
* <li><strong>fileName</strong>: Name of the file associated with the ingestion flow.</li>
* <li><strong>downloadedFileSize</strong>: Size of the file in bytes.</li>
* <li><strong>requestTokenCode</strong>: Token code for the request associated with the ingestion flow.</li>
* <li><strong>creationDate</strong>: Timestamp indicating when the ingestion flow was created.</li>
* <li><strong>lastChangeDate</strong>: Timestamp of the last modification to the ingestion flow.</li>
* <li><strong>fileSourceCode</strong>: Code indicating the source of the file.</li>
* <li><strong>descriptionFileNameScraps</strong>: Additional description or scraps from the file name.</li>
* <li><strong>errorCode</strong>: Code representing any errors encountered during the ingestion process.</li>
* <li><strong>TotalRowsNumber</strong>: Total number of rows in the file.</li>
* <li><strong>numberLinesImportedCorrectly</strong>: Number of rows successfully imported.</li>
* </ul>
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* <h2>Key Features</h2>
* <ul>
* <li>Comprehensive metadata representation for ingestion flows.</li>
* <li>Integration with other DTOs, such as {@link OrganizationDTO}, for structured relationships.</li>
* <li>Leveraging Lombok annotations for concise and maintainable code.</li>
* </ul>
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* @see OrganizationDTO
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class IngestionFlowDTO {
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
private Long ingestionFlowId;
private int version;
private OrganizationDTO orgId;
private String PspIdentifier;
private String flowIdentifierCode;
private Timestamp flowDateTime;
private String flowType;
private String flowTypeCode;
private String operatorName;
private String status;
private String filePathName;
private String fileName;
private Long downloadedFileSize;
private String requestTokenCode;
private Timestamp creationDate;
private Timestamp lastChangeDate;
private String fileSourceCode;
private String descriptionFileNameScraps;
private String errorCode;
private Long TotalRowsNumber;
private Long numberLinesImportedCorrectly;
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package it.gov.pagopa.payhub.activities.dto.fdr;
package it.gov.pagopa.payhub.activities.dto.reportingflow;

antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
import lombok.AllArgsConstructor;
import lombok.Data;
Expand All @@ -12,7 +12,7 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FdRIngestionActivityResult {
public class ReportingFlowIngestionActivityResult {
/** List of extracted IUFs */
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
private List<String> iufs;
/** Success flag for the operation */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
package it.gov.pagopa.payhub.activities.exception;

/**
* A custom exception that represents errors related to activities within an application.
* This exception extends {@link RuntimeException}, allowing it to be thrown during runtime
* without requiring explicit declaration in the method signature.
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* <p>
* The {@code ActivitiesException} is designed to provide a meaningful message about
* what caused the exception, helping developers to debug and understand issues in the
* activity processing flow.
* </p>
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* <h2>Usage</h2>
* <pre>{@code
* if (someConditionFails) {
* throw new ActivitiesException("Activity failed due to some condition.");
* }
* }</pre>
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* <h2>Key Features</h2>
* <ul>
* <li>Extends {@code RuntimeException} for unchecked exception behavior.</li>
* <li>Accepts a detailed message to describe the nature of the error.</li>
* </ul>
*
* @see RuntimeException
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*/
public class ActivitiesException extends RuntimeException {

/**
* Constructs a new {@code ActivitiesException} with the specified detail message.
*
* @param message the detail message explaining the cause of the exception.
*/
public ActivitiesException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package it.gov.pagopa.payhub.activities.exception;

/**
* A custom exception that indicates the absence of an expected ingestion flow
* in the application's processing logic.
*
* <p>
* This exception extends {@link ActivitiesException}, providing a more specific
* exception type within the activities-related exception hierarchy.
* </p>
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*
* <h2>Purpose</h2>
* The {@code IngestionFlowNotFoundException} is thrown when an ingestion flow,
* identified by a specific parameter (e.g., name, ID, or type), cannot be found.
* This can occur in scenarios such as:
* <ul>
* <li>An unregistered or undefined ingestion flow being accessed.</li>
* <li>A misconfiguration in the application's ingestion flow definitions.</li>
* </ul>
*
* <h2>Usage</h2>
* <pre>{@code
* String flowId = "flow123";
* if (!ingestionFlowExists(flowId)) {
* throw new IngestionFlowNotFoundException("Ingestion flow not found: " + flowId);
* }
* }</pre>
*
* <h2>Key Features</h2>
* <ul>
* <li>Extends {@link ActivitiesException}, allowing it to integrate seamlessly into the
* application's exception-handling framework for activity-related errors.</li>
* <li>Accepts a detailed message to describe the nature and context of the error.</li>
* </ul>
*
* @see ActivitiesException
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
*/
public class IngestionFlowNotFoundException extends ActivitiesException {

/**
* Constructs a new {@code IngestionFlowNotFoundException} with the specified detail message.
*
* @param message the detail message explaining the cause of the exception.
*/
public IngestionFlowNotFoundException(String message) {
super(message);
}
}

Loading
Loading