-
Notifications
You must be signed in to change notification settings - Fork 0
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
SIDM-8901 add caseworkers #377
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c812dee
add caseworkers
jburke-idam 1b2e58b
checkstyle
jburke-idam ad923e1
Merge branch 'master' into SIDM-8901-caseworkers
jburke-idam e9ff02c
add caseworkers
jburke-idam 527a776
caseworker
jburke-idam 45e75ce
Merge branch 'master' into SIDM-8901-caseworkers
jburke-idam c3b5398
checkstyle
jburke-idam c9c8e53
Merge remote-tracking branch 'origin' into SIDM-8901-caseworkers
jburke-idam 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 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.
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.
Would we ever want testing-support-api clients to send us things like roles, user types, regions, locations?
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.
Probably yes, but we don't have a "V2" model for that (yet). I think it's fine to leave these as defaults for now since IDAM is the only user. When we want to expand the usage of this we can discuss a newer input model