use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class TreeTypeDeleteBulkActionIntegrationTest method testForceDelete.
@Test
public void testForceDelete() {
logout();
loginAsAdmin();
// create sub tree nodes, automatic roles, contract, contract positions, system mapping and sync
IdmTreeTypeDto treeType = getHelper().createTreeType();
SysSystemDto system = getHelper().createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filter = new SysSystemMappingFilter();
filter.setSystemId(system.getId());
SysSystemMappingDto mapping = systemMappingService.find(filter, null).getContent().get(0);
mapping.setTreeType(treeType.getId());
mapping = systemMappingService.save(mapping);
SysSyncConfigDto syncConfig = new SysSyncConfigDto();
syncConfig.setName(getHelper().createName());
syncConfig.setSystemMapping(mapping.getId());
// finds mapped attributes in existing system
SysSystemAttributeMappingFilter attributeFilter = new SysSystemAttributeMappingFilter();
attributeFilter.setSystemId(system.getId());
attributeFilter.setName(TestHelper.ATTRIBUTE_MAPPING_NAME);
SysSystemAttributeMappingDto attribute = attributeMappingService.find(attributeFilter, null).getContent().get(0);
syncConfig.setCorrelationAttribute(attribute.getId());
syncConfig = (SysSyncConfigDto) syncService.save(syncConfig);
IdmRoleDto role = getHelper().createRole();
getHelper().createRoleSystem(role, system);
//
IdmTreeNodeDto treeNode = getHelper().createTreeNode(treeType, null, null);
IdmTreeNodeDto subTreeNode = getHelper().createTreeNode(treeType, (String) null, treeNode);
IdmTreeNodeDto subSubTreeNode = getHelper().createTreeNode(treeType, (String) null, subTreeNode);
IdmTreeNodeDto otherTreeNode = getHelper().createTreeNode();
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
IdmIdentityContractDto contract = getHelper().createContract(identity, subTreeNode);
IdmContractPositionDto contractPosition = getHelper().createContractPosition(contract, subSubTreeNode);
IdmIdentityRoleDto assignedRoleOne = getHelper().createIdentityRole(contract, role);
IdmIdentityRoleDto assignedRoleTwo = getHelper().createIdentityRole(contractPosition, role);
IdmIdentityRoleDto assignedRoleOther = getHelper().createIdentityRole(getHelper().getPrimeContract(identity), role);
IdmRoleTreeNodeDto automaticRole = getHelper().createRoleTreeNode(role, treeNode, RecursionType.DOWN, false);
//
// 3 manual, 2 automatic
Assert.assertEquals(5, identityRoleService.findAllByIdentity(identity.getId()).size());
//
// remove tree type
Map<String, Object> properties = new HashMap<>();
properties.put(EntityEventProcessor.PROPERTY_FORCE_DELETE, Boolean.TRUE);
// delete by bulk action
IdmBulkActionDto bulkAction = this.findBulkAction(IdmTreeType.class, TreeTypeDeleteBulkAction.NAME);
bulkAction.setIdentifiers(Sets.newHashSet(treeType.getId()));
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
//
checkResultLrt(processAction, 1l, 0l, 0l);
//
Assert.assertNull(treeTypeService.get(treeType));
Assert.assertNull(treeNodeService.get(treeNode));
Assert.assertNull(treeNodeService.get(subTreeNode));
Assert.assertNull(treeNodeService.get(subSubTreeNode));
Assert.assertNull(treeNodeService.get(subSubTreeNode));
Assert.assertNotNull(identityRoleService.get(assignedRoleOne));
Assert.assertNotNull(identityRoleService.get(assignedRoleTwo));
Assert.assertNull(identityContractService.get(contract).getWorkPosition());
Assert.assertNull(contractPositionService.get(contractPosition).getWorkPosition());
Assert.assertNull(roleTreeNodeService.get(automaticRole));
Assert.assertNull(systemMappingService.get(mapping));
Assert.assertNull(attributeMappingService.get(attribute));
Assert.assertNull(syncService.get(syncConfig));
//
Assert.assertNotNull(treeNodeService.get(otherTreeNode));
Assert.assertNotNull(getHelper().getPrimeContract(identity));
Assert.assertNotNull(identityRoleService.get(assignedRoleOther));
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemMappingService method export.
@Override
public void export(UUID id, IdmExportImportDto batch) {
super.export(id, batch);
// Tree-type will be searching by code (advanced paring by treeType field)
ExportDescriptorDto descriptorDto = getExportManager().getDescriptor(batch, this.getDtoClass());
descriptorDto.getAdvancedParingFields().add(SysSystemMapping_.treeType.getName());
// Export mapped attributes
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemMappingId(id);
List<SysSystemAttributeMappingDto> attributes = this.getAttributeMappingService().find(filter, null).getContent();
if (attributes.isEmpty()) {
this.getAttributeMappingService().export(ExportManager.BLANK_UUID, batch);
}
attributes.forEach(systemAttributeMapping -> {
this.getAttributeMappingService().export(systemAttributeMapping.getId(), batch);
});
// Set parent field -> set authoritative mode.
getExportManager().setAuthoritativeMode(SysSystemAttributeMapping_.systemMapping.getName(), "systemId", SysSystemAttributeMappingDto.class, batch);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemMappingService method duplicateMapping.
@Override
@Transactional
public SysSystemMappingDto duplicateMapping(UUID id, SysSchemaObjectClassDto schema, Map<UUID, UUID> schemaAttributesIds, Map<UUID, UUID> mappedAttributesIds, boolean usedInSameSystem) {
Assert.notNull(id, "Id of duplication mapping, must be filled!");
Assert.notNull(schema, "Parent schema must be filled!");
SysSystemMappingDto clonedMapping = this.clone(id);
clonedMapping.setObjectClass(schema.getId());
if (usedInSameSystem) {
String newName = duplicateName(clonedMapping.getName());
clonedMapping.setName(newName);
clonedMapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
}
SysSystemMappingDto mapping = this.save(clonedMapping);
// Clone mapped attributes
SysSystemAttributeMappingFilter attributesFilter = new SysSystemAttributeMappingFilter();
attributesFilter.setSystemMappingId(id);
attributeMappingService.find(attributesFilter, null).forEach(attribute -> {
UUID originalAttributeId = attribute.getId();
SysSystemAttributeMappingDto clonedAttribute = attributeMappingService.clone(originalAttributeId);
// Find cloned schema attribute in cache (by original Id)
SysSchemaAttributeDto clonedSchemaAttribute = attributeService.get(schemaAttributesIds.get(clonedAttribute.getSchemaAttribute()));
clonedAttribute.setSystemMapping(mapping.getId());
clonedAttribute.setSchemaAttribute(clonedSchemaAttribute.getId());
clonedAttribute = attributeMappingService.save(clonedAttribute);
// Put original and new id to cache
mappedAttributesIds.put(originalAttributeId, clonedAttribute.getId());
});
return mapping;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method testCreateContractWithAutomaticRoleByEavAttribute.
@Test
public void testCreateContractWithAutomaticRoleByEavAttribute() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
//
// create form definition, roles, automatic role etc.
IdmRoleDto roleContract = getHelper().createRole();
IdmRoleDto subRoleContract = getHelper().createRole();
getHelper().createRoleComposition(roleContract, subRoleContract);
// sync supports default definition only
IdmFormAttributeDto formAttribute = new IdmFormAttributeDto(getHelper().createName());
IdmFormAttributeDto formAttributeContract = formService.saveAttribute(IdmIdentityContractDto.class, formAttribute);
//
IdmAutomaticRoleAttributeDto automaticRoleContract = getHelper().createAutomaticRole(roleContract.getId());
getHelper().createAutomaticRoleRule(automaticRoleContract.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.CONTRACT_EAV, null, formAttributeContract.getId(), "mockContract");
//
// create mapping to eav attribute - leader = eav
SysSystemMappingDto syncSystemMapping = systemMappingService.get(config.getSystemMapping());
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(syncSystemMapping.getId());
SysSystemAttributeMappingDto leaderAttributeMapping = schemaAttributeMappingService.findBySystemMappingAndName(syncSystemMapping.getId(), "leader");
leaderAttributeMapping.setEntityAttribute(false);
leaderAttributeMapping.setExtendedAttribute(true);
leaderAttributeMapping.setIdmPropertyName(formAttributeContract.getCode());
schemaAttributeMappingService.save(leaderAttributeMapping);
//
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
String positionCode = getHelper().createName();
this.getBean().createContractData(positionCode, identity.getUsername(), "mockContract", Boolean.TRUE.toString(), null, null, null);
//
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityId(identity.getId());
List<IdmIdentityRoleDto> assignedRoles = identityRoleService.find(identityRoleFilter, null).getContent();
Assert.assertTrue(assignedRoles.isEmpty());
//
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 1);
Assert.assertFalse(log.isRunning());
IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
contractFilter.setIdentity(identity.getId());
contractFilter.setAddEavMetadata(Boolean.TRUE);
contractFilter.setProperty(IdmIdentityContract_.position.getName());
contractFilter.setValue(positionCode);
List<IdmIdentityContractDto> contracts = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contracts.size());
Assert.assertEquals("mockContract", contracts.get(0).getEavs().stream().filter(fi -> fi.getFormDefinition().isMain()).findFirst().get().getValues().stream().filter(v -> v.getFormAttribute().equals(formAttributeContract.getId())).findFirst().get().getShortTextValue());
assignedRoles = identityRoleService.find(identityRoleFilter, null).getContent();
Assert.assertEquals(2, assignedRoles.size());
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getRole().equals(roleContract.getId())));
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getRole().equals(subRoleContract.getId())));
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class RoleWorkflowAdSyncTest method doCreateSyncConfig.
private SysSyncRoleConfigDto doCreateSyncConfig(SysSystemDto system) {
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.ROLE);
mappingFilter.setSystemId(system.getId());
mappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
List<SysSystemMappingDto> mappings = systemMappingService.find(mappingFilter, null).getContent();
Assert.assertEquals(1, mappings.size());
SysSystemMappingDto mapping = mappings.get(0);
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
SysSystemAttributeMappingDto uidAttribute = attributes.stream().filter(attribute -> {
return attribute.isUid();
}).findFirst().orElse(null);
// Create default synchronization config
SysSyncRoleConfigDto syncConfigCustom = new SysSyncRoleConfigDto();
syncConfigCustom.setReconciliation(true);
syncConfigCustom.setCustomFilter(false);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(uidAttribute.getId());
syncConfigCustom.setName(SYNC_CONFIG_NAME);
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK_AND_UPDATE_ENTITY);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.DELETE_ENTITY);
syncConfigCustom = (SysSyncRoleConfigDto) syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
return syncConfigCustom;
}
Aggregations