Search in sources :

Example 11 with IdmRoleFormAttributeFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter in project CzechIdMng by bcvsolutions.

the class AbstractRoleParametrizationFormDefaultValueGenerator method getDefaultValue.

/**
 * Return default value for given form-attribute. First try to find override
 * role-form-attribute. If exists, then return it's default value. If not, then
 * default value from given form-attribute will be returned.
 *
 * @param attribute
 * @param role
 * @return
 */
private String getDefaultValue(IdmFormAttributeDto attribute, IdmRoleDto role) {
    Assert.notNull(attribute, "Attribute is required.");
    Assert.notNull(role, "Role is required.");
    IdmRoleFormAttributeFilter roleFormAttributeFilter = new IdmRoleFormAttributeFilter();
    roleFormAttributeFilter.setRole(role.getId());
    roleFormAttributeFilter.setFormAttribute(attribute.getId());
    List<IdmRoleFormAttributeDto> roleFormAttributes = roleFormAttributeService.find(roleFormAttributeFilter, null).getContent();
    if (roleFormAttributes.size() > 0) {
        return roleFormAttributes.get(0).getDefaultValue();
    }
    return attribute.getDefaultValue();
}
Also used : IdmRoleFormAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleFormAttributeDto) IdmRoleFormAttributeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter)

Example 12 with IdmRoleFormAttributeFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleService method getFormAttributeSubdefinition.

@Override
public IdmFormDefinitionDto getFormAttributeSubdefinition(IdmRoleDto role) {
    Assert.notNull(role, "Role is required.");
    UUID identityRoleAttributeDefinition = role.getIdentityRoleAttributeDefinition();
    if (identityRoleAttributeDefinition == null) {
        return null;
    }
    IdmFormDefinitionDto definition = this.getFormService().getDefinition(identityRoleAttributeDefinition);
    List<IdmFormAttributeDto> allAttributes = definition.getFormAttributes();
    // Find sub-definition for given role
    IdmRoleFormAttributeFilter attributeFilter = new IdmRoleFormAttributeFilter();
    attributeFilter.setRole(role.getId());
    List<IdmRoleFormAttributeDto> roleFormAttributes = roleFormAttributeService.find(attributeFilter, null).getContent();
    // Find allowed attributes by sub-definition (and set default value from sub-definition attribute)
    List<IdmFormAttributeDto> allowedAttributes = // 
    allAttributes.stream().filter(attribute -> {
        IdmRoleFormAttributeDto result = // 
        roleFormAttributes.stream().filter(roleFormAttribute -> attribute.getId().equals(roleFormAttribute.getFormAttribute())).findFirst().orElse(// 
        null);
        if (result != null) {
            // Set default value from sub-definition attribute
            attribute.setDefaultValue(result.getDefaultValue());
            // Set validations
            attribute.setRequired(result.isRequired());
            attribute.setUnique(result.isUnique());
            attribute.setMin(result.getMin());
            attribute.setMax(result.getMax());
            attribute.setRegex(result.getRegex());
            attribute.setValidationMessage(result.getValidationMessage());
            return true;
        }
        return false;
    }).collect(Collectors.toList());
    definition.setFormAttributes(allowedAttributes);
    return definition;
}
Also used : IdmRoleFormAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleFormAttributeDto) RoleType(eu.bcvsolutions.idm.core.api.domain.RoleType) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) AbstractReadDtoService(eu.bcvsolutions.idm.core.api.service.AbstractReadDtoService) Autowired(org.springframework.beans.factory.annotation.Autowired) SiemLoggerManager(eu.bcvsolutions.idm.core.api.audit.service.SiemLoggerManager) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) IdmRoleCatalogue(eu.bcvsolutions.idm.core.model.entity.IdmRoleCatalogue) StringUtils(org.apache.commons.lang3.StringUtils) IdmRoleCatalogueRole(eu.bcvsolutions.idm.core.model.entity.IdmRoleCatalogueRole) IdmRoleComposition(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) Predicate(javax.persistence.criteria.Predicate) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Pageable(org.springframework.data.domain.Pageable) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) IdmRoleCatalogueRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCatalogueRoleFilter) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) IdmRoleCatalogue_(eu.bcvsolutions.idm.core.model.entity.IdmRoleCatalogue_) IdmRoleRepository(eu.bcvsolutions.idm.core.model.repository.IdmRoleRepository) UUID(java.util.UUID) RoleConfiguration(eu.bcvsolutions.idm.core.api.config.domain.RoleConfiguration) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) RequestConfiguration(eu.bcvsolutions.idm.core.api.config.domain.RequestConfiguration) List(java.util.List) Lazy(org.springframework.context.annotation.Lazy) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) PageImpl(org.springframework.data.domain.PageImpl) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) IdmRoleFormAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleFormAttributeDto) IdmRoleSystemService(eu.bcvsolutions.idm.core.api.service.IdmRoleSystemService) IdmRoleCatalogueRole_(eu.bcvsolutions.idm.core.model.entity.IdmRoleCatalogueRole_) RoleEvent(eu.bcvsolutions.idm.core.model.event.RoleEvent) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) CollectionUtils(org.apache.commons.collections.CollectionUtils) IdmRoleFormAttributeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Root(javax.persistence.criteria.Root) IdmFormDefinition_(eu.bcvsolutions.idm.core.eav.entity.IdmFormDefinition_) IdmRole_(eu.bcvsolutions.idm.core.model.entity.IdmRole_) IdmRoleComposition_(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) IdmRoleCatalogueRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleCatalogueRoleService) IdmRoleSystemFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleSystemFilter) IdmRoleFormAttributeService(eu.bcvsolutions.idm.core.api.service.IdmRoleFormAttributeService) IdmForestIndexEntity_(eu.bcvsolutions.idm.core.model.entity.IdmForestIndexEntity_) BaseFilter(eu.bcvsolutions.idm.core.api.dto.filter.BaseFilter) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AbstractFormableService(eu.bcvsolutions.idm.core.eav.api.service.AbstractFormableService) Subquery(javax.persistence.criteria.Subquery) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) AuthorizableType(eu.bcvsolutions.idm.core.security.api.dto.AuthorizableType) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) UUID(java.util.UUID) IdmRoleFormAttributeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter)

Example 13 with IdmRoleFormAttributeFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter in project CzechIdMng by bcvsolutions.

the class DefaultIdmFormAttributeService method deleteInternal.

@Override
@Transactional
@SuppressWarnings({ "rawtypes", "unchecked" })
public void deleteInternal(IdmFormAttributeDto dto) {
    Assert.notNull(dto, "DTO is required.");
    // attribute with filled values cannot be deleted
    IdmFormValueFilter filter = new IdmFormValueFilter();
    filter.setAttributeId(dto.getId());
    formValueServices.getPlugins().forEach(formValueService -> {
        if (formValueService.find(filter, PageRequest.of(0, 1)).getTotalElements() > 0) {
            throw new ResultCodeException(CoreResultCode.FORM_ATTRIBUTE_DELETE_FAILED_HAS_VALUES, ImmutableMap.of("formAttribute", dto.getCode()));
        }
    });
    // 
    // check rules for automatic role attributes
    IdmAutomaticRoleAttributeRuleFilter automaticRoleRuleFilter = new IdmAutomaticRoleAttributeRuleFilter();
    automaticRoleRuleFilter.setFormAttributeId(dto.getId());
    long totalElements = automaticRoleAttributeService.find(automaticRoleRuleFilter, PageRequest.of(0, 1)).getTotalElements();
    if (totalElements > 0) {
        // some automatic roles use this attribute
        throw new ResultCodeException(CoreResultCode.FORM_ATTRIBUTE_DELETE_FAILED_AUTOMATIC_ROLE_RULE_ASSIGNED, ImmutableMap.of("formAttribute", dto.getId()));
    }
    // Check on using this attribute on role (sub-definition)
    if (dto.getId() != null) {
        IdmRoleFormAttributeFilter roleFormAttributeFilter = new IdmRoleFormAttributeFilter();
        roleFormAttributeFilter.setFormAttribute(dto.getId());
        List<IdmRoleFormAttributeDto> attributes = roleFormAttributeService.find(roleFormAttributeFilter, PageRequest.of(0, 1)).getContent();
        if (attributes.size() > 0) {
            IdmRoleDto roleDto = DtoUtils.getEmbedded(attributes.get(0), IdmRoleFormAttribute_.role.getName(), IdmRoleDto.class);
            throw new ResultCodeException(CoreResultCode.FORM_ATTRIBUTE_DELETE_FAILED_ROLE_ATTRIBUTE, ImmutableMap.of("definition", dto.getCode(), "role", roleDto.getCode()));
        }
    }
    // 
    // Check rules requests for automatic role attributes. Deletes relation on this form attribute.
    IdmAutomaticRoleAttributeRuleRequestFilter automaticRoleRuleRequestFilter = new IdmAutomaticRoleAttributeRuleRequestFilter();
    automaticRoleRuleRequestFilter.setFormAttributeId(dto.getId());
    List<IdmAutomaticRoleAttributeRuleRequestDto> ruleRequests = automaticRoleAttributeRequestService.find(automaticRoleRuleRequestFilter, null).getContent();
    ruleRequests.forEach(rule -> {
        rule.setFormAttribute(null);
        automaticRoleAttributeRequestService.save(rule);
    });
    // 
    super.deleteInternal(dto);
}
Also used : IdmRoleFormAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleFormAttributeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmAutomaticRoleAttributeRuleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmAutomaticRoleAttributeRuleRequestFilter) IdmAutomaticRoleAttributeRuleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeRuleRequestDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmFormValueFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter) IdmAutomaticRoleAttributeRuleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmAutomaticRoleAttributeRuleFilter) IdmRoleFormAttributeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with IdmRoleFormAttributeFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter in project CzechIdMng by bcvsolutions.

