Search in sources :

Example 36 with FormDefinition

use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.

the class VFSFormFinderServiceImpl method findForms.

private List<FormDefinition> findForms(final Path path, final FormSearchConstraint constraint) {
    List<FormDefinition> result = new ArrayList<>();
    Module module = moduleService.resolveModule(path);
    FileUtils utils = FileUtils.getInstance();
    List<org.uberfire.java.nio.file.Path> nioPaths = new ArrayList<>();
    nioPaths.add(Paths.convert(module.getRootPath()));
    Collection<FileUtils.ScanResult> forms = utils.scan(ioService, nioPaths, FormResourceTypeDefinition.EXTENSION, true);
    for (FileUtils.ScanResult form : forms) {
        org.uberfire.java.nio.file.Path formPath = form.getFile();
        try {
            FormDefinition formDefinition = serializer.deserialize(ioService.readAllString(formPath).trim());
            if (constraint == null || constraint.accepts(formDefinition)) {
                result.add(formDefinition);
            }
        } catch (Exception ex) {
            logger.warn("Unable to generate FormDefinition for {}", path, ex);
        }
    }
    return result;
}
Also used : Path(org.uberfire.backend.vfs.Path) FileUtils(org.kie.workbench.common.services.datamodeller.util.FileUtils) ArrayList(java.util.ArrayList) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Module(org.guvnor.common.services.project.model.Module)

Example 37 with FormDefinition

use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.

the class FormEditorServiceImplTest method verifyNewForm.

protected String verifyNewForm(InvocationOnMock invocationOnMock) {
    FormDefinition form = (FormDefinition) invocationOnMock.getArguments()[0];
    assertNotNull(form);
    assertNotNull(form.getId());
    assertNotNull(form.getModel());
    assertEquals(FORM_NAME, form.getName());
    assertTrue(form.getFields().isEmpty());
    assertNotNull(form.getLayoutTemplate());
    return "";
}
Also used : FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 38 with FormDefinition

use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.

the class DynamicBPMNFormGeneratorImpl method createFormDefinition.

protected Collection<FormDefinition> createFormDefinition(JBPMFormModel model, ClassLoader classLoader) {
    FormGenerationResult generationResult = formGeneratorService.generateForms(model, classLoader);
    List<FormDefinition> result = new ArrayList<>();
    result.add(generationResult.getRootForm());
    result.addAll(generationResult.getNestedForms());
    return result;
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) ArrayList(java.util.ArrayList) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 39 with FormDefinition

use of org.kie.workbench.common.forms.model.FormDefinition 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 40 with FormDefinition

use of org.kie.workbench.common.forms.model.FormDefinition 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)

Aggregations

FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)89 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)30 Test (org.junit.Test)29 ArrayList (java.util.ArrayList)16 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)14 FormGenerationResult (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult)14 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)13 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)12 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)12 AbstractFormGenerationTest (org.kie.workbench.common.forms.adf.engine.shared.test.AbstractFormGenerationTest)10 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)10 List (java.util.List)9 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)9 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)8 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)8 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)8 Person (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Person)7 FormModel (org.kie.workbench.common.forms.model.FormModel)7 PortableJavaModel (org.kie.workbench.common.forms.model.impl.PortableJavaModel)7 Date (java.util.Date)6