1 2 Previous Next 20 Replies Latest reply on Mar 13, 2014 2:28 PM by guyr Go to original post
      • 15. Re: Swing application for jBPM 6
        pmehra1

        Hi Tan and Mauricio


        i was able to use the rest urls to control processes and tasks. I used the apache http client to make the calls. I can post the code here later in the day.

        But I had a few issues using the remoterestruntimefactory when I tried with that. So I moved ahead with the pure rest calls and that worked for me

        • 16. Re: Swing application for jBPM 6
          salaboy21

          Hi Prateek,

          that's good to know.. we need to make sure that both approaches works well. It will be nice if you can write a wiki page here.. or a blog post talking about what you achieve and how. If you put your code in github its better.

           

          Regards

          • 17. Re: Swing application for jBPM 6
            tanvu

            Hi Mauricio,

             

            In previous post you said "

            That's exactly what Maciej second option was proposing.

            • integrate directly on data base level - embed jbpm into swing application and congiure it to the same data base as the web tooling

            Where the file that you mention is the persistence.xml which says where the database is"

             

            I cannot find any documentation for this.  Where can I obtain this "persistence.xml" file?  also, where should I put it in my project?  Any sample codes to let my application to read this file and connect to the database used for "demo" project?

             

            Thank you,

             

            Tan

            • 18. Re: Re: Swing application for jBPM 6
              guyr

              Mauricio, thank you for the time and effort you contribute to answering questions in this forum.  I'm trying to do something similar to what Tan is doing, though with simple Java code.  I installed the KIE Workbench and the demo app into JBoss 7.1.1.  I'm using the Java APIs with RemoteRestRuntimeFactory, and I too am getting "java.lang.UnsupportedOperationException: getProcess/getProcessName is not supported on the JAXB ProcessInstance implementation."  I'll post my code below, which I took from the documentation section 17.1.1 The REST Remote Java RuntimeEngine Factory.  In our work environment (which I imagine is pretty typical), an individual will commonly work tasks from different workflows.  So, our app will list workflow and task.  RemoteRestRuntimeFactory wants to work with one process at a time, which won't be very helpful, but I'll deal with that issue later.

               

              [EDIT]: After posting this message, I discovered two things:

               

              1. Even though you must provide a specific deploymentId to RemoteRestRuntimeFactory, that does not limit your task queries to that one deployment.  That is very counter-intuitive, but in my case welcome, since I want to find all tasks in all workflows.
              2. TaskSummary.getProcessId() returns the process name (hiring or evaluation for the demo app.) That also is counter-intuitive, leaving me to wonder what value getProcessName() returns.  Again, this is lucky for me, since getProcessName() throws UnsupportedOperationException but getProcessId() returns the value I need anyway.

               

              Here is the code that produces the UnsupportedOperationException:

               

              public class WorkbenchTest

                 {

                 static private final String deploymentId = "org.jbpm:Evaluation:1.0"; // "org.jbpm:HR:1.0";

                 static private final URL    baseUrl      = initBaseUrl();

                 static private final String user         = "salaboy";

                 static private final String password     = "salaboy";

               

                 private static URL initBaseUrl()

                    {

                    URL url = null;

               

                    try

                       {

                       url = new URL("http://localhost:8080/jbpm-console/");

                       }

                    catch (MalformedURLException e)

                       {

                       // TODO Auto-generated catch block

                       e.printStackTrace();

                       }

               

                    return(url);

                    }

               

                 public static void main(String[] args)

                    {

                    // Setup the factory class with the necessarry information to communicate

                    // with the REST services

               

                    RemoteRestRuntimeFactory restSessionFactory = new RemoteRestRuntimeFactory(deploymentId, baseUrl, user, password);

               

                    // Create KieSession and TaskService instances and use them

               

                    RuntimeEngine engine = restSessionFactory.newRuntimeEngine();

               

                    KieSession ksession = engine.getKieSession();

               

                    String taskUserId = "mary";

               

                    TaskService taskService = engine.getTaskService();

               

                    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(taskUserId, "en-UK");

               

                    if ((null != tasks) && (tasks.size() > 0))

                       {

                       for (TaskSummary task: tasks)

                          {

                          ProcessInstance instance = ksession.getProcessInstance(task.getProcessInstanceId());

                          Process process = instance.getProcess(); // exception here

                          String processName = process.getName();

                          System.out.println("Task " + task.getId() + " name: " + task.getName() + " description: "

                                             + task.getDescription() + " Process name: " + processName);

                          }

                       }

                    else

                       {

                       System.out.println("No tasks found for " + taskUserId);

                       }

              }

              • 19. Re: Re: Swing application for jBPM 6
                salaboy21

                Hi Guy,

                Notice this line: RuntimeEngine engine = restSessionFactory.newRuntimeEngine();

                If you do this:

                RemoteRuntimeEngine engine = restSessionFactory.newRuntimeEngine();

                You will have access to the audit logs also, which might help you to get the information that you need.

                The ProcessInstance and KIESessions are very complicated objects that contains several nested other complicated objects, which makes impractical to send all of that over the wire. For that reason we have chosen to return the minimum possible, and rely on the audit logs for all the rest of the information.

                Take a look at the audit service provided by the RemoteRuntimeEngine and if you still need more information let us know we are working to provide a full service for accessing the data associated to the tasks and processes.

                 

                Regards

                • 20. Re: Re: Swing application for jBPM 6
                  guyr

                  Mauricio, thank you.  The following works to get the process name:

                   

                  RemoteRuntimeEngine engine = restRuntimeFactory.newRuntimeEngine();

                  AuditLogService auditLogService = engine.getAuditLogService();

                  ProcessInstanceLog processInstanceLog = auditLogService.findProcessInstance(task.getProcessInstanceId());

                   

                  System.out.println("ProcessInstanceLog processName: " + processInstanceLog.getProcessName());

                   

                  Where is the AuditLogService documented?  I could not find it in either the primary JBPM Javadocs KIE API 6.0.1.Final API or the kie-services-client Javadocs.  I found the class in jbpm-audit-6.0.1.jar.

                  1 2 Previous Next