Search in sources :

Example 41 with FieldDefinition

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);
    }
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition)

Example 42 with FieldDefinition

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());
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) DecimalBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 43 with FieldDefinition

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));
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) ArrayList(java.util.ArrayList) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 44 with FieldDefinition

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());
}
Also used : SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 45 with FieldDefinition

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()));
}
Also used : SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) Person(org.kie.workbench.common.forms.jbpm.server.service.impl.model.Person)

Aggregations

FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)85 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)42 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)29 Test (org.junit.Test)27 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)24 TextAreaFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition)22 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)21 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)20 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)18 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)17 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)14 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)13 ArrayList (java.util.ArrayList)11 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)9 LayoutComponent (org.uberfire.ext.layout.editor.api.editor.LayoutComponent)8 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)7 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)7 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)7 LayoutColumn (org.uberfire.ext.layout.editor.api.editor.LayoutColumn)7 LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)7