Search in sources :

Example 31 with IdmFormDefinitionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceItegrationTest method testFindDefinitionByDtoClass.

@Test
public void testFindDefinitionByDtoClass() {
    IdmFormDefinitionDto definitionByEntityClass = formService.getDefinition(IdmIdentity.class, null);
    IdmFormDefinitionDto definitionByDtoClass = formService.getDefinition(IdmIdentityDto.class, null);
    // 
    Assert.assertNotNull(definitionByEntityClass);
    Assert.assertEquals(definitionByEntityClass, definitionByDtoClass);
}
Also used : IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 32 with IdmFormDefinitionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.

the class AbstractWorkingPositionFilterIntegrationTest method createPosition.

private IdmTreeNodeDto createPosition(IdmTreeTypeDto type, IdmTreeNodeDto parent) {
    IdmTreeNodeDto node = helper.createTreeNode(type, parent);
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmTreeNode.class, FormService.DEFAULT_DEFINITION_CODE);
    IdmFormAttributeDto attr = formDefinition.getMappedAttributeByCode(EavCodeSubordinatesFilter.DEFAULT_FORM_ATTRIBUTE_CODE);
    if (attr == null) {
        attr = new IdmFormAttributeDto();
        attr.setName("Parent code");
        attr.setCode(EavCodeSubordinatesFilter.DEFAULT_FORM_ATTRIBUTE_CODE);
        attr.setFormDefinition(formDefinition.getId());
        attr.setPersistentType(PersistentType.TEXT);
        attr.setUnmodifiable(true);
        attr = formService.saveAttribute(attr);
    }
    // 
    formService.saveValues(node, attr, Lists.newArrayList(parent.getCode()));
    // 
    return node;
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)

Example 33 with IdmFormDefinitionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemServiceTest method testCreateConnectorConfiguration.

@Test
public void testCreateConnectorConfiguration() {
    // TODO: test system will be moved here, after UI eav form implementation
    @SuppressWarnings("deprecation") IcConnectorKey connectorKey = systemService.getTestConnectorKey();
    // create connector instance impl with connector key
    IcConnectorInstance connectorInstance = new IcConnectorInstanceImpl(null, connectorKey, false);
    IcConnectorConfiguration conf = icConfigurationAggregatorService.getConnectorConfiguration(connectorInstance);
    IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(connectorInstance);
    assertEquals(conf.getConfigurationProperties().getProperties().size(), savedFormDefinition.getFormAttributes().size());
    assertEquals(conf.getConfigurationProperties().getProperties().get(3).getDisplayName(), savedFormDefinition.getFormAttributes().get(3).getName());
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) IcConnectorInstanceImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorInstanceImpl) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 34 with IdmFormDefinitionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.

the class SysSystemController method getConnectorFormDefinition.

/**
 * Returns connector form definition to given system
 * or throws exception with code {@code CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND}, when system is wrong configured
 *
 * @param backendId
 * @return
 */
@ResponseBody
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_READ + "')")
@RequestMapping(value = "/{backendId}/connector-form-definition", method = RequestMethod.GET)
@ApiOperation(value = "Connector configuration - form definition", nickname = "getConnectorFormDefinition", tags = { SysSystemController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_READ, description = "") }) })
public ResponseEntity<?> getConnectorFormDefinition(@ApiParam(value = "System's uuid identifier or code.", required = true) @PathVariable @NotNull String backendId) {
    SysSystemDto system = getDto(backendId);
    if (system == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
    }
    IdmFormDefinitionDto formDefinition = getConnectorFormDefinition(system);
    // 
    return new ResponseEntity<>(new Resource<>(formDefinition), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 35 with IdmFormDefinitionDto

use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto in project CzechIdMng by bcvsolutions.

the class SysSystemController method saveConnectorFormValues.

/**
 * Saves connector configuration form values
 *
 * @param backendId
 * @param formValues
 * @return
 */
@ResponseBody
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_UPDATE + "')")
@RequestMapping(value = "/{backendId}/connector-form-values", method = RequestMethod.POST)
@ApiOperation(value = "Connector configuration - save values", nickname = "postConnectorFormValues", tags = { SysSystemController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_UPDATE, description = "") }) })
public Resource<?> saveConnectorFormValues(@ApiParam(value = "System's uuid identifier or code.", required = true) @PathVariable @NotNull String backendId, @RequestBody @Valid List<IdmFormValueDto> formValues) {
    SysSystemDto entity = getDto(backendId);
    if (entity == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
    }
    IdmFormDefinitionDto formDefinition = getConnectorFormDefinition(entity);
    return formDefinitionController.saveFormValues(entity, formDefinition, formValues);
}
Also used : ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)71 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)35 Test (org.junit.Test)35 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)33 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)23 Transactional (org.springframework.transaction.annotation.Transactional)18 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)16 FormableEntity (eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity)14 ApiOperation (io.swagger.annotations.ApiOperation)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)13 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)12 ArrayList (java.util.ArrayList)12 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)12 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)11 UUID (java.util.UUID)8 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)7 List (java.util.List)7 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)6 Serializable (java.io.Serializable)6