Search in sources :

Example 1 with IdmTreeTypeFilter

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);
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) ArrayList(java.util.ArrayList) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IdmTreeTypeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeTypeFilter)

Example 2 with IdmTreeTypeFilter

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);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmTreeTypeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeTypeFilter)

Aggregations

IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)2 IdmTreeTypeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeTypeFilter)2 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)1 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)1 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)1 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)1 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)1 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)1 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)1 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)1 IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)1 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)1 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)1 ArrayList (java.util.ArrayList)1