use of eu.bcvsolutions.idm.core.exception.TreeTypeException in project CzechIdMng by bcvsolutions.
the class TreeTypeDeleteProcessor method process.
@Override
public EventResult<IdmTreeTypeDto> process(EntityEvent<IdmTreeTypeDto> event) {
IdmTreeTypeDto treeType = event.getContent();
Assert.notNull(treeType);
//
Page<IdmTreeNode> nodes = nodeRepository.findChildren(treeType.getId(), null, new PageRequest(0, 1));
if (nodes.getTotalElements() > 0) {
throw new TreeTypeException(CoreResultCode.TREE_TYPE_DELETE_FAILED_HAS_CHILDREN, ImmutableMap.of("treeType", treeType.getName()));
}
if (identityContractRepository.countByWorkPosition_TreeType_Id(treeType.getId()) > 0) {
throw new TreeTypeException(CoreResultCode.TREE_TYPE_DELETE_FAILED_HAS_CONTRACTS, ImmutableMap.of("treeType", treeType.getName()));
}
//
service.deleteInternal(treeType);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.exception.TreeTypeException in project CzechIdMng by bcvsolutions.
the class TreeTypeDeleteProcessor method process.
@Override
public EventResult<IdmTreeTypeDto> process(EntityEvent<IdmTreeTypeDto> event) {
IdmTreeTypeDto treeType = event.getContent();
Asserts.notNull(treeType, "TreeType must be set!");
SysSystemMappingFilter filter = new SysSystemMappingFilter();
filter.setTreeTypeId(treeType.getId());
List<SysSystemMappingDto> mappings = systemMappingService.find(filter, null).getContent();
long count = mappings.size();
if (count > 0) {
SysSystemDto systemDto = systemService.get(schemaObjectClassService.get(mappings.get(0).getObjectClass()).getSystem());
throw new TreeTypeException(AccResultCode.SYSTEM_MAPPING_TREE_TYPE_DELETE_FAILED, ImmutableMap.of("treeType", treeType.getName(), "system", systemDto.getCode()));
}
// Delete link to sync contract configuration
if (treeType != null && treeType.getId() != null) {
syncConfigRepository.clearDefaultTreeType(treeType.getId());
}
return new DefaultEventResult<>(event, this);
}
Aggregations