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