use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningStrategyMergeException.
// Expected PROVISIONING_MERGE_ATTRIBUTE_IS_NOT_MULTIVALUE
@Test(expected = ProvisioningException.class)
public void doIdentityProvisioningStrategyMergeException() {
IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
filterSchemaAttr.setIdmPropertyName("email");
filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
attributeHandling.setEntityAttribute(true);
attributeHandling.setStrategyType(AttributeMappingStrategyType.MERGE);
SysSchemaAttributeDto schemaAttributeDto = schemaAttributeService.get(attributeHandling.getSchemaAttribute());
schemaAttributeDto.setMultivalued(false);
schemaAttributeService.save(schemaAttributeDto);
systemAttributeMappingService.save(attributeHandling);
// Do provisioning
provisioningService.doProvisioning(identity);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceTest method idmPropertyNameFilterTest.
@Test
public void idmPropertyNameFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
AttributeMappingStrategyType strategyType = AttributeMappingStrategyType.MERGE;
SysSystemDto system = createSystem();
SysSchemaObjectClassDto objectClass = createObjectClass(system);
SysSystemMappingDto systemMapping = testHelper.createMappingSystem(entityType, objectClass);
SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(objectClass);
SysSystemAttributeMappingDto attributeMapping1 = createAttributeMappingSystem(systemMapping, strategyType, schemaAttribute.getId());
attributeMapping1.setIdmPropertyName("PropName31");
attributeMappingService.save(attributeMapping1);
SysSystemAttributeMappingDto attributeMapping2 = createAttributeMappingSystem(systemMapping, AttributeMappingStrategyType.CREATE, schemaAttribute.getId());
attributeMapping2.setIdmPropertyName("PropName42");
attributeMappingService.save(attributeMapping2);
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setIdmPropertyName("PropName4");
Page<SysSystemAttributeMappingDto> result = attributeMappingService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(attributeMapping2));
assertFalse(result.getContent().contains(attributeMapping1));
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceTest method systemMappingIdFilterTest.
@Test
public void systemMappingIdFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
AttributeMappingStrategyType strategyType = AttributeMappingStrategyType.MERGE;
SysSystemDto system = createSystem();
SysSchemaObjectClassDto objectClass = createObjectClass(system);
SysSystemMappingDto systemMapping1 = testHelper.createMappingSystem(entityType, objectClass);
SysSystemMappingDto systemMapping2 = testHelper.createMappingSystem(entityType, objectClass);
SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(objectClass);
SysSystemAttributeMappingDto attributeMapping1 = createAttributeMappingSystem(systemMapping1, strategyType, schemaAttribute.getId());
SysSystemAttributeMappingDto attributeMapping2 = createAttributeMappingSystem(systemMapping2, strategyType, schemaAttribute.getId());
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemMappingId(systemMapping1.getId());
Page<SysSystemAttributeMappingDto> result = attributeMappingService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(attributeMapping1));
assertFalse(result.getContent().contains(attributeMapping2));
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationService method resolveLinkedSituation.
@Override
public SysSyncItemLogDto resolveLinkedSituation(String uid, SystemEntityType entityType, List<IcAttribute> icAttributes, UUID accountId, UUID configId, String actionType) {
Assert.notNull(uid);
Assert.notNull(entityType);
Assert.notNull(icAttributes);
Assert.notNull(configId);
Assert.notNull(actionType);
Assert.notNull(accountId);
SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
AbstractSysSyncConfigDto config = synchronizationConfigService.get(configId);
SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
AccAccountDto account = accountService.get(accountId);
SysSystemAttributeMappingFilter attributeHandlingFilter = new SysSystemAttributeMappingFilter();
attributeHandlingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> mappedAttributes = attributeHandlingService.find(attributeHandlingFilter, null).getContent();
// Little workaround, we have only IcAttributes ... we create IcObject manually
IcConnectorObjectImpl icObject = new IcConnectorObjectImpl();
icObject.setAttributes(icAttributes);
icObject.setUidValue(uid);
SynchronizationContext context = new SynchronizationContext();
context.addUid(uid).addAccount(account).addConfig(config).addEntityType(entityType).addLogItem(itemLog).addMappedAttributes(mappedAttributes).addIcObject(icObject);
getSyncExecutor(entityType).resolveLinkedSituation(SynchronizationLinkedActionType.valueOf(actionType), context);
return itemLog;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemService method duplicateMapping.
/**
* Duplication of mapping attributes. Is not in attribute mapping service, because we need use IDs cache (Old vs New IDs)
* @param id
* @param schema
* @param schemaAttributesIds
* @param mappedAttributesIds
* @return
*/
private SysSystemMappingDto duplicateMapping(UUID id, SysSchemaObjectClassDto schema, Map<UUID, UUID> schemaAttributesIds, Map<UUID, UUID> mappedAttributesIds) {
Assert.notNull(id, "Id of duplication mapping, must be filled!");
Assert.notNull(schema, "Parent schema must be filled!");
SysSystemMappingDto clonedMapping = systemMappingService.clone(id);
clonedMapping.setObjectClass(schema.getId());
SysSystemMappingDto mapping = this.systemMappingService.save(clonedMapping);
// Clone mapped attributes
SysSystemAttributeMappingFilter attributesFilter = new SysSystemAttributeMappingFilter();
attributesFilter.setSystemMappingId(id);
systemAttributeMappingService.find(attributesFilter, null).forEach(attribute -> {
UUID originalAttributeId = attribute.getId();
SysSystemAttributeMappingDto clonedAttribute = systemAttributeMappingService.clone(originalAttributeId);
// Find cloned schema attribute in cache (by original Id)
SysSchemaAttributeDto clonedSchemaAttribute = attributeService.get(schemaAttributesIds.get(clonedAttribute.getSchemaAttribute()));
clonedAttribute.setSystemMapping(mapping.getId());
clonedAttribute.setSchemaAttribute(clonedSchemaAttribute.getId());
clonedAttribute = systemAttributeMappingService.save(clonedAttribute);
// Put original and new id to cache
mappedAttributesIds.put(originalAttributeId, clonedAttribute.getId());
});
return mapping;
}
Aggregations