use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testFindOwnersByMultiStringAttributeValue.
@Test
public void testFindOwnersByMultiStringAttributeValue() {
FormableEntity owner = createTestOwner("test12");
FormableEntity ownerTwo = createTestOwner("test13");
FormableEntity ownerThree = createTestOwner("test14");
IdmFormDefinitionDto formDefinition = formService.getDefinition(owner.getClass());
IdmFormAttributeDto attribute = formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_WWW);
// save values
formService.saveValues(owner, attribute, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
formService.saveValues(ownerTwo, attribute, Lists.newArrayList(FORM_VALUE_THREE, FORM_VALUE_TWO));
formService.saveValues(ownerThree, attribute, Lists.newArrayList(FORM_VALUE_FOUR, FORM_VALUE_FOUR));
//
Page<? extends Identifiable> owners = formService.findOwners(owner.getClass(), attribute, FORM_VALUE_ONE, null);
//
assertEquals(1, owners.getTotalElements());
assertEquals(owner.getId(), owners.getContent().get(0).getId());
//
owners = formService.findOwners(owner.getClass(), attribute.getCode(), FORM_VALUE_TWO, null);
assertEquals(2, owners.getTotalElements());
//
owners = formService.findOwners(owner.getClass(), attribute, FORM_VALUE_FOUR, null);
assertEquals(1, owners.getTotalElements());
//
identityService.deleteById(owner.getId());
identityService.deleteById(ownerTwo.getId());
identityService.deleteById(ownerThree.getId());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemService method getConnectorConfiguration.
@Override
@Transactional
public IcConnectorConfiguration getConnectorConfiguration(SysSystemDto system) {
Assert.notNull(system);
if (system.getConnectorKey() == null) {
return null;
}
IcConnectorConfiguration connectorConfig = null;
// load connector properties, different between local and remote
IcConnectorInstance connectorInstance = system.getConnectorInstance();
if (system.isRemote() && connectorInstance.getConnectorServer() != null) {
connectorInstance.getConnectorServer().setPassword(confidentialStorage.getGuardedString(system.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD));
}
connectorConfig = icConfigurationFacade.getConnectorConfiguration(connectorInstance);
// load filled form values
IdmFormDefinitionDto formDefinition = getConnectorFormDefinition(system.getConnectorInstance());
IdmFormInstanceDto formValues = getFormService().getFormInstance(system, formDefinition);
Map<String, List<IdmFormValueDto>> attributeValues = formValues.toValueMap();
// fill connector configuration from form values
IcConnectorConfigurationImpl icConf = null;
if (SysSystemService.CONNECTOR_FRAMEWORK_CZECHIDM.equals(connectorInstance.getConnectorKey().getFramework())) {
// For CzechIdM connector framework is needs system ID (exactly for virtual systems).
icConf = new IcConnectorConfigurationCzechIdMImpl();
((IcConnectorConfigurationCzechIdMImpl) icConf).setSystemId(system.getId());
} else {
icConf = new IcConnectorConfigurationImpl();
}
IcConfigurationProperties properties = new IcConfigurationPropertiesImpl();
icConf.setConfigurationProperties(properties);
//
for (short seq = 0; seq < connectorConfig.getConfigurationProperties().getProperties().size(); seq++) {
IcConfigurationProperty propertyConfig = connectorConfig.getConfigurationProperties().getProperties().get(seq);
IdmFormAttributeDto formAttribute = formDefinition.getMappedAttributeByCode(propertyConfig.getName());
List<IdmFormValueDto> eavAttributeValues = attributeValues.get(formAttribute.getCode());
// create property instance from configuration
IcConfigurationProperty property = formPropertyManager.toConnectorProperty(propertyConfig, eavAttributeValues);
if (property.getValue() != null) {
// only filled values to configuration
properties.getProperties().add(property);
}
}
return icConf;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemService method getConnectorFormDefinition.
@Override
@Transactional
public IdmFormDefinitionDto getConnectorFormDefinition(IcConnectorInstance connectorInstance) {
Assert.notNull(connectorInstance);
Assert.notNull(connectorInstance.getConnectorKey());
//
IdmFormDefinitionDto formDefinition = getFormService().getDefinition(SysSystem.class.getName(), connectorInstance.getConnectorKey().getFullName());
//
if (formDefinition == null) {
// we creates new form definition
formDefinition = createConnectorFormDefinition(connectorInstance);
formDefinition.setUnmodifiable(true);
}
return formDefinition;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemService method createTestSystem.
@Deprecated
@Transactional
public SysSystemDto createTestSystem() {
// create owner
SysSystemDto system = new SysSystemDto();
system.setName("sysOne_" + System.currentTimeMillis());
system.setConnectorKey(new SysConnectorKeyDto(getTestConnectorKey()));
system = save(system);
IdmFormDefinitionDto savedFormDefinition = getConnectorFormDefinition(system.getConnectorInstance());
List<IdmFormValueDto> values = new ArrayList<>();
IdmFormValueDto host = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("host"));
host.setValue("localhost");
values.add(host);
IdmFormValueDto port = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("port"));
port.setValue("5432");
values.add(port);
IdmFormValueDto user = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("user"));
user.setValue("idmadmin");
values.add(user);
IdmFormValueDto password = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("password"));
password.setValue("idmadmin");
values.add(password);
IdmFormValueDto database = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("database"));
database.setValue("bcv_idm_storage");
values.add(database);
IdmFormValueDto table = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("table"));
table.setValue("system_users");
values.add(table);
IdmFormValueDto keyColumn = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("keyColumn"));
keyColumn.setValue("name");
values.add(keyColumn);
IdmFormValueDto passwordColumn = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("passwordColumn"));
passwordColumn.setValue("password");
values.add(passwordColumn);
IdmFormValueDto allNative = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("allNative"));
allNative.setValue(Boolean.TRUE);
values.add(allNative);
IdmFormValueDto jdbcDriver = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("jdbcDriver"));
jdbcDriver.setValue("org.postgresql.Driver");
values.add(jdbcDriver);
IdmFormValueDto jdbcUrlTemplate = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("jdbcUrlTemplate"));
jdbcUrlTemplate.setValue("jdbc:postgresql://%h:%p/%d");
values.add(jdbcUrlTemplate);
IdmFormValueDto rethrowAllSQLExceptions = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("rethrowAllSQLExceptions"));
rethrowAllSQLExceptions.setValue(Boolean.TRUE);
values.add(rethrowAllSQLExceptions);
IdmFormValueDto statusColumn = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("statusColumn"));
statusColumn.setValue("status");
values.add(statusColumn);
IdmFormValueDto disabledStatusValue = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("disabledStatusValue"));
disabledStatusValue.setValue("disabled");
values.add(disabledStatusValue);
IdmFormValueDto enabledStatusValue = new IdmFormValueDto(savedFormDefinition.getMappedAttributeByCode("enabledStatusValue"));
enabledStatusValue.setValue("enabled");
values.add(enabledStatusValue);
// TODO: eav to DTO
getFormService().saveValues(getEntity(system.getId()), savedFormDefinition, values);
return system;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto 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 = originalSystem.getConnectorInstance();
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 = this.duplicateMapping(originalMappingId, duplicatedSchema, schemaAttributesCache, mappedAttributesCache);
// 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;
}
Aggregations