Search in sources :

Example 11 with IdmFormAttributeFilter

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

the class DefaultFormService method getAttributes.

@Override
@Transactional(readOnly = true)
public List<IdmFormAttributeDto> getAttributes(IdmFormDefinitionDto formDefinition, BasePermission... permission) {
    Assert.notNull(formDefinition, "Form definition is required.");
    // 
    if (PermissionUtils.isEmpty(permission)) {
        IdmFormDefinitionDto cachedDefinition = getCachedDefinition(formDefinition.getId());
        if (cachedDefinition != null) {
            // sorted already
            return cachedDefinition.getFormAttributes();
        }
    }
    // 
    IdmFormAttributeFilter filter = new IdmFormAttributeFilter();
    filter.setDefinitionType(formDefinition.getType());
    filter.setDefinitionCode(formDefinition.getCode());
    // 
    return formAttributeService.find(filter, PageRequest.of(0, Integer.MAX_VALUE, Sort.by(IdmFormAttribute_.seq.getName())), permission).getContent();
}
Also used : IdmFormAttributeFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with IdmFormAttributeFilter

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

the class DefaultIdmFormDefinitionService method toDto.

@Override
protected IdmFormDefinitionDto toDto(IdmFormDefinition entity, IdmFormDefinitionDto dto) {
    dto = super.toDto(entity, dto);
    if (dto == null) {
        return null;
    }
    // 
    if (!dto.isTrimmed()) {
        // set mapped attributes - required to cache form definition with attributes
        IdmFormAttributeFilter filter = new IdmFormAttributeFilter();
        filter.setDefinitionId(dto.getId());
        dto.setFormAttributes(formAttributeService.find(filter, getPageableAll(Sort.by(IdmFormAttribute_.seq.getName(), IdmFormAttribute_.name.getName()))).getContent());
        LOG.trace("Form attributes were loaded for definition [{},{}]", dto.getType(), dto.getCode());
    }
    // 
    return dto;
}
Also used : IdmFormAttributeFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter)

Example 13 with IdmFormAttributeFilter

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

the class DefaultIdmFormDefinitionService method deleteInternal.

@Override
@Transactional
public void deleteInternal(IdmFormDefinitionDto dto) {
    Assert.notNull(dto, "Form definition is required for delete.");
    UUID id = dto.getId();
    Assert.notNull(id, "Form definition identifier is required for delete.");
    // 
    // delete all attributes in definition
    IdmFormAttributeFilter filter = new IdmFormAttributeFilter();
    filter.setDefinitionId(id);
    formAttributeService.find(filter, null).forEach(formAttribute -> {
        formAttributeService.delete(formAttribute);
    });
    // 
    IdmRoleFilter roleFilter = new IdmRoleFilter();
    roleFilter.setAttributeFormDefinitionId(id);
    List<IdmRoleDto> roles = roleService.find(roleFilter, PageRequest.of(0, 1)).getContent();
    if (roles.size() > 0) {
        throw new ResultCodeException(CoreResultCode.FORM_DEFINITION_DELETE_FAILED_ROLE, ImmutableMap.of("definition", dto.getCode(), "role", roles.get(0).getCode()));
    }
    super.deleteInternal(dto);
}
Also used : IdmFormAttributeFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) UUID(java.util.UUID) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with IdmFormAttributeFilter

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

the class DefaultIdmFormDefinitionService method export.

@Override
public void export(UUID id, IdmExportImportDto batch) {
    super.export(id, batch);
    // Export form attributes
    IdmFormAttributeFilter systemMappingFilter = new IdmFormAttributeFilter();
    systemMappingFilter.setDefinitionId(id);
    List<IdmFormAttributeDto> attributes = formAttributeService.find(systemMappingFilter, null).getContent();
    if (attributes.isEmpty()) {
        formAttributeService.export(ExportManager.BLANK_UUID, batch);
    }
    attributes.forEach(mapping -> {
        formAttributeService.export(mapping.getId(), batch);
        // Authoritative mode is not set here only parent field could be sets.
        ExportDescriptorDto descriptor = getExportManager().getDescriptor(batch, mapping.getClass());
        if (descriptor != null) {
            descriptor.getParentFields().add(IdmFormAttribute_.formDefinition.getName());
        }
    });
}
Also used : ExportDescriptorDto(eu.bcvsolutions.idm.core.api.dto.ExportDescriptorDto) IdmFormAttributeFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)

Aggregations

IdmFormAttributeFilter (eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter)14 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)8 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)6 Test (org.junit.Test)4 Transactional (org.springframework.transaction.annotation.Transactional)4 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)3 IdmFormDefinitionFilter (eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormDefinitionFilter)3 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)3 UUID (java.util.UUID)3 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)2 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)2 IdmAutomaticRoleAttributeRuleDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeRuleDto)2 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)2 IdmRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter)2 IdmIdentityContract (eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract)2 Serializable (java.io.Serializable)2 HashMap (java.util.HashMap)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 InMemoryDirectoryServer (com.unboundid.ldap.listener.InMemoryDirectoryServer)1