-
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 pull request #377 from hmcts/SIDM-8901-caseworkers
SIDM-8901 add caseworkers
- Loading branch information
Showing
20 changed files
with
732 additions
and
75 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
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
19 changes: 19 additions & 0 deletions
19
src/main/java/uk/gov/hmcts/cft/idam/testingsupportapi/properties/CategoryProperties.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,19 @@ | ||
package uk.gov.hmcts.cft.idam.testingsupportapi.properties; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Getter | ||
@Setter | ||
@Component | ||
@ConfigurationProperties(prefix = "cft.categories") | ||
public class CategoryProperties { | ||
|
||
Map<String, List<String>> rolePatterns; | ||
|
||
} |
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
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
90 changes: 90 additions & 0 deletions
90
...java/uk/gov/hmcts/cft/idam/testingsupportapi/service/TestingCaseWorkerProfileService.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,90 @@ | ||
package uk.gov.hmcts.cft.idam.testingsupportapi.service; | ||
|
||
import org.springframework.jms.core.JmsTemplate; | ||
import org.springframework.stereotype.Service; | ||
import uk.gov.hmcts.cft.idam.api.v2.common.model.User; | ||
import uk.gov.hmcts.cft.idam.testingsupportapi.repo.TestingEntityRepo; | ||
import uk.gov.hmcts.cft.idam.testingsupportapi.repo.model.TestingEntityType; | ||
import uk.gov.hmcts.cft.rd.api.RefDataCaseWorkerApi; | ||
import uk.gov.hmcts.cft.rd.model.CaseWorkerLocation; | ||
import uk.gov.hmcts.cft.rd.model.CaseWorkerProfile; | ||
import uk.gov.hmcts.cft.rd.model.CaseWorkerRole; | ||
import uk.gov.hmcts.cft.rd.model.CaseWorkerService; | ||
import uk.gov.hmcts.cft.rd.model.CreateCaseWorkerProfileRequest; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@Service | ||
public class TestingCaseWorkerProfileService extends TestingEntityService<CaseWorkerProfile> { | ||
|
||
private final RefDataCaseWorkerApi refDataCaseWorkerApi; | ||
|
||
public TestingCaseWorkerProfileService(TestingEntityRepo testingEntityRepo, | ||
JmsTemplate jmsTemplate, | ||
RefDataCaseWorkerApi refDataCaseWorkerApi) { | ||
super(testingEntityRepo, jmsTemplate); | ||
this.refDataCaseWorkerApi = refDataCaseWorkerApi; | ||
} | ||
|
||
public User createCaseWorkerProfile(String sessionId, User user) { | ||
CreateCaseWorkerProfileRequest createRequest = convertToCreateRequest(user); | ||
refDataCaseWorkerApi.createCaseWorkerProfile(createRequest); | ||
|
||
createTestingEntity(sessionId, createRequest); | ||
|
||
return user; | ||
} | ||
|
||
private CreateCaseWorkerProfileRequest convertToCreateRequest(User user) { | ||
CreateCaseWorkerProfileRequest createRequest = new CreateCaseWorkerProfileRequest(); | ||
createRequest.setCaseWorkerId(user.getId()); | ||
createRequest.setFirstName(user.getForename()); | ||
createRequest.setLastName(user.getSurname()); | ||
createRequest.setEmail(user.getEmail()); | ||
|
||
createRequest.setSkills(Collections.emptyList()); | ||
createRequest.setUserType("CTSC"); | ||
createRequest.setUserProfileIdamStatus("ACTIVE"); | ||
createRequest.setStaffAdmin(user.getRoleNames().contains("staff-admin")); | ||
createRequest.setRegionId("4"); | ||
createRequest.setRegion("North East"); | ||
|
||
CaseWorkerRole role = new CaseWorkerRole(); | ||
role.setRoleId("2"); | ||
role.setRoleDescription("Legal Caseworker"); | ||
role.setPrimary(true); | ||
createRequest.setRoles(List.of(role)); | ||
|
||
CaseWorkerLocation location = new CaseWorkerLocation(); | ||
location.setLocationId("206150"); | ||
location.setPrimary(true); | ||
createRequest.setBaseLocations(List.of(location)); | ||
|
||
CaseWorkerService service = new CaseWorkerService(); | ||
service.setServiceCode("BAB2"); | ||
createRequest.setServices(List.of(service)); | ||
|
||
return createRequest; | ||
} | ||
|
||
public CaseWorkerProfile getCaseWorkerProfileById(String userId) { | ||
return refDataCaseWorkerApi.findCaseWorkerProfileByUserId(userId); | ||
} | ||
|
||
@Override | ||
protected void deleteEntity(String key) { | ||
refDataCaseWorkerApi.deleteCaseWorkerProfileByUserId(key); | ||
} | ||
|
||
@Override | ||
protected String getEntityKey(CaseWorkerProfile entity) { | ||
return entity.getCaseWorkerId(); | ||
} | ||
|
||
@Override | ||
protected TestingEntityType getTestingEntityType() { | ||
return TestingEntityType.PROFILE_CASEWORKER; | ||
} | ||
|
||
} |
Oops, something went wrong.