use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto in project CzechIdMng by bcvsolutions.
the class DefaultFormService method getFormInstance.
@Override
@Transactional(readOnly = true)
public IdmFormInstanceDto getFormInstance(Identifiable owner, IdmFormDefinitionDto formDefinition) {
Assert.notNull(owner, "Form values owner is required!");
Assert.notNull(owner.getId(), "Owner id is required!");
FormableEntity ownerEntity = getOwnerEntity(owner);
formDefinition = checkDefaultDefinition(owner.getClass(), formDefinition);
//
FormValueService<FormableEntity> formValueService = getFormValueService(owner);
//
return new IdmFormInstanceDto(ownerEntity, formDefinition, formValueService.getValues(ownerEntity, formDefinition));
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto 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.IdmFormInstanceDto 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.IdmFormInstanceDto 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;
}
Aggregations