Search in sources :

Example 6 with SysSchemaObjectClassFilter

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

the class CsvConnectorType method executeStepOne.

/**
 * Execute first step of CSV wizard.
 *
 * @param connectorType
 */
private void executeStepOne(ConnectorTypeDto connectorType) {
    // Validations:
    String csvPath = connectorType.getMetadata().get(FILE_PATH);
    if (Strings.isBlank(csvPath)) {
        throw new ResultCodeException(AccResultCode.WIZARD_CSV_CONNECTOR_CSV_FILE_NOT_FOUND, ImmutableMap.of("path", "-"));
    }
    Path csvFilePath = Paths.get(csvPath);
    if (!csvFilePath.toFile().exists()) {
        throw new ResultCodeException(AccResultCode.WIZARD_CSV_CONNECTOR_CSV_FILE_NOT_FOUND, ImmutableMap.of("path", csvPath));
    }
    String lastPart = csvFilePath.getFileName().toString();
    if (lastPart == null || !lastPart.contains(".")) {
        // Last part isn't file!
        throw new ResultCodeException(AccResultCode.WIZARD_CSV_CONNECTOR_CSV_FILE_NOT_FOUND, ImmutableMap.of("path", csvPath));
    }
    String systemId = connectorType.getMetadata().get(SYSTEM_DTO_KEY);
    SysSystemDto systemDto;
    if (systemId != null) {
        // System already exists.
        systemDto = getSystemService().get(UUID.fromString(systemId), IdmBasePermission.READ);
    } else {
        // Create new system.
        systemDto = new SysSystemDto();
    }
    systemDto.setName(connectorType.getMetadata().get(SYSTEM_NAME));
    // Resolve remote system.
    systemDto.setRemoteServer(connectorType.getRemoteServer());
    // Find connector key and set it to the system.
    IcConnectorKey connectorKey = connectorManager.findConnectorKey(connectorType);
    Assert.notNull(connectorKey, "Connector key was not found!");
    systemDto.setConnectorKey(new SysConnectorKeyDto(connectorKey));
    systemDto = getSystemService().save(systemDto, IdmBasePermission.CREATE);
    // Put new system to the connector type (will be returned to FE).
    connectorType.getEmbedded().put(SYSTEM_DTO_KEY, systemDto);
    // Find and update attribute with CSV file path.
    IdmFormDefinitionDto connectorFormDef = getSystemService().getConnectorFormDefinition(systemDto);
    IdmFormAttributeDto csvFilePathAttribute = connectorFormDef.getMappedAttributeByCode(CONNECTOR_SOURCE_PATH);
    List<Serializable> csvFileValue = new ArrayList<>();
    csvFileValue.add(csvFilePath.toString());
    formService.saveValues(systemDto, csvFilePathAttribute, csvFileValue);
    // Find and update attribute contains separator.
    IdmFormAttributeDto separatorAttribute = connectorFormDef.getMappedAttributeByCode(CONNECTOR_SEPARATOR);
    List<Serializable> separatorValue = new ArrayList<>();
    separatorValue.add(connectorType.getMetadata().get(SEPARATOR));
    formService.saveValues(systemDto, separatorAttribute, separatorValue);
    // Find and update attribute defines if headers are included in the file.
    IdmFormAttributeDto includeHeaderAttribute = connectorFormDef.getMappedAttributeByCode(CONNECTOR_INCLUDES_HEADERS);
    List<Serializable> includesHeaderValue = new ArrayList<>();
    includesHeaderValue.add(Boolean.TRUE);
    formService.saveValues(systemDto, includeHeaderAttribute, includesHeaderValue);
    // This is skipped for reopen case.
    if (!connectorType.isReopened()) {
        // Find and update attribute defines UID attribute.
        // UID attribute have to be filled before schema generating, but I don't know it (I need list of column first).
        // So UID attribute will be set to random value, and modified in next step.
        IdmFormAttributeDto uidAttribute = connectorFormDef.getMappedAttributeByCode(CONNECTOR_UID);
        List<Serializable> uidValue = new ArrayList<>();
        uidValue.add("...random...");
        formService.saveValues(systemDto, uidAttribute, uidValue);
        // Load existing sync from system and delete them (because this wizard step could be repeated).
        SysSyncConfigFilter syncConfigFilter = new SysSyncConfigFilter();
        syncConfigFilter.setSystemId(systemDto.getId());
        syncConfigService.find(syncConfigFilter, null).getContent().forEach(syncConfigDto -> syncConfigService.delete(syncConfigDto));
        // Load existing object class from system and delete them (because this wizard step could be repeated).
        SysSchemaObjectClassFilter objectClassFilter = new SysSchemaObjectClassFilter();
        objectClassFilter.setSystemId(systemDto.getId());
        objectClassService.find(objectClassFilter, null).getContent().forEach(sysSchemaObjectClassDto -> objectClassService.delete(sysSchemaObjectClassDto));
        // Generate schema
        List<SysSchemaObjectClassDto> schemas = getSystemService().generateSchema(systemDto);
        SysSchemaObjectClassDto schemaAccount = schemas.stream().filter(schema -> IcObjectClassInfo.ACCOUNT.equals(schema.getObjectClassName())).findFirst().orElse(null);
        Assert.notNull(schemaAccount, "We cannot found schema for ACCOUNT!");
        // Attribute __NAME__ is generate for random value. We need delete him now (will be generated in next wizard step).
        SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
        schemaAttributeFilter.setSystemId(systemDto.getId());
        Assert.notNull(schemaAccount.getId(), "Schema ID cannot be null!");
        schemaAttributeFilter.setObjectClassId(schemaAccount.getId());
        schemaAttributeFilter.setName(IcAttributeInfo.NAME);
        schemaAttributeService.find(schemaAttributeFilter, null).getContent().forEach(nameAttribute -> schemaAttributeService.delete(nameAttribute));
        connectorType.getMetadata().put(SCHEMA_ID_KEY, schemaAccount.getId().toString());
    } else {
        // Generate schema
        List<SysSchemaObjectClassDto> schemas = getSystemService().generateSchema(systemDto);
        SysSchemaObjectClassDto schemaAccount = schemas.stream().filter(schema -> IcObjectClassInfo.ACCOUNT.equals(schema.getObjectClassName())).findFirst().orElse(null);
        Assert.notNull(schemaAccount, "We cannot found schema for ACCOUNT!");
        connectorType.getMetadata().put(SCHEMA_ID_KEY, schemaAccount.getId().toString());
    }
}
Also used : Path(java.nio.file.Path) Serializable(java.io.Serializable) SysConnectorKeyDto(eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)

