Skip to content

Commit

Permalink
[SELC-5584] Feat: Enabled send event for aggregator (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminiaScarciofolo authored Sep 18, 2024
1 parent ce426fe commit 8fe35fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import java.util.Optional;
import java.util.stream.Collectors;

import static it.pagopa.selfcare.onboarding.utils.Utils.ALLOWED_WORKFLOWS_FOR_INSTITUTION_NOTIFICATIONS;
import static it.pagopa.selfcare.onboarding.utils.Utils.CONTRACT_FILENAME_FUNC;
import static it.pagopa.selfcare.onboarding.utils.Utils.NOT_ALLOWED_WORKFLOWS_FOR_INSTITUTION_NOTIFICATIONS;

@ApplicationScoped
public class OnboardingService {
Expand Down Expand Up @@ -283,7 +283,7 @@ private Document createQuery(String productId, List<OnboardingStatus> status, St
query.append("productId", productId);
query.append("status", new Document("$in", status.stream().map(OnboardingStatus::name).toList()));
if (workflowTypeExist) {
query.append(WORKFLOW_TYPE, new Document("$in", ALLOWED_WORKFLOWS_FOR_INSTITUTION_NOTIFICATIONS.stream().map(Enum::name).toList()));
query.append(WORKFLOW_TYPE, new Document("$nin", NOT_ALLOWED_WORKFLOWS_FOR_INSTITUTION_NOTIFICATIONS.stream().map(Enum::name).toList()));
} else {
query.append(WORKFLOW_TYPE, new Document("$exists", false));
}
Expand Down Expand Up @@ -325,7 +325,7 @@ private Document createQueryByFilters(ResendNotificationsFilters filters) {
}

List<Document> workflowCriteria = new ArrayList<>();
workflowCriteria.add(new Document(WORKFLOW_TYPE, new Document("$in", ALLOWED_WORKFLOWS_FOR_INSTITUTION_NOTIFICATIONS.stream().map(Enum::name).toList())));
workflowCriteria.add(new Document(WORKFLOW_TYPE, new Document("$nin", NOT_ALLOWED_WORKFLOWS_FOR_INSTITUTION_NOTIFICATIONS.stream().map(Enum::name).toList())));
workflowCriteria.add(new Document(WORKFLOW_TYPE, new Document("$exists", false)));
query.append("$or", workflowCriteria);
return query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ private Utils() { }
public static final BinaryOperator<String> CONTRACT_FILENAME_FUNC =
(filename, productName) -> String.format(filename, StringUtils.stripAccents(productName.replaceAll("\\s+","_")));

public static final List<WorkflowType> ALLOWED_WORKFLOWS_FOR_INSTITUTION_NOTIFICATIONS = List.of(
WorkflowType.CONFIRMATION,
WorkflowType.FOR_APPROVE,
WorkflowType.IMPORT,
WorkflowType.CONTRACT_REGISTRATION,
WorkflowType.FOR_APPROVE_PT
public static final List<WorkflowType> NOT_ALLOWED_WORKFLOWS_FOR_INSTITUTION_NOTIFICATIONS = List.of(
WorkflowType.USERS,
WorkflowType.USERS_IMPORT
);

public static Onboarding readOnboardingValue(ObjectMapper objectMapper, String onboardingString) {
Expand Down Expand Up @@ -87,7 +84,7 @@ public static AckPayloadRequest readAckPayloadValue(ObjectMapper objectMapper, S
}

public static boolean isNotInstitutionOnboarding(Onboarding onboarding) {
return Objects.nonNull(onboarding.getWorkflowType()) && !ALLOWED_WORKFLOWS_FOR_INSTITUTION_NOTIFICATIONS.contains(onboarding.getWorkflowType());
return Objects.nonNull(onboarding.getWorkflowType()) && NOT_ALLOWED_WORKFLOWS_FOR_INSTITUTION_NOTIFICATIONS.contains(onboarding.getWorkflowType());
}

public static String getOnboardingAggregateString(ObjectMapper objectMapper, OnboardingAggregateOrchestratorInput onboarding) {
Expand Down

0 comments on commit 8fe35fd

Please sign in to comment.