Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
introduced bsnr (Betriebsstaettennummer) for new PoCs (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
bergmann-dierk authored Oct 28, 2021
1 parent ec8af1c commit f8dd693
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class QuickTestConfig {
private String pointOfCareIdName;
private String tenantIdKey;
private String groupKey;
private String bsnrKey;
private String tenantPointOfCareIdKey;
private String pointOfCareInformationName;
private String pointOfCareInformationDelimiter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ public class KeycloakGroupDetails {

private Boolean appointmentRequired;

// Optional Betriebsstaettennummer of a poc
@Size(min = 9, max = 9)
private String bsnr;
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class KeycloakService {

private static final String POC_ID_ATTRIBUTE = "poc_id";
private static final String POC_DETAILS_ATTRIBUTE = "poc_details";
private static final String BSNR_ATTRIBUTE = "bsnr";

/**
* Creates a new Keycloak User in the Main Realm and sets roles and the root group.
Expand Down Expand Up @@ -237,6 +238,7 @@ public KeycloakGroupDetails getSubGroupDetails(String groupId) {
groupDetails.setName(group.getName());
groupDetails.setPocDetails(getFromAttributes(group.getAttributes(), POC_DETAILS_ATTRIBUTE));
groupDetails.setPocId(getFromAttributes(group.getAttributes(), POC_ID_ATTRIBUTE));
groupDetails.setBsnr(getFromAttributes(group.getAttributes(), BSNR_ATTRIBUTE));
MapEntrySingleResponse mapEntry = mapEntryService.getMapEntry(groupId);
if (mapEntry != null) {
log.info(mapEntry.toString());
Expand Down Expand Up @@ -497,7 +499,7 @@ public void updateGroup(KeycloakGroupDetails details)
group.setName(details.getName());
// do not update POC ID
group.setAttributes(getGroupAttributes(details.getPocDetails(),
getFromAttributes(group.getAttributes(), POC_ID_ATTRIBUTE)));
getFromAttributes(group.getAttributes(), POC_ID_ATTRIBUTE), details.getBsnr()));

try {
groupResource.update(group);
Expand Down Expand Up @@ -541,7 +543,7 @@ public void createGroup(KeycloakGroupDetails details, String parent)
log.info("created group");
// setting group properties with Group Details and POC ID
newGroup = response.readEntity(GroupRepresentation.class);
newGroup.setAttributes(getGroupAttributes(details.getPocDetails(), newGroup.getId()));
newGroup.setAttributes(getGroupAttributes(details.getPocDetails(), newGroup.getId(), details.getBsnr()));
realm().groups().group(newGroup.getId()).update(newGroup);
if (details.getSearchPortalConsent()) {
details.setId(newGroup.getId());
Expand Down Expand Up @@ -634,7 +636,7 @@ private String getFromAttributes(Map<String, List<String>> attributes, String ke
}
}

private Map<String, List<String>> getGroupAttributes(String pocDetails, String pocId) {
private Map<String, List<String>> getGroupAttributes(String pocDetails, String pocId, String bsnr) {
Map<String, List<String>> attributes = new HashMap<>();
if (pocDetails != null) {
attributes.put(POC_DETAILS_ATTRIBUTE, List.of(pocDetails));
Expand All @@ -644,6 +646,10 @@ private Map<String, List<String>> getGroupAttributes(String pocDetails, String p
attributes.put(POC_ID_ATTRIBUTE, List.of(pocId));
}

if (bsnr != null) {
attributes.put(BSNR_ATTRIBUTE, List.of(bsnr));
}

return attributes;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ quicktest:
pointOfCareIdName: poc_id
tenantIdKey: tenantId
groupKey: groups
bsnrKey: bsnr
tenantPointOfCareIdKey: pocId
pointOfCareInformationName: poc_details
pointOfCareInformationDelimiter: \,
Expand Down

0 comments on commit f8dd693

Please sign in to comment.