Example 7 with SysSchemaObjectClassFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter 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 8 with SysSchemaObjectClassFilter

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

the class AdUserConnectorType method load.

@Override
public ConnectorTypeDto load(ConnectorTypeDto connectorType) {
    super.load(connectorType);
    if (!connectorType.isReopened()) {
        connectorType.getMetadata().put(REGENERATE_SCHEMA_SWITCH, Boolean.TRUE.toString());
        return connectorType;
    }
    connectorType.getMetadata().put(REGENERATE_SCHEMA_SWITCH, Boolean.FALSE.toString());
    // Load the system.
    SysSystemDto systemDto = (SysSystemDto) connectorType.getEmbedded().get(SYSTEM_DTO_KEY);
    Assert.notNull(systemDto, "System must exists!");
    connectorType.getMetadata().put(SYSTEM_NAME, systemDto.getName());
    Map<String, String> metadata = connectorType.getMetadata();
    IdmFormDefinitionDto connectorFormDef = this.getSystemService().getConnectorFormDefinition(systemDto);
    // Find attribute with port.
    metadata.put(PORT, getValueFromConnectorInstance(PORT, systemDto, connectorFormDef));
    // Find attribute with host.
    metadata.put(HOST, getValueFromConnectorInstance(HOST, systemDto, connectorFormDef));
    // Find attribute with user.
    metadata.put(USER, getValueFromConnectorInstance(PRINCIPAL, systemDto, connectorFormDef));
    // Find attribute with ssl switch.
    metadata.put(SSL_SWITCH, getValueFromConnectorInstance(SSL, systemDto, connectorFormDef));
    IdmFormDefinitionDto operationOptionsFormDefinition = this.getSystemService().getOperationOptionsConnectorFormDefinition(systemDto);
    if (operationOptionsFormDefinition != null) {
        // Find attribute with domain.
        metadata.put(DOMAIN_KEY, getValueFromConnectorInstance(DOMAIN_KEY, systemDto, operationOptionsFormDefinition));
        // Find attribute with container with existed users.
        metadata.put(USER_SEARCH_CONTAINER_KEY, getValueFromConnectorInstance(USER_SEARCH_CONTAINER_KEY, systemDto, operationOptionsFormDefinition));
        // Find attribute with container with new users.
        metadata.put(NEW_USER_CONTAINER_KEY, getValueFromConnectorInstance(NEW_USER_CONTAINER_KEY, systemDto, operationOptionsFormDefinition));
        // Find attribute with container with deleted users.
        metadata.put(DELETE_USER_CONTAINER_KEY, getValueFromConnectorInstance(DELETE_USER_CONTAINER_KEY, systemDto, operationOptionsFormDefinition));
    }
    // Load the provisioning mapping.
    SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
    mappingFilter.setSystemId(systemDto.getId());
    mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
    SysSystemMappingDto mappingDto = systemMappingService.find(mappingFilter, null).getContent().stream().min(Comparator.comparing(SysSystemMappingDto::getCreated)).orElse(null);
    if (mappingDto != null) {
        connectorType.getEmbedded().put(DefaultConnectorType.MAPPING_DTO_KEY, mappingDto);
        connectorType.getMetadata().put(MAPPING_ID, mappingDto.getId().toString());
        connectorType.getMetadata().put(PROTECTED_MODE_SWITCH_KEY, String.valueOf(mappingDto.isProtectionEnabled()));
    }
    // Load the sync mapping.
    SysSystemMappingFilter syncMappingFilter = new SysSystemMappingFilter();
    syncMappingFilter.setSystemId(systemDto.getId());
    syncMappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
    SysSystemMappingDto syncMappingDto = systemMappingService.find(syncMappingFilter, null).getContent().stream().min(Comparator.comparing(SysSystemMappingDto::getCreated)).orElse(null);
    if (syncMappingDto != null) {
        connectorType.getMetadata().put(MAPPING_SYNC_ID, syncMappingDto.getId().toString());
    }
    // Load the pairing sync (beware by name!).
    SysSyncConfigFilter syncFilter = new SysSyncConfigFilter();
    syncFilter.setSystemId(systemDto.getId());
    syncFilter.setName(PAIRING_SYNC_NAME);
    AbstractSysSyncConfigDto syncDto = syncConfigService.find(syncFilter, null).getContent().stream().min(Comparator.comparing(AbstractDto::getCreated)).orElse(null);
    if (syncDto != null) {
        connectorType.getMetadata().put(PAIRING_SYNC_ID, syncDto.getId().toString());
    }
    IdmEntityStateFilter entityStateFilter = new IdmEntityStateFilter();
    entityStateFilter.setOwnerId(systemDto.getId());
    entityStateFilter.setOwnerType(entityStateManager.getOwnerType(systemDto.getClass()));
    entityStateFilter.setResultCode(AccResultCode.WIZARD_AD_CREATED_TEST_USER_DN.getCode());
    IdmEntityStateDto entityStateDto = entityStateManager.findStates(entityStateFilter, null).stream().findFirst().orElse(null);
    Object dn = null;
    if (entityStateDto != null && entityStateDto.getResult() != null && entityStateDto.getResult().getModel() != null && entityStateDto.getResult().getModel().getParameters() != null) {
        dn = entityStateDto.getResult().getModel().getParameters().get(TEST_CREATED_USER_DN_KEY);
    }
    if (dn instanceof String) {
        String testUserDN = (String) dn;
        connectorType.getMetadata().put(ENTITY_STATE_WITH_TEST_CREATED_USER_DN_KEY, entityStateDto.getId().toString());
        connectorType.getMetadata().put(TEST_CREATED_USER_DN_KEY, testUserDN);
    }
    // Load a schema.
    SysSchemaObjectClassFilter schemaFilter = new SysSchemaObjectClassFilter();
    schemaFilter.setSystemId(systemDto.getId());
    schemaFilter.setObjectClassName(getSchemaType());
    SysSchemaObjectClassDto schemaDto = schemaObjectClassService.find(schemaFilter, null).getContent().stream().findFirst().orElse(null);
    if (schemaDto != null) {
        connectorType.getMetadata().put(SCHEMA_ID_KEY, schemaDto.getId().toString());
    }
    return connectorType;
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter)

