use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class IdentitySyncTest method setDescriptionMappedToState.
private void setDescriptionMappedToState(SysSystemDto system, boolean withTransfor) {
SysSystemAttributeMappingFilter descAttrMapFilt = new SysSystemAttributeMappingFilter();
descAttrMapFilt.setSystemId(system.getId());
descAttrMapFilt.setIdmPropertyName("description");
List<SysSystemAttributeMappingDto> mapAttrs = schemaAttributeMappingService.find(descAttrMapFilt, null).getContent();
if (mapAttrs.size() == 0) {
// try if re-mapping has been already set
descAttrMapFilt.setIdmPropertyName(IDM_IDENTITY_STATE);
mapAttrs = schemaAttributeMappingService.find(descAttrMapFilt, null).getContent();
}
Assert.assertEquals(1, mapAttrs.size());
SysSystemAttributeMappingDto descAttrMap = mapAttrs.get(0);
descAttrMap.setIdmPropertyName(IDM_IDENTITY_STATE);
descAttrMap.setName(ATTRIBUTE_DESCRIP);
if (withTransfor) {
StringBuilder sb = new StringBuilder("import eu.bcvsolutions.idm.core.api.domain.IdentityState;\n");
sb.append("return IdentityState.CREATED;\n");
descAttrMap.setTransformFromResourceScript(sb.toString());
}
schemaAttributeMappingService.save(descAttrMap);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class ContractSliceSyncTest method doCreateSyncConfig.
public AbstractSysSyncConfigDto doCreateSyncConfig(SysSystemDto system) {
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.CONTRACT_SLICE);
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
AbstractSysSyncConfigDto syncConfigCustom = new SysSyncContractConfigDto();
syncConfigCustom.setReconciliation(true);
syncConfigCustom.setCustomFilter(false);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
syncConfigCustom.setName(SYNC_CONFIG_NAME);
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom = syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
return syncConfigCustom;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method doCreateSyncConfig.
public AbstractSysSyncConfigDto doCreateSyncConfig(SysSystemDto system) {
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
AbstractSysSyncConfigDto syncConfigCustom = new SysSyncContractConfigDto();
syncConfigCustom.setReconciliation(true);
syncConfigCustom.setCustomFilter(false);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
syncConfigCustom.setName(SYNC_CONFIG_NAME);
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK_AND_UPDATE_ENTITY);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom = syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
return syncConfigCustom;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class RoleCatalogueSyncTest method doCreateSyncConfig.
@Transactional
public AbstractSysSyncConfigDto doCreateSyncConfig(String nameSuffix) {
initData(nameSuffix);
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.ROLE_CATALOGUE);
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().get();
// Create default synchronization config
SysSyncConfigDto syncConfigCustom = new SysSyncConfigDto();
syncConfigCustom.setReconciliation(true);
syncConfigCustom.setCustomFilter(true);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
syncConfigCustom.setReconciliation(true);
syncConfigCustom.setName(helper.createName());
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom = (SysSyncConfigDto) syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
return syncConfigCustom;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class SystemMappingDeleteProcessor method process.
@Override
public EventResult<SysSystemMappingDto> process(EntityEvent<SysSystemMappingDto> event) {
SysSystemMappingDto systemMapping = event.getContent();
UUID systemMappingId = systemMapping.getId();
boolean forceDelete = getBooleanProperty(PROPERTY_FORCE_DELETE, event.getProperties());
//
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.findRoleConfigBySystemMapping(systemMappingId);
if (!forceDelete) {
if (syncConfigService.countBySystemMapping(systemMapping) > 0) {
SysSchemaObjectClassDto objectClassDto = DtoUtils.getEmbedded(systemMapping, SysSystemMapping_.objectClass, SysSchemaObjectClassDto.class);
SysSystemDto systemDto = DtoUtils.getEmbedded(objectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
throw new ResultCodeException(AccResultCode.SYSTEM_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("mapping", systemMapping.getName(), "system", systemDto.getName()));
}
if (syncConfigs.size() > 0) {
SysSystemMappingDto systemMappingDto = DtoUtils.getEmbedded(syncConfigs.get(0), SysSyncRoleConfig_.systemMapping, SysSystemMappingDto.class);
SysSchemaObjectClassDto objectClassDto = DtoUtils.getEmbedded(systemMappingDto, SysSystemMapping_.objectClass, SysSchemaObjectClassDto.class);
SysSystemDto systemDto = DtoUtils.getEmbedded(objectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
throw new ResultCodeException(AccResultCode.SYSTEM_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("mapping", systemMapping.getName(), "system", systemDto.getName()));
}
} else {
SysSyncConfigFilter syncFilter = new SysSyncConfigFilter();
syncFilter.setSystemMappingId(systemMappingId);
syncConfigService.find(syncFilter, null).forEach(syncConfig -> {
SyncConfigEvent syncConfigEvent = new SyncConfigEvent(SyncConfigEventType.DELETE, syncConfig);
//
syncConfigService.publish(syncConfigEvent, event);
});
//
syncConfigs.forEach(syncConfig -> {
SyncConfigEvent syncConfigEvent = new SyncConfigEvent(SyncConfigEventType.DELETE, syncConfig);
//
syncConfigService.publish(syncConfigEvent, event);
});
}
//
// remove all handled attributes
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemMappingId(systemMapping.getId());
systemAttributeMappingService.find(filter, null).forEach(systemAttributeMapping -> {
systemAttributeMappingService.delete(systemAttributeMapping);
});
//
// delete mapped roles
SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
roleSystemFilter.setSystemMappingId(systemMapping.getId());
roleSystemService.find(roleSystemFilter, null).forEach(roleSystem -> {
roleSystemService.delete(roleSystem);
});
//
systemMappingService.deleteInternal(systemMapping);
//
return new DefaultEventResult<>(event, this);
}
Aggregations