Search in sources :

Example 56 with SysSystemAttributeMappingFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter 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 57 with SysSystemAttributeMappingFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter 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 58 with SysSystemAttributeMappingFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter 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)

Example 59 with SysSystemAttributeMappingFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.

the class DefaultSynchronizationServiceTest method doStartSyncE_StrategyWriteIfNull.

@Test
public void doStartSyncE_StrategyWriteIfNull() {
    SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
    configFilter.setName(SYNC_CONFIG_NAME);
    List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
    Assert.assertEquals(1, syncConfigs.size());
    AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
    Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
    // Find email attribute and change strategy on WRITE_IF_NULL
    SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
    mappingFilter.setEntityType(SystemEntityType.IDENTITY);
    SysSystemMappingDto systemMapping = systemMappingService.get(syncConfigCustom.getSystemMapping());
    SysSystemDto system = systemService.get(schemaObjectClassService.get(systemMapping.getObjectClass()).getSystem());
    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 emailAttribute = attributes.stream().filter(attribute -> {
        return attribute.getName().equalsIgnoreCase(ATTRIBUTE_EMAIL);
    }).findFirst().get();
    emailAttribute.setStrategyType(AttributeMappingStrategyType.WRITE_IF_NULL);
    schemaAttributeMappingService.save(emailAttribute);
    // 
    // Set email on identity ONE to null
    IdmIdentityDto one = identityService.getByUsername("x" + IDENTITY_USERNAME_ONE);
    one.setEmail(null);
    identityService.save(one);
    // Prepare resource data
    this.getBean().deleteAllResourceData();
    this.getBean().initResourceData();
    this.getBean().changeResourceData();
    // Set sync config
    syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
    syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    syncConfigCustom.setReconciliation(true);
    syncConfigService.save(syncConfigCustom);
    // Check state before sync
    Assert.assertEquals(null, identityService.getByUsername("x" + IDENTITY_USERNAME_ONE).getEmail());
    Assert.assertEquals(IDENTITY_EMAIL_CORRECT, identityService.getByUsername("x" + IDENTITY_USERNAME_TWO).getEmail());
    // Start synchronization
    helper.startSynchronization(syncConfigCustom);
    // 
    SysSyncLogFilter logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    SysSyncLogDto log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
    actionLogFilter.setSynchronizationLogId(log.getId());
    List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
    Assert.assertEquals(1, actions.size());
    SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
        return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
    }).findFirst().get();
    SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
    itemLogFilter.setSyncActionLogId(actionLog.getId());
    List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
    Assert.assertEquals(2, items.size());
    // Check state after sync
    Assert.assertEquals(IDENTITY_EMAIL_CORRECT_CHANGED, identityService.getByUsername("x" + IDENTITY_USERNAME_ONE).getEmail());
    Assert.assertEquals(IDENTITY_EMAIL_CORRECT, identityService.getByUsername("x" + IDENTITY_USERNAME_TWO).getEmail());
    // Delete log
    syncLogService.delete(log);
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSyncItemLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 60 with SysSystemAttributeMappingFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.

the class ChangesOnSystemReportExecutor method getAttributesById.

/**
 * Get defined attributes for report
 *
 * @param list of attribute Ids
 * @return
 */
private List<SysSystemAttributeMappingDto> getAttributesById(List<UUID> attributeIds, SysSystemMappingDto mapping) {
    if (CollectionUtils.isEmpty(attributeIds)) {
        SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
        filter.setSystemMappingId(mapping.getId());
        filter.setDisabledAttribute(Boolean.FALSE);
        // 
        return systemAttributeMappingService.find(filter, null).getContent();
    }
    // 
    return attributeIds.stream().map(systemAttributeMappingService::get).filter(Objects::nonNull).collect(Collectors.toList());
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)

Aggregations

SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)138 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)125 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)93 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)86 Test (org.junit.Test)85 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)82 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)53 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)37 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)36 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)34 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)32 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)27 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)24 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)24 ConnectorType (eu.bcvsolutions.idm.acc.service.api.ConnectorType)23 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)22 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)22 UUID (java.util.UUID)22 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)18 SysSystemAttributeMappingService (eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService)18