use of eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeTypeFilter in project CzechIdMng by bcvsolutions.
the class ComplexHrProcessIntegrationTest method createHrContractSystem.
private void createHrContractSystem() {
getBean().deleteAllResourceData(TestContractResource.TABLE_NAME);
// create new system
SysSystemDto system = accTestHelper.createSystem(TestContractResource.TABLE_NAME, contractSysName, null, "ID");
system.setReadonly(true);
system.setDisabledProvisioning(true);
system = systemService.save(system);
List<IdmFormValueDto> values = new ArrayList<IdmFormValueDto>();
IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(system);
IdmFormValueDto changeLogColumnValue = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("changeLogColumn"));
changeLogColumnValue.setValue("MODIFIED");
values.add(changeLogColumnValue);
formService.saveValues(system, savedFormDefinition, values);
// generate schema for system
List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
// Create synchronization mapping
SysSystemMappingDto syncSystemMapping = new SysSystemMappingDto();
syncSystemMapping.setName(getHelper().createName());
syncSystemMapping.setEntityType(SystemEntityType.CONTRACT);
syncSystemMapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
syncSystemMapping = systemMappingService.save(syncSystemMapping);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
for (SysSchemaAttributeDto schemaAttr : schemaAttributes) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(syncSystemMapping.getId());
attributeMapping.setEntityAttribute(true);
// just id, not mapped to attribute
if (StringUtils.equalsIgnoreCase("ID", schemaAttr.getName())) {
attributeMapping.setUid(true);
attributeMapping.setEntityAttribute(true);
// correlation attr
attributeMapping.setName(schemaAttr.getName().toLowerCase());
// used for storing contract id
attributeMapping.setIdmPropertyName("position");
} else if (StringUtils.equalsIgnoreCase("STATE", schemaAttr.getName())) {
attributeMapping.setName(schemaAttr.getName().toLowerCase());
attributeMapping.setIdmPropertyName("state");
} else if (StringUtils.equalsIgnoreCase("VALIDFROM", schemaAttr.getName())) {
attributeMapping.setName(schemaAttr.getName().toLowerCase());
attributeMapping.setIdmPropertyName("validFrom");
attributeMapping.setTransformFromResourceScript(getScriptCallExpression(stringToLocalDateScript));
attributeMapping.setCached(true);
} else if (StringUtils.equalsIgnoreCase("VALIDTILL", schemaAttr.getName())) {
attributeMapping.setName(schemaAttr.getName().toLowerCase());
attributeMapping.setIdmPropertyName("validTill");
attributeMapping.setTransformFromResourceScript(getScriptCallExpression(stringToLocalDateScript));
attributeMapping.setCached(true);
// this maps personalNumber to identity to which contract belongs; transformation script is used
} else if (StringUtils.equalsIgnoreCase("NAME", schemaAttr.getName())) {
// NAME used for personalNumber aka externalCode
attributeMapping.setName(schemaAttr.getName().toLowerCase());
// represents IdmIentityDto
attributeMapping.setIdmPropertyName("identity");
attributeMapping.setTransformFromResourceScript(getScriptCallExpression(getIdentityUuidByPersonalNumScript));
attributeMapping.setCached(true);
} else if (StringUtils.equalsIgnoreCase("WORKPOSITION", schemaAttr.getName())) {
attributeMapping.setName(schemaAttr.getName().toLowerCase());
attributeMapping.setIdmPropertyName("workPosition");
} else if (StringUtils.equalsIgnoreCase("POSITIONS", schemaAttr.getName())) {
attributeMapping.setName(schemaAttr.getName().toLowerCase());
attributeMapping.setIdmPropertyName(eavAutoRoleAttrName);
attributeMapping.setEntityAttribute(false);
attributeMapping.setExtendedAttribute(true);
} else {
// skip those undefined
continue;
}
attributeMapping = systemAttributeMappingService.save(attributeMapping);
}
// Create default synchronization config
SysSystemAttributeMappingFilter mapAttrFilt = new SysSystemAttributeMappingFilter();
mapAttrFilt.setSystemId(system.getId());
mapAttrFilt.setName("id");
SysSystemAttributeMappingDto correlationAttr = systemAttributeMappingService.find(mapAttrFilt, null).getContent().get(0);
IdmTreeTypeFilter typeFilt = new IdmTreeTypeFilter();
typeFilt.setCode(orgTreeTypeName);
IdmTreeTypeDto treeType = treeTypeService.find(typeFilt, null).getContent().get(0);
SysSyncContractConfigDto syncConfigCustom = new SysSyncContractConfigDto();
syncConfigCustom.setReconciliation(false);
syncConfigCustom.setCustomFilter(false);
syncConfigCustom.setSystemMapping(syncSystemMapping.getId());
syncConfigCustom.setCorrelationAttribute(correlationAttr.getId());
syncConfigCustom.setName(contractSysName + "-SYNC");
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setStartOfHrProcesses(true);
syncConfigCustom.setStartAutoRoleRec(true);
syncConfigCustom.setDefaultTreeType(treeType.getId());
syncConfigCustom = (SysSyncContractConfigDto) sysSyncConfigService.save(syncConfigCustom);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeTypeFilter in project CzechIdMng by bcvsolutions.
the class ComplexHrProcessIntegrationTest method initOrgStructure.
/**
* Creates organization structure common for all test cases
*/
private void initOrgStructure() {
IdmTreeNodeDto root = null;
IdmTreeNodeDto node = null;
// get tree type dto
IdmTreeTypeFilter typeFilt = new IdmTreeTypeFilter();
typeFilt.setCode(orgTreeTypeName);
IdmTreeTypeDto treeType = treeTypeService.find(typeFilt, null).getContent().get(0);
IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
filter.setCode(rootNodeName);
filter.setTreeTypeId(treeType.getId());
List<IdmTreeNodeDto> roots = treeNodeService.find(filter, null).getContent();
if (roots.size() == 0) {
root = new IdmTreeNodeDto();
root.setCode(rootNodeName);
root.setName(rootNodeName);
root.setTreeType(treeType.getId());
root = treeNodeService.save(root);
} else {
root = roots.get(0);
}
// Department1
node = new IdmTreeNodeDto();
node.setCode(dep1NodeName);
node.setName(dep1NodeName);
node.setTreeType(treeType.getId());
node.setParent(root.getId());
node = treeNodeService.save(node);
// Department2
node = new IdmTreeNodeDto();
node.setCode(dep2NodeName);
node.setName(dep2NodeName);
node.setTreeType(treeType.getId());
node.setParent(root.getId());
node = treeNodeService.save(node);
}
Aggregations