use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class BusinessProcessFormModelVisitor method visitProperty.
protected void visitProperty(ResourceReference reference, FormDefinition formDefinition, ModelProperty property) {
addResourceReference(property.getTypeInfo().getClassName(), ResourceType.JAVA);
FieldDefinition field = formDefinition.getFieldByBoundProperty(property);
if (field != null) {
reference.addPartReference(property.getName(), PartType.VARIABLE);
}
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class AbstractBPMNFormGeneratorServiceTest method checkRootForm.
protected void checkRootForm(JBPMFormModel model, FormGenerationResult result, List<ModelProperty> variableList) {
FormDefinition form = result.getRootForm();
assertEquals(model, form.getModel());
assertFalse(form.getFields().isEmpty());
assertEquals(variableList.size(), form.getFields().size());
variableList.forEach(variable -> {
FieldDefinition field = form.getFieldByBinding(variable.getName());
assertNotNull(field);
assertEquals(variable.getName(), field.getName());
assertEquals(variable.getName(), field.getBinding());
assertEquals(variable.getTypeInfo().getClassName(), field.getStandaloneClassName());
});
assertNotNull(form.getLayoutTemplate());
assertFalse(form.getLayoutTemplate().getRows().isEmpty());
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormGenerationWithSynchronizationTest method testRemoveModelProperties.
@Test
public void testRemoveModelProperties() {
List<ModelProperty> modelProperties = new ArrayList<>();
modelProperties.add(new ModelPropertyImpl(NAME_PROPERTY, new TypeInfoImpl(String.class.getName())));
modelProperties.add(new ModelPropertyImpl(LASTNAME_PROPERTY, new TypeInfoImpl(String.class.getName())));
newFormModel = new TaskFormModel(PROCESS_ID, TASK_NAME, modelProperties);
FormGenerationResult generationResult = service.generateForms(newFormModel, source);
assertNotNull(generationResult);
assertNotNull(generationResult.getRootForm());
FormDefinition formDefinition = generationResult.getRootForm();
assertEquals(newFormModel, formDefinition.getModel());
assertEquals(ORIGINAL_FORM_FIELDS, Integer.valueOf(formDefinition.getFields().size()));
FieldDefinition field = formDefinition.getFieldByBinding(NAME_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
field = formDefinition.getFieldByBinding(LASTNAME_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertNull(formDefinition.getFieldByBinding(AGE_PROPERTY));
assertNull(formDefinition.getFieldByBinding(MARRIED_PROPERTY));
assertNull(formDefinition.getFieldByBinding(ADDRESS_PROPERTY));
assertNotNull(formDefinition.getFieldByName(AGE_PROPERTY));
assertNotNull(formDefinition.getFieldByName(MARRIED_PROPERTY));
assertNotNull(formDefinition.getFieldByName(ADDRESS_PROPERTY));
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class NestedFormsBPMNVFSFormDefinitionGeneratorServiceTest method testCreateNewProcessFormNestedFormsWithModelFormsOnVFS.
@Test
public void testCreateNewProcessFormNestedFormsWithModelFormsOnVFS() {
when(ioService.exists(any())).thenReturn(false);
when(formFinderService.findFormsForType(any(), any())).thenAnswer(this::findVFSForms);
FormGenerationResult result = launchNestedFormsTest();
FormDefinition rootForm = result.getRootForm();
assertNotNull(rootForm);
FieldDefinition expenseField = rootForm.getFieldByBinding(EXPENSE_VARIABLE);
assertNotNull(expenseField);
assertTrue(expenseField instanceof SubFormFieldDefinition);
SubFormFieldDefinition subFormFieldDefinition = (SubFormFieldDefinition) expenseField;
// The nested form should be the form with a field not the empty one
assertEquals(EXPENSE_FORM_ID, subFormFieldDefinition.getNestedForm());
assertEquals(EXPENSE_FORM_ID, subFormFieldDefinition.getStandaloneClassName());
// since the nested forms exist on VFS there shouldn't be any nested forms on the result
assertTrue(result.getNestedForms().isEmpty());
// since the nested forms exist on VFS it shouldn't be any write operation on the VFS
verify(ioService, never()).write(any(), anyString(), any());
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class BPMNFormGenerationTest method checkBPMForm.
private void checkBPMForm(FormDefinition form, Map<String, FormDefinition> allForms) {
assertNotNull(form);
assertEquals(getModelId() + BPMNVariableUtils.TASK_FORM_SUFFIX, form.getId());
assertEquals(getModelId() + BPMNVariableUtils.TASK_FORM_SUFFIX, form.getName());
assertEquals(1, form.getFields().size());
FieldDefinition field = form.getFieldByBinding("person");
assertFieldStatus(field, "person", Person.class.getName());
assertTrue(field instanceof SubFormFieldDefinition);
SubFormFieldDefinition subForm = (SubFormFieldDefinition) field;
assertNotNull(subForm.getNestedForm());
assertNotNull(allForms.get(subForm.getNestedForm()));
}
Aggregations