the class IdmRequestIdentityRoleServiceIntegrationTest method testUniqueConceptValidation.

@Test(expected = InvalidFormException.class)
public void testUniqueConceptValidation() {
    // Create role with attribute (include the sub-definition)
    IdmRoleDto role = createRoleWithAttributes(true);
    IdmRoleFormAttributeFilter filter = new IdmRoleFormAttributeFilter();
    filter.setRole(role.getId());
    List<IdmRoleFormAttributeDto> list = roleFormAttributeService.find(filter, null).getContent();
    Assert.assertEquals(2, list.size());
    IdmFormDefinitionDto formAttributeSubdefinition = roleService.getFormAttributeSubdefinition(role);
    Assert.assertEquals(2, formAttributeSubdefinition.getFormAttributes().size());
    // Delete IP attribute from the sub-definition
    list.stream().filter(roleFormAttributeDto -> {
        IdmFormAttributeDto formAttributeDto = DtoUtils.getEmbedded(roleFormAttributeDto, IdmRoleFormAttribute_.formAttribute.getName(), IdmFormAttributeDto.class);
        return formAttributeDto.getCode().equals(IP);
    }).forEach(roleFormAttributeDto -> roleFormAttributeService.delete(roleFormAttributeDto));
    formAttributeSubdefinition = roleService.getFormAttributeSubdefinition(role);
    Assert.assertEquals(1, formAttributeSubdefinition.getFormAttributes().size());
    Assert.assertEquals(NUMBER_OF_FINGERS, formAttributeSubdefinition.getFormAttributes().get(0).getCode());
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmIdentityContractDto contract = getHelper().getPrimeContract(identity);
    IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
    identityRoleFilter.setIdentityContractId(contract.getId());
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, null).getContent();
    assertEquals(0, identityRoles.size());
    // Create request identity-role
    IdmRequestIdentityRoleDto createdRequestIdentityRole = new IdmRequestIdentityRoleDto();
    createdRequestIdentityRole.setIdentityContract(contract.getId());
    // Change the valid from
    createdRequestIdentityRole.setValidFrom(LocalDate.now());
    createdRequestIdentityRole.setRole(role.getId());
    // Create role attribute value in concept
    IdmFormDefinitionDto formDefinitionDto = roleService.getFormAttributeSubdefinition(role);
    IdmFormInstanceDto formInstanceDto = new IdmFormInstanceDto();
    IdmFormAttributeDto attribute = formDefinitionDto.getMappedAttributeByCode(NUMBER_OF_FINGERS);
    IdmFormValueDto formValueDto = new IdmFormValueDto(attribute);
    formValueDto.setValue(5);
    List<IdmFormValueDto> values = Lists.newArrayList(formValueDto);
    formInstanceDto.setValues(values);
    List<IdmFormInstanceDto> forms = Lists.newArrayList(formInstanceDto);
    createdRequestIdentityRole.setEavs(forms);
    createdRequestIdentityRole = requestIdentityRoleService.save(createdRequestIdentityRole);
    IdmRoleRequestDto request = roleRequestService.get(createdRequestIdentityRole.getRoleRequest(), new IdmRoleRequestFilter(true));
    Assert.assertNotNull(request);
    // Execute a role-request.
    getHelper().executeRequest(request, false, true);
    IdmRequestIdentityRoleFilter filterRequestIdentityRole = new IdmRequestIdentityRoleFilter();
    filterRequestIdentityRole.setIdentityId(identity.getId());
    filterRequestIdentityRole.setRoleRequestId(request.getId());
    // Include EAV attributes
    filterRequestIdentityRole.setIncludeEav(true);
    // Check EAV value in the request-identity-role
    List<IdmRequestIdentityRoleDto> requestIdentityRoles = requestIdentityRoleService.find(filterRequestIdentityRole, null).getContent();
    Assert.assertEquals(1, requestIdentityRoles.size());
    Assert.assertEquals(role.getId(), requestIdentityRoles.get(0).getRole());
    Assert.assertEquals(1, requestIdentityRoles.get(0).getEavs().size());
    IdmFormInstanceDto formInstance = requestIdentityRoles.get(0).getEavs().get(0);
    Assert.assertEquals(1, formInstance.getValues().size());
    IdmFormValueDto formValue = formInstance.getValues().get(0);
    Serializable value = formValue.getValue();
    Assert.assertEquals(((BigDecimal) formValueDto.getValue()).longValue(), ((BigDecimal) value).longValue());
    IdmFormAttributeDto mappedAttribute = formInstance.getMappedAttribute(formValue.getFormAttribute());
    Assert.assertNotNull(mappedAttribute);
    Assert.assertNull(formInstance.getValidationErrors());
    identityRoles = identityRoleService.find(identityRoleFilter, null).getContent();
    assertEquals(1, identityRoles.size());
    // Create request identity-role
    createdRequestIdentityRole = new IdmRequestIdentityRoleDto();
    createdRequestIdentityRole.setIdentityContract(contract.getId());
    // Change the valid from
    createdRequestIdentityRole.setValidFrom(LocalDate.now());
    createdRequestIdentityRole.setRole(role.getId());
    // Create role attribute value in concept
    formDefinitionDto = roleService.getFormAttributeSubdefinition(role);
    formInstanceDto = new IdmFormInstanceDto();
    attribute = formDefinitionDto.getMappedAttributeByCode(NUMBER_OF_FINGERS);
    formValueDto = new IdmFormValueDto(attribute);
    formValueDto.setValue(5);
    values = Lists.newArrayList(formValueDto);
    formInstanceDto.setValues(values);
    forms = Lists.newArrayList(formInstanceDto);
    createdRequestIdentityRole.setEavs(forms);
    requestIdentityRoleService.save(createdRequestIdentityRole);
}
Also used : IdmRoleFormAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleFormAttributeDto) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmRequestIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) IdmRoleRequestService(eu.bcvsolutions.idm.core.api.service.IdmRoleRequestService) BigDecimal(java.math.BigDecimal) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmRequestIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmRequestIdentityRoleService) After(org.junit.After) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Set(java.util.Set) UUID(java.util.UUID) InvalidFormException(eu.bcvsolutions.idm.core.api.exception.InvalidFormException) Serializable(java.io.Serializable) List(java.util.List) LocalDate(java.time.LocalDate) IdmRoleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmRoleFormAttribute_(eu.bcvsolutions.idm.core.model.entity.IdmRoleFormAttribute_) IdmRoleFormAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleFormAttributeDto) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) Lists(com.google.common.collect.Lists) IdmIdentityRole(eu.bcvsolutions.idm.core.model.entity.IdmIdentityRole) Sets(org.mockito.internal.util.collections.Sets) ImmutableList(com.google.common.collect.ImmutableList) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleFormAttributeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter) Before(org.junit.Before) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) RoleRequestState(eu.bcvsolutions.idm.core.api.domain.RoleRequestState) Test(org.junit.Test) IdmRoleFormAttributeService(eu.bcvsolutions.idm.core.api.service.IdmRoleFormAttributeService) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) Assert.assertNull(org.junit.Assert.assertNull) IdmRequestIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRequestIdentityRoleFilter) Assert(org.junit.Assert) ConceptRoleRequestOperation(eu.bcvsolutions.idm.core.api.domain.ConceptRoleRequestOperation) Assert.assertEquals(org.junit.Assert.assertEquals) Transactional(org.springframework.transaction.annotation.Transactional) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) Serializable(java.io.Serializable) IdmRequestIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestIdentityRoleDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmRoleFormAttributeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter) IdmRequestIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRequestIdentityRoleFilter) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmRoleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 15 with IdmRoleFormAttributeFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter in project CzechIdMng by bcvsolutions.

