Search in sources :

Example 36 with SysSystemMappingFilter

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;
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 37 with SysSystemMappingFilter

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());
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) AbstractConnectorType(eu.bcvsolutions.idm.acc.connector.AbstractConnectorType) CsvConnectorType(eu.bcvsolutions.idm.acc.connector.CsvConnectorType) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) PostgresqlConnectorType(eu.bcvsolutions.idm.acc.connector.PostgresqlConnectorType) DefaultConnectorType(eu.bcvsolutions.idm.acc.connector.DefaultConnectorType) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 38 with SysSystemMappingFilter

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());
}
Also used : SystemMappingEvent(eu.bcvsolutions.idm.acc.event.SystemMappingEvent) ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) AbstractConnectorType(eu.bcvsolutions.idm.acc.connector.AbstractConnectorType) CsvConnectorType(eu.bcvsolutions.idm.acc.connector.CsvConnectorType) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) PostgresqlConnectorType(eu.bcvsolutions.idm.acc.connector.PostgresqlConnectorType) DefaultConnectorType(eu.bcvsolutions.idm.acc.connector.DefaultConnectorType) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 39 with SysSystemMappingFilter

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());
}
Also used : SystemMappingEvent(eu.bcvsolutions.idm.acc.event.SystemMappingEvent) ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) AbstractConnectorType(eu.bcvsolutions.idm.acc.connector.AbstractConnectorType) CsvConnectorType(eu.bcvsolutions.idm.acc.connector.CsvConnectorType) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) PostgresqlConnectorType(eu.bcvsolutions.idm.acc.connector.PostgresqlConnectorType) DefaultConnectorType(eu.bcvsolutions.idm.acc.connector.DefaultConnectorType) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 40 with SysSystemMappingFilter

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());
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)91 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)84 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)67 Test (org.junit.Test)62 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)55 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)51 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)49 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)25 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)23 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)20 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)14 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)11 ConnectorType (eu.bcvsolutions.idm.acc.service.api.ConnectorType)11 ConnectorTypeDto (eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto)10 SysSyncIdentityConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto)10 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)8 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)8 Transactional (org.springframework.transaction.annotation.Transactional)8 SysSyncRoleConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto)7 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)7