Search in sources :

Example 1 with IdmAutomaticRoleAttribute

use of eu.bcvsolutions.idm.core.model.entity.IdmAutomaticRoleAttribute in project CzechIdMng by bcvsolutions.

the class DefaultIdmConceptRoleRequestService method toDto.

@Override
protected IdmConceptRoleRequestDto toDto(IdmConceptRoleRequest entity, IdmConceptRoleRequestDto dto) {
    dto = super.toDto(entity, dto);
    if (dto == null) {
        return null;
    }
    // Contract from identity role has higher priority then contract ID in concept role
    if (entity != null && entity.getIdentityRole() != null) {
        dto.setIdentityContract(entity.getIdentityRole().getIdentityContract().getId());
    }
    // we must set automatic role to role tree node
    if (entity != null && entity.getAutomaticRole() != null) {
        dto.setAutomaticRole(entity.getAutomaticRole().getId());
        IdmAutomaticRole automaticRole = entity.getAutomaticRole();
        Map<String, BaseDto> embedded = dto.getEmbedded();
        // 
        BaseDto baseDto = null;
        if (automaticRole instanceof IdmAutomaticRoleAttribute) {
            baseDto = lookupService.getDtoService(IdmAutomaticRoleAttributeDto.class).get(automaticRole.getId());
        } else {
            baseDto = lookupService.getDtoService(IdmRoleTreeNodeDto.class).get(automaticRole.getId());
        }
        // roleTreeNode must be placed there as string, in meta model isn't any attribute like this
        embedded.put("roleTreeNode", baseDto);
        dto.setEmbedded(embedded);
    }
    return dto;
}
Also used : IdmAutomaticRole(eu.bcvsolutions.idm.core.model.entity.IdmAutomaticRole) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) IdmAutomaticRoleAttribute(eu.bcvsolutions.idm.core.model.entity.IdmAutomaticRoleAttribute)

Example 2 with IdmAutomaticRoleAttribute

use of eu.bcvsolutions.idm.core.model.entity.IdmAutomaticRoleAttribute in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityRoleService method toDto.

@Override
protected IdmIdentityRoleDto toDto(IdmIdentityRole entity, IdmIdentityRoleDto dto) {
    dto = super.toDto(entity, dto);
    if (dto == null) {
        return null;
    }
    // 
    IdmAutomaticRole automaticRole = entity.getAutomaticRole();
    if (automaticRole != null) {
        dto.setRoleTreeNode(automaticRole.getId());
        dto.setAutomaticRole(true);
        BaseDto baseDto = null;
        Map<String, BaseDto> embedded = dto.getEmbedded();
        if (automaticRole instanceof IdmAutomaticRoleAttribute) {
            baseDto = lookupService.getDtoService(IdmAutomaticRoleAttributeDto.class).get(automaticRole.getId());
        } else {
            baseDto = lookupService.getDtoService(IdmRoleTreeNodeDto.class).get(automaticRole.getId());
        }
        embedded.put(IdmAutomaticRoleAttributeService.ROLE_TREE_NODE_ATTRIBUTE_NAME, baseDto);
        dto.setEmbedded(embedded);
    }
    // 
    return dto;
}
Also used : IdmAutomaticRole(eu.bcvsolutions.idm.core.model.entity.IdmAutomaticRole) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) IdmAutomaticRoleAttribute(eu.bcvsolutions.idm.core.model.entity.IdmAutomaticRoleAttribute)

Aggregations

BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)2 IdmAutomaticRole (eu.bcvsolutions.idm.core.model.entity.IdmAutomaticRole)2 IdmAutomaticRoleAttribute (eu.bcvsolutions.idm.core.model.entity.IdmAutomaticRoleAttribute)2