Author: samindaw
Date: Fri Nov  2 22:22:07 2012
New Revision: 1405183

URL: http://svn.apache.org/viewvc?rev=1405183&view=rev
Log:
add functions to the API to return workflow inputs, return all workflows 
(published & private), work with published workflows from airavata api, search 
experiments by their name

Added:
    
airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/WorkflowData.java
   (with props)
Modified:
    
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/WorkflowManager.java
    
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java
    
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
    
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java

Modified: 
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/WorkflowManager.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/WorkflowManager.java?rev=1405183&r1=1405182&r2=1405183&view=diff
==============================================================================
--- 
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/WorkflowManager.java
 (original)
+++ 
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/WorkflowManager.java
 Fri Nov  2 22:22:07 2012
@@ -22,8 +22,11 @@
 package org.apache.airavata.client.api;
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.workflow.model.wf.WorkflowData;
+import org.apache.airavata.workflow.model.wf.WorkflowInput;
 
 public interface WorkflowManager {
 
@@ -184,6 +187,29 @@ public interface WorkflowManager {
      * @param templateID
      * @return
      */
-    public List<String> getWorkflowServiceNodeIDs(String templateID) throws 
AiravataAPIInvocationException;;
+    public List<String> getWorkflowServiceNodeIDs(String templateID) throws 
AiravataAPIInvocationException;
+    
 
+    
+    
+    
//---------------------------------------------------------------------------------
+    
+    
+       public boolean isPublishedWorkflowExists(String workflowName) throws 
AiravataAPIInvocationException;
+       public void publishWorkflow(String workflowName, String 
publishWorkflowName) throws AiravataAPIInvocationException;
+       public void publishWorkflow(String workflowName) throws 
AiravataAPIInvocationException;
+       
+       public String getPublishedWorkflowGraphXML(String workflowName) throws 
AiravataAPIInvocationException;
+       public Workflow getPublishedWorkflow(String workflowName) throws 
AiravataAPIInvocationException;
+       public List<String> getPublishedWorkflowNames() throws 
AiravataAPIInvocationException;
+       public Map<String,Workflow> getPublishedWorkflows() throws 
AiravataAPIInvocationException;
+       
+       public void removePublishedWorkflow(String workflowName)throws 
AiravataAPIInvocationException;
+
+    public List<WorkflowInput> getWorkflowInputs(String workflowName) throws 
AiravataAPIInvocationException, Exception;
+    
+    public List<WorkflowInput> getWorkflowInputs(WorkflowData workflowData) 
throws AiravataAPIInvocationException, Exception;
+    
+    public List<WorkflowData> getAllWorkflows() throws 
AiravataAPIInvocationException;
+    
 }

Modified: 
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java?rev=1405183&r1=1405182&r2=1405183&view=diff
==============================================================================
--- 
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java
 (original)
+++ 
airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java
 Fri Nov  2 22:22:07 2012
@@ -22,15 +22,18 @@
 package org.apache.airavata.client.impl;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.airavata.client.AiravataClient;
 import org.apache.airavata.client.api.AiravataAPIInvocationException;
 import org.apache.airavata.client.api.WorkflowManager;
-import org.apache.airavata.registry.api.exception.RegistryException;
 import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.registry.api.exception.RegistryException;
 import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.workflow.model.wf.WorkflowData;
+import org.apache.airavata.workflow.model.wf.WorkflowInput;
 
 public class WorkflowManagerImpl implements WorkflowManager {
        private AiravataClient client;
@@ -213,4 +216,117 @@ public class WorkflowManagerImpl impleme
         return getWorkflow(templateID).getWorkflowServiceNodeIDs();
        }
 
+       @Override
+       public boolean isPublishedWorkflowExists(String workflowName)
+                       throws AiravataAPIInvocationException {
+               try {
+                       return 
getClient().getRegistry().isPublishedWorkflowExists(workflowName);
+               } catch (RegistryException e) {
+                       throw new AiravataAPIInvocationException(e);
+               }
+       }
+
+       @Override
+       public void publishWorkflow(String workflowName, String 
publishWorkflowName)
+                       throws AiravataAPIInvocationException {
+               try {
+                       getClient().getRegistry().publishWorkflow(workflowName, 
publishWorkflowName);
+               } catch (Exception e) {
+                       throw new AiravataAPIInvocationException(e);
+               }
+       }
+
+       @Override
+       public void publishWorkflow(String workflowName)
+                       throws AiravataAPIInvocationException {
+               try {
+                       getClient().getRegistry().publishWorkflow(workflowName);
+               } catch (Exception e) {
+                       throw new AiravataAPIInvocationException(e);
+               }
+       }
+
+       @Override
+       public String getPublishedWorkflowGraphXML(String workflowName)
+                       throws AiravataAPIInvocationException {
+               try {
+                       return 
getClient().getRegistry().getPublishedWorkflowGraphXML(workflowName);
+               } catch (Exception e) {
+                       throw new AiravataAPIInvocationException(e);
+               }
+       }
+       
+       @Override
+       public Workflow getPublishedWorkflow(String workflowName)
+                       throws AiravataAPIInvocationException {
+               return 
getWorkflowFromString(getPublishedWorkflowGraphXML(workflowName));
+       }
+
+       @Override
+       public List<String> getPublishedWorkflowNames()
+                       throws AiravataAPIInvocationException {
+               try {
+                       return 
getClient().getRegistry().getPublishedWorkflowNames();
+               } catch (RegistryException e) {
+                       throw new AiravataAPIInvocationException(e);
+               }
+       }
+
+       @Override
+       public Map<String, Workflow> getPublishedWorkflows()
+                       throws AiravataAPIInvocationException {
+               try {
+                       Map<String, Workflow> workflows=new HashMap<String, 
Workflow>();
+                       Map<String, String> publishedWorkflows = 
getClient().getRegistry().getPublishedWorkflows();
+                       for (String name : publishedWorkflows.keySet()) {
+                               workflows.put(name, 
getWorkflowFromString(publishedWorkflows.get(name)));
+                       }
+                       return workflows;
+               } catch (RegistryException e) {
+                       throw new AiravataAPIInvocationException(e);
+               }
+       }
+
+       @Override
+       public void removePublishedWorkflow(String workflowName)
+                       throws AiravataAPIInvocationException {
+               try {
+                       
getClient().getRegistry().removePublishedWorkflow(workflowName);
+               } catch (Exception e) {
+                       throw new AiravataAPIInvocationException(e);
+               }
+       }
+
+       @Override
+       public List<WorkflowInput> getWorkflowInputs(String workflowName) 
throws AiravataAPIInvocationException, Exception {
+               return getWorkflow(workflowName).getWorkflowInputs();
+       }
+
+       @Override
+       public List<WorkflowInput> getWorkflowInputs(WorkflowData workflowData) 
throws AiravataAPIInvocationException, Exception {
+               if (workflowData.isPublished()){
+                       return 
getWorkflowFromString(getClient().getRegistry().getPublishedWorkflowGraphXML(workflowData.getName())).getWorkflowInputs();
+               }else{
+                       return getWorkflowInputs(workflowData.getName());
+               }
+       }
+
+       @Override
+       public List<WorkflowData> getAllWorkflows() throws 
AiravataAPIInvocationException {
+               List<WorkflowData> list = new ArrayList<WorkflowData>();
+               List<String> workflowTemplateIds = getWorkflowTemplateIds();
+               try {
+                       for (String id : workflowTemplateIds) {
+                               list.add(new WorkflowData(id,null,false));
+                       }
+                       List<String> publishedWorkflowNames = 
getClient().getRegistry().getPublishedWorkflowNames();
+                       for (String id : publishedWorkflowNames) {
+                               list.add(new WorkflowData(id,null,false));
+                       }
+                       return list;
+               } catch (RegistryException e) {
+                       throw new AiravataAPIInvocationException(e);
+               }
+       }
+
 }

