Skip to content

Commit

Permalink
Merge branch 'main' into feature/SELC-6157
Browse files Browse the repository at this point in the history
  • Loading branch information
giampieroferrara committed Dec 12, 2024
2 parents 6a4aa5d + 2f236fa commit 4715326
Show file tree
Hide file tree
Showing 23 changed files with 362 additions and 287 deletions.
2 changes: 1 addition & 1 deletion apps/onboarding-functions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<skipITs>true</skipITs>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<commons-sdk-version>0.6.1</commons-sdk-version>
<commons-sdk-version>0.6.2</commons-sdk-version>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@
import java.util.Optional;

import static it.pagopa.selfcare.onboarding.entity.OnboardingWorkflowType.INSTITUTION;
import static it.pagopa.selfcare.onboarding.functions.utils.ActivityName.*;
import static it.pagopa.selfcare.onboarding.utils.Utils.getOnboardingWorkflowString;

public record WorkflowExecutorConfirmation(ObjectMapper objectMapper, TaskOptions optionsRetry) implements WorkflowExecutor {
public record WorkflowExecutorConfirmation(ObjectMapper objectMapper,
TaskOptions optionsRetry) implements WorkflowExecutor {

@Override
public Optional<OnboardingStatus> executeRequestState(TaskOrchestrationContext ctx, OnboardingWorkflow onboardingWorkflow) {
return Optional.empty();
String onboardingWorkflowString = getOnboardingWorkflowString(objectMapper, onboardingWorkflow);
ctx.callActivity(BUILD_CONTRACT_ACTIVITY_NAME, onboardingWorkflowString, optionsRetry, String.class).await();
ctx.callActivity(SAVE_TOKEN_WITH_CONTRACT_ACTIVITY_NAME, onboardingWorkflowString, optionsRetry, String.class).await();
return Optional.of(OnboardingStatus.PENDING);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion apps/onboarding-ms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<skipITs>true</skipITs>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<quarkus-openapi-generator.version>2.4.1</quarkus-openapi-generator.version>
<commons-sdk-version>0.6.1</commons-sdk-version>
<commons-sdk-version>0.6.2</commons-sdk-version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down
63 changes: 12 additions & 51 deletions apps/onboarding-ms/src/main/docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,24 +502,9 @@
"operationId" : "onboardingCompletion",
"requestBody" : {
"content" : {
"multipart/form-data" : {
"application/json" : {
"schema" : {
"required" : [ "contract" ],
"type" : "object",
"properties" : {
"onboardingRequest" : {
"$ref" : "#/components/schemas/OnboardingDefaultRequest"
},
"contract" : {
"format" : "binary",
"type" : "string"
}
}
},
"encoding" : {
"onboardingRequest" : {
"contentType" : "application/json"
}
"$ref" : "#/components/schemas/OnboardingDefaultRequest"
}
}
}
Expand Down Expand Up @@ -695,24 +680,9 @@
"operationId" : "onboardingPaCompletion",
"requestBody" : {
"content" : {
"multipart/form-data" : {
"application/json" : {
"schema" : {
"required" : [ "contract" ],
"type" : "object",
"properties" : {
"onboardingRequest" : {
"$ref" : "#/components/schemas/OnboardingPaRequest"
},
"contract" : {
"format" : "binary",
"type" : "string"
}
}
},
"encoding" : {
"onboardingRequest" : {
"contentType" : "application/json"
}
"$ref" : "#/components/schemas/OnboardingPaRequest"
}
}
}
Expand Down Expand Up @@ -862,24 +832,9 @@
"operationId" : "onboardingPspCompletion",
"requestBody" : {
"content" : {
"multipart/form-data" : {
"application/json" : {
"schema" : {
"required" : [ "contract" ],
"type" : "object",
"properties" : {
"onboardingRequest" : {
"$ref" : "#/components/schemas/OnboardingPspRequest"
},
"contract" : {
"format" : "binary",
"type" : "string"
}
}
},
"encoding" : {
"onboardingRequest" : {
"contentType" : "application/json"
}
"$ref" : "#/components/schemas/OnboardingPspRequest"
}
}
}
Expand Down Expand Up @@ -1979,6 +1934,9 @@
"legalRegisterName" : {
"type" : "string"
},
"longTermPayments" : {
"type" : "boolean"
},
"manager" : {
"type" : "boolean"
},
Expand Down Expand Up @@ -2746,6 +2704,9 @@
"legalRegisterName" : {
"type" : "string"
},
"longTermPayments" : {
"type" : "boolean"
},
"abiCode" : {
"type" : "string"
},
Expand Down
49 changes: 10 additions & 39 deletions apps/onboarding-ms/src/main/docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,9 @@ paths:
operationId: onboardingCompletion
requestBody:
content:
multipart/form-data:
application/json:
schema:
required:
- contract
type: object
properties:
onboardingRequest:
$ref: "#/components/schemas/OnboardingDefaultRequest"
contract:
format: binary
type: string
encoding:
onboardingRequest:
contentType: application/json
$ref: "#/components/schemas/OnboardingDefaultRequest"
responses:
"200":
description: OK
Expand Down Expand Up @@ -511,20 +500,9 @@ paths:
operationId: onboardingPaCompletion
requestBody:
content:
multipart/form-data:
application/json:
schema:
required:
- contract
type: object
properties:
onboardingRequest:
$ref: "#/components/schemas/OnboardingPaRequest"
contract:
format: binary
type: string
encoding:
onboardingRequest:
contentType: application/json
$ref: "#/components/schemas/OnboardingPaRequest"
responses:
"200":
description: OK
Expand Down Expand Up @@ -631,20 +609,9 @@ paths:
operationId: onboardingPspCompletion
requestBody:
content:
multipart/form-data:
application/json:
schema:
required:
- contract
type: object
properties:
onboardingRequest:
$ref: "#/components/schemas/OnboardingPspRequest"
contract:
format: binary
type: string
encoding:
onboardingRequest:
contentType: application/json
$ref: "#/components/schemas/OnboardingPspRequest"
responses:
"200":
description: OK
Expand Down Expand Up @@ -1438,6 +1405,8 @@ components:
type: string
legalRegisterName:
type: string
longTermPayments:
type: boolean
manager:
type: boolean
managerAuthorized:
Expand Down Expand Up @@ -2027,6 +1996,8 @@ components:
type: string
legalRegisterName:
type: string
longTermPayments:
type: boolean
abiCode:
type: string
vatNumberGroup:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.resteasy.reactive.PartType;
import org.jboss.resteasy.reactive.RestForm;
import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext;

Expand Down Expand Up @@ -172,21 +171,12 @@ public Uni<OnboardingResponse> onboardingPsp(@Valid OnboardingPspRequest onboard
@POST
@Tag(name = "Onboarding Controller")
@Tag(name = "internal-v1")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Uni<OnboardingResponse> onboardingCompletion(
@NotNull @RestForm("contract") File file,
@NotNull @FormParam("onboardingRequest") @PartType(MediaType.APPLICATION_JSON) OnboardingDefaultRequest onboardingRequest,
@Context ResteasyReactiveRequestContext ctx,
@Context SecurityContext securityContext) {

return readUserIdFromToken(securityContext)
.onItem()
.transformToUni(
userId -> onboardingService.onboardingCompletion(
fillUserId(onboardingMapper.toEntity(onboardingRequest), userId),
onboardingRequest.getUsers(),
retrieveContractFromFormData(ctx.getFormData(), file)));
public Uni<OnboardingResponse> onboardingCompletion(@Valid OnboardingDefaultRequest onboardingRequest, @Context SecurityContext ctx) {
return readUserIdFromToken(ctx)
.onItem().transformToUni(userId -> onboardingService
.onboardingCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers()));
}

@Operation(
Expand All @@ -197,21 +187,12 @@ public Uni<OnboardingResponse> onboardingCompletion(
@Path("/pa/completion")
@Tag(name = "Onboarding Controller")
@Tag(name = "internal-v1")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Uni<OnboardingResponse> onboardingPaCompletion(
@NotNull @RestForm("contract") File file,
@NotNull @FormParam("onboardingRequest") @PartType(MediaType.APPLICATION_JSON) OnboardingPaRequest onboardingRequest,
@Context ResteasyReactiveRequestContext ctx,
@Context SecurityContext securityContext) {

return readUserIdFromToken(securityContext)
.onItem()
.transformToUni(
userId -> onboardingService.onboardingCompletion(
fillUserId(onboardingMapper.toEntity(onboardingRequest), userId),
onboardingRequest.getUsers(),
retrieveContractFromFormData(ctx.getFormData(), file)));
public Uni<OnboardingResponse> onboardingPaCompletion(@Valid OnboardingPaRequest onboardingRequest, @Context SecurityContext ctx) {
return readUserIdFromToken(ctx)
.onItem().transformToUni(userId -> onboardingService
.onboardingCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers()));
}

@Operation(
Expand Down Expand Up @@ -250,21 +231,12 @@ public Uni<OnboardingResponse> onboardingPspImport(@Valid OnboardingImportPspReq
@Path("/psp/completion")
@Tag(name = "Onboarding Controller")
@Tag(name = "internal-v1")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Uni<OnboardingResponse> onboardingPspCompletion(
@NotNull @RestForm("contract") File file,
@NotNull @FormParam("onboardingRequest") @PartType(MediaType.APPLICATION_JSON) OnboardingPspRequest onboardingRequest,
@Context ResteasyReactiveRequestContext ctx,
@Context SecurityContext securityContext) {

return readUserIdFromToken(securityContext)
.onItem()
.transformToUni(
userId -> onboardingService.onboardingCompletion(
fillUserId(onboardingMapper.toEntity(onboardingRequest), userId),
onboardingRequest.getUsers(),
retrieveContractFromFormData(ctx.getFormData(), file)));
public Uni<OnboardingResponse> onboardingPspCompletion(@Valid OnboardingPspRequest onboardingRequest, @Context SecurityContext ctx) {
return readUserIdFromToken(ctx)
.onItem().transformToUni(userId -> onboardingService
.onboardingCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers()));
}

@Operation(
Expand All @@ -280,7 +252,7 @@ public Uni<OnboardingResponse> onboardingPspCompletion(
public Uni<OnboardingResponse> onboardingPgCompletion(@Valid OnboardingPgRequest onboardingRequest, @Context SecurityContext ctx) {
return readUserIdFromToken(ctx)
.onItem().transformToUni(userId -> onboardingService
.onboardingCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers(), null));
.onboardingPgCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers()));
}

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class BusinessData {
private String businessRegisterNumber;
private String legalRegisterNumber;
private String legalRegisterName;
private boolean longTermPayments;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public Uni<Onboarding> customValidation(Product product) {
onboarding.getInstitution().getTaxCode(),
onboarding.getProductId()), DEFAULT_ERROR.getCode());
}
return Uni.createFrom().item(onboarding);

return super.customValidation(product);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package it.pagopa.selfcare.onboarding.entity.registry;

import io.smallrye.mutiny.Uni;
import it.pagopa.selfcare.onboarding.common.Origin;
import it.pagopa.selfcare.onboarding.common.WorkflowType;
import it.pagopa.selfcare.onboarding.entity.Onboarding;
import it.pagopa.selfcare.onboarding.exception.InvalidRequestException;
import it.pagopa.selfcare.product.entity.Product;

public class RegistryManagerSELC extends BaseRegistryManager<Object> {
Expand All @@ -11,12 +14,28 @@ public RegistryManagerSELC(Onboarding onboarding) {
}

public Object retrieveInstitution() {
return Uni.createFrom().item(new Object());
setDefaultOriginAndOriginId();
return Uni.createFrom().item(new Object());
}

private void setDefaultOriginAndOriginId() {
onboarding.getInstitution().setOriginId(onboarding.getInstitution().getTaxCode());
onboarding.getInstitution().setOrigin(Origin.SELC);
}

@Override
public Uni<Onboarding> customValidation(Product product) {
return Uni.createFrom().item(onboarding);
if (isWorkflowTypeAllowed(onboarding.getWorkflowType())) {
return Uni.createFrom().item(onboarding);
}

return Uni.createFrom().failure(new InvalidRequestException("Invalid workflow type for origin SELC"));
}

protected boolean isWorkflowTypeAllowed(WorkflowType workflowType) {
return workflowType == WorkflowType.FOR_APPROVE ||
workflowType == WorkflowType.IMPORT ||
workflowType == WorkflowType.FOR_APPROVE_PT;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ Uni<OnboardingResponse> onboardingImport(
boolean forceImport);

Uni<OnboardingResponse> onboardingCompletion(
Onboarding onboarding, List<UserRequest> userRequests, FormItem formItem);
Onboarding onboarding, List<UserRequest> userRequests);

Uni<OnboardingResponse> onboardingPgCompletion(
Onboarding onboarding, List<UserRequest> userRequests);

Uni<OnboardingResponse> onboardingAggregationCompletion(
Onboarding onboarding,
Expand Down
Loading

0 comments on commit 4715326

Please sign in to comment.