Search in sources :

Example 81 with FormDefinition

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;
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)

Example 82 with FormDefinition

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;
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) Date(java.util.Date)

Example 83 with FormDefinition

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);
}
Also used : BigInteger(java.math.BigInteger) MapPropertyType(org.jboss.errai.databinding.client.MapPropertyType) MapPropertyType(org.jboss.errai.databinding.client.MapPropertyType) PropertyType(org.jboss.errai.databinding.client.PropertyType) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 84 with FormDefinition

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);
    }
}
Also used : JBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Example 85 with FormDefinition

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);
        }
    }
}
Also used : BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) JBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) 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