use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter 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.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.
the class MockMsSqlConnectorType method initMockSysSystemService.
private MockSysSystemService initMockSysSystemService() {
if (systemService == null) {
systemService = AutowireHelper.createBean(MockSysSystemService.class);
systemService.setGetSchemaCallBack(new GetSchemaCallBack() {
@Override
public List<SysSchemaObjectClassDto> call(SysSystemDto systemDto) {
if (systemDto != null) {
SysSchemaObjectClassFilter schemaFilter = new SysSchemaObjectClassFilter();
schemaFilter.setSystemId(systemDto.getId());
List<SysSchemaObjectClassDto> content = schemaObjectClassService.find(schemaFilter, null).getContent();
if (content.size() > 0) {
return content;
}
SysSchemaObjectClassDto schemaObjectClassDto = new SysSchemaObjectClassDto();
schemaObjectClassDto.setObjectClassName(IcObjectClassInfo.ACCOUNT);
schemaObjectClassDto.setSystem(systemDto.getId());
schemaObjectClassDto = schemaObjectClassService.save(schemaObjectClassDto);
return Lists.newArrayList(schemaObjectClassDto);
}
return null;
}
});
}
return systemService;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.
the class SystemDeleteProcessor method process.
@Override
public EventResult<SysSystemDto> process(EntityEvent<SysSystemDto> event) {
SysSystemDto system = event.getContent();
Assert.notNull(system, "System is required.");
//
// if exists provisioning operations, then is not possible to delete
// system
SysProvisioningOperationFilter operationFilter = new SysProvisioningOperationFilter();
operationFilter.setSystemId(system.getId());
if (provisioningOperationService.count(operationFilter) > 0) {
throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_OPERATIONS, ImmutableMap.of("system", system.getName()));
}
if (accountRepository.countBySystem_Id(system.getId()) > 0) {
throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_ACCOUNTS, ImmutableMap.of("system", system.getName()));
}
// Check if system is used in some systems group.
SysSystemGroupSystemFilter groupSystemFilter = new SysSystemGroupSystemFilter();
groupSystemFilter.setSystemId(system.getId());
long count = systemGroupSystemService.count(groupSystemFilter);
if (count > 0) {
throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_SYSTEM_GROUPS, ImmutableMap.of("system", system.getName(), "count", count));
}
// delete system entities
SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
systemEntityFilter.setSystemId(system.getId());
systemEntityService.find(systemEntityFilter, null).forEach(systemEntity -> {
systemEntityService.delete(systemEntity);
});
// delete synchronization configs
SysSyncConfigFilter synchronizationConfigFilter = new SysSyncConfigFilter();
synchronizationConfigFilter.setSystemId(system.getId());
synchronizationConfigService.find(synchronizationConfigFilter, null).forEach(config -> {
synchronizationConfigService.delete(config);
});
// delete schema
SysSchemaObjectClassFilter filter = new SysSchemaObjectClassFilter();
filter.setSystemId(system.getId());
objectClassService.find(filter, null).forEach(schemaObjectClass -> {
objectClassService.delete(schemaObjectClass);
});
// delete archived provisioning operations
provisioningArchiveRepository.deleteBySystem_Id(system.getId());
//
// clear provisioning break cache
clearProvisioningBreakAndCache(system.getId());
//
// deletes all confidential values
confidentialStorage.deleteAll(system.getId(), SysSystem.class);
//
// Delete connected uniform password. Or throw error at the beginning?
AccUniformPasswordSystemFilter uniformPasswordSystemFilter = new AccUniformPasswordSystemFilter();
uniformPasswordSystemFilter.setSystemId(system.getId());
passwordFilterSystemService.find(uniformPasswordSystemFilter, null).forEach(uniformPasswordSystem -> {
passwordFilterSystemService.delete(uniformPasswordSystem);
});
//
// deletes identity
service.deleteInternal(system);
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountService method getSchemaAttributes.
/**
* Find schema's attributes for the system id and schema name.
*
* @param systemId
* @param schema
* - If is schema name null, then will used default '__ACCOUNT__'.
* @return
*/
private List<SysSchemaAttributeDto> getSchemaAttributes(UUID systemId, String schema) {
SysSchemaObjectClassFilter schemaFilter = new SysSchemaObjectClassFilter();
schemaFilter.setSystemId(systemId);
schemaFilter.setObjectClassName(schema != null ? schema : IcObjectClassInfo.ACCOUNT);
List<SysSchemaObjectClassDto> schemas = schemaObjectClassService.find(schemaFilter, null).getContent();
if (schemas.size() != 1) {
return null;
}
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setObjectClassId(schemas.get(0).getId());
schemaAttributeFilter.setSystemId(systemId);
return schemaAttributeService.find(schemaAttributeFilter, null).getContent();
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysRoleSystemAttributeService method getObjectClassId.
/**
* Returns systems object's scheme
*
* @param systemId
* @param objectClassName
* @return
*/
private UUID getObjectClassId(UUID systemId, String objectClassName) {
SysSchemaObjectClassFilter filter = new SysSchemaObjectClassFilter();
filter.setSystemId(systemId);
filter.setObjectClassName(objectClassName);
List<SysSchemaObjectClassDto> objectClasses = schemaObjectClassService.find(filter, null).getContent();
if (objectClasses.isEmpty()) {
throw new ResultCodeException(AccResultCode.SYSTEM_SCHEMA_OBJECT_CLASS_NOT_FOUND, ImmutableMap.of("objectClassName", objectClassName, "systemId", systemId));
}
return objectClasses.get(0).getId();
}
Aggregations