use of eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleRequestService method realizeAttributeRules.
/**
* Execute change of the request for attribute automatic role
*
* @param request
* @param automaticRoleId
* @param ruleConcepts
*/
private void realizeAttributeRules(IdmAutomaticRoleRequestDto request, IdmAutomaticRoleAttributeDto automaticRole, List<IdmAutomaticRoleAttributeRuleRequestDto> ruleConcepts) {
// Create new rule
ruleConcepts.stream().filter(concept -> {
return RequestOperationType.ADD == concept.getOperation();
}).forEach(concept -> {
IdmAutomaticRoleAttributeRuleDto rule = new IdmAutomaticRoleAttributeRuleDto();
rule.setAutomaticRoleAttribute(automaticRole.getId());
rule = automaticRoleRuleService.save(convertConceptRuleToRule(concept, rule));
// Save created identity role id
concept.setRule(rule.getId());
automaticRoleRuleRequestService.save(concept);
});
// Update rule
ruleConcepts.stream().filter(concept -> {
return RequestOperationType.UPDATE == concept.getOperation();
}).filter(concept -> {
return concept.getRule() != null;
}).forEach(concept -> {
IdmAutomaticRoleAttributeRuleDto rule = automaticRoleRuleService.get(concept.getRule());
rule = automaticRoleRuleService.save(convertConceptRuleToRule(concept, rule));
// Save created identity role id
concept.setRule(rule.getId());
automaticRoleRuleRequestService.save(concept);
});
// Delete rule
ruleConcepts.stream().filter(concept -> {
return RequestOperationType.REMOVE == concept.getOperation();
}).filter(concept -> {
return concept.getRule() != null;
}).forEach(concept -> {
IdmAutomaticRoleAttributeRuleDto rule = automaticRoleRuleService.get(concept.getRule());
if (rule != null) {
concept.setRule(rule.getId());
automaticRoleRuleRequestService.save(concept);
// Finally delete of the rule
automaticRoleRuleService.delete(rule);
}
});
}
Aggregations