use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class MultipleSubformBackendFormRenderingContextManagerTest method getRootForm.
@Override
protected FormDefinition getRootForm() {
FormDefinition form = new FormDefinition(new PortableJavaModel(Person.class.getName()));
form.setId("form");
FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(TypeKind.OBJECT, Person.class.getName(), true));
field.setName("persons");
field.setBinding("persons");
MultipleSubFormFieldDefinition multpleSubForm = (MultipleSubFormFieldDefinition) field;
multpleSubForm.setCreationForm("person-creation");
multpleSubForm.setEditionForm("person-edition");
form.getFields().add(field);
return form;
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class SimpleFieldTypesBackendFormRenderingContextManagerTest method getRootForm.
@Override
protected FormDefinition getRootForm() {
FormDefinition form = new FormDefinition();
FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
field.setName("string");
field.setBinding("string");
form.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Integer.class.getName()));
field.setName("integer");
field.setBinding("integer");
form.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Date.class.getName()));
field.setName("date");
field.setBinding("date");
form.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Boolean.class.getName()));
field.setName("boolean");
field.setBinding("boolean");
form.getFields().add(field);
return form;
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class MapModelBindingHelper method getModeldefinitionFor.
public MapPropertyType getModeldefinitionFor(MultipleSubFormFieldDefinition subFormField, MapModelRenderingContext context, Map<String, Map<String, PropertyType>> availableModels) {
FormDefinition creationForms = context.getAvailableForms().get(subFormField.getCreationForm());
Map<String, PropertyType> modelDefinition = generateModelDefinition(creationForms, context, availableModels);
FormDefinition editionForm = context.getAvailableForms().get(subFormField.getCreationForm());
modelDefinition.putAll(generateModelDefinition(editionForm, context, availableModels));
modelDefinition.put(MapModelRenderingContext.FORM_ENGINE_OBJECT_IDX, new PropertyType(Integer.class));
modelDefinition.put(MapModelRenderingContext.FORM_ENGINE_EDITED_OBJECT, new PropertyType(Boolean.class));
return new MapPropertyType(modelDefinition);
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorImplTest method testGenerateSelectedTaskForms.
@Test
public void testGenerateSelectedTaskForms() {
generator.generateSelectedForms(diagram, FULL_TASK_ID, INPUTS_TASK_ID, OUTPUTS_TASK_ID);
verify(generator, times(3)).createFormForModel(formModelArgumentCaptor.capture(), any());
verify(formDefinitionSerializer, times(3)).serialize(formDefinitionArgumentCaptor.capture());
verify(ioService, times(1)).startBatch(any());
verify(ioService, times(1)).getFileSystem(any());
verify(ioService, times(3)).createFile(any());
verify(ioService, times(3)).write(any(), anyString());
verify(ioService, times(1)).endBatch();
List<JBPMFormModel> formModels = formModelArgumentCaptor.getAllValues();
List<FormDefinition> taskForms = formDefinitionArgumentCaptor.getAllValues();
Assertions.assertThat(formModels).isNotEmpty().hasSize(taskForms.size()).allMatch(formModel -> formModel instanceof TaskFormModel);
for (int i = 0; i < formModels.size(); i++) {
TaskFormModel taskFormModel = (TaskFormModel) formModels.get(i);
FormDefinition taskForm = taskForms.get(i);
checkTaskFormGenerated(taskFormModel, taskFormModel.getTaskName(), taskForm);
}
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorImplTest method testGenerateAllForms.
@Test
public void testGenerateAllForms() {
generator.generateAllForms(diagram);
verify(generator, times(4)).createFormForModel(formModelArgumentCaptor.capture(), any());
verify(formDefinitionSerializer, times(4)).serialize(formDefinitionArgumentCaptor.capture());
verify(ioService, times(1)).startBatch(any());
verify(ioService, times(1)).getFileSystem(any());
verify(ioService, times(4)).createFile(any());
verify(ioService, times(4)).write(any(), anyString());
verify(ioService, times(1)).endBatch();
List<JBPMFormModel> formModels = formModelArgumentCaptor.getAllValues();
List<FormDefinition> forms = formDefinitionArgumentCaptor.getAllValues();
Assertions.assertThat(formModels).isNotEmpty().hasSize(forms.size()).hasSize(4);
for (int i = 0; i < formModels.size(); i++) {
JBPMFormModel formModel = formModels.get(i);
FormDefinition form = forms.get(i);
if (formModel instanceof BusinessProcessFormModel) {
checkProcessFormGenerated((BusinessProcessFormModel) formModel, form);
} else {
TaskFormModel taskFormModel = (TaskFormModel) formModel;
checkTaskFormGenerated(taskFormModel, taskFormModel.getTaskName(), form);
}
}
}
Aggregations