Search in sources :

Example 11 with SysSystemGroupSystemFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemGroupSystemFilter in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemAttributeMappingService method delete.

@Override
@Transactional
public void delete(SysSystemAttributeMappingDto dto, BasePermission... permission) {
    Assert.notNull(dto, "DTO is required.");
    SysSystemAttributeMapping entity = this.getEntity(dto.getId());
    Assert.notNull(entity, "Entity is required.");
    SysSystemMappingDto systemMappingDto = DtoUtils.getEmbedded(dto, SysSystemAttributeMapping_.systemMapping, SysSystemMappingDto.class);
    SysSchemaObjectClassDto objectClassDto = DtoUtils.getEmbedded(systemMappingDto, SysSystemMapping_.objectClass, SysSchemaObjectClassDto.class);
    SysSystemDto systemDto = DtoUtils.getEmbedded(objectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
    // Check if attribute is used in some systems group.
    SysSystemGroupSystemFilter groupSystemFilter = new SysSystemGroupSystemFilter();
    groupSystemFilter.setMergeMappingAttributeId(entity.getId());
    long count = systemGroupSystemService.count(groupSystemFilter);
    if (count > 0) {
        throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_SYSTEM_GROUPS, ImmutableMap.of("attribute", dto.getName(), "count", count));
    }
    if (syncConfigRepository.countByCorrelationAttribute_Id(dto.getId()) > 0) {
        throw new ResultCodeException(AccResultCode.ATTRIBUTE_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("attribute", dto.getName(), "system", systemDto.getName()));
    }
    if (syncConfigRepository.countByFilterAttribute(entity) > 0) {
        throw new ResultCodeException(AccResultCode.ATTRIBUTE_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("attribute", dto.getName(), "system", systemDto.getName()));
    }
    if (syncConfigRepository.countByTokenAttribute(entity) > 0) {
        throw new ResultCodeException(AccResultCode.ATTRIBUTE_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("attribute", dto.getName(), "system", systemDto.getName()));
    }
    List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.findRoleConfigByMemberOfAttribute(entity.getId());
    if (syncConfigs.size() > 0) {
        systemMappingDto = DtoUtils.getEmbedded(syncConfigs.get(0), SysSyncRoleConfig_.systemMapping, SysSystemMappingDto.class);
        objectClassDto = DtoUtils.getEmbedded(systemMappingDto, SysSystemMapping_.objectClass, SysSchemaObjectClassDto.class);
        systemDto = DtoUtils.getEmbedded(objectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
        throw new ResultCodeException(AccResultCode.ATTRIBUTE_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("attribute", dto.getName(), "system", systemDto.getName()));
    }
    // Delete attributes
    roleSystemAttributeRepository.deleteBySystemAttributeMapping(entity);
    // Delete of controlled and historic values
    if (dto.getId() != null) {
        SysAttributeControlledValueFilter attributeControlledValueFilter = new SysAttributeControlledValueFilter();
        attributeControlledValueFilter.setAttributeMappingId(dto.getId());
        List<SysAttributeControlledValueDto> controlledAndHistoricValues = attributeControlledValueService.find(attributeControlledValueFilter, null).getContent();
        controlledAndHistoricValues.forEach(value -> attributeControlledValueService.delete(value));
    }
    super.delete(dto, permission);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemGroupSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemGroupSystemFilter) SysAttributeControlledValueDto(eu.bcvsolutions.idm.acc.dto.SysAttributeControlledValueDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysAttributeControlledValueFilter(eu.bcvsolutions.idm.acc.dto.filter.SysAttributeControlledValueFilter) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemAttributeMapping(eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with SysSystemGroupSystemFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemGroupSystemFilter in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemGroupSystemService method getSystemsInCrossDomainGroup.

@Override
public List<SysSystemGroupSystemDto> getSystemsInCrossDomainGroup(SysSystemDto system) {
    Assert.notNull(system, "System cannot be null!");
    Assert.notNull(system.getId(), "System ID cannot be null!");
    SysSystemGroupSystemFilter systemGroupSystemFilter = new SysSystemGroupSystemFilter();
    systemGroupSystemFilter.setOthersSystemsInGroupSystemId(system.getId());
    systemGroupSystemFilter.setGroupType(SystemGroupType.CROSS_DOMAIN);
    systemGroupSystemFilter.setDisabled(Boolean.FALSE);
    return this.find(systemGroupSystemFilter, null).getContent();
}
Also used : SysSystemGroupSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemGroupSystemFilter)

Aggregations

SysSystemGroupSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemGroupSystemFilter)12 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)6 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)6 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)5 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)5 SysSystemGroupSystemService (eu.bcvsolutions.idm.acc.service.api.SysSystemGroupSystemService)5 DtoUtils (eu.bcvsolutions.idm.core.api.utils.DtoUtils)5 Serializable (java.io.Serializable)5 List (java.util.List)5 UUID (java.util.UUID)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Transactional (org.springframework.transaction.annotation.Transactional)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 Lists (com.google.common.collect.Lists)4 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)4 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)4 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)4 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)4 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)4 AccountType (eu.bcvsolutions.idm.acc.domain.AccountType)3