use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class AbstractConnectorType method load.
@Override
public ConnectorTypeDto load(ConnectorTypeDto connectorType) {
if (!connectorType.isReopened()) {
// Load default value for new system.
connectorType.setMetadata(this.getMetadata());
return connectorType;
}
// Load the system.
SysSystemDto systemDto = (SysSystemDto) connectorType.getEmbedded().get(SYSTEM_DTO_KEY);
Assert.notNull(systemDto, "System must exists!");
connectorType.getEmbedded().put(SYSTEM_DTO_KEY, systemDto);
// Set remote server ID to the connector type.
connectorType.setRemoteServer(systemDto.getRemoteServer());
// Load the mapping.
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(systemDto.getId());
List<SysSystemMappingDto> mappingDtos = systemMappingService.find(mappingFilter, null).getContent().stream().sorted(Comparator.comparing(SysSystemMappingDto::getCreated)).collect(Collectors.toList());
// Show alert if more mappings exists.
if (mappingDtos.size() > 1) {
connectorType.getMetadata().put(ALERT_MORE_MAPPINGS, Boolean.TRUE.toString());
}
SysSystemMappingDto mappingDto = mappingDtos.stream().findFirst().orElse(null);
connectorType.getEmbedded().put(MAPPING_DTO_KEY, mappingDto);
// Load the sync.
SysSyncConfigFilter syncFilter = new SysSyncConfigFilter();
syncFilter.setSystemId(systemDto.getId());
if (mappingDto != null) {
syncFilter.setSystemMappingId(mappingDto.getId());
}
AbstractSysSyncConfigDto syncDto = syncConfigService.find(syncFilter, null).getContent().stream().min(Comparator.comparing(AbstractDto::getCreated)).orElse(null);
connectorType.getEmbedded().put(SYNC_DTO_KEY, syncDto);
return connectorType;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultConnectorManagerTest method testAutoProvisioningMappingInWizard.
@Test
public void testAutoProvisioningMappingInWizard() {
SysSystemDto systemDto = helper.createTestResourceSystem(true);
ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(systemDto);
Assert.assertEquals(DefaultConnectorType.NAME, connectorType.getConnectorName());
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(systemDto.getId());
SysSystemMappingDto sysSystemMappingDto = mappingService.find(mappingFilter, null).getContent().stream().findFirst().orElse(null);
Assert.assertNotNull(sysSystemMappingDto);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
connectorTypeDto.getMetadata().put(AbstractConnectorType.SCHEMA_ID, (sysSystemMappingDto).getObjectClass().toString());
// Delete a created mapping.
mappingService.delete(sysSystemMappingDto);
connectorTypeDto.getEmbedded().put(AbstractConnectorType.SYSTEM_DTO_KEY, systemDto);
connectorTypeDto.setReopened(true);
connectorTypeDto = connectorManager.load(connectorTypeDto);
// Execute mapping step.
connectorTypeDto.setReopened(false);
connectorTypeDto.setWizardStepName(AbstractConnectorType.STEP_MAPPING);
connectorTypeDto.getMetadata().put(AbstractConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
connectorTypeDto.getMetadata().put(AbstractConnectorType.OPERATION_TYPE, SystemOperationType.PROVISIONING.name());
connectorTypeDto.getMetadata().put(AbstractConnectorType.ENTITY_TYPE, SystemEntityType.IDENTITY.name());
systemController.executeConnectorType(connectorTypeDto);
ConnectorTypeDto connectorTypeDtoAfterMappingStep = connectorManager.convertTypeToDto(connectorType);
connectorTypeDtoAfterMappingStep.getEmbedded().put(AbstractConnectorType.SYSTEM_DTO_KEY, systemDto);
connectorTypeDtoAfterMappingStep.setReopened(true);
connectorTypeDtoAfterMappingStep = connectorManager.load(connectorTypeDtoAfterMappingStep);
// Sync mapping must exist.
BaseDto mapping = connectorTypeDtoAfterMappingStep.getEmbedded().get(AbstractConnectorType.MAPPING_DTO_KEY);
Assert.assertTrue(mapping instanceof SysSystemMappingDto);
SysSystemMappingDto syncMapping = (SysSystemMappingDto) mapping;
Assert.assertSame(SystemOperationType.PROVISIONING, syncMapping.getOperationType());
// Attributes had to be created.
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(syncMapping.getId());
List<SysSystemAttributeMappingDto> attributeMappingDtos = attributeMappingService.find(attributeMappingFilter, null).getContent();
Assert.assertEquals(7, attributeMappingDtos.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultConnectorManagerTest method testAutoProvisioningMappingOutsideWizard.
@Test
public void testAutoProvisioningMappingOutsideWizard() {
SysSystemDto systemDto = helper.createTestResourceSystem(true);
ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(systemDto);
Assert.assertEquals(DefaultConnectorType.NAME, connectorType.getConnectorName());
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(systemDto.getId());
SysSystemMappingDto sysSystemMappingDto = mappingService.find(mappingFilter, null).getContent().stream().findFirst().orElse(null);
Assert.assertNotNull(sysSystemMappingDto);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
connectorTypeDto.getMetadata().put(AbstractConnectorType.SCHEMA_ID, (sysSystemMappingDto).getObjectClass().toString());
// Delete a created mapping.
mappingService.delete(sysSystemMappingDto);
SysSystemMappingDto mappingDto = new SysSystemMappingDto();
mappingDto.setObjectClass(sysSystemMappingDto.getObjectClass());
mappingDto.setName("Mapping");
mappingDto.setEntityType(SystemEntityType.IDENTITY);
mappingDto.setOperationType(SystemOperationType.PROVISIONING);
mappingDto = mappingService.publish(new SystemMappingEvent(SystemMappingEvent.SystemMappingEventType.CREATE, mappingDto, ImmutableMap.of(SysSystemMappingService.ENABLE_AUTOMATIC_CREATION_OF_MAPPING, true))).getContent();
// Attributes had to be created.
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mappingDto.getId());
List<SysSystemAttributeMappingDto> attributeMappingDtos = attributeMappingService.find(attributeMappingFilter, null).getContent();
Assert.assertEquals(7, attributeMappingDtos.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultConnectorManagerTest method testAutoSyncMappingOutsideWizard.
@Test
public void testAutoSyncMappingOutsideWizard() {
SysSystemDto systemDto = helper.createTestResourceSystem(true);
ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(systemDto);
Assert.assertEquals(DefaultConnectorType.NAME, connectorType.getConnectorName());
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(systemDto.getId());
SysSystemMappingDto sysSystemMappingDto = mappingService.find(mappingFilter, null).getContent().stream().findFirst().orElse(null);
Assert.assertNotNull(sysSystemMappingDto);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
connectorTypeDto.getMetadata().put(AbstractConnectorType.SCHEMA_ID, (sysSystemMappingDto).getObjectClass().toString());
// Delete a created mapping.
mappingService.delete(sysSystemMappingDto);
SysSystemMappingDto syncMapping = new SysSystemMappingDto();
syncMapping.setObjectClass(sysSystemMappingDto.getObjectClass());
syncMapping.setName("Mapping");
syncMapping.setEntityType(SystemEntityType.IDENTITY);
syncMapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
syncMapping = mappingService.publish(new SystemMappingEvent(SystemMappingEvent.SystemMappingEventType.CREATE, syncMapping, ImmutableMap.of(SysSystemMappingService.ENABLE_AUTOMATIC_CREATION_OF_MAPPING, true))).getContent();
// Attributes had to be created.
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(syncMapping.getId());
List<SysSystemAttributeMappingDto> attributeMappingDtos = attributeMappingService.find(attributeMappingFilter, null).getContent();
Assert.assertEquals(7, attributeMappingDtos.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method doCreateSyncConfig.
@Test
@Transactional
public void doCreateSyncConfig() {
initData();
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
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 nameAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equals(ATTRIBUTE_NAME);
}).findFirst().get();
SysSystemAttributeMappingDto modifiedAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equals(ATTRIBUTE_MODIFIED);
}).findFirst().get();
// Create default synchronization config
AbstractSysSyncConfigDto syncConfigCustom = new SysSyncIdentityConfigDto();
syncConfigCustom.setCustomFilter(true);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(nameAttribute.getId());
syncConfigCustom.setTokenAttribute(modifiedAttribute.getId());
syncConfigCustom.setFilterAttribute(modifiedAttribute.getId());
syncConfigCustom.setReconciliation(true);
syncConfigCustom.setName(SYNC_CONFIG_NAME);
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
}
Aggregations