Search in sources :

Example 1 with BusinessProcessFormModel

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

the class BPMFinderServiceImpl method scannProcessesForType.

protected void scannProcessesForType(final Path path, final String extension, final GenerationConfig generationConfig) {
    List<org.uberfire.java.nio.file.Path> nioPaths = new ArrayList<>();
    nioPaths.add(Paths.convert(path));
    Collection<FileUtils.ScanResult> processes = fileUtils.scan(ioService, nioPaths, extension, true);
    processes.stream().map(scanResult -> parse(scanResult)).filter(definitions -> definitions != null && generationConfig.getPredicate().test(definitions)).forEach(definitions -> {
        BusinessProcessFormModel processFormModel = bpmnFormModelGenerator.generateProcessFormModel(definitions.get(), path);
        List<TaskFormModel> taskModels = bpmnFormModelGenerator.generateTaskFormModels(definitions.get(), path);
        generationConfig.getConsumer().accept(new JBPMProcessModel(processFormModel, taskModels));
    });
}
Also used : Path(org.uberfire.backend.vfs.Path) URI(org.eclipse.emf.common.util.URI) BPMFinderService(org.kie.workbench.common.forms.jbpm.service.shared.BPMFinderService) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) Paths(org.uberfire.backend.server.util.Paths) Inject(javax.inject.Inject) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Map(java.util.Map) Service(org.jboss.errai.bus.server.annotations.Service) Named(javax.inject.Named) Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) DroolsResourceFactoryImpl(org.jboss.drools.util.DroolsResourceFactoryImpl) FileUtils(org.kie.workbench.common.services.datamodeller.util.FileUtils) Process(org.eclipse.bpmn2.Process) Logger(org.slf4j.Logger) DroolsPackage(org.jboss.drools.DroolsPackage) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) Predicate(java.util.function.Predicate) Collection(java.util.Collection) JBPMProcessModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Consumer(java.util.function.Consumer) List(java.util.List) Dependent(javax.enterprise.context.Dependent) PostConstruct(javax.annotation.PostConstruct) Bpmn2ResourceFactoryImpl(org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl) Resource(org.eclipse.emf.ecore.resource.Resource) IOService(org.uberfire.io.IOService) Optional(java.util.Optional) BPMNFormModelGenerator(org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator) Bpmn2Package(org.eclipse.bpmn2.Bpmn2Package) JBPMProcessModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel) ArrayList(java.util.ArrayList) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)

Example 2 with BusinessProcessFormModel

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

the class MigrationToolTest method testProcessForm.