Modified: 
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java?rev=1405183&r1=1405182&r2=1405183&view=diff
==============================================================================
--- 
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
 (original)
+++ 
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
 Fri Nov  2 22:22:07 2012
@@ -22,27 +22,43 @@ package org.apache.airavata.persistance.
 
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.sql.*;
+import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
 import org.apache.airavata.persistance.registry.jpa.JPAResourceAccessor;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.resources.*;
+import 
org.apache.airavata.persistance.registry.jpa.resources.ApplicationDescriptorResource;
+import 
org.apache.airavata.persistance.registry.jpa.resources.ConfigurationResource;
+import 
org.apache.airavata.persistance.registry.jpa.resources.ExperimentDataResource;
+import 
org.apache.airavata.persistance.registry.jpa.resources.ExperimentDataRetriever;
+import 
org.apache.airavata.persistance.registry.jpa.resources.ExperimentMetadataResource;
+import 
org.apache.airavata.persistance.registry.jpa.resources.ExperimentResource;
+import org.apache.airavata.persistance.registry.jpa.resources.GatewayResource;
+import org.apache.airavata.persistance.registry.jpa.resources.GramDataResource;
+import 
org.apache.airavata.persistance.registry.jpa.resources.HostDescriptorResource;
+import org.apache.airavata.persistance.registry.jpa.resources.NodeDataResource;
+import org.apache.airavata.persistance.registry.jpa.resources.ProjectResource;
+import 
org.apache.airavata.persistance.registry.jpa.resources.PublishWorkflowResource;
+import 
org.apache.airavata.persistance.registry.jpa.resources.ServiceDescriptorResource;
+import 
org.apache.airavata.persistance.registry.jpa.resources.UserWorkflowResource;
+import org.apache.airavata.persistance.registry.jpa.resources.WorkerResource;
+import 
org.apache.airavata.persistance.registry.jpa.resources.WorkflowDataResource;
 import org.apache.airavata.registry.api.AiravataExperiment;
 import org.apache.airavata.registry.api.AiravataRegistry2;
 import org.apache.airavata.registry.api.AiravataUser;
 import org.apache.airavata.registry.api.Gateway;
 import org.apache.airavata.registry.api.ResourceMetadata;
 import org.apache.airavata.registry.api.WorkspaceProject;
