generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:pagopa/selfcare-onboarding into EC-…
…96-pipeline-deployment-con-supporto-ambienti
- Loading branch information
Showing
13 changed files
with
350 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 0 additions & 123 deletions
123
.../src/main/java/it/pagopa/selfcare/onboarding/functions/OnboardingCompletionFunctions.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...g-functions/src/main/java/it/pagopa/selfcare/onboarding/functions/utils/ActivityName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package it.pagopa.selfcare.onboarding.functions.utils; | ||
|
||
public class ActivityName { | ||
|
||
public static final String SAVE_TOKEN_WITH_CONTRACT_ACTIVITY_NAME = "SaveTokenWithContract"; | ||
public static final String BUILD_CONTRACT_ACTIVITY_NAME = "BuildContract"; | ||
public static final String SEND_MAIL_REGISTRATION_WITH_CONTRACT_ACTIVITY = "SendMailRegistrationWithContract"; | ||
|
||
public static final String SEND_MAIL_REGISTRATION_WITH_CONTRACT_WHEN_APPROVE_ACTIVITY = "SendMailRegistrationWithContractWhenApprove"; | ||
public static final String SEND_MAIL_REGISTRATION_REQUEST_ACTIVITY = "SendMailRegistrationRequest"; | ||
public static final String SEND_MAIL_REGISTRATION_APPROVE_ACTIVITY = "SendMailRegistrationApprove"; | ||
public static final String SEND_MAIL_ONBOARDING_APPROVE_ACTIVITY = "SendMailOnboardingApprove"; | ||
public static final String SEND_MAIL_CONFIRMATION_ACTIVITY = "SendMailConfirmation"; | ||
|
||
|
||
public static final String ONBOARDING_COMPLETION_ACTIVITY = "OnboardingCompletion"; | ||
public static final String CREATE_INSTITUTION_ACTIVITY = "CreateInstitution"; | ||
public static final String CREATE_ONBOARDING_ACTIVITY = "CreateOnboarding"; | ||
public static final String SEND_MAIL_COMPLETION_ACTIVITY = "SendMailCompletion"; | ||
} |
46 changes: 46 additions & 0 deletions
46
...ding-functions/src/main/java/it/pagopa/selfcare/onboarding/workflow/WorkflowExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package it.pagopa.selfcare.onboarding.workflow; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.microsoft.durabletask.TaskOptions; | ||
import com.microsoft.durabletask.TaskOrchestrationContext; | ||
import it.pagopa.selfcare.onboarding.common.OnboardingStatus; | ||
import it.pagopa.selfcare.onboarding.entity.Onboarding; | ||
import it.pagopa.selfcare.onboarding.functions.utils.SaveOnboardingStatusInput; | ||
|
||
import static it.pagopa.selfcare.onboarding.functions.CommonFunctions.SAVE_ONBOARDING_STATUS_ACTIVITY; | ||
import static it.pagopa.selfcare.onboarding.functions.utils.ActivityName.*; | ||
import static it.pagopa.selfcare.onboarding.utils.Utils.getOnboardingString; | ||
|
||
public interface WorkflowExecutor { | ||
|
||
void executeRequestState(TaskOrchestrationContext ctx, Onboarding onboarding); | ||
void executeToBeValidatedState(TaskOrchestrationContext ctx, Onboarding onboarding); | ||
|
||
ObjectMapper objectMapper(); | ||
|
||
TaskOptions optionsRetry(); | ||
|
||
default void execute(TaskOrchestrationContext ctx, Onboarding onboarding){ | ||
switch (onboarding.getStatus()){ | ||
case REQUEST -> executeRequestState(ctx, onboarding); | ||
case TO_BE_VALIDATED -> executeToBeValidatedState(ctx, onboarding); | ||
case PENDING -> executePendingState(ctx, onboarding); | ||
} | ||
} | ||
|
||
default void executePendingState(TaskOrchestrationContext ctx, Onboarding onboarding) { | ||
String onboardingString = getOnboardingString(objectMapper(), onboarding); | ||
|
||
//CreateInstitution activity return an institutionId that is used by CreateOnboarding activity | ||
String institutionId = ctx.callActivity(CREATE_INSTITUTION_ACTIVITY, onboardingString, optionsRetry(), String.class).await(); | ||
onboarding.getInstitution().setId(institutionId); | ||
onboardingString = getOnboardingString(objectMapper(), onboarding); | ||
|
||
ctx.callActivity(CREATE_ONBOARDING_ACTIVITY, onboardingString, optionsRetry(), String.class).await(); | ||
ctx.callActivity(SEND_MAIL_COMPLETION_ACTIVITY, onboardingString, optionsRetry(), String.class).await(); | ||
|
||
//Last activity consist of saving pending status | ||
String saveOnboardingStatusInput = SaveOnboardingStatusInput.buildAsJsonString(onboarding.getOnboardingId(), OnboardingStatus.COMPLETED.name()); | ||
ctx.callActivity(SAVE_ONBOARDING_STATUS_ACTIVITY, saveOnboardingStatusInput, optionsRetry(), String.class).await(); | ||
} | ||
} |
Oops, something went wrong.