Search in sources :

Example 6 with IdmFormInstanceDto

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));
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with IdmFormInstanceDto

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());
    }
}
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 8 with IdmFormInstanceDto

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());
}
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 9 with IdmFormInstanceDto

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;
}
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)

Aggregations

IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)9 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)5 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)5 FormableEntity (eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity)5 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)3 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)3 ReportGenerateException (eu.bcvsolutions.idm.rpt.api.exception.ReportGenerateException)3 List (java.util.List)3 Pageable (org.springframework.data.domain.Pageable)3 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)2 Lists (com.google.common.collect.Lists)2 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)2 PersistentType (eu.bcvsolutions.idm.core.eav.api.domain.PersistentType)2 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 Collectors (java.util.stream.Collectors)2 StringUtils (org.apache.commons.lang3.StringUtils)2