incubator-hise-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r.@apache.org
Subject svn commit: r991214 - in /incubator/hise/trunk: hise-services/src/main/java/org/apache/hise/api/ hise-services/src/main/java/org/apache/hise/engine/ hise-services/src/main/java/org/apache/hise/engine/jaxws/ hise-test-example-osgi/src/main/java/org/apac...
Date Tue, 31 Aug 2010 15:11:30 GMT
Author: rr
Date: Tue Aug 31 15:11:29 2010
New Revision: 991214

URL: http://svn.apache.org/viewvc?rev=991214&view=rev
Log:
HISE-85: Implement paging for getMyTask and getMyTaskAbstracts (Thanks to Michał Więcław)

Added:
    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
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/ManagementImpl.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsAdministrative.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsBaseImpl.java
    incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/TestingManagment.java
    incubator/hise/trunk/hise-wsdl/src/main/resources/ws-humantask-api-wsdl.xsd

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=991214&r1=991213&r2=991214&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 Tue
Aug 31 15:11:29 2010
@@ -37,6 +37,7 @@ import org.apache.hise.lang.xsd.htdt.Com
 import org.apache.hise.lang.xsd.htdt.CompleteResponseDocument;
 import org.apache.hise.lang.xsd.htdt.GetMyTaskAbstractsDocument;
 import org.apache.hise.lang.xsd.htdt.GetMyTaskAbstractsResponseDocument;
+import org.apache.hise.lang.xsd.htdt.GetMyTasksResponseDocument;
 import org.apache.hise.lang.xsd.htdt.GetTaskInfoDocument;
 import org.apache.hise.lang.xsd.htdt.GetTaskInfoResponseDocument;
 import org.apache.hise.lang.xsd.htdt.NominateDocument;
