use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.
the class SystemExportBulkActionIntegrationTest method findSchemas.
private List<SysSchemaObjectClassDto> findSchemas(SysSystemDto system) {
SysSchemaObjectClassFilter filter = new SysSchemaObjectClassFilter();
filter.setSystemId(system.getId());
return schemaObjectClassService.find(filter, null).getContent();
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.
the class SysSchemaObjectClassController method toFilter.
@Override
protected SysSchemaObjectClassFilter toFilter(MultiValueMap<String, Object> parameters) {
SysSchemaObjectClassFilter filter = new SysSchemaObjectClassFilter();
filter.setSystemId(getParameterConverter().toUuid(parameters, "systemId"));
filter.setObjectClassName(getParameterConverter().toString(parameters, "objectClassName"));
return filter;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceIntegrationTest method testReferentialIntegrity.
@Test
public void testReferentialIntegrity() {
SysSystemDto system = new SysSystemDto();
String systemName = getHelper().createName();
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()));
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemService method generateSchema.
@Override
@Transactional
public List<SysSchemaObjectClassDto> generateSchema(SysSystemDto system) {
Assert.notNull(system, "System is required.");
Assert.notNull(system.getId(), "System identifier is required.");
// Find connector identification persisted in system
IcConnectorKey connectorKey = system.getConnectorKey();
if (connectorKey == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Find connector configuration persisted in system
IcConnectorConfiguration connectorConfig = getConnectorConfiguration(system);
if (connectorConfig == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Call IC module and find schema for given connector key and
// configuration
IcSchema icSchema = null;
try {
icSchema = icConfigurationFacade.getSchema(getConnectorInstance(system), connectorConfig);
} catch (Exception ex) {
throw new ResultCodeException(AccResultCode.CONNECTOR_SCHEMA_GENERATION_EXCEPTION, ImmutableMap.of("system", system.getName(), "exception", ex.getLocalizedMessage()), ex);
}
if (icSchema == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_SCHEMA_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Load existing object class from system
SysSchemaObjectClassFilter objectClassFilter = new SysSchemaObjectClassFilter();
objectClassFilter.setSystemId(system.getId());
List<SysSchemaObjectClassDto> sysObjectClassesInSystem = null;
Page<SysSchemaObjectClassDto> page = objectClassService.find(objectClassFilter, null);
sysObjectClassesInSystem = page.getContent();
// Convert IC schema to ACC entities
List<IcObjectClassInfo> declaredObjectClasses = icSchema.getDeclaredObjectClasses();
List<SysSchemaObjectClassDto> sysObjectClasses = new ArrayList<>(declaredObjectClasses.size());
List<SysSchemaAttributeDto> sysAttributes = new ArrayList<>();
for (IcObjectClassInfo objectClass : declaredObjectClasses) {
// __ACCOUNT__ and __GROUP__
if (!(objectClass.getType().startsWith("__") && objectClass.getType().endsWith("__"))) {
continue;
}
SysSchemaObjectClassDto sysObjectClass = null;
// values from resource
if (sysObjectClassesInSystem != null) {
Optional<SysSchemaObjectClassDto> objectClassSame = sysObjectClassesInSystem.stream().filter(objectClassInSystem -> {
//
return objectClassInSystem.getObjectClassName().equals(objectClass.getType());
}).findFirst();
if (objectClassSame.isPresent()) {
sysObjectClass = objectClassSame.get();
}
}
// Convert IC object class to ACC (if is null, then will be created
// new instance)
sysObjectClass = convertIcObjectClassInfo(objectClass, sysObjectClass);
sysObjectClass.setSystem(system.getId());
// object class may not exist
sysObjectClass = schemaObjectClassService.save(sysObjectClass);
sysObjectClasses.add(sysObjectClass);
List<SysSchemaAttributeDto> attributesInSystem = null;
// Load existing attributes for existing object class in system
if (sysObjectClass.getId() != null) {
SysSchemaAttributeFilter attFilter = new SysSchemaAttributeFilter();
attFilter.setSystemId(system.getId());
attFilter.setObjectClassId(sysObjectClass.getId());
Page<SysSchemaAttributeDto> attributesInSystemPage = attributeService.find(attFilter, null);
attributesInSystem = attributesInSystemPage.getContent();
}
for (IcAttributeInfo attribute : objectClass.getAttributeInfos()) {
// If will be IC and ACC attribute same (same name), then we
// will do only refresh object values from resource
SysSchemaAttributeDto sysAttribute = null;
if (attributesInSystem != null) {
Optional<SysSchemaAttributeDto> sysAttributeOptional = attributesInSystem.stream().filter(a -> {
return a.getName().equals(attribute.getName());
}).findFirst();
if (sysAttributeOptional.isPresent()) {
sysAttribute = sysAttributeOptional.get();
}
}
sysAttribute = convertIcAttributeInfo(attribute, sysAttribute);
sysAttribute.setObjectClass(sysObjectClass.getId());
sysAttributes.add(sysAttribute);
}
}
// Persist generated schema to system
sysObjectClasses = (List<SysSchemaObjectClassDto>) objectClassService.saveAll(sysObjectClasses);
attributeService.saveAll(sysAttributes);
return sysObjectClasses;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.
the class MockSysSystemService method generateSchema.
@Override
public List<SysSchemaObjectClassDto> generateSchema(SysSystemDto system) {
// Mock - We don't have an AD.
if (getSchemaCallBack != null) {
return getSchemaCallBack.call(system);
}
SysSchemaObjectClassFilter schemaFilter = new SysSchemaObjectClassFilter();
schemaFilter.setSystemId(system.getId());
return schemaService.find(schemaFilter, null).getContent();
}
Aggregations