use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class TreeTypeDeleteProcessor method process.
@Override
public EventResult<IdmTreeTypeDto> process(EntityEvent<IdmTreeTypeDto> event) {
IdmTreeTypeDto treeType = event.getContent();
UUID treeTypeId = treeType.getId();
Asserts.notNull(treeTypeId, "Tree type identifier is required.");
boolean forceDelete = getBooleanProperty(PROPERTY_FORCE_DELETE, event.getProperties());
//
SysSystemMappingFilter filter = new SysSystemMappingFilter();
filter.setTreeTypeId(treeTypeId);
List<SysSystemMappingDto> mappings = systemMappingService.find(filter, null).getContent();
if (!forceDelete) {
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.getCode(), "system", systemDto.getCode()));
}
} else {
mappings.forEach(mapping -> {
SystemMappingEvent mappingEvent = new SystemMappingEvent(SystemMappingEventType.DELETE, mapping);
//
systemMappingService.publish(mappingEvent, event);
});
}
// Delete link to sync contract configuration.
syncConfigRepository.findByDefaultTreeType(treeTypeId).forEach(config -> {
SysSyncContractConfigDto configDto = (SysSyncContractConfigDto) syncConfigService.get(config.getId());
configDto.setDefaultTreeType(null);
syncConfigService.save(configDto);
});
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class SystemExportBulkActionIntegrationTest method findMappings.
private List<SysSystemMappingDto> findMappings(SysSystemDto system) {
SysSystemMappingFilter filter = new SysSystemMappingFilter();
filter.setSystemId(system.getId());
return systemMappingService.find(filter, null).getContent();
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class SystemMappingDuplicateBulkActionTest method processBulkActionByIds.
@Test
public void processBulkActionByIds() {
SysSystemDto system = helper.createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filter = new SysSystemMappingFilter();
filter.setSystemId(system.getId());
List<SysSystemMappingDto> mappings = mappingService.find(filter, null).getContent();
// Contains only one created system mapping
assertEquals(1, mappings.size());
SysSystemMappingDto origMapping = mappings.get(0);
IdmBulkActionDto bulkAction = this.findBulkAction(SysSystemMapping.class, SystemMappingDuplicateBulkAction.NAME);
bulkAction.setIdentifiers(ImmutableSet.of(origMapping.getId()));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
// Some new cloned mappings were created
mappings = mappingService.find(filter, null).getContent();
assertTrue(mappings.size() > 1);
compareCloningResult(origMapping, mappings);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class SystemMappingDuplicateBulkActionTest method processBulkActionByFilter.
@Test
public void processBulkActionByFilter() {
SysSystemDto system = helper.createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filter = new SysSystemMappingFilter();
filter.setSystemId(system.getId());
List<SysSystemMappingDto> mappings = mappingService.find(filter, null).getContent();
// Contains only one created system mapping
assertEquals(1, mappings.size());
SysSystemMappingDto origMapping = mappings.get(0);
IdmBulkActionDto bulkAction = this.findBulkAction(SysSystemMapping.class, SystemMappingDuplicateBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
// Some new cloned mappings were created
mappings = mappingService.find(filter, null).getContent();
assertTrue(mappings.size() > 1);
compareCloningResult(origMapping, mappings);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultUniformPasswordManagerIntegrationTest method doCreateSyncConfig.
public AbstractSysSyncConfigDto doCreateSyncConfig(SysSystemDto system, IdmTreeTypeDto treeType) {
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.CONTRACT);
mappingFilter.setSystemId(system.getId());
mappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
List<SysSystemMappingDto> mappings = systemMappingService.find(mappingFilter, null).getContent();
Assert.assertEquals(1, mappings.size());
SysSystemMappingDto mapping = mappings.get(0);
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
SysSystemAttributeMappingDto uidAttribute = attributes.stream().filter(attribute -> {
return attribute.isUid();
}).findFirst().orElse(null);
// Create default synchronization config
SysSyncContractConfigDto syncConfigCustom = new SysSyncContractConfigDto();
syncConfigCustom.setReconciliation(true);
syncConfigCustom.setCustomFilter(false);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
syncConfigCustom.setName(this.getHelper().createName());
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK_AND_UPDATE_ENTITY);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setStartOfHrProcesses(true);
syncConfigCustom.setStartAutoRoleRec(true);
if (treeType != null) {
syncConfigCustom.setDefaultTreeType(treeType.getId());
}
syncConfigCustom = (SysSyncContractConfigDto) syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
return syncConfigCustom;
}
Aggregations