Example 9 with SysSchemaObjectClassFilter

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

the class AbstractConnectorType method executeMappingStep.

/**
 * Execute simple mapping step.
 *
 * @param connectorTypeDto
 */
private void executeMappingStep(ConnectorTypeDto connectorTypeDto) {
    String schemaId = connectorTypeDto.getMetadata().get(SCHEMA_ID);
    SysSchemaObjectClassDto schemaDto = null;
    if (schemaId != null) {
        schemaDto = schemaService.get(UUID.fromString(schemaId), IdmBasePermission.READ);
    } else {
        String systemId = connectorTypeDto.getMetadata().get(SYSTEM_DTO_KEY);
        SysSchemaObjectClassFilter filter = new SysSchemaObjectClassFilter();
        Assert.isTrue(Strings.isNotBlank(systemId), "System ID cannot be empty!");
        filter.setSystemId(UUID.fromString(systemId));
        List<SysSchemaObjectClassDto> schemas = schemaService.find(filter, null, IdmBasePermission.READ).getContent().stream().sorted(Comparator.comparing(SysSchemaObjectClassDto::getCreated)).collect(Collectors.toList());
        if (!schemas.isEmpty()) {
            schemaDto = schemas.get(0);
        }
    }
    Assert.notNull(schemaDto, "System schema must exists!");
    String entityType = connectorTypeDto.getMetadata().get(ENTITY_TYPE);
    SystemEntityType systemEntityType = SystemEntityType.valueOf(entityType);
    Assert.notNull(systemEntityType, "Entity type cannot be null!");
    // For tree type have to be filled tree type ID too.
    IdmTreeTypeDto treeTypeDto = null;
    if (SystemEntityType.TREE == systemEntityType) {
        String treeTypeId = connectorTypeDto.getMetadata().get(TREE_TYPE_ID);
        Assert.notNull(treeTypeId, "Tree type ID cannot be null for TREE entity type!");
        treeTypeDto = treeTypeService.get(UUID.fromString(treeTypeId));
        Assert.notNull(treeTypeDto, "Tree type DTO cannot be null for TREE entity type!");
    }
    String operationType = connectorTypeDto.getMetadata().get(OPERATION_TYPE);
    SystemOperationType systemOperationType = SystemOperationType.valueOf(operationType);
    Assert.notNull(systemOperationType, "Operation type cannot be null!");
    // Load existing mapping or create new one.
    String mappingId = connectorTypeDto.getMetadata().get(MAPPING_ID);
    SysSystemMappingDto mappingDto = new SysSystemMappingDto();
    mappingDto.setName("Mapping");
    boolean isNew = true;
    if (mappingId != null) {
        SysSystemMappingDto mappingExisted = systemMappingService.get(mappingId, IdmBasePermission.READ);
        if (mappingExisted != null) {
            isNew = false;
            mappingDto = mappingExisted;
        }
    }
    // For tree type have to be filled tree type ID too.
    if (SystemEntityType.TREE == systemEntityType) {
        mappingDto.setTreeType(treeTypeDto.getId());
    }
    mappingDto.setEntityType(systemEntityType);
    mappingDto.setOperationType(systemOperationType);
    mappingDto.setObjectClass(schemaDto.getId());
    // Save mapping. Event must be publish with property for enable automatic mapping.
    mappingDto = systemMappingService.publish(new SystemMappingEvent(isNew ? SystemMappingEvent.SystemMappingEventType.CREATE : SystemMappingEvent.SystemMappingEventType.UPDATE, mappingDto, ImmutableMap.of(SysSystemMappingService.ENABLE_AUTOMATIC_CREATION_OF_MAPPING, Boolean.TRUE)), isNew ? IdmBasePermission.CREATE : IdmBasePermission.UPDATE).getContent();
    connectorTypeDto.getEmbedded().put(MAPPING_DTO_KEY, mappingDto);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) SystemMappingEvent(eu.bcvsolutions.idm.acc.event.SystemMappingEvent) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Example 10 with SysSchemaObjectClassFilter

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

