Skip to content

Commit

Permalink
DTSAM-183 SSCS Multi-region for CTSC (#1841)
Browse files Browse the repository at this point in the history
* DTSAM-183 SSCS Multi-region for CTSC

   [DTSAM-183](https://tools.hmcts.net/jira/browse/DTSAM-183)

SSCS CTSC Multi-region for England & Wales.

NB: Also updates SSCS Judicial Multi-region for South West & Wales.

* DTSAM-183 SSCS Multi-region refactor

   [DTSAM-183](https://tools.hmcts.net/jira/browse/DTSAM-183)

SSCS Multi-region refactor for both CTSC and non-CTSC roles.

* DTSAM-183 SSCS FTA change for CTSC regions

   [DTSAM-183](https://tools.hmcts.net/jira/browse/DTSAM-183)

SSCS FTA change for CTSC regions.

---------

Co-authored-by: mikebrownccd <104495891+mikebrownccd@users.noreply.github.com>
  • Loading branch information
mattnayler and mikebrownccd authored Apr 4, 2024
1 parent 8b4638f commit 75d4825
Show file tree
Hide file tree
Showing 9 changed files with 829 additions and 205 deletions.
11 changes: 8 additions & 3 deletions src/functionalTest/resources/features/F-006/S-057.td.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"attributes": {
"substantive": "N",
"primaryLocation": "[[ANYTHING_PRESENT]]",
"jurisdiction": "SSCS"
"jurisdiction": "SSCS",
"region": "[[ANYTHING_PRESENT]]"
}
},
{
Expand All @@ -58,6 +59,7 @@
"substantive": "Y",
"primaryLocation": "[[ANYTHING_PRESENT]]",
"jurisdiction": "SSCS",
"region": "[[ANYTHING_PRESENT]]",
"workTypes": "pre_hearing,post_hearing,decision_making_work,applications,hearing_work,routine_work,priority"
}
},
Expand All @@ -75,7 +77,8 @@
"attributes": {
"substantive": "Y",
"primaryLocation": "[[ANYTHING_PRESENT]]",
"jurisdiction": "SSCS"
"jurisdiction": "SSCS",
"region": "[[ANYTHING_PRESENT]]"
}
},
{
Expand Down Expand Up @@ -141,6 +144,7 @@
"substantive" : "N",
"primaryLocation" : "[[ANYTHING_PRESENT]]",
"jurisdiction" : "SSCS",
"region": "[[ANYTHING_PRESENT]]",
"workTypes" : "access_requests"
}
},
Expand All @@ -158,7 +162,8 @@
"attributes": {
"substantive": "N",
"primaryLocation": "[[ANYTHING_PRESENT]]",
"jurisdiction": "SSCS"
"jurisdiction": "SSCS",
"region": "[[ANYTHING_PRESENT]]"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

Expand Down Expand Up @@ -357,4 +358,29 @@ public static RoleAssignment buildJudicialRoleAssignment() {
.build();
}


public static RoleAssignment cloneNewRoleAssignmentAndChangeRegion(RoleAssignment roleAssignment, String region) {
Map<String,JsonNode> attribute = CollectionUtils.isEmpty(roleAssignment.getAttributes())
? new HashMap<>() // default if empty
: new HashMap<>(roleAssignment.getAttributes()); // clone
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode(region));

return RoleAssignment.builder()
// NB: copy only the properties required for a NEW role assignment
.actorIdType(roleAssignment.getActorIdType())
.actorId(roleAssignment.getActorId())
.roleType(roleAssignment.getRoleType())
.roleName(roleAssignment.getRoleName())
.classification(roleAssignment.getClassification())
.grantType(roleAssignment.getGrantType())
.roleCategory(roleAssignment.getRoleCategory())
.readOnly(roleAssignment.isReadOnly())
.beginTime(roleAssignment.getBeginTime())
.endTime(roleAssignment.getEndTime())
.attributes(attribute)
.notes(roleAssignment.getNotes())
.authorisations(roleAssignment.getAuthorisations())
.build();
}

}
9 changes: 7 additions & 2 deletions src/main/resources/validationrules/sscs/sscs-ctsc-mapping.drl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package validationrules.sscs;

import uk.gov.hmcts.reform.orgrolemapping.domain.model.RoleAssignment;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.enums.ActorIdType;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.enums.RoleCategory;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.enums.RoleType;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.enums.Classification;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.enums.GrantType;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.CaseWorkerAccessProfile;
import java.util.ArrayList;
import uk.gov.hmcts.reform.orgrolemapping.util.JacksonUtils;
import java.util.HashMap
import java.util.Map
Expand Down Expand Up @@ -53,6 +53,7 @@ then
attribute.put("jurisdiction", JacksonUtils.convertObjectIntoJsonNode("SSCS"));
attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($cap.getPrimaryLocationId()));
attribute.put("workTypes", JacksonUtils.convertObjectIntoJsonNode("pre_hearing,post_hearing,decision_making_work,applications,hearing_work,routine_work,priority"));
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($cap.getRegionId()));

