2 Replies Latest reply on Dec 20, 2011 9:46 PM by tsurdilovic

    Extract bpm2 xml flow from guvnor package

    xantrax

      Hi everybody,

       

      I'm using jbpm 5.1.0.final.

       

      I wonder if it's possible to extract with the java api the bpmn2 xml process from a  guvnor package?

        • 1. Re: Extract bpm2 xml flow from guvnor package
          xantrax

          for those interested

           

          Properties properties = new Properties();

          PackageBuilderConfiguration cfg = new PackageBuilderConfiguration(properties);

          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(cfg);

          kbuilder.add(ResourceFactory.newFileResource("PATH_OF_YOUR_PKG"), ResourceType.PKG);

          Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();

              

          for(KnowledgePackage pkg : pkgs){

               for(org.drools.definition.process.Process proc:pkg.getProcesses()){

                              InputStream in = ((org.jbpm.process.core.Process) proc).getResource().getInputStream());

                              // Now you can serialize to a Dom element for example

                    }

          }

          • 2. Re: Extract bpm2 xml flow from guvnor package
            tsurdilovic

            Xantrax, there is a lot easier way to do this using the Guvnor REST Api. If you for example have a process in Guvnor's myPackage called myProcess

            just get:

            http://localhost:8080/drools-guvnor/rest/packages/myPackage/assets/myProcess/source

             

            Just use for example java.net to get the stream from this connection.

            Your approach is fine, but it requires the package the be re-built after each change to your process (to rebuild the pkg file).

             

            Hope this helps.