Search in sources :

Example 31 with IdmFormValueDto

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());
}
Also used : IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 32 with IdmFormValueDto

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());
    }
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 33 with IdmFormValueDto

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());
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 34 with IdmFormValueDto

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;
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IcConnectorConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IcConfigurationPropertiesImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcConnectorConfigurationCzechIdMImpl(eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) List(java.util.List) ArrayList(java.util.ArrayList) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 35 with IdmFormValueDto

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;
}
Also used : SysConnectorKeyDto(eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)39 Test (org.junit.Test)24 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)23 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)19 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)13 FormableEntity (eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity)12 Transactional (org.springframework.transaction.annotation.Transactional)11 ArrayList (java.util.ArrayList)10 List (java.util.List)9 UUID (java.util.UUID)9 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)8 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)6 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)6 IdmFormDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto)5 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)4 FormService (eu.bcvsolutions.idm.core.eav.api.service.FormService)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 SysConnectorKeyDto (eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto)3 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)3 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)3