hi, i am trying to show the graph of the current task in the process instance that i pass by the taskInstanceId parameter. today i can see the general graph of the process , not of the instance of the process . the error in on : gpdBytes = fileDefinition.getBytes("gpd.xml");
because the fileDefinition comes out null. should i insert a file definition to the processdefinition.xml ? and if so - how ? | final long serialVersionUID = 1L; | long taskInstanceId = -1; | long tokenInstanceId = -1; | | byte[] gpdBytes = null; | byte[] imageBytes = null; | Token currentToken = null; | ProcessDefinition processDefinition = null; | | String currentTokenColor = "red"; | String childTokenColor = "blue"; | String tokenNameColor = "blue"; | | ProcessImageJbpm PIJ = new ProcessImageJbpm(); | | String tempInsId = DBDate.nullstring(request | .getParameter("TaskInstanceId")); | | if (tempInsId.equals("")) | tempInsId = "0"; | | long TaskInstanceId = Long.parseLong(tempInsId); | | try { | | JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance(); | JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext(); | | TaskInstance taskInstance = jbpmContext.getTaskMgmtSession().loadTaskInstance(TaskInstanceId); | | currentToken = taskInstance.getToken(); | | processDefinition = currentToken.getProcessInstance().getProcessDefinition(); | | PIJ.setCurrentToken(currentToken); | | | FileDefinition fileDefinition = processDefinition.getFileDefinition(); | if(fileDefinition!=null) | { | gpdBytes = fileDefinition.getBytes("gpd.xml"); | imageBytes = fileDefinition.getBytes("processimage.jpg"); | | if (gpdBytes != null && imageBytes != null) { | int borderWidth = 4; | Element rootDiagramElement = DocumentHelper.parseText( | new String(gpdBytes)).getRootElement(); | int[] boxConstraint; | int[] imageDimension = PIJ | .extractImageDimension(rootDiagramElement); | String imageLink = "processimage?definitionId=" | + processDefinition.getId(); | | if (tokenInstanceId > 0) { | | List allTokens = new ArrayList(); | allTokens = PIJ.walkTokens(currentToken, allTokens); | | out.println("<div style='position:relative; background-image:url(" | + imageLink | + "); width: " | + imageDimension[0] | + "px; height: " | + imageDimension[1] + "px;'>"); | | for (int i = 0; i < allTokens.size(); i++) { | Token token = (Token) allTokens.get(i); | | //check how many tokens are on teh same level (= having the same parent) | int offset = i; | if (i > 0) { | while (offset > 0&& ((Token) allTokens.get(offset - 1)).getParent().equals(token.getParent())) { | offset--; | } | } | boxConstraint = PIJ.extractBoxConstraint(rootDiagramElement, token); | | //Adjust for borders | boxConstraint[2] -= borderWidth * 2; | boxConstraint[3] -= borderWidth * 2; | | out.println("<div style='position:absolute; left: " | + boxConstraint[0] + "px; top: " | + boxConstraint[1] + "px; "); | | if (i == (allTokens.size() - 1)) { | out.println("border: " + currentTokenColor); | } else { | out.println("border: " + childTokenColor); | } | | out.println(" " + borderWidth + "px groove; " | + "width: " + boxConstraint[2] | + "px; height: " + boxConstraint[3] | + "px;'>"); | | if (token.getName() != null) { | out.println("<span style='color:" | + tokenNameColor | + ";font-style:italic;position:absolute;left:" | + (boxConstraint[2] + 10) | + "px;top:" | + ((i - offset) * 20) | + ";'> " + token.getName() | + "</span>"); | } | | out.println("</div>"); | } | out.println("</div>"); | } else { | boxConstraint = PIJ.extractBoxConstraint(rootDiagramElement); | | out.println("<table border=0 cellspacing=0 cellpadding=0 width=" | + imageDimension[0] | + " height=" | + imageDimension[1] + ">"); | out.println(" <tr>"); | out.println(" <td width=" + imageDimension[0] | + " height=" + imageDimension[1] | + " style=\"background-image:url(" + imageLink | + ")\" valign=top>"); | out.println(" <table border=0 cellspacing=0 cellpadding=0>"); | out.println(" <tr>"); | out.println(" <td width=" | + (boxConstraint[0] - borderWidth) | + " height=" | + (boxConstraint[1] - borderWidth) | + " style=\"background-color:transparent;\"></td>"); | out.println(" </tr>"); | out.println(" <tr>"); | out.println(" <td style=\"background-color:transparent;\"></td>"); | out.println(" <td style=\"border-color:" | + currentTokenColor | + "; border-width:" | + borderWidth | + "px; border-style:groove; background-color:transparent;\" width=" | + boxConstraint[2] | + " height=" | + (boxConstraint[3] + (2 * borderWidth)) | + "> </td>"); | out.println(" </tr>"); | out.println(" </table>"); | out.println(" </td>"); | out.println(" </tr>"); | out.println("</table>"); | } | out.flush(); | } | } | } | catch (IOException e) { | e.printStackTrace(); | //throw new JspException("table couldn't be displayed", e); | } | catch (DocumentException e) | { | e.printStackTrace(); | } | //throw new JspException("table couldn't be displayed", e); | catch (Exception e) { | e.printStackTrace(); | } | | taskInstanceId = -1; | gpdBytes = null; | imageBytes = null; | currentToken = null; | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067455#4067455 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067455 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user