use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceTest method testReferentialIntegrity.
@Test
public void testReferentialIntegrity() {
SysSystemDto system = new SysSystemDto();
String systemName = "t_s_" + System.currentTimeMillis();
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.SysSchemaObjectClassDto in project CzechIdMng by bcvsolutions.
the class AbstractSynchronizationExecutor method startExport.
/**
* Start export entities to target resource
*
* @param entityType
* @param config
* @param mappedAttributes
* @param log
* @param actionsLog
*/
@Beta
protected void startExport(SystemEntityType entityType, AbstractSysSyncConfigDto config, List<SysSystemAttributeMappingDto> mappedAttributes, SysSyncLogDto log, List<SysSyncActionLogDto> actionsLog) {
SysSystemMappingDto systemMapping = systemMappingService.get(config.getSystemMapping());
SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(systemMapping.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(schemaObjectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
SysSystemAttributeMappingDto uidAttribute = systemAttributeMappingService.getUidAttribute(mappedAttributes, system);
List<DTO> entities = this.findAll();
entities.stream().forEach(entity -> {
// TODO: evaluate to groovy script
SynchronizationContext itemBuilder = new SynchronizationContext();
//
itemBuilder.addConfig(config).addSystem(//
system).addEntityType(//
entityType).addEntityId(//
entity.getId()).addLog(//
log).addActionLogs(actionsLog);
// Start export for this entity
exportEntity(itemBuilder, uidAttribute, entity);
});
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto in project CzechIdMng by bcvsolutions.
the class TreeSynchronizationExecutor method startExport.
/**
* Start export entities to target resource
*
* @param entityType
* @param config
* @param mappedAttributes
* @param log
* @param actionsLog
*/
@Override
protected void startExport(SystemEntityType entityType, AbstractSysSyncConfigDto config, List<SysSystemAttributeMappingDto> mappedAttributes, SysSyncLogDto log, List<SysSyncActionLogDto> actionsLog) {
SysSystemMappingDto systemMapping = systemMappingService.get(config.getSystemMapping());
SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(systemMapping.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(schemaObjectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
SysSystemAttributeMappingDto uidAttribute = attributeHandlingService.getUidAttribute(mappedAttributes, system);
List<IdmTreeNodeDto> roots = treeNodeService.findRoots(systemMapping.getTreeType(), null).getContent();
roots.stream().forEach(root -> {
SynchronizationContext itemBuilder = new SynchronizationContext();
//
itemBuilder.addConfig(config).addSystem(//
system).addEntityType(//
entityType).addLog(//
log).addActionLogs(actionsLog);
// Start export for this entity
exportChildrenRecursively(root, itemBuilder, uidAttribute);
});
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto in project CzechIdMng by bcvsolutions.
the class DefaultTestHelper method createTestResourceSystem.
@Override
public SysSystemDto createTestResourceSystem(boolean withMapping, String systemName) {
// create test system
SysSystemDto system = createSystem(TestResource.TABLE_NAME, systemName);
//
if (!withMapping) {
return system;
}
//
// generate schema for system
List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
//
SysSystemMappingDto systemMapping = new SysSystemMappingDto();
systemMapping.setName("default_" + System.currentTimeMillis());
systemMapping.setEntityType(SystemEntityType.IDENTITY);
systemMapping.setOperationType(SystemOperationType.PROVISIONING);
systemMapping.setObjectClass(objectClasses.get(0).getId());
systemMapping = systemMappingService.save(systemMapping);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
for (SysSchemaAttributeDto schemaAttr : schemaAttributesPage) {
if (ATTRIBUTE_MAPPING_NAME.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setUid(true);
attributeMapping.setEntityAttribute(true);
attributeMapping.setIdmPropertyName(IdmIdentity_.username.getName());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_ENABLE.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setUid(false);
attributeMapping.setEntityAttribute(true);
attributeMapping.setIdmPropertyName("disabled");
attributeMapping.setTransformToResourceScript("return String.valueOf(!attributeValue);");
attributeMapping.setTransformFromResourceScript("return !attributeValue;");
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_PASSWORD.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName("password");
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_FIRSTNAME.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName(IdmIdentity_.firstName.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_LASTNAME.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName(IdmIdentity_.lastName.getName());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_EMAIL.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName(IdmIdentity_.email.getName());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
}
}
return system;
}
use of eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestSchedulerTest method createAndSaveSystemWithMapping.
private SysSystemDto createAndSaveSystemWithMapping() {
system = null;
systemMapping = null;
SysSystemAttributeMappingDto nameAttributeMapping = null;
SysSystemAttributeMappingDto firstNameAttributeMapping = null;
SysSystemAttributeMappingDto lastNameAttributeMapping = null;
SysSystemAttributeMappingDto passwordAttributeMapping = null;
// prepare test system
system = helper.createSystem(TestResource.TABLE_NAME);
// generate schema
List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
// create test mapping
systemMapping = new SysSystemMappingDto();
systemMapping.setName("default_" + System.currentTimeMillis());
systemMapping.setEntityType(SystemEntityType.IDENTITY);
systemMapping.setOperationType(SystemOperationType.PROVISIONING);
systemMapping.setObjectClass(objectClasses.get(0).getId());
systemMapping = mappingService.save(systemMapping);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
for (SysSchemaAttributeDto schemaAttr : schemaAttributesPage) {
if ("__NAME__".equals(schemaAttr.getName())) {
nameAttributeMapping = new SysSystemAttributeMappingDto();
nameAttributeMapping.setUid(true);
nameAttributeMapping.setEntityAttribute(true);
nameAttributeMapping.setIdmPropertyName("username");
nameAttributeMapping.setName(schemaAttr.getName());
nameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
nameAttributeMapping.setSystemMapping(systemMapping.getId());
nameAttributeMapping = attributeMappingService.save(nameAttributeMapping);
} else if ("firstname".equalsIgnoreCase(schemaAttr.getName())) {
firstNameAttributeMapping = new SysSystemAttributeMappingDto();
firstNameAttributeMapping.setIdmPropertyName("firstName");
firstNameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
firstNameAttributeMapping.setName(schemaAttr.getName());
firstNameAttributeMapping.setSystemMapping(systemMapping.getId());
firstNameAttributeMapping = attributeMappingService.save(firstNameAttributeMapping);
} else if ("lastname".equalsIgnoreCase(schemaAttr.getName())) {
lastNameAttributeMapping = new SysSystemAttributeMappingDto();
lastNameAttributeMapping.setIdmPropertyName("lastName");
lastNameAttributeMapping.setName(schemaAttr.getName());
lastNameAttributeMapping.setSchemaAttribute(schemaAttr.getId());
lastNameAttributeMapping.setSystemMapping(systemMapping.getId());
lastNameAttributeMapping = attributeMappingService.save(lastNameAttributeMapping);
} else if (IcConnectorFacade.PASSWORD_ATTRIBUTE_NAME.equalsIgnoreCase(schemaAttr.getName())) {
passwordAttributeMapping = new SysSystemAttributeMappingDto();
passwordAttributeMapping.setIdmPropertyName("password");
passwordAttributeMapping.setSchemaAttribute(schemaAttr.getId());
passwordAttributeMapping.setName(schemaAttr.getName());
passwordAttributeMapping.setSystemMapping(systemMapping.getId());
passwordAttributeMapping = attributeMappingService.save(passwordAttributeMapping);
}
}
assertNotNull(system);
assertNotNull(nameAttributeMapping);
assertNotNull(firstNameAttributeMapping);
assertNotNull(lastNameAttributeMapping);
assertNotNull(passwordAttributeMapping);
return system;
}
Aggregations