Search in sources :

Example 11 with TaskFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel in project kie-wb-common by kiegroup.

the class BPMNFormModelGeneratorImplTest method testCorrectTaskFormModelIsGeneratedForTaskThatContainsOnlyInputs.

@Test
public void testCorrectTaskFormModelIsGeneratedForTaskThatContainsOnlyInputs() {
    final String TASK_ID = "_9F3A7665-E7EF-4DC2-94F1-F9D20A38547E", TASK_NAME = "taskOnlyWithInputs";
    TaskFormModel taskFormModel = generator.generateTaskFormModel(processWithAllVariablesDefinitions, TASK_ID, path);
    assertTaskFormModelIsCorrect(taskFormModel, PROCESS_WITH_ALL_VARIABLES_ID, TASK_NAME);
    assertJBPMVariablesAreCorrect(taskFormModel, EXPECTED_INPUT_VARIABLES);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Example 12 with TaskFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel in project kie-wb-common by kiegroup.

the class BPMNFormModelGeneratorImpl method generateTaskFormModels.

@Override
public List<TaskFormModel> generateTaskFormModels(Definitions source, Path path) {
    Process process = getProcess(source);
    final ClassLoader projectClassLoader = projectClassLoaderHelper.getModuleClassLoader(moduleService.resolveModule(path));
    if (process != null) {
        ProcessTaskFormsGenerationResult result = readUserTaskFormVariables(process);
        return result.getAllTaskFormVariables().stream().filter(taskFormVariables -> {
            if (!taskFormVariables.isValid()) {
                logger.warn(generateErrorMessage(taskFormVariables));
                return false;
            }
            return true;
        }).map(taskFormVariables -> taskFormVariables.toFormModel(variable -> createModelProperty(variable, projectClassLoader))).collect(Collectors.toList());
    }
    return Collections.emptyList();
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) FormalExpression(org.eclipse.bpmn2.FormalExpression) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) ModuleClassLoaderHelper(org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper) LoggerFactory(org.slf4j.LoggerFactory) FieldReadOnlyEntry(org.kie.workbench.common.forms.model.impl.meta.entries.FieldReadOnlyEntry) StringUtils(org.apache.commons.lang3.StringUtils) Parser(org.jsoup.parser.Parser) Inject(javax.inject.Inject) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) FieldTypeEntry(org.kie.workbench.common.forms.model.impl.meta.entries.FieldTypeEntry) DataInput(org.eclipse.bpmn2.DataInput) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) DataOutput(org.eclipse.bpmn2.DataOutput) Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) Process(org.eclipse.bpmn2.Process) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) BPMNVariableUtils(org.kie.workbench.common.forms.jbpm.service.bpmn.util.BPMNVariableUtils) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) Collectors(java.util.stream.Collectors) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) List(java.util.List) Dependent(javax.enterprise.context.Dependent) Assignment(org.eclipse.bpmn2.Assignment) ModelPropertiesGenerator(org.kie.workbench.common.forms.service.backend.util.ModelPropertiesGenerator) Optional(java.util.Optional) FormModelPropertiesUtil(org.kie.workbench.common.forms.model.util.formModel.FormModelPropertiesUtil) Collections(java.util.Collections) BPMNFormModelGenerator(org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator) UserTask(org.eclipse.bpmn2.UserTask) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) Process(org.eclipse.bpmn2.Process)

Example 13 with TaskFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel 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)

Example 14 with TaskFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel in project kie-wb-common by kiegroup.

the class FormGenerationWithSynchronizationTest method testModelPropertiesConflict.

@Test
public void testModelPropertiesConflict() {
    List<ModelProperty> modelProperties = new ArrayList<>();
    modelProperties.add(new ModelPropertyImpl(NAME_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
    modelProperties.add(new ModelPropertyImpl(LASTNAME_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
    modelProperties.add(new ModelPropertyImpl(AGE_PROPERTY, new TypeInfoImpl(String.class.getName())));
    modelProperties.add(new ModelPropertyImpl(MARRIED_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
    modelProperties.add(new ModelPropertyImpl(ADDRESS_PROPERTY, new TypeInfoImpl(Boolean.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(), Integer.class.getName());
    assertTrue(field instanceof IntegerBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(LASTNAME_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), Integer.class.getName());
    assertTrue(field instanceof IntegerBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(AGE_PROPERTY);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    assertTrue(field instanceof TextBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(MARRIED_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), Integer.class.getName());
    assertTrue(field instanceof IntegerBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(ADDRESS_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), Boolean.class.getName());
    assertTrue(field instanceof CheckBoxFieldDefinition);
}
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)

Example 15 with TaskFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel in project kie-wb-common by kiegroup.

the class BPMNFormModelGeneratorImplTest method testGenerateAllTaskFormModelForTasksWithSharedForm.

@Test
public void testGenerateAllTaskFormModelForTasksWithSharedForm() {
    final String TASK_NAME = "task";
    final int EXPECTED_MODELS = 2;
    List<TaskFormModel> generatedModels = generator.generateTaskFormModels(processWithSharedForms, path);
    assertNotNull(generatedModels);
    assertEquals(EXPECTED_MODELS, generatedModels.size());
    for (TaskFormModel formModel : generatedModels) {
        assertNotNull(formModel);
        assertEquals(PROCESS_WITH_SHARED_FORMS_ID, formModel.getProcessId());
        assertNotNull(formModel.getProperties());
        assertFalse(formModel.getProperties().isEmpty());
        if (formModel.getFormName().equals(TASK_NAME + BPMNVariableUtils.TASK_FORM_SUFFIX)) {
            checkExpectedMergedFormVariables(formModel);
        }
    }
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Aggregations

TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)21 Test (org.junit.Test)15 Matchers.anyString (org.mockito.Matchers.anyString)9 BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 Definitions (org.eclipse.bpmn2.Definitions)4 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)4 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)4 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)4 Path (org.uberfire.backend.vfs.Path)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 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)3 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)3 IOException (java.io.IOException)2 List (java.util.List)2 Optional (java.util.Optional)2 Dependent (javax.enterprise.context.Dependent)2