@Test
public void testProcessForm() throws IOException {
    final FormDefinition processFormDef = getFormFromResources("formmodeler-migration.UpdateUserProfile-taskform");
    checkFields(processFormDef, new HashMap<String, List<String>>() {

        {
            put("boolean", Arrays.asList("boolean (boolean)", "CheckBox", "boolean"));
            put("cv", Arrays.asList("cv (cv)", "Document", "cv"));
            put("float", Arrays.asList("float (float)", "DecimalBox", "float"));
            put("integer", Arrays.asList("integer (integer)", "IntegerBox", "integer"));
            put("string", Arrays.asList("string (string)", "TextBox", "string"));
            put("person", Arrays.asList("person", "SubForm", "person"));
        }
    });
    assertThat(((BusinessProcessFormModel) processFormDef.getModel()).getProcessName()).isEqualTo("UpdateUserProfile");
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 3 with BusinessProcessFormModel

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

the class BPMNFormModelGeneratorImplTest method testGenerateAllForProcessWithAllPossibleProcessVariables.

@Test
public void testGenerateAllForProcessWithAllPossibleProcessVariables() {
    final Map<String, String> EXPECTED_PROCESS_VARIABLES = new HashMap<String, String>() {

        {
            put("string", String.class.getName());
            put("integer", Integer.class.getName());
            put("boolean", Boolean.class.getName());
            put("float", Float.class.getName());
            put("object", Object.class.getName());
            put("dataObject", DATA_OBJECT_TYPE);
            put("customType", CUSTOM_TYPE);
            put("list", Object.class.getName());
        }
    };
    // generate all = generateProcessFormModel + generateTaskFormModels
    BusinessProcessFormModel processFormModel = generator.generateProcessFormModel(processWithAllVariablesDefinitions, path);
    assertProcessFormModelFieldsAreCorrect(processFormModel, PROCESS_WITH_ALL_VARIABLES_NAME);
    assertJBPMVariablesAreCorrect(processFormModel, EXPECTED_PROCESS_VARIABLES);
    List<TaskFormModel> taskFormModels = generator.generateTaskFormModels(processWithAllVariablesDefinitions, path);
    // taskOnlyWithOutputs-taskform, emptyTask-taskform, taskOnlyWithInputs-taskform, taskWithDifferentInputsAndOutputs-taskform, taskWithTheSameInputsAndOutputs-taskform
    final int EXPECTED_NUMBER_OF_HUMAN_TASKS = 5;
    assertEquals("Forms should be generated for all human tasks including tasks in subprocesses and swimlanes", EXPECTED_NUMBER_OF_HUMAN_TASKS, taskFormModels.size());
}
Also used : HashMap(java.util.HashMap) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Example 4 with BusinessProcessFormModel

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

the class BPMNFormModelGeneratorImplTest method testGenerateAllWithWrongTypes.

@Test
public void testGenerateAllWithWrongTypes() throws Exception {
    when(projectClassLoader.loadClass(Mockito.<String>any())).thenAnswer(invocationOnMock -> getClass().getClassLoader().loadClass(invocationOnMock.getArguments()[0].toString()));
    final Map<String, String> EXPECTED_PROPERTIES = new HashMap<String, String>() {

        {
            put("name", String.class.getName());
            put("age", Integer.class.getName());
            put("error", WorkItemHandlerRuntimeException.class.getName());
            put("list", Object.class.getName());
        }
    };
    BusinessProcessFormModel processFormModel = generator.generateProcessFormModel(processWithWrongTypes, path);
    assertProcessFormModelFieldsAreCorrect(processFormModel, PROCESS_WITH_WRONG_TYPES);
    Assertions.assertThat(processFormModel.getProperties()).isNotNull().isNotEmpty().hasSize(EXPECTED_PROPERTIES.size());
    assertEquals(EXPECTED_PROPERTIES.size(), processFormModel.getProperties().size());
    assertJBPMVariablesAreCorrect(processFormModel, EXPECTED_PROPERTIES);
    List<TaskFormModel> taskFormModels = generator.generateTaskFormModels(processWithWrongTypes, path);
    final int EXPECTED_NUMBER_OF_HUMAN_TASKS = 1;
    Assertions.assertThat(taskFormModels).isNotNull().isNotEmpty().hasSize(EXPECTED_NUMBER_OF_HUMAN_TASKS);
    TaskFormModel taskFormModel = taskFormModels.get(0);
    Assertions.assertThat(taskFormModel.getProperties()).isNotNull().isNotEmpty().hasSize(EXPECTED_PROPERTIES.size());
    assertJBPMVariablesAreCorrect(taskFormModel, EXPECTED_PROPERTIES);
}
Also used : HashMap(java.util.HashMap) WorkItemHandlerRuntimeException(org.jbpm.bpmn2.handler.WorkItemHandlerRuntimeException) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Example 5 with BusinessProcessFormModel

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

the class BPMNFormModelGeneratorImplTest method testGenerateAllForProcessWithoutProcessVariables.

@Test
public void testGenerateAllForProcessWithoutProcessVariables() {
    // generate all = generateProcessFormModel + generateTaskFormModels
    BusinessProcessFormModel processFormModel = generator.generateProcessFormModel(processWithoutVariablesDefinitions, path);
    assertProcessFormModelFieldsAreCorrect(processFormModel, PROCESS_WITHOUT_VARIABLES_NAME);
    assertTrue(processFormModel.getProperties().isEmpty());
    List<TaskFormModel> taskFormModels = generator.generateTaskFormModels(processWithoutVariablesDefinitions, path);
    assertTrue(taskFormModels.isEmpty());
}
Also used : BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Aggregations

BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)16 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)9 ArrayList (java.util.ArrayList)6 Definitions (org.eclipse.bpmn2.Definitions)5 Test (org.junit.Test)5 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)4 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)4 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)4 Path (org.uberfire.backend.vfs.Path)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Process (org.eclipse.bpmn2.Process)3 FormGenerationResult (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult)3 IOException (java.io.IOException)2 Optional (java.util.Optional)2 Dependent (javax.enterprise.context.Dependent)2 Inject (javax.inject.Inject)2 JBPMProcessModel (org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel)2 BPMNFormModelGenerator (org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator)2 KieModuleService (org.kie.workbench.common.services.shared.project.KieModuleService)2