use of eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto in project CzechIdMng by bcvsolutions.
the class TreeSynchronizationExecutor method doUpdateEntity.
/**
* Fill data from IC attributes to entity (EAV and confidential storage too)
*
* @param account
* @param entityType
* @param uid
* @param icAttributes
* @param mappedAttributes
* @param log
* @param logItem
* @param actionLogs
*/
@Override
protected void doUpdateEntity(SynchronizationContext context) {
String uid = context.getUid();
SysSyncLogDto log = context.getLog();
SysSyncItemLogDto logItem = context.getLogItem();
List<SysSyncActionLogDto> actionLogs = context.getActionLogs();
List<SysSystemAttributeMappingDto> mappedAttributes = context.getMappedAttributes();
AccAccountDto account = context.getAccount();
List<IcAttribute> icAttributes = context.getIcObject().getAttributes();
UUID entityId = getEntityByAccount(account.getId());
IdmTreeNodeDto treeNode = null;
if (entityId != null) {
treeNode = treeNodeService.get(entityId);
}
if (treeNode != null) {
// Update entity
treeNode = fillEntity(mappedAttributes, uid, icAttributes, treeNode, false, context);
treeNode = this.save(treeNode, true);
// Update extended attribute (entity must be persisted first)
updateExtendedAttributes(mappedAttributes, uid, icAttributes, treeNode, false, context);
// Update confidential attribute (entity must be persisted first)
updateConfidentialAttributes(mappedAttributes, uid, icAttributes, treeNode, false, context);
// TreeNode Updated
addToItemLog(logItem, MessageFormat.format("TreeNode with id {0} was updated", treeNode.getId()));
if (logItem != null) {
logItem.setDisplayName(treeNode.getName());
}
// Call provisioning for entity
this.callProvisioningForEntity(treeNode, context.getEntityType(), logItem);
return;
} else {
addToItemLog(logItem, "Tree - account relation (with ownership = true) was not found!");
initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
return;
}
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto in project CzechIdMng by bcvsolutions.
the class TreeSynchronizationExecutor method startExport.
/**
* Start export entities to target resource
*
* @param entityType
* @param config
* @param mappedAttributes
* @param log
* @param actionsLog
*/
@Override
protected void startExport(SystemEntityType entityType, AbstractSysSyncConfigDto config, List<SysSystemAttributeMappingDto> mappedAttributes, SysSyncLogDto log, List<SysSyncActionLogDto> actionsLog) {
SysSystemMappingDto systemMapping = systemMappingService.get(config.getSystemMapping());
SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(systemMapping.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(schemaObjectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
SysSystemAttributeMappingDto uidAttribute = attributeHandlingService.getUidAttribute(mappedAttributes, system);
List<IdmTreeNodeDto> roots = treeNodeService.findRoots(systemMapping.getTreeType(), null).getContent();
roots.stream().forEach(root -> {
SynchronizationContext itemBuilder = new SynchronizationContext();
//
itemBuilder.addConfig(config).addSystem(//
system).addEntityType(//
entityType).addLog(//
log).addActionLogs(actionsLog);
// Start export for this entity
exportChildrenRecursively(root, itemBuilder, uidAttribute);
});
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultTestHelper method createTestResourceSystem.
@Override
public SysSystemDto createTestResourceSystem(boolean withMapping, String systemName) {
// create test system
SysSystemDto system = createSystem(TestResource.TABLE_NAME, systemName);
//
if (!withMapping) {
return system;
}
//
// generate schema for system
List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
//
SysSystemMappingDto systemMapping = new SysSystemMappingDto();
systemMapping.setName("default_" + System.currentTimeMillis());
systemMapping.setEntityType(SystemEntityType.IDENTITY);
systemMapping.setOperationType(SystemOperationType.PROVISIONING);
systemMapping.setObjectClass(objectClasses.get(0).getId());
systemMapping = systemMappingService.save(systemMapping);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
for (SysSchemaAttributeDto schemaAttr : schemaAttributesPage) {
if (ATTRIBUTE_MAPPING_NAME.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setUid(true);
attributeMapping.setEntityAttribute(true);
attributeMapping.setIdmPropertyName(IdmIdentity_.username.getName());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_ENABLE.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setUid(false);
attributeMapping.setEntityAttribute(true);
attributeMapping.setIdmPropertyName("disabled");
attributeMapping.setTransformToResourceScript("return String.valueOf(!attributeValue);");
attributeMapping.setTransformFromResourceScript("return !attributeValue;");
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_PASSWORD.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName("password");
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_FIRSTNAME.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName(IdmIdentity_.firstName.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_LASTNAME.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName(IdmIdentity_.lastName.getName());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_EMAIL.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName(IdmIdentity_.email.getName());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
}
}
return system;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto in project CzechIdMng by bcvsolutions.
the class AccountManagementTest method createMapping.
private void createMapping(SysSystemDto system, final SysSystemMappingDto entityHandlingResult) {
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
schemaAttributesPage.forEach(schemaAttr -> {
if (ATTRIBUTE_NAME.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setUid(true);
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setIdmPropertyName("name");
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
// For provisioning .. we need create UID
attributeHandlingName.setTransformToResourceScript("return entity.getName();");
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("TYPE".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName("roleType");
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("PRIORITY".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName("priority");
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("APPROVE_REMOVE".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName("approveRemove");
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("MODIFIED".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName("changed");
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setEntityAttribute(false);
attributeHandlingName.setExtendedAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("DESCRIPTION".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName("description");
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setEntityAttribute(true);
;
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
}
});
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto in project CzechIdMng by bcvsolutions.
the class AccountManagementTest method createIdentityMapping.
private void createIdentityMapping(SysSystemDto system, final SysSystemMappingDto entityHandlingResult) {
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
schemaAttributesPage.forEach(schemaAttr -> {
if (ATTRIBUTE_NAME.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setUid(true);
attributeMapping.setEntityAttribute(true);
attributeMapping.setIdmPropertyName("username");
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
} else if ("firstname".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName("firstName");
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
} else if ("lastname".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName("lastName");
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_EMAIL.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName("email");
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
}
});
}
Aggregations