Search in sources :

Example 96 with SysSchemaAttributeDto

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

the class ContractSliceSyncTest 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 ("id".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setUid(true);
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            // it is for link
            attributeHandlingName.setIdmPropertyName(IdmIdentityContract_.description.getName());
            // and update
            // situation
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("name".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName("position");
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("owner".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_IDENTITY_FIELD);
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("workposition".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_WORK_POSITION_FIELD);
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("state".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_STATE_FIELD);
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setTransformFromResourceScript("return scriptEvaluator.evaluate(\n" + "    scriptEvaluator.newBuilder()\n" + "        .setScriptCode('compileIdentityRelationState')\n" + "        .addParameter('scriptEvaluator', scriptEvaluator)\n" + "        .addParameter('attributeValue', attributeValue)\n" + "        .addParameter('icAttributes', icAttributes)\n" + "        .addParameter('system', system)\n" + "	.build());");
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("leader".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_GUARANTEES_FIELD);
            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.setName(schemaAttr.getName());
            attributeHandlingName.setEntityAttribute(false);
            attributeHandlingName.setExtendedAttribute(false);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("validfrom".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setIdmPropertyName(IdmContractSlice_.contractValidFrom.getName());
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setExtendedAttribute(false);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("validtill".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setIdmPropertyName(IdmContractSlice_.contractValidTill.getName());
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setExtendedAttribute(false);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("validfrom_slice".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setIdmPropertyName(IdmContractSlice_.validFrom.getName());
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setExtendedAttribute(false);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("description".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto extendedAttribute = new SysSystemAttributeMappingDto();
            extendedAttribute.setUid(false);
            extendedAttribute.setEntityAttribute(false);
            extendedAttribute.setExtendedAttribute(true);
            extendedAttribute.setName(EXTENDED_ATTRIBUTE);
            extendedAttribute.setSchemaAttribute(schemaAttr.getId());
            extendedAttribute.setSystemMapping(entityHandlingResult.getId());
            extendedAttribute.setIdmPropertyName(EXTENDED_ATTRIBUTE);
            schemaAttributeMappingService.save(extendedAttribute);
        } else if ("contract_code".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(IdmContractSlice_.contractCode.getName());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        }
    });
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)

Example 97 with SysSchemaAttributeDto

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

the class IdentityContractSyncTest 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 ("id".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setUid(true);
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            // it is for link and update situation
            attributeHandlingName.setIdmPropertyName(IdmIdentityContract_.description.getName());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("name".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName("position");
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("owner".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_IDENTITY_FIELD);
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("workposition".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_WORK_POSITION_FIELD);
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("state".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_STATE_FIELD);
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setTransformFromResourceScript("return scriptEvaluator.evaluate(\n" + "    scriptEvaluator.newBuilder()\n" + "        .setScriptCode('compileIdentityRelationState')\n" + "        .addParameter('scriptEvaluator', scriptEvaluator)\n" + "        .addParameter('attributeValue', attributeValue)\n" + "        .addParameter('icAttributes', icAttributes)\n" + "        .addParameter('system', system)\n" + "	.build());");
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("leader".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_GUARANTEES_FIELD);
            attributeHandlingName.setName(schemaAttr.getName().toLowerCase());
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("positions".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_POSITIONS_FIELD);
            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.setName(schemaAttr.getName());
            attributeHandlingName.setEntityAttribute(false);
            attributeHandlingName.setExtendedAttribute(false);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("validfrom".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setIdmPropertyName("validFrom");
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setExtendedAttribute(false);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            attributeHandlingName.setTransformFromResourceScript("return attributeValue == null ? null : java.time.LocalDate.parse(attributeValue);");
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if ("validtill".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setIdmPropertyName("validTill");
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setExtendedAttribute(false);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            attributeHandlingName.setTransformFromResourceScript("return attributeValue == null ? null : java.time.LocalDate.parse(attributeValue);");
            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);
        }
    });
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)

Example 98 with SysSchemaAttributeDto

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

the class IdentitySyncTest 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 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().toLowerCase());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
        } else if (ATTRIBUTE_EMAIL.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName(ATTRIBUTE_EMAIL);
            attributeMapping.setName(schemaAttr.getName().toLowerCase());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
            SysSystemAttributeMappingDto attributeMappingTwo = new SysSystemAttributeMappingDto();
            attributeMappingTwo.setIdmPropertyName(ATTRIBUTE_EMAIL_TWO);
            attributeMappingTwo.setEntityAttribute(false);
            attributeMappingTwo.setExtendedAttribute(true);
            attributeMappingTwo.setName(ATTRIBUTE_EMAIL_TWO);
            attributeMappingTwo.setSchemaAttribute(schemaAttr.getId());
            attributeMappingTwo.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMappingTwo);
        } else if (ATTRIBUTE_DESCRIP.equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
            attributeMapping.setIdmPropertyName("description");
            attributeMapping.setName(schemaAttr.getName().toLowerCase());
            attributeMapping.setSchemaAttribute(schemaAttr.getId());
            attributeMapping.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeMapping);
        }
    });
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)

