-
Notifications
You must be signed in to change notification settings - Fork 2
Hdpi 6585 new claim create new hearing #2198
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
Open
gmmagruder
wants to merge
41
commits into
HDPI-wa-preview-chart
Choose a base branch
from
HDPI-6585-new-claim-create-new-hearing
base: HDPI-wa-preview-chart
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
a2dfcc2
HDPI-6585: add camunda api, task creation and dmns
gmmagruder ae67522
HDPI-6585: add configuration dmn
gmmagruder fe7c854
HDPI-6585: add unit test to camunda service
gmmagruder d4f6968
HDPI-6585: add feature flag and camunda url
gmmagruder b0d233c
HDPI-6585: add access for WA user
gmmagruder 57ca7ab
Merge branch 'HDPI-wa-preview-chart' into HDPI-6585-new-claim-create-…
scottstewart-sl 8e6c889
Merge branch 'HDPI-wa-preview-chart' into HDPI-6585-new-claim-create-…
scottstewart-sl 5d801f2
Merge branch 'master' into HDPI-6585-new-claim-create-new-hearing
gmmagruder 98810ba
HDPI-6585: add feature flag to CamundaService
gmmagruder 96cb778
HDPI-6501: fix checkstyle
gmmagruder 853b1c7
HDPI-6501: add task creation to notify case issued event
gmmagruder 1aed3cd
HDPI-6501: add role assignment url
gmmagruder e23dda0
HDPI-6501: add publish to camunda and add role assignment url to wa-t…
gmmagruder 6bf7728
HDPI-6585: add service bus to ccd preview
gmmagruder 471dc33
HDPI-6585: update cron job config
gmmagruder d6786ba
HDPI-6585: reverse changes
gmmagruder 576668a
HDPI-6585: stop suspension of cron jobs
gmmagruder 222c443
HDPI-6585: add WA access to more states
gmmagruder 716b22a
HDPI-6585: add WA access to more states
gmmagruder f95cde5
HDPI-6585: remove WA access to property address
gmmagruder 5b486c2
HDPI-6585: increase WA access to fields in PCS case
gmmagruder 323e326
HDPI-6585: add WA access to AWAITING_SUBMISSION_TO_HMCTS
gmmagruder 82a4575
HDPI-6585: increase WA access
gmmagruder dd8a2fa
HDPI-6585: specify camunda version to fix bpm upload problem
gmmagruder ddce3bc
HDPI-6585: reverse change to image version
gmmagruder cb056d4
HDPI-6585: change to a different camunda version
gmmagruder f583ebf
HDPI-6585: add caseworker access profile
gmmagruder 0d811e6
HDPI-6585: fix merge conflicts
gmmagruder e0e2ff0
HDPI-6585: add interval days and move service bus config to applicati…
gmmagruder f5392be
HDPI-6585: add definition-snapshots to dockerfile
gmmagruder d6dcd28
HDPI-6585: add depend on dumpCCDDefinitions
gmmagruder ea78b96
HDPI-6585: reverse changes to Dockerfile
gmmagruder a4093c3
HDPI-6585: programmatically send cancel task message
gmmagruder 7f7fc6a
HDPI-6585: fix unit test
gmmagruder 89d4b27
HDPI-6585: use task id for process categories and add unit test
gmmagruder ce6fde9
HDPI-6585: update dmns and remove service bus config
gmmagruder 701a2d0
HDPI-6585: update dmn id
gmmagruder 88dda10
HDPI-6585: Schedule Camunda task creation via db-scheduler (#2258)
scottstewart-sl 7c847de
HDPI-6585: remove feature flag show condition and add CAMUNDA_BASE_UR…
gmmagruder 75ef882
HDPI-6585: disableActiveClusterCheck and set suspend to false
gmmagruder bed6271
HDPI-6585: reverse change to dmn
gmmagruder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,30 +1,6 @@ | ||
| java: | ||
| secrets: | ||
| AZURE_SERVICE_BUS_CONNECTION_STRING: | ||
| secretRef: pcs-sb-preview | ||
| key: connectionString | ||
| AZURE_SERVICE_BUS_PREVIEW_CONNECTION_STRING: | ||
| secretRef: pcs-sb-preview | ||
| key: connectionString | ||
| environment: | ||
| SPRING_JMS_SERVICEBUS_ENABLED: true | ||
| AZURE_SERVICE_BUS_TOPIC_NAME: ${SERVICE_NAME}-asb-ccd-case-events | ||
| AZURE_SERVICE_BUS_SUBSCRIPTION_NAME: ${SERVICE_NAME}-asb-ccd-case-events | ||
|
|
||
| servicebus: | ||
| enabled: true | ||
| releaseNameOverride: ${SERVICE_NAME}-asb | ||
| resourceGroup: pcs-aso-preview-rg | ||
| sbNamespace: pcs-servicebus-preview | ||
| setup: | ||
| topics: | ||
| - name: crd-topic | ||
| subscriptionNeeded: yes | ||
| - name: jrd-topic | ||
| subscriptionNeeded: yes | ||
| - name: ccd-case-events | ||
| subscriptionNeeded: yes | ||
| requiresSession: true | ||
| CAMUNDA_BASE_URL: http://pcs-api-pr-${CHANGE_ID}-camunda/engine-rest | ||
|
scottstewart-sl marked this conversation as resolved.
|
||
|
|
||
| postgresql: | ||
| enabled: true | ||
|
|
@@ -52,7 +28,7 @@ wa: | |
|
|
||
| camunda-bpm: | ||
| java: | ||
| image: hmctsprod.azurecr.io/camunda/bpm:latest | ||
| image: hmctsprod.azurecr.io/camunda/bpm:pr-1025 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be reversed |
||
|
|
||
| wa-case-event-handler: | ||
| java: | ||
|
|
@@ -64,6 +40,7 @@ wa: | |
| AZURE_SERVICE_BUS_TOPIC_NAME: ${SERVICE_NAME}-asb-ccd-case-events | ||
| AZURE_SERVICE_BUS_SUBSCRIPTION_NAME: ${SERVICE_NAME}-asb-ccd-case-events | ||
| AZURE_SERVICE_BUS_CCD_CASE_EVENTS_SUBSCRIPTION_NAME: ${SERVICE_NAME}-asb-ccd-case-events | ||
| ROLE_ASSIGNMENT_URL: http://am-role-assignment-service-aat.service.core-compute-aat.internal | ||
| keyVaults: | ||
| wa: | ||
| secrets: | ||
|
|
@@ -80,8 +57,9 @@ wa: | |
| java: | ||
| ingressHost: wa-task-management-api-${SERVICE_FQDN} | ||
| environment: | ||
| ALLOWED_CASE_TYPES: pcs-${CHANGE_ID} | ||
| ALLOWED_CASE_TYPES: pcs | ||
| ALLOWED_JURISDICTIONS: pcs | ||
| ROLE_ASSIGNMENT_URL: http://am-role-assignment-service-aat.service.core-compute-aat.internal | ||
| keyVaults: | ||
| wa: | ||
| secrets: | ||
|
|
@@ -136,6 +114,8 @@ wa: | |
| wa-initiation-batch: | ||
| job: | ||
| schedule: "*/1 * * * *" | ||
| disableActiveClusterCheck: true | ||
| suspend: false | ||
|
|
||
| wa-reconfiguration-batch: | ||
| job: | ||
|
|
@@ -144,6 +124,8 @@ wa: | |
| wa-termination-batch: | ||
| job: | ||
| schedule: "*/1 * * * *" | ||
| disableActiveClusterCheck: true | ||
| suspend: false | ||
|
|
||
| #disable wa db as we are using the postgres flexible server | ||
| wa: | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
19 changes: 19 additions & 0 deletions
19
src/main/java/uk/gov/hmcts/reform/pcs/camunda/CamundaApi.java
This file contains hidden or 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,19 @@ | ||
| package uk.gov.hmcts.reform.pcs.camunda; | ||
|
|
||
| import org.springframework.cloud.openfeign.FeignClient; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestHeader; | ||
|
|
||
| @FeignClient(name = "camunda", url = "${camunda.url}") | ||
| public interface CamundaApi { | ||
| String SERVICE_AUTHORIZATION = "ServiceAuthorization"; | ||
|
|
||
| @PostMapping( | ||
| value = "/message", | ||
| consumes = MediaType.APPLICATION_JSON_VALUE, | ||
| produces = MediaType.APPLICATION_JSON_VALUE) | ||
| void sendMessage(@RequestHeader(SERVICE_AUTHORIZATION) String serviceAuthorisation, | ||
| SendMessageRequest sendMessageRequest); | ||
|
|
||
| } |
63 changes: 63 additions & 0 deletions
63
src/main/java/uk/gov/hmcts/reform/pcs/camunda/CamundaRequestTaskComponent.java
This file contains hidden or 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,63 @@ | ||
| package uk.gov.hmcts.reform.pcs.camunda; | ||
|
|
||
| import com.github.kagkarlsson.scheduler.task.CompletionHandler; | ||
| import com.github.kagkarlsson.scheduler.task.FailureHandler; | ||
| import com.github.kagkarlsson.scheduler.task.TaskDescriptor; | ||
| import com.github.kagkarlsson.scheduler.task.helper.CustomTask; | ||
| import com.github.kagkarlsson.scheduler.task.helper.Tasks; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| public class CamundaRequestTaskComponent { | ||
|
|
||
| private static final String CAMUNDA_REQUEST_TASK_NAME = "camunda-request-task"; | ||
|
|
||
| public static final TaskDescriptor<CamundaRequestTaskData> CAMUNDA_REQUEST_TASK_DESCRIPTOR = | ||
| TaskDescriptor.of(CAMUNDA_REQUEST_TASK_NAME, CamundaRequestTaskData.class); | ||
|
|
||
| private final CamundaService camundaService; | ||
| private final int maxRetries; | ||
| private final Duration backoffDelay; | ||
|
|
||
| public CamundaRequestTaskComponent(CamundaService camundaService, | ||
| @Value("${camunda.request.max-retries}") int maxRetries, | ||
| @Value("${camunda.request.backoff-delay-duration}") Duration backoffDelay) { | ||
|
|
||
| this.camundaService = camundaService; | ||
| this.maxRetries = maxRetries; | ||
| this.backoffDelay = backoffDelay; | ||
| } | ||
|
|
||
| @Bean | ||
| public CustomTask<CamundaRequestTaskData> camundaRequestTask() { | ||
| return Tasks.custom(CAMUNDA_REQUEST_TASK_DESCRIPTOR) | ||
| .onFailure( | ||
| FailureHandler.<CamundaRequestTaskData>maxRetries(maxRetries) | ||
| .withBackoff(backoffDelay) | ||
| .thenRemove(complete -> | ||
| log.warn( | ||
| "Execution has failed {} times. Giving up.", | ||
| complete.getExecution().consecutiveFailures | ||
| ) | ||
| )) | ||
| .execute((taskInstance, executionContext) -> { | ||
| CamundaRequestTaskData taskData = taskInstance.getData(); | ||
| log.debug("Executing Camunda request task for {}", taskData); | ||
| try { | ||
| camundaService.handleRequest(taskData); | ||
| return new CompletionHandler.OnCompleteRemove<>(); | ||
| } catch (Exception e) { | ||
| log.error("Failed to create Camunda request for: {}. Attempt {}/{}", | ||
| taskData, executionContext.getExecution().consecutiveFailures + 1, maxRetries, e); | ||
| throw e; | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| } |
23 changes: 23 additions & 0 deletions
23
src/main/java/uk/gov/hmcts/reform/pcs/camunda/CamundaRequestTaskData.java
This file contains hidden or 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,23 @@ | ||
| package uk.gov.hmcts.reform.pcs.camunda; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| @Builder | ||
| @AllArgsConstructor | ||
| public class CamundaRequestTaskData { | ||
|
|
||
| enum Action { | ||
| CREATE, | ||
| CANCEL | ||
| } | ||
|
|
||
| private final Action action; | ||
|
|
||
| private final long caseReference; | ||
|
|
||
| private final TaskType taskType; | ||
|
|
||
| } |
152 changes: 152 additions & 0 deletions
152
src/main/java/uk/gov/hmcts/reform/pcs/camunda/CamundaService.java
This file contains hidden or 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,152 @@ | ||
| package uk.gov.hmcts.reform.pcs.camunda; | ||
|
|
||
| import com.github.kagkarlsson.scheduler.SchedulerClient; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Service; | ||
| import uk.gov.hmcts.reform.authorisation.generators.AuthTokenGenerator; | ||
| import uk.gov.hmcts.reform.pcs.camunda.CamundaRequestTaskData.Action; | ||
| import uk.gov.hmcts.reform.pcs.ccd.CaseType; | ||
| import uk.gov.hmcts.reform.pcs.service.FeatureFlag; | ||
| import uk.gov.hmcts.reform.pcs.service.FeatureToggleService; | ||
|
|
||
| import java.time.Clock; | ||
| import java.time.Instant; | ||
| import java.time.LocalDateTime; | ||
| import java.util.Map; | ||
| import java.util.UUID; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
||
| import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE_TIME; | ||
| import static uk.gov.hmcts.reform.pcs.camunda.CamundaRequestTaskComponent.CAMUNDA_REQUEST_TASK_DESCRIPTOR; | ||
|
|
||
| @Slf4j | ||
| @AllArgsConstructor | ||
| @Service | ||
| public class CamundaService { | ||
|
|
||
| private final CamundaApi camundaApi; | ||
| private final AuthTokenGenerator authTokenGenerator; | ||
| private final SchedulerClient schedulerClient; | ||
| private final FeatureToggleService featureToggleService; | ||
|
|
||
| private static final String CREATE = "createTaskMessage"; | ||
| private static final String CANCEL = "cancelTasks"; | ||
| private static final String UNCONFIGURED = "unconfigured"; | ||
| private static final String EMPTY_WARNINGS_LIST = "[]"; | ||
| private static final String CANCELLATION_PROCESS = "CASE_EVENT_CANCELLATION"; | ||
| private final Clock utcClock; | ||
|
|
||
| public void createTask(long caseId, TaskType taskType) { | ||
| scheduleCamundaRequest(Action.CREATE, caseId, taskType); | ||
| } | ||
|
|
||
| public void cancelTask(long caseId, TaskType taskType) { | ||
| scheduleCamundaRequest(Action.CANCEL, caseId, taskType); | ||
| } | ||
|
|
||
| void handleRequest(CamundaRequestTaskData taskData) { | ||
| switch (taskData.getAction()) { | ||
| case CREATE -> requestTaskCreation(taskData.getCaseReference(), taskData.getTaskType()); | ||
| case CANCEL -> requestTaskCancellation(taskData.getCaseReference(), taskData.getTaskType()); | ||
| } | ||
| } | ||
|
|
||
| private void scheduleCamundaRequest(Action action, long caseId, TaskType taskType) { | ||
| if (!featureToggleService.isEnabled(FeatureFlag.CASEWORKER_WA)) { | ||
| log.info("Skipped scheduling Camunda request for {}", caseId); | ||
| return; | ||
| } | ||
|
|
||
| CamundaRequestTaskData taskData = CamundaRequestTaskData.builder() | ||
| .action(action) | ||
| .caseReference(caseId) | ||
| .taskType(taskType) | ||
| .build(); | ||
|
|
||
| schedulerClient.scheduleIfNotExists( | ||
| CAMUNDA_REQUEST_TASK_DESCRIPTOR | ||
| .instance(UUID.randomUUID().toString()) | ||
| .data(taskData) | ||
| .scheduledTo(Instant.now(utcClock))); | ||
| } | ||
|
|
||
| private void requestTaskCreation(Long caseId, TaskType taskType) { | ||
| if (!featureToggleService.isEnabled(FeatureFlag.CASEWORKER_WA)) { | ||
| log.info("Skipped creating task for {}", caseId); | ||
| return; | ||
| } | ||
|
|
||
| log.info("Creating task for {}", caseId); | ||
| Map<String, DmnValue<?>> processVariables = new ConcurrentHashMap<>(); | ||
|
|
||
| LocalDateTime delayUntil = LocalDateTime.now(utcClock); | ||
| LocalDateTime dueDate = delayUntil.plusDays(taskType.getWorkingDays()); | ||
|
|
||
| processVariables.put("taskState", dmnStringValue(UNCONFIGURED)); | ||
| processVariables.put("caseTypeId", dmnStringValue(CaseType.getCaseType())); | ||
| processVariables.put("dueDate", dmnStringValue(dueDate.format(ISO_LOCAL_DATE_TIME))); | ||
| processVariables.put("workingDaysAllowed", dmnIntegerValue(taskType.getWorkingDays())); | ||
| processVariables.put("jurisdiction", dmnStringValue(CaseType.getJurisdictionId())); | ||
| processVariables.put("name", dmnStringValue(taskType.getName())); | ||
| processVariables.put("taskId", dmnStringValue(taskType.getId())); | ||
| processVariables.put("caseId", dmnStringValue(caseId.toString())); | ||
| processVariables.put("delayUntil", dmnStringValue(delayUntil.format(ISO_LOCAL_DATE_TIME))); | ||
| processVariables.put("hasWarnings", dmnBooleanValue(false)); | ||
| processVariables.put("warningList", dmnStringValue(EMPTY_WARNINGS_LIST)); | ||
| processVariables.put("__processCategory__" + taskType.getId(), dmnBooleanValue(true)); | ||
|
|
||
| SendMessageRequest request = SendMessageRequest.builder() | ||
| .messageName(CREATE) | ||
| .processVariables(processVariables) | ||
| .build(); | ||
|
|
||
| sendCamundaRequest(request, caseId); | ||
| } | ||
|
|
||
| private void requestTaskCancellation(Long caseId, TaskType taskType) { | ||
| if (!featureToggleService.isEnabled(FeatureFlag.CASEWORKER_WA)) { | ||
| log.info("Skipped cancelling task for {}", caseId); | ||
| return; | ||
| } | ||
|
|
||
| Map<String, DmnValue<?>> correlationKeys = new ConcurrentHashMap<>(); | ||
| correlationKeys.put("caseId", dmnStringValue(caseId.toString())); | ||
| correlationKeys.put("__processCategory__" + taskType.getId(), dmnBooleanValue(true)); | ||
|
|
||
| Map<String, DmnValue<?>> processVariables = new ConcurrentHashMap<>(); | ||
| processVariables.put("cancellationProcess", dmnStringValue(CANCELLATION_PROCESS)); | ||
|
|
||
| SendMessageRequest request = SendMessageRequest.builder() | ||
| .messageName(CANCEL) | ||
| .processVariables(processVariables) | ||
| .correlationKeys(correlationKeys) | ||
| .build(); | ||
|
|
||
| sendCamundaRequest(request, caseId); | ||
| } | ||
|
|
||
| private void sendCamundaRequest(SendMessageRequest request, long caseId) { | ||
| String s2sToken = authTokenGenerator.generate(); | ||
|
|
||
| try { | ||
| log.info("Camunda request for case id {}: {}", caseId, request); | ||
| camundaApi.sendMessage(s2sToken, request); | ||
| } catch (Exception e) { | ||
| log.error("Failed to send Camunda request for caseId {}", caseId, e); | ||
| } | ||
| } | ||
|
|
||
| private DmnValue<String> dmnStringValue(String value) { | ||
| return DmnValue.<String>builder().value(value).type("String").build(); | ||
| } | ||
|
|
||
| private DmnValue<Integer> dmnIntegerValue(Integer value) { | ||
| return DmnValue.<Integer>builder().value(value).type("Integer").build(); | ||
| } | ||
|
|
||
| private DmnValue<Boolean> dmnBooleanValue(Boolean value) { | ||
| return DmnValue.<Boolean>builder().value(value).type("Boolean").build(); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be reversed