Search in sources :

Example 21 with SysSystemMappingFilter

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

the class DefaultSysSystemMappingServiceTest method treeTypeIdFilterTest.

@Test
public void treeTypeIdFilterTest() {
    IdmBasePermission permission = IdmBasePermission.ADMIN;
    SystemEntityType entityType = SystemEntityType.IDENTITY;
    IdmTreeTypeDto treeType = new IdmTreeTypeDto();
    treeType.setName("SomeTreeTypeName");
    treeType.setCode("CodeCodeCodeCode");
    treeType = treeTypeService.save(treeType);
    IdmTreeTypeDto treeType2 = new IdmTreeTypeDto();
    treeType2.setName("SomeTreeTypeName2");
    treeType2.setCode("CodeCodeCodeCode2");
    treeType2 = treeTypeService.save(treeType2);
    SysSystemDto system = createSystem();
    SysSchemaObjectClassDto objectClass = createObjectClass(system);
    SysSystemMappingDto mappingSystem1 = testHelper.createMappingSystem(entityType, objectClass);
    mappingSystem1.setTreeType(treeType.getId());
    mappingSystem1 = mappingService.save(mappingSystem1);
    SysSystemMappingDto mappingSystem2 = testHelper.createMappingSystem(entityType, objectClass);
    mappingSystem2.setTreeType(treeType2.getId());
    mappingSystem2 = mappingService.save(mappingSystem2);
    SysSystemMappingFilter filter = new SysSystemMappingFilter();
    filter.setTreeTypeId(mappingSystem1.getTreeType());
    Page<SysSystemMappingDto> result = mappingService.find(filter, null, permission);
    assertEquals(1, result.getTotalElements());
    assertTrue(result.getContent().contains(mappingSystem1));
    assertFalse(result.getContent().contains(mappingSystem2));
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 22 with SysSystemMappingFilter

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

the class DefaultSysSystemMappingService method findByObjectClass.

@Override
public List<SysSystemMappingDto> findByObjectClass(SysSchemaObjectClassDto objectClass, SystemOperationType operation, SystemEntityType entityType) {
    Assert.notNull(objectClass);
    SysSystemMappingFilter filter = new SysSystemMappingFilter();
    filter.setObjectClassId(objectClass.getId());
    filter.setOperationType(operation);
    filter.setEntityType(entityType);
    Page<SysSystemMappingDto> page = toDtoPage(repository.find(filter, null));
    return page.getContent();
}
Also used : SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Example 23 with SysSystemMappingFilter

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

the class DefaultSysSystemMappingService method findBySystemId.

@Override
public List<SysSystemMappingDto> findBySystemId(UUID systemId, SystemOperationType operation, SystemEntityType entityType) {
    Assert.notNull(systemId);
    // 
    SysSystemMappingFilter filter = new SysSystemMappingFilter();
    filter.setSystemId(systemId);
    filter.setOperationType(operation);
    filter.setEntityType(entityType);
    Page<SysSystemMappingDto> page = toDtoPage(repository.find(filter, null));
    return page.getContent();
}
Also used : SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Example 24 with SysSystemMappingFilter

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

the class DefaultSysSystemMappingService method findProvisioningMapping.

@Override
public SysSystemMappingDto findProvisioningMapping(UUID systemId, SystemEntityType entityType) {
    Assert.notNull(systemId);
    Assert.notNull(entityType);
    SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
    mappingFilter.setSystemId(systemId);
    mappingFilter.setEntityType(entityType);
    mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
    List<SysSystemMappingDto> mappings = this.find(mappingFilter, null).getContent();
    if (mappings.isEmpty()) {
        return null;
    }
    // Only one mapping for provisioning and entity type and system can exists
    return mappings.get(0);
}
Also used : SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Example 25 with SysSystemMappingFilter

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

the class DefaultSysSystemService method duplicate.

@Override
@Transactional
public SysSystemDto duplicate(UUID id) {
    SysSystemDto originalSystem = this.get(id);
    Asserts.notNull(originalSystem, "System must be found!");
    // Clone and save system
    SysSystemDto clone = this.clone(id);
    String name = MessageFormat.format("{0}{1}", "Copy-of-", clone.getName());
    name = this.duplicateName(name, 0);
    clone.setName(name);
    // Set as inactive system
    clone.setDisabled(true);
    SysSystemDto system = this.save(clone);
    // Cache old and new IDs
    Map<UUID, UUID> schemaAttributesCache = new HashMap<UUID, UUID>();
    Map<UUID, UUID> mappedAttributesCache = new HashMap<UUID, UUID>();
    // Duplicate connector configuration values in EAV
    IcConnectorInstance connectorInstance = originalSystem.getConnectorInstance();
    if (connectorInstance != null && connectorInstance.getConnectorKey() != null && connectorInstance.getConnectorKey().getFramework() != null) {
        IdmFormDefinitionDto formDefinition = getConnectorFormDefinition(connectorInstance);
        List<IdmFormValueDto> originalFormValues = this.getFormService().getValues(id, SysSystem.class, formDefinition);
        SysSystem systemEntity = getEntity(system.getId());
        originalFormValues.stream().forEach(value -> {
            systemFormValueService.duplicate(value.getId(), systemEntity);
        });
    }
    // Duplicate schema
    SysSchemaObjectClassFilter objectClassFilter = new SysSchemaObjectClassFilter();
    objectClassFilter.setSystemId(id);
    objectClassService.find(objectClassFilter, null).getContent().stream().forEach(schema -> {
        UUID originalSchemaId = schema.getId();
        SysSchemaObjectClassDto duplicatedSchema = this.duplicateSchema(originalSchemaId, system, schemaAttributesCache);
        // Duplicate mapped attributes
        SysSystemMappingFilter systemMappingFilter = new SysSystemMappingFilter();
        systemMappingFilter.setSystemId(id);
        systemMappingService.find(systemMappingFilter, null).getContent().stream().filter(mapping -> {
            // Find mapping for this schema
            return mapping.getObjectClass().equals(originalSchemaId);
        }).forEach(mapping -> {
            final UUID originalMappingId = mapping.getId();
            SysSystemMappingDto duplicatedMapping = this.duplicateMapping(originalMappingId, duplicatedSchema, schemaAttributesCache, mappedAttributesCache);
            // Duplicate sync configs
            List<AbstractSysSyncConfigDto> syncConfigs = findSyncConfigs(id);
            syncConfigs.stream().filter(syncConfig -> {
                // Find configuration of sync for this mapping
                return syncConfig.getSystemMapping().equals(originalMappingId);
            }).forEach(syncConfig -> {
                UUID syncConfigId = syncConfig.getId();
                duplicateSyncConf(syncConfigId, duplicatedMapping, mappedAttributesCache);
            });
        });
    });
    return system;
}
Also used : SysSystem_(eu.bcvsolutions.idm.acc.entity.SysSystem_) FormPropertyManager(eu.bcvsolutions.idm.acc.service.api.FormPropertyManager) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) IcConfigurationPropertiesImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl) Asserts(org.apache.http.util.Asserts) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) StringUtils(org.apache.commons.lang3.StringUtils) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) SysConnectorKeyDto(eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) Predicate(javax.persistence.criteria.Predicate) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) BasePermission(eu.bcvsolutions.idm.core.security.api.domain.BasePermission) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IcConnectorConfigurationCzechIdMImpl(eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl) SysSyncConfigService(eu.bcvsolutions.idm.acc.service.api.SysSyncConfigService) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IcConfigurationFacade(eu.bcvsolutions.idm.ic.service.api.IcConfigurationFacade) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) ImmutableMap(com.google.common.collect.ImmutableMap) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) IcConnectorKeyImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorKeyImpl) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) Serializable(java.io.Serializable) List(java.util.List) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Optional(java.util.Optional) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) HashMap(java.util.HashMap) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSystemRepository(eu.bcvsolutions.idm.acc.repository.SysSystemRepository) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) IdmPasswordPolicy_(eu.bcvsolutions.idm.core.model.entity.IdmPasswordPolicy_) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) IcObjectClassInfo(eu.bcvsolutions.idm.ic.api.IcObjectClassInfo) IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) Service(org.springframework.stereotype.Service) EntityUtils(eu.bcvsolutions.idm.core.api.utils.EntityUtils) SysSystemFormValueService(eu.bcvsolutions.idm.acc.service.api.SysSystemFormValueService) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) Root(javax.persistence.criteria.Root) IcAttributeInfo(eu.bcvsolutions.idm.ic.api.IcAttributeInfo) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) IcSchema(eu.bcvsolutions.idm.ic.api.IcSchema) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) IcConnectorConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AbstractFormableService(eu.bcvsolutions.idm.core.eav.api.service.AbstractFormableService) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) AuthorizableType(eu.bcvsolutions.idm.core.security.api.dto.AuthorizableType) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) HashMap(java.util.HashMap) 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) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)26 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)24 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)15 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)15 Test (org.junit.Test)15 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)13 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)12 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)10 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)10 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)9 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)6 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)5 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)5 Transactional (org.springframework.transaction.annotation.Transactional)5 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)4 SysSyncIdentityConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto)4 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)4 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)4 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)3 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)3