Search in sources :

Example 81 with Definitions

use of org.kie.dmn.model.v1_1.Definitions in project kie-wb-common by kiegroup.

the class EventSubprocessPropertyReaderTest method setUp.

@Before
public void setUp() {
    Definitions definitions = bpmn2.createDefinitions();
    definitions.getRootElements().add(bpmn2.createProcess());
    BPMNDiagram bpmnDiagram = di.createBPMNDiagram();
    bpmnDiagram.setPlane(di.createBPMNPlane());
    definitions.getDiagrams().add(bpmnDiagram);
    definitionResolverReal = new DefinitionResolver(definitions, Collections.emptyList());
}
Also used : BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) Definitions(org.eclipse.bpmn2.Definitions) Before(org.junit.Before)

Example 82 with Definitions

use of org.kie.dmn.model.v1_1.Definitions in project kie-wb-common by kiegroup.

the class CallActivityPropertyReaderTest method setUp.

@Before
public void setUp() {
    Definitions definitions = bpmn2.createDefinitions();
    definitions.getRootElements().add(bpmn2.createProcess());
    BPMNDiagram bpmnDiagram = di.createBPMNDiagram();
    bpmnDiagram.setPlane(di.createBPMNPlane());
    definitions.getDiagrams().add(bpmnDiagram);
    definitionResolver = new DefinitionResolver(definitions, Collections.emptyList());
}
Also used : BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) Definitions(org.eclipse.bpmn2.Definitions) Before(org.junit.Before)

Example 83 with Definitions

use of org.kie.dmn.model.v1_1.Definitions 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) ModuleClassLoaderHelper(org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) Parser(org.jsoup.parser.Parser) Inject(javax.inject.Inject) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInput(org.eclipse.bpmn2.DataInput) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) MultiInstanceLoopCharacteristics(org.eclipse.bpmn2.MultiInstanceLoopCharacteristics) 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) BaseElement(org.eclipse.bpmn2.BaseElement) 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) Optional(java.util.Optional) Collections(java.util.Collections) BPMNFormModelGenerator(org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator) UserTask(org.eclipse.bpmn2.UserTask) Process(org.eclipse.bpmn2.Process)

Example 84 with Definitions

use of org.kie.dmn.model.v1_1.Definitions in project kie-wb-common by kiegroup.

the class GenericServiceTaskTest method marshallServiceTask.

@Test
public void marshallServiceTask() throws Exception {
    Diagram<Graph, Metadata> d = unmarshall(marshaller, BPMN_FILE_PATH);
    DefinitionsConverter definitionsConverter = new DefinitionsConverter(d.getGraph());
    Definitions definitions = definitionsConverter.toDefinitions();
    Process p = (Process) definitions.getRootElements().get(0);
    assertEquals(ServiceTaskImpl.class, p.getFlowElements().stream().filter(e -> e.getId().equals(TASK_ID)).findFirst().get().getClass());
    org.eclipse.bpmn2.ServiceTask flowElement = (org.eclipse.bpmn2.ServiceTask) p.getFlowElements().stream().filter(e -> e.getId().equals(TASK_ID)).findFirst().get();
    assertEquals("Service", flowElement.getName());
    assertEquals("op", flowElement.getOperationRef().getName());
    assertEquals("Java", CustomAttribute.serviceImplementation.of(flowElement).get());
    assertEquals("op", CustomAttribute.serviceOperation.of(flowElement).get());
    assertEquals("hgfhfgh", CustomAttribute.serviceInterface.of(flowElement).get());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Process(org.eclipse.bpmn2.Process) ServiceTaskImpl(org.eclipse.bpmn2.impl.ServiceTaskImpl) Test(org.junit.Test) CustomAttribute(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.CustomAttribute) BPMNDiagramMarshallerBaseTest(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.marshalling.BPMNDiagramMarshallerBaseTest) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Definitions(org.eclipse.bpmn2.Definitions) TestCase.assertEquals(junit.framework.TestCase.assertEquals) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Process(org.eclipse.bpmn2.Process) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Test(org.junit.Test) BPMNDiagramMarshallerBaseTest(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.marshalling.BPMNDiagramMarshallerBaseTest)

Example 85 with Definitions

use of org.kie.dmn.model.v1_1.Definitions in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImpl method generateSelectedFormsForTasks.

private void generateSelectedFormsForTasks(Diagram diagram, String... taskIds) {
    try {
        final String idsRaw = Arrays.stream(taskIds).collect(Collectors.joining(","));
        LOGGER.finest("Generating form for tasks " + idsRaw);
        final Path path = diagram.getMetadata().getPath();
        org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
        ioService.startBatch(ioService.getFileSystem(nioPath.toUri()));
        final Definitions definitions = toDefinitions(diagram);
        for (String taskId : taskIds) {
            final TaskFormModel formModel = bpmnFormModelGenerator.generateTaskFormModel(definitions, taskId, path);
            createFormForModel(formModel, nioPath);
        }
    } catch (Exception ex) {
        LOGGER.severe("Error generating task forms");
        throw new RuntimeException(ex);
    } finally {
        ioService.endBatch();
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) IOException(java.io.IOException)

Aggregations

Test (org.junit.Test)43 Definitions (org.eclipse.bpmn2.Definitions)42 Definitions (org.kie.dmn.model.api.Definitions)32 TDefinitions (org.kie.dmn.model.v1_1.TDefinitions)31 DecisionNodeImpl (org.kie.dmn.core.ast.DecisionNodeImpl)28 DMNModelImpl (org.kie.dmn.core.impl.DMNModelImpl)28 List (java.util.List)27 DMNResult (org.kie.dmn.api.core.DMNResult)27 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)27 ArrayList (java.util.ArrayList)23 HashMap (java.util.HashMap)23 Collectors (java.util.stream.Collectors)22 DMNModel (org.kie.dmn.api.core.DMNModel)22 Map (java.util.Map)21 Logger (org.slf4j.Logger)21 LoggerFactory (org.slf4j.LoggerFactory)21 Arrays (java.util.Arrays)20 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 Collection (java.util.Collection)19 Collections (java.util.Collections)19