Search in sources :

Example 11 with SysSyncConfigFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter 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.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;
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)

Example 12 with SysSyncConfigFilter

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

the class IdentitySyncTest method doCreateSyncConfig.

public SysSyncIdentityConfigDto doCreateSyncConfig(SysSystemDto system) {
    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 uidAttribute = attributes.stream().filter(attribute -> {
        return attribute.isUid();
    }).findFirst().orElse(null);
    // Create default synchronization config
    SysSyncIdentityConfigDto syncConfigCustom = new SysSyncIdentityConfigDto();
    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);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    syncConfigCustom = (SysSyncIdentityConfigDto) syncConfigService.save(syncConfigCustom);
    SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
    configFilter.setSystemId(system.getId());
    Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
    return syncConfigCustom;
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) 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)

Example 13 with SysSyncConfigFilter

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

the class SysSyncConfigController method toFilter.

@Override
protected SysSyncConfigFilter toFilter(MultiValueMap<String, Object> parameters) {
    SysSyncConfigFilter filter = new SysSyncConfigFilter();
    filter.setSystemId(getParameterConverter().toUuid(parameters, "systemId"));
    return filter;
}
Also used : SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)

Example 14 with SysSyncConfigFilter

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

the class DefaultSysSystemService method findSyncConfigs.

/**
 * Find sync configs for given system ID and do detach.
 * @param id
 * @return
 */
private List<AbstractSysSyncConfigDto> findSyncConfigs(UUID id) {
    SysSyncConfigFilter syncConfigFilter = new SysSyncConfigFilter();
    syncConfigFilter.setSystemId(id);
    return synchronizationConfigService.find(syncConfigFilter, null).getContent();
}
Also used : SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)

Example 15 with SysSyncConfigFilter

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

the class DefaultSysSystemServiceTest method duplicateSystemWithSynchronization.

@Test
public void duplicateSystemWithSynchronization() {
    String syncName = "test-sync-config";
    // create test system
    SysSystemDto system = helper.createTestResourceSystem(true);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    // Number of schema attributes on original system
    int numberOfSchemaAttributesOrig = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
    SysSystemMappingDto mappingOrig = helper.getDefaultMapping(system);
    // Number of mapping attributes on original system
    int numberOfMappingAttributesOrig = systemAttributeMappingService.findBySystemMapping(mappingOrig).size();
    SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
    attributeMappingFilter.setSystemMappingId(mappingOrig.getId());
    List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
    SysSystemAttributeMappingDto nameAttribute = attributes.stream().filter(attribute -> {
        return attribute.getName().equals(TestHelper.ATTRIBUTE_MAPPING_NAME);
    }).findFirst().get();
    SysSystemAttributeMappingDto firstNameAttribute = attributes.stream().filter(attribute -> {
        return attribute.getName().equals(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
    }).findFirst().get();
    SysSystemAttributeMappingDto emailAttribute = attributes.stream().filter(attribute -> {
        return attribute.getName().equals(TestHelper.ATTRIBUTE_MAPPING_EMAIL);
    }).findFirst().get();
    // create synchronization config
    AbstractSysSyncConfigDto syncConfigDuplicate = new SysSyncIdentityConfigDto();
    syncConfigDuplicate.setCustomFilter(true);
    syncConfigDuplicate.setSystemMapping(mappingOrig.getId());
    syncConfigDuplicate.setCorrelationAttribute(nameAttribute.getId());
    syncConfigDuplicate.setTokenAttribute(firstNameAttribute.getId());
    syncConfigDuplicate.setFilterAttribute(emailAttribute.getId());
    syncConfigDuplicate.setReconciliation(true);
    syncConfigDuplicate.setName(syncName);
    syncConfigDuplicate.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
    syncConfigDuplicate.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    syncConfigDuplicate.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
    syncConfigDuplicate.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    syncConfigDuplicate = syncConfigService.save(syncConfigDuplicate);
    SysSystemDto duplicatedSystem = systemService.duplicate(system.getId());
    // check duplicate
    systemService.checkSystem(duplicatedSystem);
    Assert.assertNotEquals(system.getId(), duplicatedSystem.getId());
    schemaAttributeFilter.setSystemId(duplicatedSystem.getId());
    // Number of schema attributes on duplicated system
    int numberOfSchemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
    Assert.assertEquals(numberOfSchemaAttributesOrig, numberOfSchemaAttributes);
    SysSystemMappingDto mapping = helper.getDefaultMapping(duplicatedSystem);
    // Number of mapping attributes on duplicated system
    int numberOfMappingAttributes = systemAttributeMappingService.findBySystemMapping(mapping).size();
    Assert.assertEquals(numberOfMappingAttributesOrig, numberOfMappingAttributes);
    // check synchronization config
    SysSyncConfigFilter syncFilter = new SysSyncConfigFilter();
    syncFilter.setSystemId(duplicatedSystem.getId());
    List<AbstractSysSyncConfigDto> configs = syncConfigService.find(syncFilter, null).getContent();
    Assert.assertEquals(1, configs.size());
    Assert.assertEquals(1, configs.size());
    AbstractSysSyncConfigDto configNew = configs.get(0);
    Assert.assertFalse(configNew.isEnabled());
    Assert.assertTrue(configNew.isReconciliation());
    Assert.assertEquals(syncName, configNew.getName());
    Assert.assertTrue(configNew.isCustomFilter());
    Assert.assertEquals(syncConfigDuplicate.getLinkedAction(), configNew.getLinkedAction());
    Assert.assertEquals(syncConfigDuplicate.getUnlinkedAction(), configNew.getUnlinkedAction());
    Assert.assertEquals(syncConfigDuplicate.getMissingEntityAction(), configNew.getMissingEntityAction());
    Assert.assertEquals(syncConfigDuplicate.getMissingAccountAction(), configNew.getMissingAccountAction());
    SysSystemAttributeMappingDto correlationAtt = schemaAttributeMappingService.get(configNew.getCorrelationAttribute());
    SysSystemAttributeMappingDto tokenAtt = schemaAttributeMappingService.get(configNew.getTokenAttribute());
    SysSystemAttributeMappingDto filterAtt = schemaAttributeMappingService.get(configNew.getFilterAttribute());
    Assert.assertEquals(nameAttribute.getName(), correlationAtt.getName());
    Assert.assertEquals(nameAttribute.getIdmPropertyName(), correlationAtt.getIdmPropertyName());
    Assert.assertEquals(firstNameAttribute.getName(), tokenAtt.getName());
    Assert.assertEquals(firstNameAttribute.getIdmPropertyName(), tokenAtt.getIdmPropertyName());
    Assert.assertEquals(emailAttribute.getName(), filterAtt.getName());
    Assert.assertEquals(emailAttribute.getIdmPropertyName(), filterAtt.getIdmPropertyName());
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)34 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)30 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)26 Test (org.junit.Test)26 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)22 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)21 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)21 SysSyncActionLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter)21 SysSyncItemLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter)21 SysSyncLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter)21 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)15 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)11 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)11 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)10 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)10 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)6 Transactional (org.springframework.transaction.annotation.Transactional)6 SysSyncIdentityConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto)4 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)4 SysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncConfigDto)3