use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class AdGroupConnectorType method load.
@Override
public ConnectorTypeDto load(ConnectorTypeDto connectorType) {
super.load(connectorType);
if (!connectorType.isReopened()) {
return connectorType;
}
// 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));
// Find group container.
List<String> containers = getValuesFromConnectorInstance(BASE_CONTEXT_GROUP_KEY, systemDto, connectorFormDef);
metadata.put(GROUP_CONTAINER_KEY, containersToString(containers));
// Load the sync mapping.
SysSystemMappingFilter syncMappingFilter = new SysSystemMappingFilter();
syncMappingFilter.setSystemId(systemDto.getId());
syncMappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
SysSystemMappingDto syncMappingDto = getSystemMappingService().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 sync.
SysSyncConfigFilter syncFilter = new SysSyncConfigFilter();
syncFilter.setSystemId(systemDto.getId());
syncFilter.setSystemMappingId(syncMappingDto.getId());
AbstractSysSyncConfigDto syncDto = getSyncConfigService().find(syncFilter, null).getContent().stream().min(Comparator.comparing(AbstractDto::getCreated)).orElse(null);
if (syncDto != null) {
connectorType.getMetadata().put(GROUP_SYNC_ID, syncDto.getId().toString());
if (syncDto instanceof SysSyncRoleConfigDto) {
SysSyncRoleConfigDto roleConfigDto = (SysSyncRoleConfigDto) syncDto;
if (roleConfigDto.getMemberSystemMapping() != null) {
connectorType.getMetadata().put(MEMBER_SYSTEM_MAPPING, roleConfigDto.getMemberSystemMapping().toString());
}
// Load setting of group sync.
connectorType.getMetadata().put(SysSyncRoleConfig_.membershipSwitch.getName(), String.valueOf(roleConfigDto.isMembershipSwitch()));
connectorType.getMetadata().put(SysSyncRoleConfig_.assignCatalogueSwitch.getName(), String.valueOf(roleConfigDto.isAssignCatalogueSwitch()));
connectorType.getMetadata().put(SysSyncRoleConfig_.assignRoleSwitch.getName(), String.valueOf(roleConfigDto.isAssignRoleSwitch()));
connectorType.getMetadata().put(SysSyncRoleConfig_.assignRoleRemoveSwitch.getName(), String.valueOf(roleConfigDto.isAssignRoleRemoveSwitch()));
connectorType.getMetadata().put(SysSyncRoleConfig_.removeCatalogueRoleSwitch.getName(), String.valueOf(roleConfigDto.isRemoveCatalogueRoleSwitch()));
connectorType.getMetadata().put(MAIN_ROLE_CATALOG, roleConfigDto.getMainCatalogueRoleNode() != null ? roleConfigDto.getMainCatalogueRoleNode().toString() : null);
}
}
}
return connectorType;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class SystemExportBulkAction method exportMappedAttributes.
/**
* Export mapped attributes
*
* @param systemId
*/
private void exportMappedAttributes(UUID systemId) {
SysSystemMappingFilter systemMappingFilter = new SysSystemMappingFilter();
systemMappingFilter.setSystemId(systemId);
List<SysSystemMappingDto> systemMappings = systemMappingService.find(systemMappingFilter, null).getContent();
if (systemMappings.isEmpty()) {
systemMappingService.export(ExportManager.BLANK_UUID, getBatch());
}
systemMappings.forEach(mapping -> {
systemMappingService.export(mapping.getId(), getBatch());
});
// Set parent field -> set authoritative mode.
this.getExportManager().setAuthoritativeMode(SysSystemMapping_.objectClass.getName(), "systemId", SysSystemMappingDto.class, getBatch());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class AbstractJdbcConnectorType method load.
@Override
public ConnectorTypeDto load(ConnectorTypeDto connectorType) {
super.load(connectorType);
if (!connectorType.isReopened()) {
return connectorType;
}
// 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 database.
metadata.put(DATABASE, getValueFromConnectorInstance(DATABASE, systemDto, connectorFormDef));
// Find attribute with table.
metadata.put(TABLE, getValueFromConnectorInstance(TABLE, systemDto, connectorFormDef));
// Find attribute with key column.
metadata.put(KEY_COLUMN, getValueFromConnectorInstance(KEY_COLUMN, systemDto, connectorFormDef));
// Find attribute with user.
metadata.put(USER, getValueFromConnectorInstance(USER, systemDto, connectorFormDef));
// Load the mapping.
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(systemDto.getId());
SysSystemMappingDto mappingDto = systemMappingService.find(mappingFilter, null).getContent().stream().min(Comparator.comparing(SysSystemMappingDto::getCreated)).orElse(null);
connectorType.getEmbedded().put(DefaultConnectorType.MAPPING_DTO_KEY, mappingDto);
// Load the sync.
SysSyncConfigFilter syncFilter = new SysSyncConfigFilter();
syncFilter.setSystemId(systemDto.getId());
if (mappingDto != null) {
syncFilter.setSystemMappingId(mappingDto.getId());
}
AbstractSysSyncConfigDto syncDto = syncConfigService.find(syncFilter, null).getContent().stream().min(Comparator.comparing(AbstractDto::getCreated)).orElse(null);
connectorType.getEmbedded().put(DefaultConnectorType.SYNC_DTO_KEY, syncDto);
return connectorType;
}
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 = getConnectorInstance(originalSystem);
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 = systemMappingService.duplicateMapping(originalMappingId, duplicatedSchema, schemaAttributesCache, mappedAttributesCache, false);
// 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;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter in project CzechIdMng by bcvsolutions.
the class SystemMappingDeleteBulkActionTest method processBulkActionByIds.
@Test
public void processBulkActionByIds() {
SysSystemDto system = helper.createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filter = new SysSystemMappingFilter();
filter.setSystemId(system.getId());
List<SysSystemMappingDto> mapping = mappingService.find(filter, null).getContent();
// Contains only one created system mapping
assertEquals(1, mapping.size());
IdmBulkActionDto bulkAction = this.findBulkAction(SysSystemMapping.class, SystemMappingDeleteBulkAction.NAME);
bulkAction.setIdentifiers(ImmutableSet.of(mapping.get(0).getId()));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
mapping = mappingService.find(filter, null).getContent();
// Contains no system mapping after deletion
assertEquals(0, mapping.size());
}
Aggregations