[jbpm-commits] JBoss JBPM SVN: r3686 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/command.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jan 20 10:47:37 EST 2009


Author: camunda
Date: 2009-01-20 10:47:36 -0500 (Tue, 20 Jan 2009)
New Revision: 3686

Added:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTokenCommand.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTokenLogCommand.java
Modified:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceLogCommand.java
Log:
added GetToken and GetTokenLog command. Fixed typo in GetProcesssInstanceLogCommand

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceLogCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceLogCommand.java	2009-01-20 12:47:48 UTC (rev 3685)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceLogCommand.java	2009-01-20 15:47:36 UTC (rev 3686)
@@ -9,7 +9,7 @@
 import org.jbpm.logging.log.ProcessLog;
 
 /**
- * Retrieve the <code>org.jbpm.logging.log.ProcessLog</code> for
+ * Retrieve the {@link ProcessLog} for
  * the process with the given process-id
  * 
  * returns a map that maps {@link Token}s to {@link List}s.
@@ -36,7 +36,7 @@
   public Object execute(JbpmContext jbpmContext) throws Exception
   {
     Map logMap = jbpmContext.getLoggingSession().findLogsByProcessInstance(processInstanceId);
-    return loadLogdFromMap(logMap);
+    return loadLogFromMap(logMap);
   }
 
   /**
@@ -45,7 +45,7 @@
    * 
    * overwrite this method, if you need more details in your client
    */
-  protected Map loadLogdFromMap(Map logMap)
+  protected Map loadLogFromMap(Map logMap)
   {
     Iterator iter = logMap.keySet().iterator();
     while (iter.hasNext())
@@ -56,15 +56,19 @@
       Iterator iter2 = logs.iterator();
       while (iter2.hasNext())
       {
-        ProcessLog pl = (ProcessLog)iter2.next();
-        // TODO: I am not sure if we need that, write a test for it
-        pl.getActorId();
-        pl.toString();
+        ProcessLog pl = (ProcessLog)iter2.next();        
+        retrieveProcessLog(pl);
       }
     }
     return logMap;
   }
 
+  public void retrieveProcessLog(ProcessLog pl)
+  {
+    pl.toString(); // to string accesses important fields
+    pl.getToken().getId();
+  }
+
   /**
    * @deprecated use getProcessInstanceId instead
    */

Added: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTokenCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTokenCommand.java	                        (rev 0)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTokenCommand.java	2009-01-20 15:47:36 UTC (rev 3686)
@@ -0,0 +1,53 @@
+package org.jbpm.command;
+
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.exe.Token;
+
+/**
+ * Return the token with the specified tokenId
+ * 
+ * @author Bernd Ruecker (bernd.ruecker at camunda.com)
+ */
+public class GetTokenCommand extends AbstractGetObjectBaseCommand
+{
+
+  private static final long serialVersionUID = 1L;
+
+  private long tokenId;
+
+  public GetTokenCommand()
+  {
+  }
+
+  public Object execute(JbpmContext jbpmContext) throws Exception
+  {
+    setJbpmContext(jbpmContext);
+    Token token = jbpmContext.getToken(tokenId);
+    retrieveToken(token);
+    return token;
+  }
+
+  public long getTokenId()
+  {
+    return tokenId;
+  }
+
+  public void setTokenId(long tokenId)
+  {
+    this.tokenId = tokenId;
+  }
+
+  @Override
+  public String getAdditionalToStringInformation()
+  {
+    return "tokenId=" + tokenId;
+  }
+
+  // methods for fluent programming
+
+  public GetTokenCommand tokenId(long tokenId)
+  {
+    setTokenId(tokenId);
+    return this;
+  }
+}

Added: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTokenLogCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTokenLogCommand.java	                        (rev 0)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTokenLogCommand.java	2009-01-20 15:47:36 UTC (rev 3686)
@@ -0,0 +1,86 @@
+package org.jbpm.command;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.jbpm.JbpmContext;
+import org.jbpm.logging.log.ProcessLog;
+
+/**
+ * Retrieve the {@link ProcessLog} for the token with the given tokenId
+ * 
+ * returns a {@link List} with {@link ProcessLog}s.
+ * 
+ * @author Bernd Ruecker (bernd.ruecker at camunda.com)
+ */
+public class GetTokenLogCommand extends AbstractBaseCommand
+{
+
+  private static final long serialVersionUID = 1L;
+
+  private long tokenId;
+
+  public GetTokenLogCommand()
+  {
+  }
+
+  public GetTokenLogCommand(long tokenId)
+  {
+    this.tokenId = tokenId;
+  }
+
+  public Object execute(JbpmContext jbpmContext) throws Exception
+  {
+    List logList = jbpmContext.getLoggingSession().findLogsByToken(tokenId);
+    return loadLogFromList(logList);
+  }
+
+  /**
+   * access everything on all ProcessLog objects, which is not in 
+   * the default fetch group from hibernate, but needs to
+   * be accessible from the client
+   * 
+   * overwrite this method, if you need more details in your client
+   */
+  protected List loadLogFromList(List logList)
+  {
+    Iterator iter = logList.iterator();
+    while (iter.hasNext())
+    {
+        ProcessLog pl = (ProcessLog)iter.next();        
+        retrieveProcessLog(pl);
+    }
+    return logList;
+  }
+
+  public void retrieveProcessLog(ProcessLog pl)
+  {
+    pl.toString(); // to string accesses important fields
+    pl.getToken().getId();
+  }
+
+ 
+  public long getTokenId()
+  {
+    return tokenId;
+  }
+
+  public void setTokenId(long tokenId)
+  {
+    this.tokenId = tokenId;
+  }
+
+  @Override
+  public String getAdditionalToStringInformation()
+  {
+    return "tokenId=" + tokenId;
+  }
+  
+  // methods for fluent programming
+  
+  public GetTokenLogCommand tokenId(long tokenId)
+  {
+    setTokenId(tokenId);
+    return this;
+  }
+}




More information about the jbpm-commits mailing list