3 Replies Latest reply on Oct 15, 2014 3:12 PM by Darren Osten

    How to view the current position of the JBPM6 flow chart, with relevant examples of it

    hn qbl Newbie

      How to view the current position of the JBPM6 flow chart, with relevant examples of it,

      Implementation as shown below

      123.png

       

      thank you very much

        • 1. Re: How to view the current position of the JBPM6 flow chart, with relevant examples of it
          Darren Osten Newbie

          Seems like you already got this working by looking at the your screenshot.

          I had to this in jBPM 5 but I am not sure if those same techniques work in 6.

          • 2. Re: How to view the current position of the JBPM6 flow chart, with relevant examples of it
            hn qbl Newbie

            Hello, you can get JBPM5 flow chart shows code to share, I this is a screenshot is seen in other posts, but no source code, you can get the flow chart of JBPM5 display code sharing it, learn about it, thank you

            • 3. Re: How to view the current position of the JBPM6 flow chart, with relevant examples of it
              Darren Osten Newbie

              Here are two snippets that might help you out.  The first is a method that gets the instance image from guvnor (note that these URL's do not seem to work with jBPM 6).

              The second is a snippet is code from a jBPM event listener that puts the x and y coordinates from the event metadata.  These are then used to overlay an arrow icon on the instance image.  I believe I learned of this method by looking at the jBPM source since it does a similar thing in the console.

               

                 /**

                  * Get process image and write to image directory.

                  *

                  * @param pid Process ID

                  * @throws IOException if error occurs

                  */

                 public static void getProcessImage(String pid) throws IOException

                 {

                    HttpClient client = new HttpClient();

               

                    String imageUrl = System.getProperty("guvnor.protocol", "http") + "://" + System.getProperty("guvnor.host") + "/business-central-server/rs/process/definition/" + pid + "/image";

                    log.trace("imageUrl={}", imageUrl);

                    GetMethod get = new GetMethod(imageUrl);

                    client.executeMethod(get);

                    get.releaseConnection();

                    Cookie[] initcookies = client.getState().getCookies();

                    log.trace("Init cookies={}", initcookies);

               

                    String loginUrl = System.getProperty("guvnor.protocol", "http") + "://" + System.getProperty("guvnor.host") + "/business-central-server/j_security_check";

                    PostMethod authpost = new PostMethod(loginUrl);

                    NameValuePair userNVP = new NameValuePair("j_username", System.getProperty("guvnor.usr"));

                    NameValuePair pwdNVP = new NameValuePair("j_password", System.getProperty("guvnor.pwd"));

                    authpost.setRequestBody(new NameValuePair[] { userNVP, pwdNVP });

                    client.executeMethod(authpost);

                    log.trace("Login form post: {}", authpost.getStatusLine().toString());

                    authpost.releaseConnection();

               

                    Cookie[] logoncookies = client.getState().getCookies();

                    log.trace("Logon cookies={}", logoncookies);

               

                    log.debug("getting image from {}", get.getURI());

                    int status = client.executeMethod(get);

                    log.trace("status={}", status);

                    // log.debug("mime type=" + get.get)

                    log.debug("response content length={}", get.getResponseContentLength());

                    InputStream is = get.getResponseBodyAsStream();

                    File imageFile = getInstanceImageFile(pid);

                    log.debug("writing image file to {}", imageFile);

                    FileOutputStream fos = new FileOutputStream(imageFile);

                    IOUtils.copy(is, fos);

                    fos.close();

                    is.close();

                 }

                

               

                

                     // snippet to get x and y coordinates for image overlay

                   Integer xMetadata = null;

                   Integer yMetadata = null;

                   if (node.getMetaData().containsKey("x")) {

                      xMetadata = (Integer) node.getMetaData().get("x");

                   }

                   if (node.getMetaData().containsKey("y")) {

                      yMetadata = (Integer) node.getMetaData().get("y");

                   }

                   if (xMetadata != null && yMetadata != null && instanceId != null) {

                      try {

                         // overlay the arrow on the instance image

                      }

                      catch (Exception e) {

                         log.warn(e.getLocalizedMessage());

                      }

                   }