Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
reiner_hille-doering
Active Contributor
0 Kudos

In my technical article about the BPMN 2.0 Metamodel Implementation for Eclipse there was a little mistake in the sample code (section "Code on it" on page 11).

Reason is that we planned to rename everything containing "Bpmn2" in the name to "Bpmn". As this didn't happen, the source code looks a little different. Here is the correct version, also containing the required import statements:

 

package org.eclipse.bpmn.sample;

import java.io.IOException;

import org.eclipse.bpmn2.Bpmn2Factory;
import org.eclipse.bpmn2.Definitions;
import org.eclipse.bpmn2.Process;
import org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

public class Sample1 {

    public static void main(String[] args) throws IOException {
        Bpmn2Factory factory = Bpmn2Factory.eINSTANCE;

        Definitions definitions = new Bpmn2ResourceFactoryImpl().createAndInitResource(URI.createFileURI("c:/temp/sample.bpmn2"));
        Process simpleProcess = factory.createProcess();
        definitions.getRootElements().add(simpleProcess);
        simpleProcess.getFlowElements().add(factory.createStartEvent());
        simpleProcess.getFlowElements().add(factory.createEndEvent());

        ResourceSet resourceSet = new ResourceSetImpl();
        Resource resource = definitions.eResource();
        resourceSet.getResources().add(resource);
        resource.save(null);
    }
}
 

4 Comments