Search in sources :

Example 81 with SysSchemaObjectClassDto

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

the class DefaultSysSystemServiceTest method testReferentialIntegrity.

@Test
public void testReferentialIntegrity() {
    SysSystemDto system = new SysSystemDto();
    String systemName = "t_s_" + System.currentTimeMillis();
    system.setName(systemName);
    system = systemService.save(system);
    // object class
    SysSchemaObjectClassDto objectClass = new SysSchemaObjectClassDto();
    objectClass.setSystem(system.getId());
    objectClass.setObjectClassName("obj_class");
    objectClass = schemaObjectClassService.save(objectClass);
    SysSchemaObjectClassFilter objectClassFilter = new SysSchemaObjectClassFilter();
    objectClassFilter.setSystemId(system.getId());
    // schema attribute
    SysSchemaAttributeDto schemaAttribute = new SysSchemaAttributeDto();
    schemaAttribute.setObjectClass(objectClass.getId());
    schemaAttribute.setName("name");
    schemaAttribute.setClassType("class");
    schemaAttribute = schemaAttributeService.save(schemaAttribute);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    // system entity handling
    SysSystemMappingDto systemMapping = new SysSystemMappingDto();
    systemMapping.setName("default_" + System.currentTimeMillis());
    systemMapping.setObjectClass(objectClass.getId());
    systemMapping.setOperationType(SystemOperationType.PROVISIONING);
    systemMapping.setEntityType(SystemEntityType.IDENTITY);
    systemMapping = systemMappingService.save(systemMapping);
    SysSystemMappingFilter entityHandlingFilter = new SysSystemMappingFilter();
    entityHandlingFilter.setSystemId(system.getId());
    // schema attribute handling
    SysSystemAttributeMappingDto schemaAttributeHandling = new SysSystemAttributeMappingDto();
    schemaAttributeHandling.setSchemaAttribute(schemaAttribute.getId());
    schemaAttributeHandling.setSystemMapping(systemMapping.getId());
    schemaAttributeHandling.setName("name");
    schemaAttributeHandling.setIdmPropertyName("name");
    schemaAttributeHandling = systemAttributeMappingService.save(schemaAttributeHandling);
    SysSystemAttributeMappingFilter schemaAttributeHandlingFilter = new SysSystemAttributeMappingFilter();
    schemaAttributeHandlingFilter.setSystemId(system.getId());
    // role system
    IdmRoleDto role = helper.createRole();
    SysRoleSystemDto roleSystem = new SysRoleSystemDto();
    roleSystem.setSystem(system.getId());
    roleSystem.setRole(role.getId());
    roleSystem.setSystemMapping(systemMapping.getId());
    roleSystem = roleSystemService.save(roleSystem);
    SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
    roleSystemFilter.setRoleId(role.getId());
    // role system attributes
    SysRoleSystemAttributeDto roleSystemAttribute = new SysRoleSystemAttributeDto();
    roleSystemAttribute.setRoleSystem(roleSystem.getId());
    roleSystemAttribute.setSystemAttributeMapping(schemaAttributeHandling.getId());
    roleSystemAttribute.setName("name");
    roleSystemAttribute.setIdmPropertyName("name");
    roleSystemAttribute = roleSystemAttributeService.save(roleSystemAttribute);
    assertEquals(systemName, systemService.getByCode(systemName).getName());
    assertEquals(1, schemaObjectClassService.find(objectClassFilter, null).getTotalElements());
    assertEquals(1, schemaAttributeService.find(schemaAttributeFilter, null).getTotalElements());
    assertEquals(1, systemMappingService.find(entityHandlingFilter, null).getTotalElements());
    assertEquals(1, systemAttributeMappingService.find(schemaAttributeHandlingFilter, null).getTotalElements());
    assertEquals(1, roleSystemService.find(roleSystemFilter, null).getTotalElements());
    assertNotNull(roleSystemAttributeService.get(roleSystemAttribute.getId()));
    systemService.delete(system);
    assertNull(systemService.getByCode(systemName));
    assertEquals(0, schemaObjectClassService.find(objectClassFilter, null).getTotalElements());
    assertEquals(0, schemaAttributeService.find(schemaAttributeFilter, null).getTotalElements());
    assertEquals(0, systemMappingService.find(entityHandlingFilter, null).getTotalElements());
    assertEquals(0, systemAttributeMappingService.find(schemaAttributeHandlingFilter, null).getTotalElements());
    assertEquals(0, roleSystemService.find(roleSystemFilter, null).getTotalElements());
    assertNull(roleSystemAttributeService.get(roleSystemAttribute.getId()));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 82 with SysSchemaObjectClassDto

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

the class AbstractSynchronizationExecutor method startExport.

/**
 * Start export entities to target resource
 *
 * @param entityType
 * @param config
 * @param mappedAttributes
 * @param log
 * @param actionsLog
 */
@Beta
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 = systemAttributeMappingService.getUidAttribute(mappedAttributes, system);
    List<DTO> entities = this.findAll();
    entities.stream().forEach(entity -> {
        // TODO: evaluate to groovy script
        SynchronizationContext itemBuilder = new SynchronizationContext();
        // 
        itemBuilder.addConfig(config).addSystem(// 
        system).addEntityType(// 
        entityType).addEntityId(// 
        entity.getId()).addLog(// 
        log).addActionLogs(actionsLog);
        // Start export for this entity
        exportEntity(itemBuilder, uidAttribute, entity);
    });
}
Also used : SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Beta(com.google.common.annotations.Beta)