+import org.apache.airavata.registry.api.exception.RegistryException;
 import 
org.apache.airavata.registry.api.exception.UnimplementedRegistryOperationException;
 import 
org.apache.airavata.registry.api.exception.gateway.DescriptorAlreadyExistsException;
 import 
org.apache.airavata.registry.api.exception.gateway.DescriptorDoesNotExistsException;
@@ -1387,4 +1403,19 @@ public class AiravataJPARegistry extends
        }
 
 
+       @Override
+       public List<ExperimentData> searchExperiments(String user, String 
experimentNameRegex)
+                       throws RegistryException {
+               Pattern pattern = Pattern.compile(experimentNameRegex);
+               List<ExperimentData> filteredExperiments=new 
ArrayList<ExperimentData>();
+               List<ExperimentData> allExperimentMetaInformation = 
getAllExperimentMetaInformation(user);
+               for (ExperimentData experimentData : 
allExperimentMetaInformation) {
+                       if (experimentData.getExperimentName()!=null && 
pattern.matcher(experimentData.getExperimentName()).find()){
+                               filteredExperiments.add(experimentData);
+                       }
+               }
+               return filteredExperiments;
+       }
+
+
 }

Modified: 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java?rev=1405183&r1=1405182&r2=1405183&view=diff
==============================================================================
--- 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
 (original)
+++ 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
 Fri Nov  2 22:22:07 2012
@@ -262,6 +262,8 @@ public interface ProvenanceRegistry exte
        public ExperimentData getExperimentMetaInformation(String 
experimentId)throws RegistryException;
        
        public List<ExperimentData> getAllExperimentMetaInformation(String 
user)throws RegistryException;
+       
+       public List<ExperimentData> searchExperiments(String user, String 
experimentNameRegex)throws RegistryException;
     
     /**
      * Return experiment ids of experiments launched by the given user
@@ -326,4 +328,5 @@ public interface ProvenanceRegistry exte
     public void updateWorkflowNodeType(WorkflowInstanceNode node, 
WorkflowNodeType type) throws RegistryException;
     
     public void addWorkflowInstanceNode(String workflowInstance, String 
nodeId) throws RegistryException;
+    
 }
\ No newline at end of file

Added: 
airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/WorkflowData.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/WorkflowData.java?rev=1405183&view=auto
==============================================================================
--- 
airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/WorkflowData.java
 (added)
+++ 
airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/WorkflowData.java
 Fri Nov  2 22:22:07 2012
@@ -0,0 +1,66 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.wf;
+
+public class WorkflowData {
+       private String graphXML;
+       private boolean published;
+       private String name;
+       private boolean lazyLoaded;
+       
+       public WorkflowData(String name, String graphXml, boolean published) {
+               setName(name);
+               setGraphXML(graphXml);
+               setPublished(published);
+               setLazyLoaded(graphXml==null);
+       }
+       
+       public String getGraphXML() throws Exception {
+               if (isLazyLoaded()){
+                       throw new Exception("This workflow data is lazy loaded. 
Please use the API to retrieve the workflow graph!!!");
+               }
+               return graphXML;
+       }
+       public void setGraphXML(String graphXML) {
+               this.graphXML = graphXML;
+       }
+       public boolean isPublished() {
+               return published;
+       }
+       public void setPublished(boolean published) {
+               this.published = published;
+       }
+       public String getName() {
+               return name;
+       }
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public boolean isLazyLoaded() {
+               return lazyLoaded;
+       }
+
+       private void setLazyLoaded(boolean lazyLoaded) {
+               this.lazyLoaded = lazyLoaded;
+       }
+}

Propchange: 
airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/WorkflowData.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to