Search in sources :

Example 11 with FormGenerationResult

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult in project kie-wb-common by kiegroup.

the class FormGenerationIntegrationTest method ProcessFormIsCorrectlyGenerated.

/**
 * Tests if all form definitions are generated correctly when you hit generate all in the designer.
 */
@Test
public void ProcessFormIsCorrectlyGenerated() {
    when(module.getRootPath()).thenReturn(rootPathWithNestedForms);
    final FormGenerationResult formGenerationResult = generateForm("new_formmodeler.FormGenerationTest_Process-taskform.frm", processFormModel);
    final List<String> expectedProcessFormFields = Arrays.asList("boolean", CHECKBOX_FIELDTYPE, "dataObject", SUBFORM_FIELDTYPE, "document", DOCUMENT_FIELDTYPE, "float", DECIMALBOX_FIELDTYPE, "integer", INTEGERBOX_FIELDTYPE, "object", TEXTAREA_FIELDTYPE, "string", TEXTBOX_FIELDTYPE);
    final FormDefinition rootForm = formGenerationResult.getRootForm();
    testFormDefinition(rootForm, expectedProcessFormFields);
    testNestedFormsHaveCorrectId(rootForm, "dataObject", DATAOBJECT_FORM_ID);
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 12 with FormGenerationResult

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult in project kie-wb-common by kiegroup.

the class AbstractBPMNFormGeneratorService method generateForms.

@Override
public FormGenerationResult generateForms(JBPMFormModel formModel, SOURCE source) {
    if (formModel == null) {
        throw new IllegalArgumentException("FormModel cannot be null");
    }
    GenerationContext<SOURCE> context = new GenerationContext<>(formModel, source);
    FormDefinition rootForm = createRootFormDefinition(context);
    if (rootForm == null) {
        throw new IllegalStateException("Impossible to generate form for: " + formModel.getFormName());
    }
    if (rootForm.getLayoutTemplate() == null) {
        createFormLayout(rootForm);
    }
    context.setRootForm(rootForm);
    processFormDefinition(rootForm, context);
    return new FormGenerationResult(context.getRootForm(), new ArrayList<>(context.getContextForms().values()));
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 13 with FormGenerationResult

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult in project kie-wb-common by kiegroup.

the class AbstractBPMNFormGeneratorServiceTest method checkSimpleVariableForms.

protected void checkSimpleVariableForms() {
    List<ModelProperty> properties = new ArrayList<>();
    properties.add(new ModelPropertyImpl(TEXT_VARIABLE, new TypeInfoImpl(String.class.getName())));
    properties.add(new ModelPropertyImpl(INTEGER_VARIABLE, new TypeInfoImpl(Integer.class.getName())));
    properties.add(new ModelPropertyImpl(DOUBLE_VARIABLE, new TypeInfoImpl(Double.class.getName())));
    properties.add(new ModelPropertyImpl(BOOLEAN_VARIABLE, new TypeInfoImpl(Boolean.class.getName())));
    properties.add(new ModelPropertyImpl(DATE_VARIABLE, new TypeInfoImpl(Date.class.getName())));
    BusinessProcessFormModel model = new BusinessProcessFormModel(PROCESS_ID, PROCESS_ID, properties);
    FormGenerationResult result = service.generateForms(model, source);
    assertNotNull(result);
    assertNotNull(result.getRootForm());
    assertTrue(result.getNestedForms().isEmpty());
    checkRootForm(model, result, properties);
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) ArrayList(java.util.ArrayList) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) Date(java.util.Date)

Example 14 with FormGenerationResult

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult in project kie-wb-common by kiegroup.

the class AbstractBPMNFormGeneratorServiceTest method launchNestedFormsTest.

protected FormGenerationResult launchNestedFormsTest() {
    List<ModelProperty> variableList = new ArrayList<>();
    variableList.add(new ModelPropertyImpl(EXPENSE_VARIABLE, new TypeInfoImpl(TypeKind.OBJECT, Expense.class.getName(), false)));
    variableList.add(new ModelPropertyImpl(TEXT_VARIABLE, new TypeInfoImpl(String.class.getName())));
    BusinessProcessFormModel model = new BusinessProcessFormModel(PROCESS_ID, PROCESS_ID, variableList);
    FormGenerationResult result = service.generateForms(model, source);
    assertNotNull(result);
    assertNotNull(result.getRootForm());
    checkRootForm(model, result, variableList);
    return result;
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) Expense(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Expense) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) ArrayList(java.util.ArrayList) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl)

Example 15 with FormGenerationResult

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult in project kie-wb-common by kiegroup.

the class FormGenerationWithSynchronizationTest method testAddModelProperties.

@Test
public void testAddModelProperties() {
    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())));
    modelProperties.add(new ModelPropertyImpl(AGE_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
    modelProperties.add(new ModelPropertyImpl(MARRIED_PROPERTY, new TypeInfoImpl(Boolean.class.getName())));
    modelProperties.add(new ModelPropertyImpl(ADDRESS_PROPERTY, new TypeInfoImpl(String.class.getName())));
    modelProperties.add(new ModelPropertyImpl(JOB_PROPERTY, new TypeInfoImpl(String.class.getName())));
    modelProperties.add(new ModelPropertyImpl(HOBBIES_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(ALL_FORM_FIELDS, Integer.valueOf(formDefinition.getFields().size()));
    FieldDefinition field = formDefinition.getFieldByBinding(NAME_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    assertTrue(field instanceof TextBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(LASTNAME_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    assertTrue(field instanceof TextBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(AGE_PROPERTY);
    assertEquals(field.getStandaloneClassName(), Integer.class.getName());
    assertTrue(field instanceof IntegerBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(MARRIED_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), Boolean.class.getName());
    assertTrue(field instanceof CheckBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(ADDRESS_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    assertTrue(field instanceof TextBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(JOB_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    assertTrue(field instanceof TextBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(HOBBIES_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    assertTrue(field instanceof TextBoxFieldDefinition);
}
Also used : 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) ArrayList(java.util.ArrayList) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) Test(org.junit.Test)

Aggregations

FormGenerationResult (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult)16 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)13 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)6 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)5 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)5 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)5 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)4 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)3 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)3 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)3 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)3 BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)2 Expense (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Expense)2 Date (java.util.Date)1 DataObjectFormModel (org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)1 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)1 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)1 Line (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Line)1 ServiceException (org.kie.workbench.common.screens.datamodeller.service.ServiceException)1