the class RoleExportBulkAction method exportRoleAttributes.

/**
 * Export role-attributes for given role.
 *
 * @param role
 */
private void exportRoleAttributes(IdmRoleDto role) {
    IdmRoleFormAttributeFilter filter = new IdmRoleFormAttributeFilter();
    filter.setRole(role.getId());
    List<IdmRoleFormAttributeDto> dtos = roleFormAttributeService.find(filter, null).getContent();
    if (dtos.isEmpty()) {
        roleFormAttributeService.export(ExportManager.BLANK_UUID, this.getBatch());
    }
    dtos.forEach(dto -> {
        roleFormAttributeService.export(dto.getId(), this.getBatch());
    });
    // Set parent field -> set authoritative mode.
    this.getExportManager().setAuthoritativeMode(IdmRoleFormAttribute_.role.getName(), "role", IdmRoleFormAttributeDto.class, this.getBatch());
}
Also used : IdmRoleFormAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleFormAttributeDto) IdmRoleFormAttributeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter)

Aggregations

IdmRoleFormAttributeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFormAttributeFilter)28 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)24 IdmRoleFormAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleFormAttributeDto)24 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)19 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)19 Test (org.junit.Test)19 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)18 IdmRoleFormAttributeService (eu.bcvsolutions.idm.core.api.service.IdmRoleFormAttributeService)17 IdmRoleService (eu.bcvsolutions.idm.core.api.service.IdmRoleService)17 List (java.util.List)17 Autowired (org.springframework.beans.factory.annotation.Autowired)17 Lists (com.google.common.collect.Lists)16 ConceptRoleRequestOperation (eu.bcvsolutions.idm.core.api.domain.ConceptRoleRequestOperation)16 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)16 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)16 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)16 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)16 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)16 IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)16 IdmIdentityRoleService (eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService)16