insert(
RoleAssignment.builder()
Expand Down Expand Up @@ -82,6 +83,7 @@ then
Map<String,JsonNode> attribute = new HashMap<>();
attribute.put("jurisdiction", JacksonUtils.convertObjectIntoJsonNode("SSCS"));
attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($cap.getPrimaryLocationId()));
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($cap.getRegionId()));

insert(
RoleAssignment.builder()
Expand Down Expand Up @@ -112,6 +114,7 @@ then
Map<String,JsonNode> attribute = new HashMap<>();
attribute.put("jurisdiction", JacksonUtils.convertObjectIntoJsonNode("SSCS"));
attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($cap.getPrimaryLocationId()));
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($cap.getRegionId()));

insert(
RoleAssignment.builder()
Expand Down Expand Up @@ -141,6 +144,7 @@ then
Map<String,JsonNode> attribute = new HashMap<>();
attribute.put("jurisdiction", JacksonUtils.convertObjectIntoJsonNode("SSCS"));
attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($cap.getPrimaryLocationId()));
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($cap.getRegionId()));

insert(
RoleAssignment.builder()
Expand Down Expand Up @@ -170,6 +174,7 @@ then
attribute.put("jurisdiction", JacksonUtils.convertObjectIntoJsonNode("SSCS"));
attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($cap.getPrimaryLocationId()));
attribute.put("workTypes", JacksonUtils.convertObjectIntoJsonNode("access_requests"));
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($cap.getRegionId()));

insert(
RoleAssignment.builder()
Expand All @@ -184,4 +189,4 @@ then
.attributes(attribute)
.build());
logMsg("Rule : sscs_specific_access_approver_ctsc_org_role");
end;
end;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import uk.gov.hmcts.reform.orgrolemapping.domain.model.enums.GrantType;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.JudicialAccessProfile;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.JudicialOfficeHolder;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.JudicialBooking;
import java.util.ArrayList;
import uk.gov.hmcts.reform.orgrolemapping.util.JacksonUtils;
import java.util.HashMap
import java.util.Map
Expand Down Expand Up @@ -523,63 +522,3 @@ then
.build());
logMsg("Rule : sscs_fee_paid_financial_org_role");
end;

/*
* SSCS "multi-region" Org role mapping.
*/

rule "sscs_multi_region_dependency_org_role_wales"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("6"))
not RoleAssignment(actorId == $ra.getActorId() && roleName == $ra.getRoleName()
&& attributes["region"] != null && attributes["region"].asText() == "7")
then
Map<String,JsonNode> attribute = new HashMap<>($ra.getAttributes());
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode("7"));

insert(RoleAssignment.builder()
.actorIdType($ra.getActorIdType())
.actorId($ra.getActorId())
.roleCategory($ra.getRoleCategory())
.roleType($ra.getRoleType())
.roleName($ra.getRoleName())
.grantType($ra.getGrantType())
.classification($ra.getClassification())
.readOnly($ra.isReadOnly())
.beginTime($ra.getBeginTime())
.endTime($ra.getEndTime())
.attributes(attribute)
.authorisations($ra.getAuthorisations())
.build());
logMsg("Rule : sscs_multi_region_dependency_org_role_wales");
end;

rule "sscs_multi_region_dependency_org_role_southwest"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("7"))
not RoleAssignment(actorId == $ra.getActorId() && roleName == $ra.getRoleName()
&& attributes["region"] != null && attributes["region"].asText() == "6" )
then
Map<String,JsonNode> attribute = new HashMap<>($ra.getAttributes());
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode("6"));

insert(RoleAssignment.builder()
.actorIdType($ra.getActorIdType())
.actorId($ra.getActorId())
.roleCategory($ra.getRoleCategory())
.roleType($ra.getRoleType())
.roleName($ra.getRoleName())
.grantType($ra.getGrantType())
.classification($ra.getClassification())
.readOnly($ra.isReadOnly())
.beginTime($ra.getBeginTime())
.endTime($ra.getEndTime())
.attributes(attribute)
.authorisations($ra.getAuthorisations())
.build());
logMsg("Rule : sscs_multi_region_dependency_org_role_southwest");
end;
161 changes: 161 additions & 0 deletions src/main/resources/validationrules/sscs/sscs-mulit-region.drl
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
package validationrules.sscs;

import uk.gov.hmcts.reform.orgrolemapping.domain.model.RoleAssignment;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.enums.RoleCategory;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.enums.FeatureFlagEnum;
import function uk.gov.hmcts.reform.orgrolemapping.domain.service.RequestMappingService.logMsg;
import function uk.gov.hmcts.reform.orgrolemapping.helper.AssignmentRequestBuilder.cloneNewRoleAssignmentAndChangeRegion;

/*
* SSCS "multi-region" Org role mapping. (non-CTSC)
*/

