airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject [1/2] adding workflow related data models
Date Mon, 06 Oct 2014 15:16:57 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 60de53978 -> dbb1c97a1


http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowOutputResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowOutputResource.java
new file mode 100644
index 0000000..edefad9
--- /dev/null
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowOutputResource.java
@@ -0,0 +1,377 @@
+/**
+ * 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.aiaravata.application.catalog.data.resources;
+
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.apache.aiaravata.application.catalog.data.model.Workflow;
+import org.apache.aiaravata.application.catalog.data.model.WorkflowOutput;
+import org.apache.aiaravata.application.catalog.data.model.WorkflowOutput_PK;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogJPAUtils;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogQueryGenerator;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogResourceType;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class WorkflowOutputResource extends AbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(WorkflowOutputResource.class);
+
+    private String wfTemplateId;
+    private String outputKey;
+    private String outputVal;
+    private String dataType;
+
+    private WorkflowResource workflowResource;
+
+    public void remove(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name
and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
+            generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, ids.get(WFOutputConstants.WF_TEMPLATE_ID));
+            generator.setParameter(WFOutputConstants.OUTPUT_KEY, ids.get(WFOutputConstants.OUTPUT_KEY));
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public Resource get(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name
and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
+            generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, ids.get(WFOutputConstants.WF_TEMPLATE_ID));
+            generator.setParameter(WFOutputConstants.OUTPUT_KEY, ids.get(WFOutputConstants.OUTPUT_KEY));
+            Query q = generator.selectQuery(em);
+            WorkflowOutput wfOutput = (WorkflowOutput) q.getSingleResult();
+            WorkflowOutputResource workflowOutputResource =
+                    (WorkflowOutputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW_OUTPUT
+                            , wfOutput);
+            em.getTransaction().commit();
+            em.close();
+            return workflowOutputResource;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public List<Resource> get(String fieldName, Object value) throws AppCatalogException
{
+        List<Resource> wfOutputResources = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
+            List results;
+            if (fieldName.equals(WFOutputConstants.WF_TEMPLATE_ID)) {
+                generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        WorkflowOutput wfOutput = (WorkflowOutput) result;
+                        WorkflowOutputResource workflowOutputResource =
+                                (WorkflowOutputResource) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.WORKFLOW_OUTPUT, wfOutput);
+                        wfOutputResources.add(workflowOutputResource);
+                    }
+                }
+            } else if (fieldName.equals(WFOutputConstants.OUTPUT_KEY)) {
+                generator.setParameter(WFOutputConstants.OUTPUT_KEY, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        WorkflowOutput workflowOutput = (WorkflowOutput) result;
+                        WorkflowOutputResource workflowOutputResource =
+                                (WorkflowOutputResource) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.WORKFLOW_OUTPUT, workflowOutput);
+                        wfOutputResources.add(workflowOutputResource);
+                    }
+                }
+            } else if (fieldName.equals(WFOutputConstants.DATA_TYPE)) {
+                generator.setParameter(WFOutputConstants.DATA_TYPE, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        WorkflowOutput workflowOutput = (WorkflowOutput) result;
+                        WorkflowOutputResource workflowOutputResource =
+                                (WorkflowOutputResource) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.WORKFLOW_OUTPUT, workflowOutput);
+                        wfOutputResources.add(workflowOutputResource);
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for WF Output Resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for WF Output
Resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return wfOutputResources;
+    }
+
+    public List<Resource> getAll() throws AppCatalogException {
+        return null;
+    }
+
+    public List<String> getAllIds() throws AppCatalogException {
+        return null;
+    }
+
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException
{
+        List<String> wfOutputResourceIDs = new ArrayList<String>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
+            List results;
+            if (fieldName.equals(WFOutputConstants.WF_TEMPLATE_ID)) {
+                generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        WorkflowOutput workflowOutput = (WorkflowOutput) result;
+                        wfOutputResourceIDs.add(workflowOutput.getWfTemplateId());
+                    }
+                }
+            }
+            if (fieldName.equals(WFOutputConstants.OUTPUT_KEY)) {
+                generator.setParameter(WFOutputConstants.OUTPUT_KEY, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        WorkflowOutput workflowOutput = (WorkflowOutput) result;
+                        wfOutputResourceIDs.add(workflowOutput.getWfTemplateId());
+                    }
+                }
+            } else if (fieldName.equals(WFOutputConstants.DATA_TYPE)) {
+                generator.setParameter(WFOutputConstants.DATA_TYPE, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        WorkflowOutput workflowOutput = (WorkflowOutput) result;
+                        wfOutputResourceIDs.add(workflowOutput.getWfTemplateId());
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for WF Output resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for WF Output
Resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return wfOutputResourceIDs;
+    }
+
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            WorkflowOutput existingWorkflowOutput = em.find(WorkflowOutput.class,
+                    new WorkflowOutput_PK(wfTemplateId, outputKey));
+            em.close();
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (existingWorkflowOutput != null) {
+                existingWorkflowOutput.setWfTemplateId(wfTemplateId);
+                Workflow workflow = em.find(Workflow.class, wfTemplateId);
+                existingWorkflowOutput.setWorkflow(workflow);
+                existingWorkflowOutput.setDataType(dataType);
+                existingWorkflowOutput.setOutputKey(outputKey);
+                if (outputKey != null){
+                    existingWorkflowOutput.setOutputVal(outputVal.toCharArray());
+                }
+                em.merge(existingWorkflowOutput);
+            } else {
+                WorkflowOutput workflowOutput = new WorkflowOutput();
+                workflowOutput.setWfTemplateId(wfTemplateId);
+                Workflow workflow = em.find(Workflow.class, wfTemplateId);
+                workflowOutput.setWorkflow(workflow);
+                workflowOutput.setDataType(dataType);
+                workflowOutput.setOutputKey(outputKey);
+                if (outputKey != null){
+                    workflowOutput.setOutputVal(outputVal.toCharArray());
+                }
+                em.persist(workflowOutput);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public boolean isExists(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name
and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            WorkflowOutput workflowOutput = em.find(WorkflowOutput.class, new WorkflowOutput_PK(
+                    ids.get(WFOutputConstants.WF_TEMPLATE_ID),
+                    ids.get(WFOutputConstants.OUTPUT_KEY)));
+
+            em.close();
+            return workflowOutput != null;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public String getWfTemplateId() {
+        return wfTemplateId;
+    }
+
+    public void setWfTemplateId(String wfTemplateId) {
+        this.wfTemplateId = wfTemplateId;
+    }
+
+    public String getOutputKey() {
+        return outputKey;
+    }
+
+    public void setOutputKey(String outputKey) {
+        this.outputKey = outputKey;
+    }
+
+    public String getOutputVal() {
+        return outputVal;
+    }
+
+    public void setOutputVal(String outputVal) {
+        this.outputVal = outputVal;
+    }
+
+    public String getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(String dataType) {
+        this.dataType = dataType;
+    }
+
+    public WorkflowResource getWorkflowResource() {
+        return workflowResource;
+    }
+
+    public void setWorkflowResource(WorkflowResource workflowResource) {
+        this.workflowResource = workflowResource;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowResource.java
index c15b521..46d150d 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/WorkflowResource.java
@@ -45,6 +45,7 @@ public class WorkflowResource extends AbstractResource {
     private String wfTemplateId;
     private Timestamp createdTime;
     private Timestamp updatedTime;
+    private String image;
 
     public Timestamp getCreatedTime() {
         return createdTime;
@@ -62,6 +63,14 @@ public class WorkflowResource extends AbstractResource {
         this.updatedTime = updatedTime;
     }
 
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
     @Override
     public void remove(Object identifier) throws AppCatalogException {
         EntityManager em = null;
@@ -282,6 +291,9 @@ public class WorkflowResource extends AbstractResource {
             if (getGraph() != null){
                 workflow.setGraph(getGraph().toCharArray());
             }
+            if (image != null){
+                workflow.setImage(image.getBytes());
+            }
             workflow.setWfTemplateId(getWfTemplateId());
             if (existingWorkflow == null) {
                 em.persist(workflow);

http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogJPAUtils.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogJPAUtils.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogJPAUtils.java
index c4420f8..309cadd 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogJPAUtils.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogJPAUtils.java
@@ -21,13 +21,6 @@
 
 package org.apache.aiaravata.application.catalog.data.util;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-
 import org.apache.aiaravata.application.catalog.data.model.*;
 import org.apache.aiaravata.application.catalog.data.resources.*;
 import org.apache.airavata.common.exception.ApplicationSettingsException;
@@ -35,6 +28,12 @@ import org.apache.airavata.common.utils.ServerSettings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import java.util.HashMap;
+import java.util.Map;
+
 public class AppCatalogJPAUtils {
     private final static Logger logger = LoggerFactory.getLogger(AppCatalogJPAUtils.class);
     private static final String PERSISTENCE_UNIT_NAME = "appcatalog_data";
@@ -340,6 +339,20 @@ public class AppCatalogJPAUtils {
                     logger.error("Object should be a Workflow.", new IllegalArgumentException());
                     throw new IllegalArgumentException("Object should be a Workflow.");
                 }
+            case WORKFLOW_INPUT:
+                if (o instanceof WorkflowInput){
+                    return createWorflowInput((WorkflowInput) o);
+                }else {
+                    logger.error("Object should be a Workflow Input.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a Workflow Input.");
+                }
+            case WORKFLOW_OUTPUT:
+                if (o instanceof WorkflowOutput){
+                    return createWorkflowOutput((WorkflowOutput) o);
+                }else {
+                    logger.error("Object should be a Workflow Output.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Object should be a Workflow Output.");
+                }
             default:
                 logger.error("Illegal data type..", new IllegalArgumentException());
                 throw new IllegalArgumentException("Illegal data type..");
@@ -735,6 +748,24 @@ public class AppCatalogJPAUtils {
         return resource;
     }
 
+    private static Resource createWorflowInput(WorkflowInput o) {
+        WorkflowInputResource resource = new WorkflowInputResource();
+        if (o != null){
+            resource.setWfTemplateId(o.getWfTemplateId());
+            resource.setInputKey(o.getInputKey());
+            if (o.getInputVal() != null){
+                resource.setInputVal(new String(o.getInputVal()));
+            }
+            resource.setDataType(o.getDataType());
+            resource.setMetadata(o.getMetadata());
+            resource.setAppArgument(o.getAppArgument());
+            resource.setUserFriendlyDesc(o.getUserFriendlyDesc());
+            resource.setStandareInput(o.isStandardInput());
+            resource.setWorkflowResource((WorkflowResource)createWorkflow(o.getWorkflow()));
+        }
+        return resource;
+    }
+
     private static Resource createApplicationOutput(ApplicationOutput o) {
         ApplicationOutputResource resource = new ApplicationOutputResource();
         if (o != null){
@@ -747,6 +778,20 @@ public class AppCatalogJPAUtils {
         return resource;
     }
 
+    private static Resource createWorkflowOutput(WorkflowOutput o) {
+        WorkflowOutputResource resource = new WorkflowOutputResource();
+        if (o != null){
+            resource.setWfTemplateId(o.getWfTemplateId());
+            resource.setOutputKey(o.getOutputKey());
+            if (o.getOutputVal() != null){
+                resource.setOutputVal(new String(o.getOutputVal()));
+            }
+            resource.setDataType(o.getDataType());
+            resource.setWorkflowResource((WorkflowResource)createWorkflow(o.getWorkflow()));
+        }
+        return resource;
+    }
+
     private static Resource createGatewayProfile(GatewayProfile o) {
         GatewayProfileResource resource = new GatewayProfileResource();
         if (o != null) {
@@ -795,6 +840,9 @@ public class AppCatalogJPAUtils {
         if (o.getGraph() != null){
             workflowResource.setGraph(new String(o.getGraph()));
         }
+        if (o.getImage() != null){
+            workflowResource.setImage(new String(o.getImage()));
+        }
         workflowResource.setCreatedTime(o.getCreationTime());
         if (o.getUpdateTime() != null){
             workflowResource.setUpdatedTime(o.getUpdateTime());

http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogResourceType.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogResourceType.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogResourceType.java
index eea1426..dface72 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogResourceType.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogResourceType.java
@@ -58,5 +58,7 @@ public enum AppCatalogResourceType {
 	LOCAL_DATA_MOVEMENT,
     MODULE_LOAD_CMD,
     ClOUD_SUBMISSION,
-    WORKFLOW
+    WORKFLOW,
+    WORKFLOW_INPUT,
+    WORKFLOW_OUTPUT
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
index dc7766e..414aa6a 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
@@ -21,13 +21,6 @@
 
 package org.apache.aiaravata.application.catalog.data.util;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.airavata.appcatalog.cpi.AppCatalogException;
 import org.apache.aiaravata.application.catalog.data.resources.*;
 import org.apache.airavata.model.Workflow;
@@ -43,6 +36,8 @@ import org.apache.airavata.model.appcatalog.computeresource.*;
 import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
 import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
 
+import java.util.*;
+
 public class AppCatalogThriftConversion {
     public static ComputeResourceResource getComputeHostResource (ComputeResourceDescription
description){
         ComputeResourceResource resource = new ComputeResourceResource();
@@ -52,7 +47,7 @@ public class AppCatalogThriftConversion {
         return resource;
     }
 
-    public static ComputeResourceDescription getComputeHostDescription (ComputeResourceResource
resource) throws AppCatalogException{
+    public static ComputeResourceDescription getComputeHostDescription (ComputeResourceResource
resource) throws AppCatalogException {
         ComputeResourceDescription description = new ComputeResourceDescription();
         description.setComputeResourceId(resource.getResourceId());
         description.setHostName(resource.getHostName());
@@ -248,20 +243,20 @@ public class AppCatalogThriftConversion {
         return resource;
     }
 
-    public static LocalDataMovementResource getLocalDataMovement(LOCALDataMovement localSubmission)throws
AppCatalogException{
+    public static LocalDataMovementResource getLocalDataMovement(LOCALDataMovement localSubmission)throws
AppCatalogException {
     	LocalDataMovementResource submission = new LocalDataMovementResource();
     	submission.setDataMovementInterfaceId(localSubmission.getDataMovementInterfaceId());
     	return submission;
     }
     
-    public static LOCALDataMovement getLocalDataMovement(LocalDataMovementResource localSubmission)throws
AppCatalogException{
+    public static LOCALDataMovement getLocalDataMovement(LocalDataMovementResource localSubmission)throws
AppCatalogException {
     	LOCALDataMovement submission = new LOCALDataMovement();
     	submission.setDataMovementInterfaceId(localSubmission.getDataMovementInterfaceId());
     	return submission;
     }
     
     
-    public static LocalSubmissionResource getLocalJobSubmission(LOCALSubmission localSubmission)throws
AppCatalogException{
+    public static LocalSubmissionResource getLocalJobSubmission(LOCALSubmission localSubmission)throws
AppCatalogException {
     	LocalSubmissionResource submission = new LocalSubmissionResource();
     	submission.setJobSubmissionInterfaceId(localSubmission.getJobSubmissionInterfaceId());
     	ResourceJobManagerResource resourceJobManager = getResourceJobManager(localSubmission.getResourceJobManager());
@@ -270,7 +265,7 @@ public class AppCatalogThriftConversion {
     	return submission;
     }
     
-    public static LOCALSubmission getLocalJobSubmission(LocalSubmissionResource localSubmission)throws
AppCatalogException{
+    public static LOCALSubmission getLocalJobSubmission(LocalSubmissionResource localSubmission)throws
AppCatalogException {
     	LOCALSubmission submission = new LOCALSubmission();
     	submission.setJobSubmissionInterfaceId(localSubmission.getJobSubmissionInterfaceId());
     	submission.setResourceJobManager(getResourceJobManager(localSubmission.getResourceJobManagerResource()));
@@ -286,7 +281,7 @@ public class AppCatalogThriftConversion {
     	return r;
     }
     
-    public static ResourceJobManager getResourceJobManager(ResourceJobManagerResource manager)
throws AppCatalogException{
+    public static ResourceJobManager getResourceJobManager(ResourceJobManagerResource manager)
throws AppCatalogException {
     	ResourceJobManager r = new ResourceJobManager();
     	r.setResourceJobManagerId(manager.getResourceJobManagerId());
     	r.setJobManagerBinPath(manager.getJobManagerBinPath());
@@ -670,6 +665,26 @@ public class AppCatalogThriftConversion {
         return preferences;
     }
 
+    public static InputDataObjectType getWorkflowInput (WorkflowInputResource resource){
+        InputDataObjectType input = new InputDataObjectType();
+        input.setName(resource.getInputKey());
+        input.setApplicationArgument(resource.getAppArgument());
+        input.setType(DataType.valueOf(resource.getDataType()));
+        input.setMetaData(resource.getMetadata());
+        input.setUserFriendlyDescription(resource.getUserFriendlyDesc());
+        return input;
+    }
+
+    public static List<InputDataObjectType> getWFInputs(List<Resource> resources){
+        List<InputDataObjectType> inputResources = new ArrayList<InputDataObjectType>();
+        if (resources != null && !resources.isEmpty()){
+            for (Resource resource : resources){
+                inputResources.add(getWorkflowInput((WorkflowInputResource) resource));
+            }
+        }
+        return inputResources;
+    }
+
     public static GatewayResourceProfile getGatewayResourceProfile(GatewayProfileResource
gw, List<ComputeResourcePreference> preferences){
         GatewayResourceProfile gatewayProfile = new GatewayResourceProfile();
         gatewayProfile.setGatewayID(gw.getGatewayID());
@@ -679,11 +694,18 @@ public class AppCatalogThriftConversion {
         return gatewayProfile;
     }
 
-    public static Workflow getWorkflow (WorkflowResource resource){
+    public static Workflow getWorkflow (WorkflowResource resource) throws AppCatalogException
{
         Workflow workflow = new Workflow();
         workflow.setTemplateId(resource.getWfTemplateId());
         workflow.setGraph(resource.getGraph());
         workflow.setName(resource.getWfName());
+        if (resource.getImage() != null){
+            workflow.setImage(resource.getImage().getBytes());
+        }
+        WorkflowInputResource inputResource = new WorkflowInputResource();
+        List<Resource> resources = inputResource.get(AbstractResource.WFInputConstants.WF_TEMPLATE_ID,
resource.getWfTemplateId());
+        workflow.setWorkflowInputs(getWFInputs(resources));
+
         return workflow;
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/resources/META-INF/persistence.xml
b/modules/app-catalog/app-catalog-data/src/main/resources/META-INF/persistence.xml
index b0d5a1a..2d7770c 100644
--- a/modules/app-catalog/app-catalog-data/src/main/resources/META-INF/persistence.xml
+++ b/modules/app-catalog/app-catalog-data/src/main/resources/META-INF/persistence.xml
@@ -57,6 +57,8 @@
         <class>org.apache.aiaravata.application.catalog.data.model.LocalSubmission</class>
         <class>org.apache.aiaravata.application.catalog.data.model.LocalDataMovement</class>
         <class>org.apache.aiaravata.application.catalog.data.model.Workflow</class>
+        <class>org.apache.aiaravata.application.catalog.data.model.WorkflowInput</class>
+        <class>org.apache.aiaravata.application.catalog.data.model.WorkflowOutput</class>
         <class>org.apache.aiaravata.application.catalog.data.model.Configuration</class>
         <exclude-unlisted-classes>true</exclude-unlisted-classes>
     </persistence-unit>

http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/resources/appcatalog-derby.sql
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/resources/appcatalog-derby.sql
b/modules/app-catalog/app-catalog-data/src/main/resources/appcatalog-derby.sql
index 9129559..8f7691f 100644
--- a/modules/app-catalog/app-catalog-data/src/main/resources/appcatalog-derby.sql
+++ b/modules/app-catalog/app-catalog-data/src/main/resources/appcatalog-derby.sql
@@ -380,9 +380,34 @@ CREATE TABLE WORKFLOW
 	OWNER VARCHAR(255),
 	CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
 	UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+	IMAGE BLOB,
 	PRIMARY KEY (WF_TEMPLATE_ID)
 );
 
+CREATE TABLE WORKFLOW_INPUT
+(
+         WF_TEMPLATE_ID VARCHAR(255),
+         INPUT_KEY VARCHAR(255),
+         INPUT_VALUE CLOB,
+         DATA_TYPE VARCHAR(255),
+         METADATA VARCHAR(255),
+         APP_ARGUMENT VARCHAR(255),
+         STANDARD_INPUT SMALLINT,
+         USER_FRIENDLY_DESC VARCHAR(255),
+         PRIMARY KEY(WF_TEMPLATE_ID,INPUT_KEY),
+         FOREIGN KEY (WF_TEMPLATE_ID) REFERENCES WORKFLOW(WF_TEMPLATE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE WORKFLOW_OUTPUT
+(
+         WF_TEMPLATE_ID VARCHAR(255),
+         OUTPUT_KEY VARCHAR(255),
+         OUTPUT_VALUE CLOB,
+         DATA_TYPE VARCHAR(255),
+         PRIMARY KEY(WF_TEMPLATE_ID,OUTPUT_KEY),
+         FOREIGN KEY (WF_TEMPLATE_ID) REFERENCES WORKFLOW(WF_TEMPLATE_ID) ON DELETE CASCADE
+);
+
 CREATE TABLE CONFIGURATION
 (
         CONFIG_KEY VARCHAR(255),

http://git-wip-us.apache.org/repos/asf/airavata/blob/dbb1c97a/modules/app-catalog/app-catalog-data/src/main/resources/appcatalog-mysql.sql
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/resources/appcatalog-mysql.sql
b/modules/app-catalog/app-catalog-data/src/main/resources/appcatalog-mysql.sql
index f00fb3b..8bd0331 100644
--- a/modules/app-catalog/app-catalog-data/src/main/resources/appcatalog-mysql.sql
+++ b/modules/app-catalog/app-catalog-data/src/main/resources/appcatalog-mysql.sql
@@ -367,10 +367,35 @@ CREATE TABLE WORKFLOW
 	GRAPH LONGTEXT,
 	OWNER VARCHAR(255),
 	CREATION_TIME TIMESTAMP DEFAULT NOW(),
-    UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00' ON UPDATE now(),
+  UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00' ON UPDATE now(),
+  IMAGE BLOB,
 	PRIMARY KEY (WF_TEMPLATE_ID)
 );
 
+CREATE TABLE WORKFLOW_INPUT
+(
+         WF_TEMPLATE_ID VARCHAR(255),
+         INPUT_KEY VARCHAR(255),
+         INPUT_VALUE LONGTEXT,
+         DATA_TYPE VARCHAR(255),
+         METADATA VARCHAR(255),
+         APP_ARGUMENT VARCHAR(255),
+         STANDARD_INPUT SMALLINT,
+         USER_FRIENDLY_DESC VARCHAR(255),
+         PRIMARY KEY(WF_TEMPLATE_ID,INPUT_KEY),
+         FOREIGN KEY (WF_TEMPLATE_ID) REFERENCES WORKFLOW(WF_TEMPLATE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE WORKFLOW_OUTPUT
+(
+         WF_TEMPLATE_ID VARCHAR(255),
+         OUTPUT_KEY VARCHAR(255),
+         OUTPUT_VALUE LONGTEXT,
+         DATA_TYPE VARCHAR(255),
+         PRIMARY KEY(WF_TEMPLATE_ID,OUTPUT_KEY),
+         FOREIGN KEY (WF_TEMPLATE_ID) REFERENCES WORKFLOW(WF_TEMPLATE_ID) ON DELETE CASCADE
+);
+
 CREATE TABLE CONFIGURATION
 (
         CONFIG_KEY VARCHAR(255),


Mime
View raw message