incubator-hise-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wi...@apache.org
Subject svn commit: r998177 - in /incubator/hise/trunk: hise-services/src/main/java/org/apache/hise/api/ hise-services/src/main/java/org/apache/hise/dao/ hise-services/src/main/java/org/apache/hise/engine/jaxws/ rtests/src/test/java/org/apache/hise/managementApi/
Date Fri, 17 Sep 2010 15:35:14 GMT
Author: witek
Date: Fri Sep 17 15:35:14 2010
New Revision: 998177

URL: http://svn.apache.org/viewvc?rev=998177&view=rev
Log:
paging fix

Modified:
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/api/Management.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/HISEDao.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/TaskQuery.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsBaseImpl.java
    incubator/hise/trunk/rtests/src/test/java/org/apache/hise/managementApi/PagingTest.java

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/api/Management.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/api/Management.java?rev=998177&r1=998176&r2=998177&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/api/Management.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/api/Management.java Fri
Sep 17 15:35:14 2010
@@ -62,15 +62,13 @@ import org.apache.hise.lang.xsd.htdt.TTi
 
 public interface Management {
 
-	public String getText();
-	
+	 public String getText();
 	
 	 public GetMyTasksResponseDocument getMyTasks(String userName, String taskType, String genericHumanRole,
String workQueue, List<TStatus.Enum> status, String whereClause, String createdOnClause,
 	            Integer maxTasks, Integer fromTaskNumber) throws IllegalArgumentFault, IllegalStateFault;
 	 
-	 public GetMyTaskAbstractsResponseDocument getMyTaskAbstracts(String userName, String taskType,
String genericHumanRole, String workQueue, List<TStatus.Enum> status, String whereClause,
-                String createdOnClause, Integer maxTasks, Integer fromTaskNumber) throws
IllegalArgumentFault, IllegalStateFault;
-	 
+	 public GetMyTaskAbstractsResponseDocument getMyTaskAbstracts(String userName, String taskType,
String genericHumanRole, String workQueue, List<TStatus.Enum> status, 
+			 String whereClause, String createdOnClause, Integer maxTasks, Integer fromTaskNumber)
throws IllegalArgumentFault, IllegalStateFault;
 	 
 	 public HISEDao getHiseDao();
 	 

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/HISEDao.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/HISEDao.java?rev=998177&r1=998176&r2=998177&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/HISEDao.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/HISEDao.java Fri
Sep 17 15:35:14 2010
@@ -68,37 +68,40 @@ public class HISEDao extends JpaDaoSuppo
     
     /**
      * Returns tasks presented to user based on TaskQuery criteria.
-     * @param query
+     * @param taskQuery
      * @return
      */
     @SuppressWarnings("unchecked")
-	public List<Task> getUserTasks(final TaskQuery query) {
-        
-        Validate.notNull(query);
-        
-            return (List<Task>) getJpaTemplate().executeFind(new JpaCallback() {
-                public Object doInJpa(EntityManager em) throws PersistenceException {
-                    
-                    Validate.notNull(em);
-   
-                    
-                    List<Task> tasks = buildSQLQueryForTaskQuery( query, em).setMaxResults(query.getMaxTasks()).getResultList();
-                    if(query.getWorkQueue() != null && !query.getWorkQueue().equals("")){
-                    	tasks = taskFilterByQuery(tasks, query);
-                    }
-                    return tasks;
-                }
+	public List<Task> getUserTasks(final TaskQuery taskQuery) {
 
+		Validate.notNull(taskQuery);
 
-            });
+		return (List<Task>) getJpaTemplate().executeFind(new JpaCallback() {
+			public Object doInJpa(EntityManager em) throws PersistenceException {
+
+				Validate.notNull(em);
+
+				Query query = buildSQLQueryForTaskQuery(taskQuery, em);
+				if (taskQuery.getMaxTasks() != null) {
+					query.setMaxResults(taskQuery.getMaxTasks());
+				}
+
+				List<Task> tasks = query.getResultList();
+
+				if (taskQuery.getWorkQueue() != null && !taskQuery.getWorkQueue().equals(""))
{
+					tasks = taskFilterByQuery(tasks, taskQuery);
+				}
+				return tasks;
+			}
+
+		});
+
+	}
 
-    }
 	public static  Query buildSQLQueryForTaskQuery(TaskQuery query, EntityManager em) {
-//		int tan[] = new int[5];
 		Vector<Object> q= new Vector<Object>();
-		q.add("select distinct t from Task t, TaskOrgEntity e where ");//t.actualOwner = :user");
-		//q.add(new JQBParam("user", query.getUser()));
-		if(addStatuses(q, query))
+		q.add("select distinct t from Task t, TaskOrgEntity e where ");
+		if(addStatuses(q, query)) 
 			q.add(" and ");
 		if(addOrgEntity(q, query))
 			q.add(" and ");

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/TaskQuery.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/TaskQuery.java?rev=998177&r1=998176&r2=998177&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/TaskQuery.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/TaskQuery.java Fri
Sep 17 15:35:14 2010
@@ -41,7 +41,9 @@ public class TaskQuery {
     private List<TStatus.Enum> statuses = Collections.EMPTY_LIST;
     private String whereClause = "";
     private String createdOnClause = "";
-    private Integer maxTasks = 20;
+    
+    //no limit on number of returned tasks 
+    private Integer maxTasks = null;
 
     public String getUser() {
         return user;
@@ -112,7 +114,6 @@ public class TaskQuery {
     }
 
     public void setMaxTasks(Integer maxTasks) {
-        Validate.notNull(maxTasks, "Maximum tasks number cannot be set to null.");
         this.maxTasks = maxTasks;
     }
 }

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsBaseImpl.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsBaseImpl.java?rev=998177&r1=998176&r2=998177&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsBaseImpl.java
(original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsBaseImpl.java
Fri Sep 17 15:35:14 2010
@@ -238,10 +238,9 @@ public abstract class TaskOperationsBase
         query.setUser(user);
         query.setUserGroups(hiseEngine.getHiseUserDetails().getUserGroups(user));
         query.setTaskType(taskType);
-        if(genericHumanRole==null) {
+        if(genericHumanRole == null) {
             query.setGenericHumanRole(null);
-        }
-        else {
+        } else {
             query.setGenericHumanRole(GenericHumanRole.valueOf(genericHumanRole));
         }
         query.setWorkQueue(workQueue);
@@ -1263,7 +1262,6 @@ public abstract class TaskOperationsBase
 
     public GetMyTaskAbstractsResponseDocument getMyTaskAbstracts(GetMyTaskAbstractsDocument
getMyTaskAbstracts) throws IllegalArgumentFault, IllegalStateFault {
 
-
         String taskType = getMyTaskAbstracts.getGetMyTaskAbstracts().getTaskType();
         String genericHumanRole = getMyTaskAbstracts.getGetMyTaskAbstracts().getGenericHumanRole();
         String workQueue = getMyTaskAbstracts.getGetMyTaskAbstracts().getWorkQueue();
@@ -1274,16 +1272,16 @@ public abstract class TaskOperationsBase
         Integer fromTaskNumber = getMyTaskAbstracts.getGetMyTaskAbstracts().getFromTaskNumber();
         
         if(!getMyTaskAbstracts.getGetMyTaskAbstracts().isSetMaxTasks()){
-       	 maxTasks = null;
+       	    maxTasks = null;
         }
         
-        return getMyTaskAbstracts(taskType, genericHumanRole, workQueue, status, whereClause,
createdOnClause,maxTasks, fromTaskNumber); 
+        return getMyTaskAbstracts(taskType, genericHumanRole, workQueue, status, whereClause,
createdOnClause, maxTasks, fromTaskNumber); 
     }
         
     public GetMyTaskAbstractsResponseDocument getMyTaskAbstracts(String taskType, String
genericHumanRole, String workQueue, List<TStatus.Enum> status, String whereClause,
                 String createdOnClause, Integer maxTasks, Integer fromTaskNumber) throws
IllegalArgumentFault, IllegalStateFault {
     	
-        List<TTaskAbstract> result = new ArrayList<TTaskAbstract>();
+        final List<TTaskAbstract> result = new ArrayList<TTaskAbstract>();
 
         String user = getUserString();
 
@@ -1296,18 +1294,17 @@ public abstract class TaskOperationsBase
         query.setStatuses(status);
         query.setWhereClause(whereClause);
         query.setCreatedOnClause(createdOnClause);
+        query.setMaxTasks(null); //TODO maxTasks + fromTaskNumber
 
         List<org.apache.hise.dao.Task> tasks = hiseEngine.getHiseDao().getUserTasks(query);
-        if(maxTasks == null){
-        	maxTasks = tasks.size();
-        }
    
-        int taskCounter = 0;
-        for(int i = fromTaskNumber; i < tasks.size() && taskCounter < maxTasks;
++i){
+        if(maxTasks == null) {
+        	maxTasks = Integer.MAX_VALUE;
+        }
+        
+        for (int i = fromTaskNumber, count = 0; i < tasks.size() && count <
maxTasks; i++, count++) {
         	TTaskAbstract t = convertTasktoTTaskAbstract(tasks.get(i).getId());
         	result.add(t);
-            
-            taskCounter++;
         }
 
         GetMyTaskAbstractsResponseDocument responseDocument = GetMyTaskAbstractsResponseDocument.Factory.newInstance();
@@ -1496,4 +1493,4 @@ public abstract class TaskOperationsBase
     
     
 
-}
\ No newline at end of file
+}

Modified: incubator/hise/trunk/rtests/src/test/java/org/apache/hise/managementApi/PagingTest.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/rtests/src/test/java/org/apache/hise/managementApi/PagingTest.java?rev=998177&r1=998176&r2=998177&view=diff
==============================================================================
--- incubator/hise/trunk/rtests/src/test/java/org/apache/hise/managementApi/PagingTest.java
(original)
+++ incubator/hise/trunk/rtests/src/test/java/org/apache/hise/managementApi/PagingTest.java
Fri Sep 17 15:35:14 2010
@@ -23,11 +23,10 @@ import org.junit.Test;
 
 public class PagingTest extends TaskTestBase {
 	
-    private Task task = null;
     final private int taskNumber = 6;
     
     public Management management;
-    
+
 
     @Before
     public void setUp() throws Exception {



Mime
View raw message