Example 83 with SysSchemaObjectClassDto

use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto 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);
    });
}
Also used : SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 84 with SysSchemaObjectClassDto

use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto 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;
}
Also used : SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 85 with SysSchemaObjectClassDto

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

the class IdentityRoleValidRequestSchedulerTest method createAndSaveSystemWithMapping.

private SysSystemDto createAndSaveSystemWithMapping() {
    system = null;
    systemMapping = null;
    SysSystemAttributeMappingDto nameAttributeMapping = null;
    SysSystemAttributeMappingDto firstNameAttributeMapping = null;
    SysSystemAttributeMappingDto lastNameAttributeMapping = null;
    SysSystemAttributeMappingDto passwordAttributeMapping = null;
    // prepare test system
    system = helper.createSystem(TestResource.TABLE_NAME);
    // generate schema
    List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
    // create test mapping
    systemMapping = new SysSystemMappingDto();
    systemMapping.setName("default_" + System.currentTimeMillis());
    systemMapping.setEntityType(SystemEntityType.IDENTITY);
    systemMapping.setOperationType(SystemOperationType.PROVISIONING);
    systemMapping.setObjectClass(objectClasses.get(0).getId());
    systemMapping = mappingService.save(systemMapping);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
    for (SysSchemaAttributeDto schemaAttr : schemaAttributesPage) {
        if ("__NAME__".equals(schemaAttr.getName())) {
            nameAttributeMapping = new SysSystemAttributeMappingDto();
            nameAttributeMapping.setUid(true);
            nameAttributeMapping.setEntityAttribute(true);
            nameAttributeMapping.setIdmPropertyName("username");
            nameAttributeMapping.setName(schemaAttr.getName());
            nameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            nameAttributeMapping.setSystemMapping(systemMapping.getId());
            nameAttributeMapping = attributeMappingService.save(nameAttributeMapping);
        } else if ("firstname".equalsIgnoreCase(schemaAttr.getName())) {
            firstNameAttributeMapping = new SysSystemAttributeMappingDto();
            firstNameAttributeMapping.setIdmPropertyName("firstName");
            firstNameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            firstNameAttributeMapping.setName(schemaAttr.getName());
            firstNameAttributeMapping.setSystemMapping(systemMapping.getId());
            firstNameAttributeMapping = attributeMappingService.save(firstNameAttributeMapping);
        } else if ("lastname".equalsIgnoreCase(schemaAttr.getName())) {
            lastNameAttributeMapping = new SysSystemAttributeMappingDto();
            lastNameAttributeMapping.setIdmPropertyName("lastName");
            lastNameAttributeMapping.setName(schemaAttr.getName());
            lastNameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            lastNameAttributeMapping.setSystemMapping(systemMapping.getId());
            lastNameAttributeMapping = attributeMappingService.save(lastNameAttributeMapping);
        } else if (IcConnectorFacade.PASSWORD_ATTRIBUTE_NAME.equalsIgnoreCase(schemaAttr.getName())) {
            passwordAttributeMapping = new SysSystemAttributeMappingDto();
            passwordAttributeMapping.setIdmPropertyName("password");
            passwordAttributeMapping.setSchemaAttribute(schemaAttr.getId());
            passwordAttributeMapping.setName(schemaAttr.getName());
            passwordAttributeMapping.setSystemMapping(systemMapping.getId());
            passwordAttributeMapping = attributeMappingService.save(passwordAttributeMapping);
        }
    }
    assertNotNull(system);
    assertNotNull(nameAttributeMapping);
    assertNotNull(firstNameAttributeMapping);
    assertNotNull(lastNameAttributeMapping);
    assertNotNull(passwordAttributeMapping);
    return system;
}
Also used : SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Aggregations

SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)156 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)125 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)114 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)65 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)63 Test (org.junit.Test)59 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)44 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)38 UUID (java.util.UUID)32 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)29 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)28 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)25 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)21 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)21 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)21 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)20 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)19 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)19 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)18 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)17