Search in sources :

Example 11 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImpl method generateProcessForm.

@Override
public void generateProcessForm(Diagram diagram) {
    try {
        LOGGER.finest("Generating form for process ");
        final Definitions definitions = toDefinitions(diagram);
        final Path path = diagram.getMetadata().getPath();
        final BusinessProcessFormModel formModel = bpmnFormModelGenerator.generateProcessFormModel(definitions, path);
        createFormForModel(formModel, Paths.convert(path));
    } catch (Exception ex) {
        LOGGER.severe("Error generating process form");
        throw new RuntimeException(ex);
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) IOException(java.io.IOException)

Example 12 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImpl method generateAllForms.

@Override
public void generateAllForms(Diagram diagram) {
    try {
        LOGGER.finest("Generating all forms");
        final Path path = diagram.getMetadata().getPath();
        final org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
        ioService.startBatch(ioService.getFileSystem(nioPath.toUri()));
        final Definitions definitions = toDefinitions(diagram);
        final BusinessProcessFormModel processFormModel = bpmnFormModelGenerator.generateProcessFormModel(definitions, path);
        createFormForModel(processFormModel, nioPath);
        List<TaskFormModel> taskFormModels = bpmnFormModelGenerator.generateTaskFormModels(definitions, path);
        for (TaskFormModel taskFormModel : taskFormModels) {
            createFormForModel(taskFormModel, nioPath);
        }
    } catch (Exception ex) {
        LOGGER.severe("Error generating all diagram forms");
        throw new RuntimeException(ex);
    } finally {
        ioService.endBatch();
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) IOException(java.io.IOException)

Example 13 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImplTest method init.

@Before
public void init() throws Exception {
    SimpleFileSystemProvider simpleFileSystemProvider = new SimpleFileSystemProvider();
    simpleFileSystemProvider.forceAsDefault();
    Definitions processDefinitions = BPMN2Utils.getDefinitions(FormDefinitionGeneratorImplTest.class.getResourceAsStream(PROCESS_PATH));
    // Prepare BPMNFormModelGenerator
    when(kieModuleService.resolveModule(any())).thenReturn(module);
    when(module.getRootPath()).thenReturn(path);
    when(moduleClassLoaderHelper.getModuleClassLoader(module)).thenReturn(moduleClassLoader);
    when(moduleClassLoader.loadClass(anyString())).thenAnswer(invocation -> Object.class);
    BPMNFormModelGenerator bpmnFormModelGenerator = spy(new BPMNFormModelGeneratorImpl(kieModuleService, moduleClassLoaderHelper));
    FormModelHandlerManager formModelHandlerManager = new TestFormModelHandlerManager(kieModuleService, moduleClassLoaderHelper, new TestFieldManager());
    BPMNFormGeneratorService<Path> bpmnFormGeneratorService = new BPMNVFSFormDefinitionGeneratorService(new TestFieldManager(), formModelHandlerManager, formFinderService, formDefinitionSerializer, ioService, commentedOptionFactory, synchronizationUtil);
    generator = spy(new TestFormDefinitionGeneratorImpl(formGenerationModelProviders, ioService, bpmnFormModelGenerator, formDefinitionSerializer, bpmnFormGeneratorService, processDefinitions));
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getPath()).thenReturn(diagramPath);
    when(diagram.getGraph()).thenReturn(graph);
    when(diagramPath.toURI()).thenReturn("default:///src/main/resources" + PROCESS_PATH);
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) Path(org.uberfire.backend.vfs.Path) FormModelHandlerManager(org.kie.workbench.common.forms.editor.service.backend.FormModelHandlerManager) Definitions(org.eclipse.bpmn2.Definitions) BPMNFormModelGenerator(org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator) BPMNFormModelGeneratorImpl(org.kie.workbench.common.forms.jbpm.server.service.impl.BPMNFormModelGeneratorImpl) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) BPMNVFSFormDefinitionGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.authoring.BPMNVFSFormDefinitionGeneratorService) Before(org.junit.Before)

Example 14 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshaller method marshall.

@Override
@SuppressWarnings("unchecked")
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
    LOG.debug("Starting diagram marshalling...");
    Bpmn2Resource resource = createBpmn2Resource();
    // we start converting from the root, then pull out the result
    DefinitionsConverter definitionsConverter = new DefinitionsConverter(diagram.getGraph());
    Definitions definitions = definitionsConverter.toDefinitions();
    resource.getContents().add(definitions);
    LOG.debug("Diagram marshalling completed successfully.");
    String outputString = renderToString(resource);
    LOG.trace(outputString);
    return outputString;
}
Also used : Bpmn2Resource(org.eclipse.bpmn2.util.Bpmn2Resource) Definitions(org.eclipse.bpmn2.Definitions) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter)

Example 15 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.

the class BaseDiagramMarshaller method unmarshall.

@Override
public Graph unmarshall(final Metadata metadata, final InputStream inputStream) throws IOException {
    LOG.debug("Starting diagram unmarshalling...");
    // No rule checking for marshalling/unmarshalling, current jbpm designer marshallers should do it for us.
    final Bpmn2UnMarshaller parser = new Bpmn2UnMarshaller(bpmnGraphBuilderFactory, definitionManager, factoryManager, rulesManager, oryxManager, graphCommandManager, commandFactory, indexBuilder, getDiagramDefinitionSetClass(), getDiagramDefinitionClass());
    Graph result = null;
    try {
        // Unmarshall the diagram definition
        final Definitions definitions = parseDefinitions(inputStream);
        parser.setProfile(new DefaultProfileImpl());
        result = parser.unmarshall(definitions, getPreProcessingData(metadata));
        // Update diagram's settings.
        updateRootUUID(metadata, result);
    } catch (IOException e) {
        LOG.error("Error unmarshalling file.", e);
    }
    LOG.debug("Diagram unmarshalling finished successfully.");
    return result;
}
Also used : Bpmn2UnMarshaller(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.Bpmn2UnMarshaller) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Definitions(org.eclipse.bpmn2.Definitions) IOException(java.io.IOException) DefaultProfileImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.profile.impl.DefaultProfileImpl)

Aggregations

Definitions (org.eclipse.bpmn2.Definitions)25 Definitions (org.kie.dmn.model.v1_1.Definitions)22 Test (org.junit.Test)20 Process (org.eclipse.bpmn2.Process)13 IOException (java.io.IOException)9 InputStreamReader (java.io.InputStreamReader)9 DMNMarshaller (org.kie.dmn.api.marshalling.v1_1.DMNMarshaller)8 Graph (org.kie.workbench.common.stunner.core.graph.Graph)8 InputStream (java.io.InputStream)7 DMNModel (org.kie.dmn.api.core.DMNModel)7 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)7 Path (org.uberfire.backend.vfs.Path)7 List (java.util.List)6 RootElement (org.eclipse.bpmn2.RootElement)6 BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)6 HashMap (java.util.HashMap)5 Optional (java.util.Optional)5 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)5 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)5 Matchers.anyString (org.mockito.Matchers.anyString)5