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);
}
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();
}
Aggregations