[jbpm-commits] JBoss JBPM SVN: r6768 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/hibernate and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Oct 17 11:59:37 EDT 2010


Author: rebody
Date: 2010-10-17 11:59:37 -0400 (Sun, 17 Oct 2010)
New Revision: 6768

Modified:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
Log:
JBPM-2953 add endedAfter and endedBefore in HistoryTaskQuery

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java	2010-10-17 15:44:46 UTC (rev 6767)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java	2010-10-17 15:59:37 UTC (rev 6768)
@@ -28,7 +28,7 @@
 
 
 /** query for history tasks.
- * 
+ *
  * @author Tom Baeyens
  * @author Maciej Swiderski
  */
@@ -53,28 +53,28 @@
 
   /** only select the history task for the given id */
   HistoryTaskQuery taskId(String taskId);
-  
+
   /** only select history tasks within the given processInstanceId */
   HistoryTaskQuery processInstanceId(String processInstanceId);
-  
+
   /** only select history tasks within the given execution */
   HistoryTaskQuery executionId(String executionId);
-  
+
   /** only select history tasks for the given assignee */
   HistoryTaskQuery assignee(String assignee);
 
   /** only select history tasks in the given state */
   HistoryTaskQuery state(String state);
-  
+
   /** only select the history task for the given id, allows to specify query operand */
   HistoryTaskQuery taskId(QueryOperator operator, String... taskId);
-  
+
   /** only select history tasks within the given processInstanceId, allows to specify query operand */
   HistoryTaskQuery processInstanceId(QueryOperator operator, String... processInstanceId);
-  
+
   /** only select history tasks within the given execution, allows to specify query operand */
   HistoryTaskQuery executionId(QueryOperator operator, String... executionId);
-  
+
   /** only select history tasks for the given assignee, allows to specify query operand */
   HistoryTaskQuery assignee(QueryOperator operator, String... assignee);
 
@@ -83,7 +83,7 @@
 
   /** only select history tasks that have the given outcome */
   HistoryTaskQuery outcome(String outcome);
-  
+
   /** only select history tasks that have the given outcome, allows to specify query operand */
   HistoryTaskQuery outcome(QueryOperator operator, String... outcome);
 
@@ -102,6 +102,12 @@
   /** only select history tasks started before the given time */
   HistoryTaskQuery startedBefore(Date time);
 
+  /** only select history tasks ended after the given time. */
+  HistoryTaskQuery endedAfter(Date time);
+
+  /** only select history tasks ended before the given time. */
+  HistoryTaskQuery endedBefore(Date time);
+
   /** only select history tasks that took less then the given duration in milliseconds */
   HistoryTaskQuery tookLessThen(long durationInMillis);
 
@@ -110,10 +116,10 @@
 
   /** execute the query and obtain the list of {@link HistoryTask}s */
   List<HistoryTask> list();
-  
+
   /** execute the query and obtain the unique {@link HistoryTask} */
   HistoryTask uniqueResult();
-  
-  /** execute a count(*) query and returns number of results */ 
+
+  /** execute a count(*) query and returns number of results */
   long count();
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java	2010-10-17 15:44:46 UTC (rev 6767)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java	2010-10-17 15:59:37 UTC (rev 6768)
@@ -605,6 +605,30 @@
             queryProperty.removeCondition("startedAfter");
         }
 
+        if (queryProperty.hasCondition("endedBefore")) {
+            if (alreadyAddWhere) {
+                buff.append(" and ");
+            } else {
+                buff.append(" where ");
+                alreadyAddWhere = true;
+            }
+            buff.append("ht.endTime<:endedBefore");
+            params.put("endedBefore", queryProperty.getCondition("endedBefore").getValue());
+            queryProperty.removeCondition("endedBefore");
+        }
+
+        if (queryProperty.hasCondition("endedAfter")) {
+            if (alreadyAddWhere) {
+                buff.append(" and ");
+            } else {
+                buff.append(" where ");
+                alreadyAddWhere = true;
+            }
+            buff.append("ht.endTime>:endedAfter");
+            params.put("endedAfter", queryProperty.getCondition("endedAfter").getValue());
+            queryProperty.removeCondition("endedAfter");
+        }
+
         this.appendWhereClause(buff, queryProperty, params, alreadyAddWhere);
 
         // order by

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java	2010-10-17 15:44:46 UTC (rev 6767)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java	2010-10-17 15:59:37 UTC (rev 6768)
@@ -50,6 +50,8 @@
  *     tookLongerThen
  *     startedBefore
  *     startedAfter
+ *     endedBefore
+ *     endedAfter
  *   order by
  *
  * @author Tom Baeyens
@@ -70,6 +72,8 @@
   protected Long tookLongerThen;
   protected Date startedBefore;
   protected Date startedAfter;
+  protected Date endedBefore;
+  protected Date endedAfter;
 
   protected Map<String, String> orders = new LinkedHashMap<String, String>();
 
@@ -138,6 +142,16 @@
     return this;
   }
 
+  public HistoryTaskQuery endedAfter(Date time) {
+    this.endedAfter = time;
+    return this;
+  }
+
+  public HistoryTaskQuery endedBefore(Date time) {
+    this.endedBefore = time;
+    return this;
+  }
+
   public HistoryTaskQuery tookLessThen(long durationInMillis) {
     this.tookLessThen = durationInMillis;
     return this;
@@ -258,6 +272,14 @@
       queryProperty.addCondition("startedAfter", startedAfter, QueryOperator.GREATER_THAN);
     }
 
+    if (endedBefore != null) {
+      queryProperty.addCondition("endedBefore", endedBefore, QueryOperator.LESS_THAN);
+    }
+
+    if (endedAfter != null) {
+      queryProperty.addCondition("endedAfter", endedAfter, QueryOperator.GREATER_THAN);
+    }
+
     // orders
     for (Map.Entry<String, String> entry : orders.entrySet()) {
       queryProperty.addOrder(entry.getKey(), entry.getValue());



More information about the jbpm-commits mailing list