Example 99 with SysSchemaAttributeDto

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

the class GenerateSchemaWithEavTest 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 ("name".equalsIgnoreCase(schemaAttr.getName())) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setUid(true);
            attributeHandlingName.setEntityAttribute(true);
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        } else if (!schemaAttr.getName().equals("__NAME__")) {
            SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
            attributeHandlingName.setIdmPropertyName(schemaAttr.getName());
            attributeHandlingName.setEntityAttribute(false);
            attributeHandlingName.setExtendedAttribute(true);
            attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
            attributeHandlingName.setName(schemaAttr.getName());
            attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
            schemaAttributeMappingService.save(attributeHandlingName);
        }
    });
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)

Example 100 with SysSchemaAttributeDto

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

the class IdentitySyncTest method updateIdentityWithUserTypeTest.

@Test
public void updateIdentityWithUserTypeTest() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
    IdmRoleDto defaultRole = helper.createRole();
    // Set default role to sync configuration
    config.setDefaultRole(defaultRole.getId());
    config.setInactiveOwnerBehavior(SynchronizationInactiveOwnerBehaviorType.LINK);
    config.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK_AND_UPDATE_ENTITY);
    config = (SysSyncIdentityConfigDto) syncConfigService.save(config);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    // Create projection
    IdmFormProjectionDto projection = new IdmFormProjectionDto();
    projection.setOwnerType(IdmIdentity.class.getCanonicalName());
    projection.setCode(getHelper().createName());
    projection.setDisabled(false);
    projection = formProjectionService.save(projection);
    SysSchemaAttributeDto someSchemaAttribute = schemaAttributeService.find(schemaAttributeFilter, null).getContent().get(0);
    Assert.assertNotNull(someSchemaAttribute);
    // Create attribute returns code of projection.
    SysSystemAttributeMappingDto projectionAttribute = new SysSystemAttributeMappingDto();
    projectionAttribute.setIdmPropertyName(IdmIdentity_.formProjection.getName());
    projectionAttribute.setEntityAttribute(true);
    projectionAttribute.setExtendedAttribute(false);
    projectionAttribute.setName(IdmIdentity_.formProjection.getName());
    projectionAttribute.setSchemaAttribute(someSchemaAttribute.getId());
    projectionAttribute.setSystemMapping(config.getSystemMapping());
    projectionAttribute.setTransformFromResourceScript(MessageFormat.format("return \"{0}\";", projection.getCode()));
    projectionAttribute = schemaAttributeMappingService.save(projectionAttribute);
    IdmIdentityDto identityOne = helper.createIdentity(IDENTITY_ONE);
    IdmIdentityFilter identityFilter = new IdmIdentityFilter();
    identityFilter.setUsername(IDENTITY_ONE);
    helper.startSynchronization(config);
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.LINK_AND_UPDATE_ENTITY, 1, OperationResultType.SUCCESS);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identityOne.getId());
    Assert.assertEquals(1, roles.size());
    Assert.assertEquals(defaultRole.getId(), roles.get(0).getRole());
    identityOne = identityService.get(identityOne.getId());
    // Identity must have sets projection.
    Assert.assertNotNull(identityOne);
    Assert.assertNotNull(identityOne.getFormProjection());
    Assert.assertEquals(projection.getId(), identityOne.getFormProjection());
    // Delete log
    syncLogService.delete(log);
    // Delete projection attribute and projection.
    schemaAttributeMappingService.delete(projectionAttribute);
    formProjectionService.delete(projection);
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IdmFormProjectionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) DefaultSynchronizationServiceTest(eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)

Aggregations

SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)168 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)119 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)96 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)89 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)86 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)79 Test (org.junit.Test)73 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)52 UUID (java.util.UUID)40 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)39 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)36 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)35 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)34 AttributeMappingStrategyType (eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType)28 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)27 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)27 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)26 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)26 Serializable (java.io.Serializable)26 List (java.util.List)25