Search in sources :

Example 66 with IdmFormDefinitionDto

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

the class DefaultTestHelper method setEavValue.

@Override
public void setEavValue(Identifiable owner, IdmFormAttributeDto attribute, Class<? extends Identifiable> clazz, Serializable value, PersistentType type) {
    UUID ownerId = UUID.fromString(owner.getId().toString());
    IdmFormDefinitionDto main = formDefinitionService.findOneByMain(clazz.getName());
    List<IdmFormValueDto> values = formService.getValues(ownerId, clazz, attribute);
    if (values.isEmpty()) {
        IdmFormValueDto newValue = new IdmFormValueDto();
        newValue.setPersistentType(type);
        newValue.setValue(value);
        newValue.setFormAttribute(attribute.getId());
        newValue.setOwnerId(owner.getId());
        values.add(newValue);
    } else {
        values.get(0).setValue(value);
    }
    formService.saveFormInstance(owner, main, values);
}
Also used : IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) UUID(java.util.UUID)

Example 67 with IdmFormDefinitionDto

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

the class DefaultRptReportServiceIntegrationTest method testReportReferentialIntegrity.

@Test
public void testReportReferentialIntegrity() throws IOException {
    RptReportDto report = new RptReportDto();
    report.setExecutorName(TestFilterReportExecutor.REPORT_NAME);
    IdmFormDto filter = new IdmFormDto();
    TestFilterReportExecutor testReportExecutor = context.getAutowireCapableBeanFactory().createBean(TestFilterReportExecutor.class);
    IdmFormDefinitionDto definition = testReportExecutor.getFormDefinition();
    IdmFormValueDto username = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentity_.username.getName()));
    username.setValue(TestReportExecutor.identities.get(0).getUsername());
    filter.getValues().add(username);
    filter.setFormDefinition(definition.getId());
    report.setFilter(filter);
    // 
    report = reportManager.generate(report);
    final UUID reportId = report.getId();
    Assert.assertNotNull(reportId);
    helper.waitForResult(res -> {
        return OperationState.isRunnable(reportService.get(reportId).getResult().getState());
    });
    Assert.assertNotNull(report.getData());
    Assert.assertNotNull(report.getFilter());
    Assert.assertFalse(commonFormService.getForms(report).isEmpty());
    Assert.assertFalse(attachmentManager.getAttachments(report, null).getTotalElements() == 0);
    // 
    // delete report
    reportService.delete(report);
    // check report is deleted
    Assert.assertNull(reportService.get(report.getId()));
    // check attachment was deleted
    Assert.assertTrue(attachmentManager.getAttachments(report, null).getTotalElements() == 0);
    // check filter is deleted
    Assert.assertTrue(commonFormService.getForms(report).isEmpty());
}
Also used : IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 68 with IdmFormDefinitionDto

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

the class BasicVirtualConnector method updateFormDefinition.

/**
 * Create/Update form definition and attributes
 *
 * @param key
 * @param type
 * @param system
 * @param virtualConfiguration
 * @return
 */
private IdmFormDefinitionDto updateFormDefinition(String key, String type, SysSystemDto system, BasicVirtualConfiguration virtualConfiguration) {
    // TODO: delete attribute definitions
    IdmFormDefinitionDto definition = this.formService.getDefinition(type, key);
    List<IdmFormAttributeDto> formAttributes = new ArrayList<>();
    Arrays.asList(virtualConfiguration.getAttributes()).forEach(virtualAttirbute -> {
        IdmFormAttributeDto formAttribute = formAttributeService.findAttribute(type, key, virtualAttirbute);
        if (formAttribute == null) {
            formAttribute = createFromAttribute(virtualAttirbute);
            formAttribute.setFormDefinition(definition == null ? null : definition.getId());
            formAttributes.add(formAttribute);
        }
    });
    if (definition == null) {
        IdmFormDefinitionDto createdDefinition = this.formService.createDefinition(type, key, formAttributes);
        createdDefinition.setName(MessageFormat.format("Virtual system for [{0}]", system.getName()));
        createdDefinition.setUnmodifiable(true);
        return this.formService.saveDefinition(createdDefinition);
    } else {
        formAttributes.forEach(formAttribute -> {
            this.formService.saveAttribute(formAttribute);
        });
        return definition;
    }
}
Also used : IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)

Example 69 with IdmFormDefinitionDto

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

the class VsAccountController method getFormValues.

/**
 * Returns filled form values
 *
 * @param backendId
 * @return
 */
@ResponseBody
@RequestMapping(value = "/{backendId}/form-values", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + VirtualSystemGroupPermission.VS_ACCOUNT_READ + "')")
@ApiOperation(value = "Account form definition - read values", nickname = "getAccountFormValues", tags = { VsAccountController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = VirtualSystemGroupPermission.VS_ACCOUNT_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = VirtualSystemGroupPermission.VS_ACCOUNT_READ, description = "") }) })
public Resource<?> getFormValues(@ApiParam(value = "Account's uuid identifier.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Code of form definition (default will be used if no code is given).", required = false, defaultValue = FormService.DEFAULT_DEFINITION_CODE) @RequestParam(name = "definitionCode", required = false) String definitionCode) {
    VsAccountDto entity = getDto(backendId);
    if (entity == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
    }
    // 
    IdmFormDefinitionDto formDefinition = formDefinitionController.getDefinition(VsAccount.class, definitionCode);
    // 
    return formDefinitionController.getFormValues(entity, formDefinition);
}
Also used : VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) 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 70 with IdmFormDefinitionDto

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

the class VsAccountController method saveFormValues.

/**
 * Saves connector configuration form values
 *
 * @param backendId
 * @param formValues
 * @return
 */
@ResponseBody
@PreAuthorize("hasAuthority('" + VirtualSystemGroupPermission.VS_ACCOUNT_UPDATE + "')")
@RequestMapping(value = "/{backendId}/form-values", method = RequestMethod.POST)
@ApiOperation(value = "Account form definition - save values", nickname = "postAccountFormValues", tags = { VsAccountController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = VirtualSystemGroupPermission.VS_ACCOUNT_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = VirtualSystemGroupPermission.VS_ACCOUNT_UPDATE, description = "") }) })
public Resource<?> saveFormValues(@ApiParam(value = "Account's uuid identifier.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Code of form definition (default will be used if no code is given).", required = false, defaultValue = FormService.DEFAULT_DEFINITION_CODE) @RequestParam(name = "definitionCode", required = false) String definitionCode, @ApiParam(value = "Filled form data.", required = true) @RequestBody @Valid List<IdmFormValueDto> formValues) {
    VsAccountDto entity = getDto(backendId);
    if (entity == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
    }
    checkAccess(entity, IdmBasePermission.UPDATE);
    // 
    IdmFormDefinitionDto formDefinition = formDefinitionController.getDefinition(VsAccount.class, definitionCode);
    // 
    return formDefinitionController.saveFormValues(entity, formDefinition, formValues);
}
Also used : VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) 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