rule "sscs_multi_region_dependency_org_role_wales"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(roleCategory != RoleCategory.CTSC,
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("6"))
not RoleAssignment(actorId == $ra.getActorId(),
roleName == $ra.getRoleName(),
roleCategory == $ra.getRoleCategory(),
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() == "7")
then
insert(cloneNewRoleAssignmentAndChangeRegion($ra, "7"));
logMsg("Rule : sscs_multi_region_dependency_org_role_wales");
end;

rule "sscs_multi_region_dependency_org_role_southwest"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(roleCategory != RoleCategory.CTSC,
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("7"))
not RoleAssignment(actorId == $ra.getActorId(),
roleName == $ra.getRoleName(),
roleCategory == $ra.getRoleCategory(),
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() == "6" )
then
insert(cloneNewRoleAssignmentAndChangeRegion($ra, "6"));
logMsg("Rule : sscs_multi_region_dependency_org_role_southwest");
end;



/*
* SSCS "multi-region" Org role mapping. (CTSC only)
*/

rule "sscs_multi_region_dependency_org_role__ctsc__region_1"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(roleCategory == RoleCategory.CTSC,
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("2","3","4","5","6","7"))
not RoleAssignment(actorId == $ra.getActorId(),
roleName == $ra.getRoleName(),
roleCategory == $ra.getRoleCategory(),
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() == "1")
then
insert(cloneNewRoleAssignmentAndChangeRegion($ra, "1"));
logMsg("Rule : sscs_multi_region_dependency_org_role__ctsc__region_1");
end;

rule "sscs_multi_region_dependency_org_role__ctsc__region_2"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(roleCategory == RoleCategory.CTSC,
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("1","3","4","5","6","7"))
not RoleAssignment(actorId == $ra.getActorId(),
roleName == $ra.getRoleName(),
roleCategory == $ra.getRoleCategory(),
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() == "2")
then
insert(cloneNewRoleAssignmentAndChangeRegion($ra, "2"));
logMsg("Rule : sscs_multi_region_dependency_org_role__ctsc__region_2");
end;

rule "sscs_multi_region_dependency_org_role__ctsc__region_3"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(roleCategory == RoleCategory.CTSC,
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("1","2","4","5","6","7"))
not RoleAssignment(actorId == $ra.getActorId(),
roleName == $ra.getRoleName(),
roleCategory == $ra.getRoleCategory(),
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() == "3")
then
insert(cloneNewRoleAssignmentAndChangeRegion($ra, "3"));
logMsg("Rule : sscs_multi_region_dependency_org_role__ctsc__region_3");
end;

rule "sscs_multi_region_dependency_org_role__ctsc__region_4"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(roleCategory == RoleCategory.CTSC,
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("1","2","3","5","6","7"))
not RoleAssignment(actorId == $ra.getActorId(),
roleName == $ra.getRoleName(),
roleCategory == $ra.getRoleCategory(),
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() == "4")
then
insert(cloneNewRoleAssignmentAndChangeRegion($ra, "4"));
logMsg("Rule : sscs_multi_region_dependency_org_role__ctsc__region_4");
end;

rule "sscs_multi_region_dependency_org_role__ctsc__region_5"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(roleCategory == RoleCategory.CTSC,
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("1","2","3","4","6","7"))
not RoleAssignment(actorId == $ra.getActorId(),
roleName == $ra.getRoleName(),
roleCategory == $ra.getRoleCategory(),
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() == "5")
then
insert(cloneNewRoleAssignmentAndChangeRegion($ra, "5"));
logMsg("Rule : sscs_multi_region_dependency_org_role__ctsc__region_5");
end;

rule "sscs_multi_region_dependency_org_role__ctsc__region_6"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(roleCategory == RoleCategory.CTSC,
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("1","2","3","4","5","7"))
not RoleAssignment(actorId == $ra.getActorId(),
roleName == $ra.getRoleName(),
roleCategory == $ra.getRoleCategory(),
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() == "6")
then
insert(cloneNewRoleAssignmentAndChangeRegion($ra, "6"));
logMsg("Rule : sscs_multi_region_dependency_org_role__ctsc__region_6");
end;

rule "sscs_multi_region_dependency_org_role__ctsc__region_7"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.SSCS_WA_1_0.getValue())
$ra: RoleAssignment(roleCategory == RoleCategory.CTSC,
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() in ("1","2","3","4","5","6"))
not RoleAssignment(actorId == $ra.getActorId(),
roleName == $ra.getRoleName(),
roleCategory == $ra.getRoleCategory(),
attributes["jurisdiction"] != null && attributes["jurisdiction"].asText() in ("SSCS"),
attributes["region"] != null && attributes["region"].asText() == "7")
then
insert(cloneNewRoleAssignmentAndChangeRegion($ra, "7"));
logMsg("Rule : sscs_multi_region_dependency_org_role__ctsc__region_7");
end;
Loading

0 comments on commit 75d4825

Please sign in to comment.