@@ -64,8 +65,12 @@ public interface Management {
 	public String getText();
 	
 	
-	 public List<TTask> getMyTasks(String taskType, String genericHumanRole, String workQueue,
List<TStatus> status, String whereClause, String createdOnClause,
-	            Integer maxTasks) throws IllegalArgumentFault;
+	 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 HISEDao getHiseDao();
 	 

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/ManagementImpl.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/ManagementImpl.java?rev=991214&r1=991213&r2=991214&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/ManagementImpl.java
(original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/ManagementImpl.java
Tue Aug 31 15:11:29 2010
@@ -44,6 +44,7 @@ import org.apache.hise.lang.xsd.htd.TGro
 import org.apache.hise.lang.xsd.htd.TOrganizationalEntity;
 import org.apache.hise.lang.xsd.htd.TUserlist;
 import org.apache.hise.lang.xsd.htda.TStatus;
+import org.apache.hise.lang.xsd.htda.TStatus.Enum;
 import org.apache.hise.lang.xsd.htda.TTask;
 import org.apache.hise.runtime.HiseIllegalStateException;
 import org.apache.hise.runtime.Task;
@@ -55,6 +56,7 @@ import org.apache.hise.lang.xsd.htdt.Com
 import org.apache.hise.lang.xsd.htdt.CompleteResponseDocument;
 import org.apache.hise.lang.xsd.htdt.GetMyTaskAbstractsDocument;
 import org.apache.hise.lang.xsd.htdt.GetMyTaskAbstractsResponseDocument;
+import org.apache.hise.lang.xsd.htdt.GetMyTasksResponseDocument;
 import org.apache.hise.lang.xsd.htdt.GetTaskInfoDocument;
 import org.apache.hise.lang.xsd.htdt.GetTaskInfoResponseDocument;
 import org.apache.hise.lang.xsd.htdt.NominateDocument;
@@ -101,42 +103,21 @@ public class ManagementImpl implements M
 	}
 	
 
+	public GetMyTasksResponseDocument getMyTasks(String userName, String taskType,
+		String genericHumanRole, String workQueue, List<Enum> status,
+		String whereClause, String createdOnClause, Integer maxTasks,
+		Integer fromTaskNumber) throws IllegalArgumentFault, IllegalStateFault {
 
-	public List<TTask> getMyTasks(String userName, String taskType, String genericHumanRole,
String workQueue, List<TStatus> status, String whereClause, String createdOnClause,
-            Integer maxTasks) throws IllegalArgumentFault  {
+			adminOperations.setUserName(userName);
+			return adminOperations.getMyTasks( taskType, genericHumanRole, workQueue, status, whereClause,
createdOnClause, maxTasks, fromTaskNumber);
 
-        List<TTask> result = new ArrayList<TTask>();
-
-//        String user = userName;
-//
-//        TaskQuery query = new TaskQuery();
-//        query.setUser(user);
-//        query.setUserGroups(hiseEngine.getHiseUserDetails().getUserGroups(user));
-//        query.setTaskType(taskType);
-//        if(genericHumanRole==null)
-//        	query.setGenericHumanRole(null);
-//        else
-//        	query.setGenericHumanRole(GenericHumanRole.valueOf(genericHumanRole));
-//        query.setWorkQueue(workQueue);
-//        query.setStatuses(status);
-//        query.setWhereClause(whereClause);
-//        query.setCreatedOnClause(createdOnClause);
-//
-//        if (maxTasks != null) {
-//            query.setMaxTasks(maxTasks);
-//        }
-//
-//        List<org.apache.hise.dao.Task> tasks = hiseEngine.getHiseDao().getUserTasks(query);
-//        for (org.apache.hise.dao.Task u : tasks) {
-//            TTask t=null;
-//		
-//				t = convertTasktoTTask(u);
-//
-//            result.add(t);
-//        }
-
-        return result;
-           
+    }
+	
+    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 {
+    	
+    		adminOperations.setUserName(userName);
+    		return adminOperations.getMyTaskAbstracts(taskType, genericHumanRole, workQueue, status,
whereClause, createdOnClause, maxTasks, fromTaskNumber);
     }
     
     public HISEDao getHiseDao(){
@@ -144,13 +125,6 @@ public class ManagementImpl implements M
     	
     }
 
-	public List<TTask> getMyTasks(String taskType, String genericHumanRole,
-			String workQueue, List<TStatus> status, String whereClause,
-			String createdOnClause, Integer maxTasks)
-			throws IllegalArgumentFault {
-		// TODO Auto-generated method stub
-		return null;
-	}
 
 	public void delegate(String identifier,
 			TOrganizationalEntity organizationalEntity, String name) throws RecipientNotAllowed, IllegalStateFault
{
@@ -351,6 +325,8 @@ public SetPriorityResponseDocument setPr
 }
 
 
+
+
 	
 	
 

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsAdministrative.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsAdministrative.java?rev=991214&r1=991213&r2=991214&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsAdministrative.java
(original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsAdministrative.java
Tue Aug 31 15:11:29 2010
@@ -1,13 +1,17 @@
 package org.apache.hise.engine.jaxws;
 
 import java.math.BigInteger;
+import java.util.List;
 
 import org.apache.hise.engine.wsdl.IllegalAccessFault;
 import org.apache.hise.engine.wsdl.IllegalArgumentFault;
 import org.apache.hise.engine.wsdl.IllegalStateFault;
 import org.apache.hise.engine.wsdl.TaskOperations;
+import org.apache.hise.lang.xsd.htda.TStatus;
 import org.apache.hise.lang.xsd.htdt.ActivateResponseDocument;
 import org.apache.hise.lang.xsd.htdt.ClaimResponseDocument;
+import org.apache.hise.lang.xsd.htdt.GetMyTaskAbstractsResponseDocument;
+import org.apache.hise.lang.xsd.htdt.GetMyTasksResponseDocument;
 import org.apache.hise.lang.xsd.htdt.GetTaskInfoResponseDocument;
 import org.apache.hise.lang.xsd.htdt.ReleaseResponseDocument;
 import org.apache.hise.lang.xsd.htdt.RemoveResponseDocument;
@@ -33,4 +37,8 @@ public interface TaskOperationsAdministr
 	public ActivateResponseDocument activate(Long id) throws IllegalArgumentFault, IllegalStateFault,
IllegalAccessFault;
 	public ClaimResponseDocument claim(Long id) throws IllegalArgumentFault, IllegalStateFault,
IllegalAccessFault ;
 	public SetPriorityResponseDocument setPriority(Long id, BigInteger priority) throws IllegalArgumentFault,
IllegalStateFault, IllegalAccessFault;
+	public GetMyTasksResponseDocument getMyTasks(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 taskType, String
genericHumanRole, String workQueue, List<TStatus.Enum> status, String whereClause,
+            String createdOnClause, Integer maxTasks, Integer fromTaskNumber) throws IllegalArgumentFault,
IllegalStateFault;
 }

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=991214&r1=991213&r2=991214&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
Tue Aug 31 15:11:29 2010
@@ -108,6 +108,7 @@ import org.apache.hise.lang.xsd.htdt.Get
 import org.apache.hise.lang.xsd.htdt.GetMyTaskAbstractsResponseDocument;
 import org.apache.hise.lang.xsd.htdt.GetMyTasksDocument;
 import org.apache.hise.lang.xsd.htdt.GetMyTasksResponseDocument;
+import org.apache.hise.lang.xsd.htdt.GetMyTasksResponseDocument.GetMyTasksResponse;
 import org.apache.hise.lang.xsd.htdt.GetOutputDocument;
 import org.apache.hise.lang.xsd.htdt.GetOutputResponseDocument;
 import org.apache.hise.lang.xsd.htdt.GetRenderingDocument;
@@ -211,16 +212,23 @@ public abstract class TaskOperationsBase
      * {@inheritDoc}
      */
     public GetMyTasksResponseDocument getMyTasks(GetMyTasksDocument getMyTasks) throws IllegalArgumentFault,
IllegalStateFault {
-//    public List<TTask> getMyTasks(String taskType, String genericHumanRole, String
workQueue, List<TStatus> status, String whereClause, String createdOnClause,
-//            Integer maxTasks) throws IllegalArgumentFault, IllegalStateFault {
-
-        String taskType = getMyTasks.getGetMyTasks().getTaskType();
-        String genericHumanRole = getMyTasks.getGetMyTasks().getGenericHumanRole();
-        String workQueue = getMyTasks.getGetMyTasks().getWorkQueue();
-        List<TStatus.Enum> status = getMyTasks.getGetMyTasks().getStatusList();
-        String whereClause = getMyTasks.getGetMyTasks().getWhereClause();
-        String createdOnClause = getMyTasks.getGetMyTasks().getCreatedOnClause();
-        Integer maxTasks = getMyTasks.getGetMyTasks().getMaxTasks();
+    	 String taskType = getMyTasks.getGetMyTasks().getTaskType();
+         String genericHumanRole = getMyTasks.getGetMyTasks().getGenericHumanRole();
+         String workQueue = getMyTasks.getGetMyTasks().getWorkQueue();
+         List<TStatus.Enum> status = getMyTasks.getGetMyTasks().getStatusList();
+         String whereClause = getMyTasks.getGetMyTasks().getWhereClause();
+         String createdOnClause = getMyTasks.getGetMyTasks().getCreatedOnClause();
+         Integer maxTasks = getMyTasks.getGetMyTasks().getMaxTasks();
+         Integer fromTaskNumber = getMyTasks.getGetMyTasks().getFromTaskNumber();
+         if(!getMyTasks.getGetMyTasks().isSetMaxTasks()){
+        	 maxTasks = null;
+         }
+         
+         return getMyTasks(taskType, genericHumanRole, workQueue, status, whereClause, createdOnClause,
maxTasks, fromTaskNumber); 
+    }
+    
+    public GetMyTasksResponseDocument getMyTasks(String taskType, String genericHumanRole,
String workQueue, List<TStatus.Enum> status, String whereClause, String createdOnClause,
+            Integer maxTasks, Integer fromTaskNumber) throws IllegalArgumentFault, IllegalStateFault
{
 
         List<TTask> result = new ArrayList<TTask>();
 
@@ -241,18 +249,19 @@ public abstract class TaskOperationsBase
         query.setWhereClause(whereClause);
         query.setCreatedOnClause(createdOnClause);
 
-        if (maxTasks != null) {
-            query.setMaxTasks(maxTasks);
-        }
-
         List<org.apache.hise.dao.Task> tasks = hiseEngine.getHiseDao().getUserTasks(query);
+        if(maxTasks == null){
+        	maxTasks = tasks.size();
+        }
    
-        for (org.apache.hise.dao.Task u : tasks) {
-            TTask t = null;
-
-            t = convertTasktoTTask(u);
-
+        int taskCounter = 0;
+        for(int i = fromTaskNumber; i < tasks.size() && taskCounter < maxTasks;
++i){
+        	TTask t = null;
+        	
+        	t = convertTasktoTTask(tasks.get(i));
             result.add(t);
+            
+            taskCounter++;
         }
 
         GetMyTasksResponseDocument responseDocument = GetMyTasksResponseDocument.Factory.newInstance();
@@ -1253,8 +1262,7 @@ public abstract class TaskOperationsBase
     }
 
     public GetMyTaskAbstractsResponseDocument getMyTaskAbstracts(GetMyTaskAbstractsDocument
getMyTaskAbstracts) throws IllegalArgumentFault, IllegalStateFault {
-    //public List<TTaskAbstract> getMyTaskAbstracts(String taskType, String genericHumanRole,
String workQueue, List<TStatus> status, String whereClause,
-//            String createdOnClause, Integer maxTasks) throws IllegalArgumentFault, IllegalStateFault
{
+
 
         String taskType = getMyTaskAbstracts.getGetMyTaskAbstracts().getTaskType();
         String genericHumanRole = getMyTaskAbstracts.getGetMyTaskAbstracts().getGenericHumanRole();
@@ -1263,7 +1271,18 @@ public abstract class TaskOperationsBase
         String whereClause = getMyTaskAbstracts.getGetMyTaskAbstracts().getWhereClause();
         String createdOnClause = getMyTaskAbstracts.getGetMyTaskAbstracts().getCreatedOnClause();
         Integer maxTasks = getMyTaskAbstracts.getGetMyTaskAbstracts().getMaxTasks();
-
+        Integer fromTaskNumber = getMyTaskAbstracts.getGetMyTaskAbstracts().getFromTaskNumber();
+        
+        if(!getMyTaskAbstracts.getGetMyTaskAbstracts().isSetMaxTasks()){
+       	 maxTasks = null;
+        }
+        
+        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>();
 
         String user = getUserString();
@@ -1278,15 +1297,17 @@ public abstract class TaskOperationsBase
         query.setWhereClause(whereClause);
         query.setCreatedOnClause(createdOnClause);
 
-        if (maxTasks != null) {
-            query.setMaxTasks(maxTasks);
-        }
-
         List<org.apache.hise.dao.Task> tasks = hiseEngine.getHiseDao().getUserTasks(query);
-    
-        for (org.apache.hise.dao.Task u : tasks) {
-        	TTaskAbstract t = convertTasktoTTaskAbstract(u.getId());
-            result.add(t);
+        if(maxTasks == null){
+        	maxTasks = tasks.size();
+        }
+   
+        int taskCounter = 0;
+        for(int i = fromTaskNumber; i < tasks.size() && taskCounter < maxTasks;
++i){
+        	TTaskAbstract t = convertTasktoTTaskAbstract(tasks.get(i).getId());
+        	result.add(t);
+            
+            taskCounter++;
         }
 
         GetMyTaskAbstractsResponseDocument responseDocument = GetMyTaskAbstractsResponseDocument.Factory.newInstance();

Modified: incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/TestingManagment.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/TestingManagment.java?rev=991214&r1=991213&r2=991214&view=diff
==============================================================================
--- incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/TestingManagment.java
(original)
+++ incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/TestingManagment.java
Tue Aug 31 15:11:29 2010
@@ -27,6 +27,7 @@ import org.apache.hise.api.Management;
 import org.apache.hise.api.Sender;
 import org.apache.hise.engine.jaxws.HISEJaxWSClient;
 import org.apache.hise.engine.wsdl.IllegalArgumentFault;
+import org.apache.hise.engine.wsdl.IllegalStateFault;
 import org.apache.hise.lang.xsd.htda.TTask;
 import org.w3c.dom.Node;
 
@@ -49,11 +50,14 @@ public class TestingManagment implements
 		if(text!=null && text.length()>0)
 				text.charAt(0);
 		try {
-			List<TTask> l = management.getMyTasks(null, null, null, null, null, null, null);
+			List<TTask> l = management.getMyTasks(null, null, null, null, null, null, null,null,null).getGetMyTasksResponse().getTaskAbstractList();
 			__log.debug("TestingManagment wielkosc listy:"+l.size());
 		} catch (IllegalArgumentFault e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
+		} catch (IllegalStateFault e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
 		}
 		
 		__log.debug("TestingManagment is alive");

Modified: incubator/hise/trunk/hise-wsdl/src/main/resources/ws-humantask-api-wsdl.xsd
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-wsdl/src/main/resources/ws-humantask-api-wsdl.xsd?rev=991214&r1=991213&r2=991214&view=diff
==============================================================================
--- incubator/hise/trunk/hise-wsdl/src/main/resources/ws-humantask-api-wsdl.xsd (original)
+++ incubator/hise/trunk/hise-wsdl/src/main/resources/ws-humantask-api-wsdl.xsd Tue Aug 31
15:11:29 2010
@@ -14,7 +14,8 @@ Business Machines Corporation, Oracle In
   <xsd:import namespace="http://www.example.org/WS-HT/api"
     schemaLocation="ws-humantask-api.xsd" />
   <xsd:import namespace="http://www.example.org/WS-HT"
-    schemaLocation="ws-humantask.xsd" />
+  schemaLocation="ws-humantask.xsd" />
+  
   <xsd:element name="claim">
     <xsd:complexType>
       <xsd:sequence>
@@ -551,6 +552,9 @@ Business Machines Corporation, Oracle In
       <xsd:element name="createdOnClause" type="xsd:string"
         minOccurs="0" />
       <xsd:element name="maxTasks" type="xsd:int" minOccurs="0" />
+      <xsd:element minOccurs="0" default="0" type="xsd:int"  name="fromTaskNumber">
+        
+      </xsd:element>
     </xsd:sequence>
   </xsd:complexType>
 </xsd:element>
@@ -577,6 +581,9 @@ Business Machines Corporation, Oracle In
       <xsd:element name="createdOnClause" type="xsd:string"
         minOccurs="0" />
       <xsd:element name="maxTasks" type="xsd:int" minOccurs="0" />
+      <xsd:element minOccurs="0" type="xsd:int" name="fromTaskNumber" default="0">
+        
+      </xsd:element>
     </xsd:sequence>
   </xsd:complexType>
 </xsd:element>

Added: 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=991214&view=auto
==============================================================================
--- incubator/hise/trunk/rtests/src/test/java/org/apache/hise/managementApi/PagingTest.java
(added)
+++ incubator/hise/trunk/rtests/src/test/java/org/apache/hise/managementApi/PagingTest.java
Tue Aug 31 15:11:29 2010
@@ -0,0 +1,132 @@
+package org.apache.hise.managementApi;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.hise.TaskTestBase;
+import org.apache.hise.api.Management;
+import org.apache.hise.dao.GenericHumanRole;
+import org.apache.hise.dao.Task.Status;
+import org.apache.hise.engine.wsdl.IllegalAccessFault;
+import org.apache.hise.engine.wsdl.IllegalArgumentFault;
+import org.apache.hise.engine.wsdl.IllegalStateFault;
+import org.apache.hise.lang.xsd.htda.TStatus;
+import org.apache.hise.lang.xsd.htda.TTask;
+import org.apache.hise.lang.xsd.htda.TTaskAbstract;
+import org.apache.hise.runtime.Task;
+import org.junit.Before;
+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 {
+        init("management/test.xml");
+        
+        for(int i = 0; i < taskNumber; ++i){
+        	getTask("management/approveHeader.xml", "management/approveBody.xml", new QName("http://www.insurance.example.com/claims",
"Task1"));
+        }
+ 
+        management = (Management) innerCtx.getBean("management");
+    }
+    
+    @Test
+    public void testGetMyTaskWithPaging() throws IllegalArgumentFault, IllegalStateFault,
IllegalAccessFault {
+    	addUser("user1");
+     
+    	String[] allTasksID = new String[taskNumber];
+    	
+    	String genericHumanRole = GenericHumanRole.POTENTIALOWNERS.toString(); 
+        Integer maxTasks = null;
+        Integer fromTaskNumber = 0;
+        List<TStatus.Enum> statuses = new ArrayList<TStatus.Enum>();
+        
+        List<TTask> tasks = management.getMyTasks("user1", "ALL", genericHumanRole,
null, statuses,null, null, maxTasks, fromTaskNumber).getGetMyTasksResponse().getTaskAbstractList();
+        for(int i = 0; i < taskNumber; ++i ){
+        	allTasksID[i] = tasks.get(i).getId();
+        }
+       
+    	Assert.assertEquals(6, tasks.size());
+    	
+    	maxTasks = null;
+    	fromTaskNumber = 3;
+    	tasks = management.getMyTasks("user1", "ALL", genericHumanRole, null, statuses,null,
null, maxTasks, fromTaskNumber).getGetMyTasksResponse().getTaskAbstractList();
+    	Assert.assertEquals(3, tasks.size());
+    	Assert.assertEquals(allTasksID[3], tasks.get(0).getId());
+    	Assert.assertEquals(allTasksID[5], tasks.get(2).getId());
+    	
+    	maxTasks = 3;
+    	fromTaskNumber = 1;
+    	tasks = management.getMyTasks("user1", "ALL", genericHumanRole, null, statuses,null,
null, maxTasks, fromTaskNumber).getGetMyTasksResponse().getTaskAbstractList();
+    	Assert.assertEquals(3, tasks.size());
+    	Assert.assertEquals(allTasksID[1], tasks.get(0).getId());
+    	Assert.assertEquals(allTasksID[3], tasks.get(2).getId());
+    	
+    	maxTasks = 3;
+    	fromTaskNumber = 4;
+    	tasks = management.getMyTasks("user1", "ALL", genericHumanRole, null, statuses,null,
null, maxTasks, fromTaskNumber).getGetMyTasksResponse().getTaskAbstractList();
+    	Assert.assertEquals(2, tasks.size());
+    	Assert.assertEquals(allTasksID[4], tasks.get(0).getId());
+    	Assert.assertEquals(allTasksID[5], tasks.get(1).getId());
+    	
+    	maxTasks = 3;
+    	fromTaskNumber = 6;
+    	tasks = management.getMyTasks("user1", "ALL", genericHumanRole, null, statuses,null,
null, maxTasks, fromTaskNumber).getGetMyTasksResponse().getTaskAbstractList();
+    	Assert.assertEquals(0, tasks.size());
+    }
+    
+    @Test
+    public void testGetMyTaskAbstractsWithPaging() throws IllegalArgumentFault, IllegalStateFault,
IllegalAccessFault {
+    	addUser("user1");
+     
+    	String[] allTasksID = new String[taskNumber];
+    	
+    	String genericHumanRole = GenericHumanRole.POTENTIALOWNERS.toString(); 
+        Integer maxTasks = null;
+        Integer fromTaskNumber = 0;
+        List<TStatus.Enum> statuses = new ArrayList<TStatus.Enum>();
+        
+        List<TTaskAbstract> tasks = management.getMyTaskAbstracts("user1", "ALL", genericHumanRole,
null, statuses, null, null, maxTasks, fromTaskNumber).getGetMyTaskAbstractsResponse().getTaskAbstractList();
+        for(int i = 0; i < taskNumber; ++i ){
+        	allTasksID[i] = tasks.get(i).getId();
+        }
+       
+    	Assert.assertEquals(6, tasks.size());
+
+    	maxTasks = null;
+    	fromTaskNumber = 3;
+    	tasks = management.getMyTaskAbstracts("user1", "ALL", genericHumanRole, null, statuses,
null, null, maxTasks, fromTaskNumber).getGetMyTaskAbstractsResponse().getTaskAbstractList();
+    	Assert.assertEquals(3, tasks.size());
+    	Assert.assertEquals(allTasksID[3], tasks.get(0).getId());
+    	Assert.assertEquals(allTasksID[5], tasks.get(2).getId());
+    	
+    	maxTasks = 3;
+    	fromTaskNumber = 1;
+    	tasks = management.getMyTaskAbstracts("user1", "ALL", genericHumanRole, null, statuses,
null, null, maxTasks, fromTaskNumber).getGetMyTaskAbstractsResponse().getTaskAbstractList();
+    	Assert.assertEquals(3, tasks.size());
+    	Assert.assertEquals(allTasksID[1], tasks.get(0).getId());
+    	Assert.assertEquals(allTasksID[3], tasks.get(2).getId());
+    	
+    	maxTasks = 3;
+    	fromTaskNumber = 4;
+    	tasks = management.getMyTaskAbstracts("user1", "ALL", genericHumanRole, null, statuses,
null, null, maxTasks, fromTaskNumber).getGetMyTaskAbstractsResponse().getTaskAbstractList();
+    	Assert.assertEquals(2, tasks.size());
+    	Assert.assertEquals(allTasksID[4], tasks.get(0).getId());
+    	Assert.assertEquals(allTasksID[5], tasks.get(1).getId());
+    	
+    	maxTasks = 3;
+    	fromTaskNumber = 6;
+    	tasks = management.getMyTaskAbstracts("user1", "ALL", genericHumanRole, null, statuses,
null, null, maxTasks, fromTaskNumber).getGetMyTaskAbstractsResponse().getTaskAbstractList();
+    	Assert.assertEquals(0, tasks.size());
+    }
+}



Mime
View raw message