Search in sources :

Example 16 with Definitions

use of org.eclipse.bpmn2.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 17 with Definitions

use of org.eclipse.bpmn2.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 18 with Definitions

use of org.eclipse.bpmn2.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 19 with Definitions

use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshaller method parseDefinitions.

private static Definitions parseDefinitions(final InputStream inputStream) throws IOException {
    DroolsPackageImpl.init();
    BpsimPackageImpl.init();
    final ResourceSet resourceSet = new ResourceSetImpl();
    Resource.Factory.Registry resourceFactoryRegistry = resourceSet.getResourceFactoryRegistry();
    resourceFactoryRegistry.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new JBPMBpmn2ResourceFactoryImpl());
    EPackage.Registry packageRegistry = resourceSet.getPackageRegistry();
    packageRegistry.put("http://www.omg.org/spec/BPMN/20100524/MODEL", Bpmn2Package.eINSTANCE);
    packageRegistry.put("http://www.jboss.org/drools", DroolsPackage.eINSTANCE);
    final JBPMBpmn2ResourceImpl resource = (JBPMBpmn2ResourceImpl) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
    resource.getDefaultLoadOptions().put(JBPMBpmn2ResourceImpl.OPTION_ENCODING, "UTF-8");
    resource.setEncoding("UTF-8");
    final Map<String, Object> options = new HashMap<String, Object>();
    options.put(JBPMBpmn2ResourceImpl.OPTION_ENCODING, "UTF-8");
    options.put(JBPMBpmn2ResourceImpl.OPTION_DEFER_IDREF_RESOLUTION, true);
    options.put(JBPMBpmn2ResourceImpl.OPTION_DISABLE_NOTIFY, true);
    options.put(JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF, JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF_RECORD);
    resource.load(inputStream, options);
    final DocumentRoot root = (DocumentRoot) resource.getContents().get(0);
    return root.getDefinitions();
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) JBPMBpmn2ResourceImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceImpl) HashMap(java.util.HashMap) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) LoggerFactory(org.slf4j.LoggerFactory) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory) GraphCommandFactory(org.kie.workbench.common.stunner.core.graph.command.impl.GraphCommandFactory) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) JBPMBpmn2ResourceFactoryImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceFactoryImpl) EPackage(org.eclipse.emf.ecore.EPackage)

Example 20 with Definitions

use of org.eclipse.bpmn2.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

Process (org.eclipse.bpmn2.Process)40 RootElement (org.eclipse.bpmn2.RootElement)35 ArrayList (java.util.ArrayList)27 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)26 SubProcess (org.eclipse.bpmn2.SubProcess)26 Definitions (org.eclipse.bpmn2.Definitions)25 Definitions (org.kie.dmn.model.v1_1.Definitions)22 List (java.util.List)21 Test (org.junit.Test)20 FlowElement (org.eclipse.bpmn2.FlowElement)18 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)16 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)15 Entry (java.util.Map.Entry)14 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)13 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)13 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)13 EventDefinition (org.eclipse.bpmn2.EventDefinition)13 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)13 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)13 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)12