the class SystemExportBulkAction method exportSchema.

/**
 * Export system schemas
 *
 * @param systemId
 */
private void exportSchema(UUID systemId) {
    SysSchemaObjectClassFilter objectClassFilter = new SysSchemaObjectClassFilter();
    objectClassFilter.setSystemId(systemId);
    List<SysSchemaObjectClassDto> objectClasses = objectClassService.find(objectClassFilter, null).getContent();
    if (objectClasses.isEmpty()) {
        schemaObjectClassService.export(ExportManager.BLANK_UUID, getBatch());
    }
    objectClasses.forEach(schema -> {
        schemaObjectClassService.export(schema.getId(), getBatch());
    });
    // Set parent field -> set authoritative mode.
    this.getExportManager().setAuthoritativeMode(SysSchemaObjectClass_.system.getName(), "systemId", SysSchemaObjectClassDto.class, getBatch());
}
Also used : SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Aggregations

SysSchemaObjectClassFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter)15 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)11 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)8 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)6 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)6 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)5 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)5 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)5 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)4 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)4 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)4 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)4 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)3 SysConnectorKeyDto (eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 DefaultConnectorType (eu.bcvsolutions.idm.acc.connector.DefaultConnectorType)2 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)2 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)2 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)2 SysRoleSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter)2