use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testEditMultipleAttributeValues.
@Test
public void testEditMultipleAttributeValues() {
FormableEntity owner = createTestOwner("test11");
// save value
formService.saveValues(owner, InitDemoData.FORM_ATTRIBUTE_WWW, Lists.newArrayList(FORM_VALUE_ONE, FORM_VALUE_TWO));
//
List<IdmFormValueDto> attributeWWWValues = formService.getValues(owner, InitDemoData.FORM_ATTRIBUTE_WWW);
assertEquals(2, attributeWWWValues.size());
assertEquals(FORM_VALUE_ONE, attributeWWWValues.get(0).getValue());
// update
formService.saveValues(owner, InitDemoData.FORM_ATTRIBUTE_WWW, Lists.newArrayList(FORM_VALUE_TWO));
//
attributeWWWValues = formService.getValues(owner, InitDemoData.FORM_ATTRIBUTE_WWW);
assertEquals(1, attributeWWWValues.size());
assertEquals(FORM_VALUE_TWO, attributeWWWValues.get(0).getValue());
//
identityService.deleteById(owner.getId());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testReadDefaultDefinitionValueNotSingle.
@Test(expected = IllegalArgumentException.class)
public void testReadDefaultDefinitionValueNotSingle() {
FormableEntity owner = createTestOwner("test5");
try {
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
// save value into default owner and default form definition
IdmFormValueDto value1 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_WWW));
value1.setValue(FORM_VALUE_ONE);
IdmFormValueDto value2 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_WWW));
value2.setValue(FORM_VALUE_TWO);
formService.saveValues(owner, formDefinition, Lists.newArrayList(value1, value2));
IdmFormInstanceDto savedValues = formService.getFormInstance(owner);
assertEquals(2, savedValues.getValues().size());
savedValues.toSinglePersistentValue(InitDemoData.FORM_ATTRIBUTE_WWW);
} finally {
identityService.deleteById(owner.getId());
}
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testReadDefaultDefinitionValue.
@Test
public void testReadDefaultDefinitionValue() {
FormableEntity owner = createTestOwner("test4");
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
// save value into default owner and default form definition
IdmFormValueDto value1 = new IdmFormValueDto(formDefinition.getMappedAttributeByCode(InitDemoData.FORM_ATTRIBUTE_PHONE));
value1.setValue(FORM_VALUE_ONE);
formService.saveValues(owner, formDefinition, Lists.newArrayList(value1));
IdmFormInstanceDto savedValues = formService.getFormInstance(owner);
assertEquals(1, savedValues.getValues().size());
assertEquals(FORM_VALUE_ONE, savedValues.toSinglePersistentValue(InitDemoData.FORM_ATTRIBUTE_PHONE));
//
identityService.deleteById(owner.getId());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto 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.IdmFormValueDto 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;
}
Aggregations