airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject svn commit: r1234185 - in /incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api: AiravataRegistry.java impl/AiravataJCRRegistry.java
Date Fri, 20 Jan 2012 22:19:32 GMT
Author: samindaw
Date: Fri Jan 20 22:19:31 2012
New Revision: 1234185

URL: http://svn.apache.org/viewvc?rev=1234185&view=rev
Log:
udpating the AiravataRegistry api to return executions based on user

Modified:
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry.java
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/AiravataJCRRegistry.java

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry.java?rev=1234185&r1=1234184&r2=1234185&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry.java
(original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry.java
Fri Jan 20 22:19:31 2012
@@ -241,5 +241,12 @@ public interface AiravataRegistry extend
     public String getWorkflowExecutionUser(String experimentId) throws RegistryException;
     
     public WorkflowExecution getWorkflowExection(String experimentId) throws RegistryException;
+    
+    public List<String> getWorkflowExecutionIdByUser(String user) throws RegistryException;
+
+    public List<WorkflowExecution> getWorkflowExecutionByUser(String user) throws RegistryException;
+    
+    public List<WorkflowExecution> getWorkflowExecutionByUser(String user, int pageSize,
int pageNo) throws RegistryException;
+    
 
 }

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/AiravataJCRRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/AiravataJCRRegistry.java?rev=1234185&r1=1234184&r2=1234185&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/AiravataJCRRegistry.java
(original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/AiravataJCRRegistry.java
Fri Jan 20 22:19:31 2012
@@ -850,7 +850,7 @@ public class AiravataJCRRegistry extends
         Session session = null;
         try {
             session = getSession();
-            Node experimentsNode = getOrAddNode(session.getRootNode(), WORKFLOW_DATA);
+            Node experimentsNode = getWorkflowDataNode(session);
             NodeIterator experimentNodes = experimentsNode.getNodes();
             for (; experimentNodes.hasNext();) {
                 Node experimentNode = experimentNodes.nextNode();
@@ -930,9 +930,14 @@ public class AiravataJCRRegistry extends
 
 	private Node getWorkflowExperimentDataNode(String experimentId,
 			Session session) throws RepositoryException {
-		return getOrAddNode(getOrAddNode(getOrAddNode(session.getRootNode(), WORKFLOW_DATA),
+		return getOrAddNode(getOrAddNode(getWorkflowDataNode(session),
 		                experimentId),experimentId);
 	}
+
+	private Node getWorkflowDataNode(Session session)
+			throws RepositoryException {
+		return getOrAddNode(session.getRootNode(), WORKFLOW_DATA);
+	}
     
 	public boolean saveWorkflowExecutionOutput(String experimentId,String outputNodeName,String
output) throws RegistryException{
 		Session session=null;
@@ -1000,7 +1005,7 @@ public class AiravataJCRRegistry extends
 		return resultNode;
 	}
     private List<String> getMatchingExperimentIds(String regex,Session session)throws
RepositoryException{
-        Node orAddNode = getOrAddNode(session.getRootNode(), WORKFLOW_DATA);
+        Node orAddNode = getWorkflowDataNode(session);
         List<String> matchList = new ArrayList<String>();
         NodeIterator nodes = orAddNode.getNodes();
         Pattern compile = Pattern.compile(regex);
@@ -1131,4 +1136,51 @@ public class AiravataJCRRegistry extends
 		}
 		return result;
 	}
+
+	public List<String> getWorkflowExecutionIdByUser(String user)
+			throws RegistryException {
+		Session session = null;
+		List<String> ids=new ArrayList<String>();
+		try {
+			session = getSession();
+			List<String> matchingExperimentIds = getMatchingExperimentIds(".*", session);
+			for (String id : matchingExperimentIds) {
+				if (user.equals(getWorkflowExecutionUser(id))){
+					ids.add(id);
+				}
+			}
+		} catch (RepositoryException e) {
+			throw new RegistryException("Error in retrieving Execution Ids for the user '"+user+"'",e);
+		}finally{
+			closeSession(session);
+		}
+		return ids;
+	}
+
+	public List<WorkflowExecution> getWorkflowExecutionByUser(String user)
+			throws RegistryException {
+		return getWorkflowExecution(user,-1,-1);
+	}
+
+	private List<WorkflowExecution> getWorkflowExecution(String user, int startLimit,
int endLimit)
+			throws RegistryException {
+		List<WorkflowExecution> executions=new ArrayList<WorkflowExecution>();
+		List<String> workflowExecutionIdByUser = getWorkflowExecutionIdByUser(user);
+		int count=0;
+		for (String id : workflowExecutionIdByUser) {
+			if ((startLimit==-1 && endLimit==-1) ||
+				(startLimit==-1 && count<endLimit) ||
+				(startLimit<=count && endLimit==-1) ||
+				(startLimit<=count && count<endLimit)){
+				executions.add(getWorkflowExection(id));
+			}
+			count++;
+		}
+		return executions;
+	}
+
+	public List<WorkflowExecution> getWorkflowExecutionByUser(String user,
+			int pageSize, int pageNo) throws RegistryException {
+		return getWorkflowExecutionByUser(user,pageSize*pageNo,pageSize*(pageNo+1));
+	}
 }



Mime
View raw message