airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sach...@apache.org
Subject git commit: updating the resource layer
Date Sat, 28 Jun 2014 07:02:26 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 69be6c770 -> da5d2f3ae


updating the resource layer


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/da5d2f3a
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/da5d2f3a
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/da5d2f3a

Branch: refs/heads/master
Commit: da5d2f3ae3030a28c634b7e2e5a9a97b7a379249
Parents: 69be6c7
Author: Sachith Withana <sachith@apache.org>
Authored: Sat Jun 28 12:34:30 2014 +0530
Committer: Sachith Withana <sachith@apache.org>
Committed: Sat Jun 28 12:34:30 2014 +0530

----------------------------------------------------------------------
 .../resources/DataMovementProtocolResource.java | 331 ++++++++++++++-
 .../resources/GSISSHSubmissionResource.java     | 407 +++++++++++++++++++
 .../data/resources/HostAliasResource.java       |   4 +-
 .../data/resources/HostIPAddressResource.java   |   6 +-
 .../JobSubmissionProtocolResource.java          |  51 +--
 .../data/resources/SSHSubmissionResource.java   | 331 +++++++++++++++
 6 files changed, 1099 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/da5d2f3a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/DataMovementProtocolResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/DataMovementProtocolResource.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/DataMovementProtocolResource.java
index 6c42d49..c7cd333 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/DataMovementProtocolResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/DataMovementProtocolResource.java
@@ -1,4 +1,333 @@
 package org.apache.aiaravata.application.catalog.data.resources;
 
-public class DataMovementProtocolResource {
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.apache.aiaravata.application.catalog.data.model.ComputeResource;
+import org.apache.aiaravata.application.catalog.data.model.DataMovementProtocol;
+import org.apache.aiaravata.application.catalog.data.model.DataMovementProtocolPK;
+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 DataMovementProtocolResource extends AbstractResource {
+
+    private final static Logger logger = LoggerFactory.getLogger(DataMovementProtocolResource.class);
+
+    private String resourceID;
+    private String dataMoveID;
+    private String jobType;
+    private ComputeHostResource computeHostResource;
+
+    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(DATA_MOVEMENT_PROTOCOL);
+            generator.setParameter(DataMoveProtocolConstants.JOB_TYPE, ids.get(DataMoveProtocolConstants.JOB_TYPE));
+            generator.setParameter(DataMoveProtocolConstants.RESOURCE_ID, ids.get(DataMoveProtocolConstants.RESOURCE_ID));
+            generator.setParameter(DataMoveProtocolConstants.DATA_MOVE_ID, ids.get(DataMoveProtocolConstants.DATA_MOVE_ID));
+            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(DATA_MOVEMENT_PROTOCOL);
+            generator.setParameter(DataMoveProtocolConstants.JOB_TYPE, ids.get(DataMoveProtocolConstants.JOB_TYPE));
+            generator.setParameter(DataMoveProtocolConstants.RESOURCE_ID, ids.get(DataMoveProtocolConstants.RESOURCE_ID));
+            generator.setParameter(DataMoveProtocolConstants.DATA_MOVE_ID, ids.get(DataMoveProtocolConstants.DATA_MOVE_ID));
+            Query q = generator.selectQuery(em);
+            DataMovementProtocol dataMovementProtocol = (DataMovementProtocol) q.getSingleResult();
+            DataMovementProtocolResource dataMovementProtocolResource =
+                    (DataMovementProtocolResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_PROTOCOL, dataMovementProtocol);
+            em.getTransaction().commit();
+            em.close();
+            return dataMovementProtocolResource;
+        } 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> dataMoveProtocolResourcesList = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_PROTOCOL);
+            List results;
+            if (fieldName.equals(DataMoveProtocolConstants.RESOURCE_ID)) {
+                generator.setParameter(DataMoveProtocolConstants.RESOURCE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        DataMovementProtocol dataMovementProtocol = (DataMovementProtocol) result;
+                        DataMovementProtocolResource dataMovementProtocolResource =
+                                (DataMovementProtocolResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_PROTOCOL, dataMovementProtocol);
+                        dataMoveProtocolResourcesList.add(dataMovementProtocolResource);
+                    }
+                }
+            } else if (fieldName.equals(DataMoveProtocolConstants.JOB_TYPE)) {
+                generator.setParameter(DataMoveProtocolConstants.JOB_TYPE, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        DataMovementProtocol dataMovementProtocol = (DataMovementProtocol) result;
+                        DataMovementProtocolResource dataMovementProtocolResource =
+                                (DataMovementProtocolResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_PROTOCOL, dataMovementProtocol);
+                        dataMoveProtocolResourcesList.add(dataMovementProtocolResource);
+                    }
+                }
+            } else if (fieldName.equals(DataMoveProtocolConstants.DATA_MOVE_ID)) {
+                generator.setParameter(DataMoveProtocolConstants.DATA_MOVE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        DataMovementProtocol dataMovementProtocol = (DataMovementProtocol) result;
+                        DataMovementProtocolResource dataMovementProtocolResource =
+                                (DataMovementProtocolResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_PROTOCOL, dataMovementProtocol);
+                        dataMoveProtocolResourcesList.add(dataMovementProtocolResource);
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for Data Movement Protocol Resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for Data Movement Protocol 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 dataMoveProtocolResourcesList;
+    }
+
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+        List<String> dataMovementProtocolIDs = new ArrayList<String>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_PROTOCOL);
+            List results;
+            if (fieldName.equals(DataMoveProtocolConstants.DATA_MOVE_ID)) {
+                generator.setParameter(DataMoveProtocolConstants.DATA_MOVE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        DataMovementProtocol dataMovementProtocol = (DataMovementProtocol) result;
+                        dataMovementProtocolIDs.add(dataMovementProtocol.getDataMoveID());
+                    }
+                }
+            } else if (fieldName.equals(DataMoveProtocolConstants.RESOURCE_ID)) {
+                generator.setParameter(DataMoveProtocolConstants.RESOURCE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        DataMovementProtocol dataMovementProtocol = (DataMovementProtocol) result;
+                        dataMovementProtocolIDs.add(dataMovementProtocol.getDataMoveID());
+                    }
+                }
+            } else if (fieldName.equals(DataMoveProtocolConstants.JOB_TYPE)) {
+                generator.setParameter(DataMoveProtocolConstants.JOB_TYPE, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        DataMovementProtocol dataMovementProtocol = (DataMovementProtocol) result;
+                        dataMovementProtocolIDs.add(dataMovementProtocol.getDataMoveID());
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for Data Move Protocol resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for Data Move Protocol 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 dataMovementProtocolIDs;
+    }
+
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            DataMovementProtocol existingDataMovementProtocol = em.find(DataMovementProtocol.class, new DataMovementProtocolPK(resourceID, dataMoveID, jobType));
+            em.close();
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (existingDataMovementProtocol != null) {
+                existingDataMovementProtocol.setJobType(jobType);
+                existingDataMovementProtocol.setDataMoveID(dataMoveID);
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
+                existingDataMovementProtocol.setComputeResource(computeResource);
+                existingDataMovementProtocol.setResourceID(resourceID);
+
+                em.merge(existingDataMovementProtocol);
+            } else {
+                DataMovementProtocol dataMovementProtocol = new DataMovementProtocol();
+                dataMovementProtocol.setJobType(jobType);
+                dataMovementProtocol.setDataMoveID(dataMoveID);
+                dataMovementProtocol.setResourceID(resourceID);
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
+                dataMovementProtocol.setComputeResource(computeResource);
+
+                em.persist(dataMovementProtocol);
+            }
+            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();
+            DataMovementProtocol dataMovementProtocol = em.find(DataMovementProtocol.class, new DataMovementProtocolPK(
+                    ids.get(DataMoveProtocolConstants.RESOURCE_ID),
+                    ids.get(DataMoveProtocolConstants.DATA_MOVE_ID), ids.get(DataMoveProtocolConstants.JOB_TYPE)));
+
+            em.close();
+            return dataMovementProtocol != 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 getResourceID() {
+        return resourceID;
+    }
+
+    public void setResourceID(String resourceID) {
+        this.resourceID = resourceID;
+    }
+
+    public String getDataMoveID() {
+        return dataMoveID;
+    }
+
+    public void setDataMoveID(String dataMoveID) {
+        this.dataMoveID = dataMoveID;
+    }
+
+    public String getJobType() {
+        return jobType;
+    }
+
+    public void setJobType(String jobType) {
+        this.jobType = jobType;
+    }
+
+    public ComputeHostResource getComputeHostResource() {
+        return computeHostResource;
+    }
+
+    public void setComputeHostResource(ComputeHostResource computeHostResource) {
+        this.computeHostResource = computeHostResource;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/da5d2f3a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/GSISSHSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/GSISSHSubmissionResource.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/GSISSHSubmissionResource.java
new file mode 100644
index 0000000..caecaf4
--- /dev/null
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/GSISSHSubmissionResource.java
@@ -0,0 +1,407 @@
+package org.apache.aiaravata.application.catalog.data.resources;
+
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.apache.aiaravata.application.catalog.data.model.ComputeResource;
+import org.apache.aiaravata.application.catalog.data.model.GSISSHSubmission;
+import org.apache.aiaravata.application.catalog.data.model.SSHSubmission;
+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.List;
+
+public class GSISSHSubmissionResource extends AbstractResource {
+
+    private final static Logger logger = LoggerFactory.getLogger(GSISSHSubmissionResource.class);
+
+    private String resourceID;
+    private String submissionID;
+    private String resourceJobManager;
+    private int sshPort;
+    private String installedPath;
+    private String monitorMode;
+
+    private ComputeHostResource computeHostResource;
+
+    public void remove(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
+            generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, identifier);
+            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 {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
+            generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, identifier);
+            Query q = generator.selectQuery(em);
+            GSISSHSubmission gsisshSubmission = (GSISSHSubmission) q.getSingleResult();
+            GSISSHSubmissionResource gsisshSubmissionResource =
+                    (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_SUBMISSION
+                            , gsisshSubmission);
+            em.getTransaction().commit();
+            em.close();
+            return gsisshSubmissionResource;
+        } 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> gsiSSHSubmissionResourceList = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
+            List results;
+            if (fieldName.equals(GSISSHSubmissionConstants.SUBMISSION_ID)) {
+                generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        GSISSHSubmissionResource gsisshSubmissionResource =
+                                (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
+                        gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
+                    }
+                }
+            } else if (fieldName.equals(GSISSHSubmissionConstants.RESOURCE_ID)) {
+                generator.setParameter(GSISSHSubmissionConstants.RESOURCE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        GSISSHSubmissionResource gsisshSubmissionResource =
+                                (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
+                        gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
+                    }
+                }
+            }else if (fieldName.equals(GSISSHSubmissionConstants.MONITOR_MODE)) {
+                generator.setParameter(GSISSHSubmissionConstants.MONITOR_MODE, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        GSISSHSubmissionResource gsisshSubmissionResource =
+                                (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
+                        gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
+                    }
+                }
+            }else if (fieldName.equals(GSISSHSubmissionConstants.INSTALLED_PATH)) {
+                generator.setParameter(GSISSHSubmissionConstants.INSTALLED_PATH, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        GSISSHSubmissionResource gsisshSubmissionResource =
+                                (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
+                        gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
+                    }
+                }
+            }else if (fieldName.equals(GSISSHSubmissionConstants.SSH_PORT)) {
+                generator.setParameter(GSISSHSubmissionConstants.SSH_PORT, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        GSISSHSubmissionResource gsisshSubmissionResource =
+                                (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
+                        gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
+                    }
+                }
+            } else if (fieldName.equals(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER)) {
+                generator.setParameter(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        GSISSHSubmissionResource gsisshSubmissionResource =
+                                (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(
+                                        AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
+                        gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
+                    }
+                }
+            }else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for GSISSH submission resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for GSISSH Submission 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 gsiSSHSubmissionResourceList;
+    }
+
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+        List<String> gsiSSHSubmissionResourceIDs = new ArrayList<String>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
+            List results;
+            if (fieldName.equals(GSISSHSubmissionConstants.SUBMISSION_ID)) {
+                generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+                    }
+                }
+            }else if (fieldName.equals(GSISSHSubmissionConstants.SSH_PORT)) {
+                generator.setParameter(GSISSHSubmissionConstants.SSH_PORT, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+                    }
+                }
+            }else if (fieldName.equals(GSISSHSubmissionConstants.MONITOR_MODE)) {
+                generator.setParameter(GSISSHSubmissionConstants.MONITOR_MODE, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+                    }
+                }
+            }else if (fieldName.equals(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER)) {
+                generator.setParameter(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+                    }
+                }
+            }else if (fieldName.equals(GSISSHSubmissionConstants.INSTALLED_PATH)) {
+                generator.setParameter(GSISSHSubmissionConstants.INSTALLED_PATH, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+                    }
+                }
+            }else if (fieldName.equals(GSISSHSubmissionConstants.RESOURCE_ID)) {
+                generator.setParameter(GSISSHSubmissionConstants.RESOURCE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+                        gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+                    }
+                }
+            }  else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for GSISSH Submission resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for GSISSH Submission 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 gsiSSHSubmissionResourceIDs;
+    }
+
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            GSISSHSubmission existingGSISSHSubmission = em.find(GSISSHSubmission.class, submissionID);
+            em.close();
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (existingGSISSHSubmission !=  null){
+                existingGSISSHSubmission.setSubmissionID(submissionID);
+                existingGSISSHSubmission.setResourceID(resourceID);
+                existingGSISSHSubmission.setSshPort(sshPort);
+                existingGSISSHSubmission.setResourceJobManager(resourceJobManager);
+                existingGSISSHSubmission.setInstalledPath(installedPath);
+                existingGSISSHSubmission.setMonitorMode(monitorMode);
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
+                existingGSISSHSubmission.setComputeResource(computeResource);
+
+                em.merge(existingGSISSHSubmission);
+            }else {
+                GSISSHSubmission gsisshSubmission = new GSISSHSubmission();
+                gsisshSubmission.setResourceID(resourceID);
+                gsisshSubmission.setSubmissionID(submissionID);
+                gsisshSubmission.setSshPort(sshPort);
+                gsisshSubmission.setResourceJobManager(resourceJobManager);
+                gsisshSubmission.setInstalledPath(installedPath);
+                gsisshSubmission.setMonitorMode(monitorMode);
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
+                gsisshSubmission.setComputeResource(computeResource);
+                em.persist(gsisshSubmission);
+            }
+            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 {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            GSISSHSubmission gsisshSubmission = em.find(GSISSHSubmission.class, identifier);
+            em.close();
+            return gsisshSubmission != 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 getResourceID() {
+        return resourceID;
+    }
+
+    public void setResourceID(String resourceID) {
+        this.resourceID = resourceID;
+    }
+
+    public String getSubmissionID() {
+        return submissionID;
+    }
+
+    public void setSubmissionID(String submissionID) {
+        this.submissionID = submissionID;
+    }
+
+    public String getResourceJobManager() {
+        return resourceJobManager;
+    }
+
+    public void setResourceJobManager(String resourceJobManager) {
+        this.resourceJobManager = resourceJobManager;
+    }
+
+    public int getSshPort() {
+        return sshPort;
+    }
+
+    public void setSshPort(int sshPort) {
+        this.sshPort = sshPort;
+    }
+
+    public String getInstalledPath() {
+        return installedPath;
+    }
+
+    public void setInstalledPath(String installedPath) {
+        this.installedPath = installedPath;
+    }
+
+    public String getMonitorMode() {
+        return monitorMode;
+    }
+
+    public void setMonitorMode(String monitorMode) {
+        this.monitorMode = monitorMode;
+    }
+
+    public ComputeHostResource getComputeHostResource() {
+        return computeHostResource;
+    }
+
+    public void setComputeHostResource(ComputeHostResource computeHostResource) {
+        this.computeHostResource = computeHostResource;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/da5d2f3a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/HostAliasResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/HostAliasResource.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/HostAliasResource.java
index 54cd61a..3f0201a 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/HostAliasResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/HostAliasResource.java
@@ -211,7 +211,7 @@ public class HostAliasResource extends AbstractResource {
             em.getTransaction().begin();
             if (existingHostAlias !=  null){
                 existingHostAlias.setAlias(alias);
-                ComputeResource computeResource = em.find(ComputeResource.class, computeHostResource.getResoureId());
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
                 existingHostAlias.setComputeResource(computeResource);
                 existingHostAlias.setResourceID(resourceID);
 
@@ -220,7 +220,7 @@ public class HostAliasResource extends AbstractResource {
                 HostAlias hostAlias = new HostAlias();
                 hostAlias.setAlias(alias);
                 hostAlias.setResourceID(resourceID);
-                ComputeResource computeResource = em.find(ComputeResource.class, computeHostResource.getResoureId());
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
                 hostAlias.setComputeResource(computeResource);
 
                 em.persist(hostAlias);

http://git-wip-us.apache.org/repos/asf/airavata/blob/da5d2f3a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/HostIPAddressResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/HostIPAddressResource.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/HostIPAddressResource.java
index 5ad6562..888fae4 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/HostIPAddressResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/HostIPAddressResource.java
@@ -215,16 +215,16 @@ public class HostIPAddressResource extends AbstractResource{
             em.getTransaction().begin();
             if (existingHostIP !=  null){
                 existingHostIP.setIpaddress(ipaddress);
-                ComputeResource computeResource = em.find(ComputeResource.class, computeHostResource.getResoureId());
-                existingHostIP.setComputeResource(computeResource);
                 existingHostIP.setResourceID(resourceID);
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
+                existingHostIP.setComputeResource(computeResource);
 
                 em.merge(existingHostIP);
             }else {
                 HostIPAddress hostIPAddress = new HostIPAddress();
                 hostIPAddress.setIpaddress(ipaddress);
                 hostIPAddress.setResourceID(resourceID);
-                ComputeResource computeResource = em.find(ComputeResource.class, computeHostResource.getResoureId());
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
                 hostIPAddress.setComputeResource(computeResource);
 
                 em.persist(hostIPAddress);

http://git-wip-us.apache.org/repos/asf/airavata/blob/da5d2f3a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/JobSubmissionProtocolResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/JobSubmissionProtocolResource.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/JobSubmissionProtocolResource.java
index a9e2517..a84131b 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/JobSubmissionProtocolResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/JobSubmissionProtocolResource.java
@@ -29,9 +29,9 @@ public class JobSubmissionProtocolResource extends AbstractResource {
 
     public void remove(Object identifier) throws AppCatalogException {
         HashMap<String, String> ids;
-        if (identifier instanceof Map){
-            ids = (HashMap)identifier;
-        }else {
+        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");
         }
@@ -40,7 +40,7 @@ public class JobSubmissionProtocolResource extends AbstractResource {
         try {
             em = AppCatalogJPAUtils.getEntityManager();
             em.getTransaction().begin();
-            AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(JOB_SUBMISSION_PROTOCOL);
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_PROTOCOL);
             generator.setParameter(JobSubmissionProtocolConstants.RESOURCE_ID, ids.get(JobSubmissionProtocolConstants.RESOURCE_ID));
             generator.setParameter(JobSubmissionProtocolConstants.SUBMISSION_ID, ids.get(JobSubmissionProtocolConstants.SUBMISSION_ID));
             generator.setParameter(JobSubmissionProtocolConstants.JOB_TYPE, ids.get(JobSubmissionProtocolConstants.JOB_TYPE));
@@ -53,7 +53,7 @@ public class JobSubmissionProtocolResource extends AbstractResource {
             throw new AppCatalogException(e);
         } finally {
             if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
+                if (em.getTransaction().isActive()) {
                     em.getTransaction().rollback();
                 }
                 em.close();
@@ -63,9 +63,9 @@ public class JobSubmissionProtocolResource extends AbstractResource {
 
     public Resource get(Object identifier) throws AppCatalogException {
         HashMap<String, String> ids;
-        if (identifier instanceof Map){
-            ids = (HashMap)identifier;
-        }else {
+        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");
         }
@@ -119,7 +119,7 @@ public class JobSubmissionProtocolResource extends AbstractResource {
                         jobSubmissionProtocolResourceList.add(jobSubmissionProtocolResource);
                     }
                 }
-            }else if (fieldName.equals(JobSubmissionProtocolConstants.JOB_TYPE)) {
+            } else if (fieldName.equals(JobSubmissionProtocolConstants.JOB_TYPE)) {
                 generator.setParameter(JobSubmissionProtocolConstants.JOB_TYPE, value);
                 q = generator.selectQuery(em);
                 results = q.getResultList();
@@ -131,7 +131,7 @@ public class JobSubmissionProtocolResource extends AbstractResource {
                         jobSubmissionProtocolResourceList.add(jobSubmissionProtocolResource);
                     }
                 }
-            }else if (fieldName.equals(HostIPAddressConstants.RESOURCE_ID)) {
+            } else if (fieldName.equals(HostIPAddressConstants.RESOURCE_ID)) {
                 generator.setParameter(HostIPAddressConstants.RESOURCE_ID, value);
                 q = generator.selectQuery(em);
                 results = q.getResultList();
@@ -181,7 +181,7 @@ public class JobSubmissionProtocolResource extends AbstractResource {
                 if (results.size() != 0) {
                     for (Object result : results) {
                         JobSubmissionProtocol jobSubmissionProtocol = (JobSubmissionProtocol) result;
-                        jobSubmissionProtocolIDs.add(jobSubmissionProtocol.getResourceID());
+                        jobSubmissionProtocolIDs.add(jobSubmissionProtocol.getSubmissionID());
                     }
                 }
             } else if (fieldName.equals(JobSubmissionProtocolConstants.RESOURCE_ID)) {
@@ -191,17 +191,17 @@ public class JobSubmissionProtocolResource extends AbstractResource {
                 if (results.size() != 0) {
                     for (Object result : results) {
                         JobSubmissionProtocol jobSubmissionProtocol = (JobSubmissionProtocol) result;
-                        jobSubmissionProtocolIDs.add(jobSubmissionProtocol.getResourceID());
+                        jobSubmissionProtocolIDs.add(jobSubmissionProtocol.getSubmissionID());
                     }
                 }
-            }else if (fieldName.equals(JobSubmissionProtocolConstants.JOB_TYPE)) {
+            } else if (fieldName.equals(JobSubmissionProtocolConstants.JOB_TYPE)) {
                 generator.setParameter(JobSubmissionProtocolConstants.JOB_TYPE, value);
                 q = generator.selectQuery(em);
                 results = q.getResultList();
                 if (results.size() != 0) {
                     for (Object result : results) {
                         JobSubmissionProtocol jobSubmissionProtocol = (JobSubmissionProtocol) result;
-                        jobSubmissionProtocolIDs.add(jobSubmissionProtocol.getResourceID());
+                        jobSubmissionProtocolIDs.add(jobSubmissionProtocol.getSubmissionID());
                     }
                 }
             } else {
@@ -223,31 +223,32 @@ public class JobSubmissionProtocolResource extends AbstractResource {
                 em.close();
             }
         }
-        return jobSubmissionProtocolIDs;    }
+        return jobSubmissionProtocolIDs;
+    }
 
     public void save() throws AppCatalogException {
         EntityManager em = null;
         try {
             em = AppCatalogJPAUtils.getEntityManager();
-            JobSubmissionProtocol existingJobSubProtocol = em.find(JobSubmissionProtocol.class, new JobSubmissionProtocolPK(resourceID,submissionID,jobType));
+            JobSubmissionProtocol existingJobSubProtocol = em.find(JobSubmissionProtocol.class, new JobSubmissionProtocolPK(resourceID, submissionID, jobType));
             em.close();
 
             em = AppCatalogJPAUtils.getEntityManager();
             em.getTransaction().begin();
-            if (existingJobSubProtocol !=  null){
+            if (existingJobSubProtocol != null) {
                 existingJobSubProtocol.setJobType(jobType);
                 existingJobSubProtocol.setSubmissionID(submissionID);
-                ComputeResource computeResource = em.find(ComputeResource.class, computeHostResource.getResoureId());
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
                 existingJobSubProtocol.setComputeResource(computeResource);
                 existingJobSubProtocol.setResourceID(resourceID);
 
                 em.merge(existingJobSubProtocol);
-            }else {
+            } else {
                 JobSubmissionProtocol jobSubmissionProtocol = new JobSubmissionProtocol();
                 jobSubmissionProtocol.setJobType(jobType);
                 jobSubmissionProtocol.setSubmissionID(submissionID);
                 jobSubmissionProtocol.setResourceID(resourceID);
-                ComputeResource computeResource = em.find(ComputeResource.class, computeHostResource.getResoureId());
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
                 jobSubmissionProtocol.setComputeResource(computeResource);
 
                 em.persist(jobSubmissionProtocol);
@@ -259,7 +260,7 @@ public class JobSubmissionProtocolResource extends AbstractResource {
             throw new AppCatalogException(e);
         } finally {
             if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
+                if (em.getTransaction().isActive()) {
                     em.getTransaction().rollback();
                 }
                 em.close();
@@ -270,9 +271,9 @@ public class JobSubmissionProtocolResource extends AbstractResource {
 
     public boolean isExists(Object identifier) throws AppCatalogException {
         HashMap<String, String> ids;
-        if (identifier instanceof Map){
-            ids = (HashMap)identifier;
-        }else {
+        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");
         }
@@ -281,7 +282,7 @@ public class JobSubmissionProtocolResource extends AbstractResource {
         try {
             em = AppCatalogJPAUtils.getEntityManager();
             JobSubmissionProtocol jobSubmissionProtocol = em.find(JobSubmissionProtocol.class, new JobSubmissionProtocolPK(ids.get(JobSubmissionProtocolConstants.RESOURCE_ID),
-                    ids.get(JobSubmissionProtocolConstants.SUBMISSION_ID),ids.get(JobSubmissionProtocolConstants.JOB_TYPE)));
+                    ids.get(JobSubmissionProtocolConstants.SUBMISSION_ID), ids.get(JobSubmissionProtocolConstants.JOB_TYPE)));
 
             em.close();
             return jobSubmissionProtocol != null;

http://git-wip-us.apache.org/repos/asf/airavata/blob/da5d2f3a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/SSHSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/SSHSubmissionResource.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/SSHSubmissionResource.java
new file mode 100644
index 0000000..b29c64c
--- /dev/null
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/SSHSubmissionResource.java
@@ -0,0 +1,331 @@
+package org.apache.aiaravata.application.catalog.data.resources;
+
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.apache.aiaravata.application.catalog.data.model.ComputeResource;
+import org.apache.aiaravata.application.catalog.data.model.SSHSubmission;
+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.List;
+
+public class SSHSubmissionResource extends AbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(SSHSubmissionResource.class);
+
+    private String resourceID;
+    private String submissionID;
+    private String resourceJobManager;
+    private int sshPort;
+    private ComputeHostResource computeHostResource;
+
+
+    public void remove(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_SUBMISSION);
+            generator.setParameter(SSHSubmissionConstants.SUBMISSION_ID, identifier);
+            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 {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_SUBMISSION);
+            generator.setParameter(SSHSubmissionConstants.SUBMISSION_ID, identifier);
+            Query q = generator.selectQuery(em);
+            SSHSubmission sshSubmission = (SSHSubmission) q.getSingleResult();
+            SSHSubmissionResource sshSubmissionResource =
+                    (SSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_SUBMISSION, sshSubmission);
+            em.getTransaction().commit();
+            em.close();
+            return sshSubmissionResource;
+        } 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> sshSubmissionResourceList = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_SUBMISSION);
+            List results;
+            if (fieldName.equals(SSHSubmissionConstants.SUBMISSION_ID)) {
+                generator.setParameter(SSHSubmissionConstants.SUBMISSION_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        SSHSubmission sshSubmission = (SSHSubmission) result;
+                        SSHSubmissionResource sshSubmissionResource =
+                                (SSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_SUBMISSION, sshSubmission);
+                        sshSubmissionResourceList.add(sshSubmissionResource);
+                    }
+                }
+            } else if (fieldName.equals(SSHSubmissionConstants.RESOURCE_ID)) {
+                generator.setParameter(SSHSubmissionConstants.RESOURCE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        SSHSubmission sshSubmission = (SSHSubmission) result;
+                        SSHSubmissionResource sshSubmissionResource =
+                                (SSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_SUBMISSION, sshSubmission);
+                        sshSubmissionResourceList.add(sshSubmissionResource);
+                    }
+                }
+            } else if (fieldName.equals(SSHSubmissionConstants.SSH_PORT)) {
+                generator.setParameter(SSHSubmissionConstants.SSH_PORT, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        SSHSubmission sshSubmission = (SSHSubmission) result;
+                        SSHSubmissionResource sshSubmissionResource =
+                                (SSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_SUBMISSION, sshSubmission);
+                        sshSubmissionResourceList.add(sshSubmissionResource);
+                    }
+                }
+            } else if (fieldName.equals(SSHSubmissionConstants.RESOURCE_JOB_MANAGER)) {
+                generator.setParameter(SSHSubmissionConstants.RESOURCE_JOB_MANAGER, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        SSHSubmission sshSubmission = (SSHSubmission) result;
+                        SSHSubmissionResource sshSubmissionResource =
+                                (SSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_SUBMISSION, sshSubmission);
+                        sshSubmissionResourceList.add(sshSubmissionResource);
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for SSH submission resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for SSH Submission 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 sshSubmissionResourceList;
+    }
+
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+        List<String> sshSubmissionResourceIDs = new ArrayList<String>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_SUBMISSION);
+            List results;
+            if (fieldName.equals(SSHSubmissionConstants.SUBMISSION_ID)) {
+                generator.setParameter(SSHSubmissionConstants.SUBMISSION_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        SSHSubmission sshSubmission = (SSHSubmission) result;
+                        sshSubmissionResourceIDs.add(sshSubmission.getSubmissionID());
+                    }
+                }
+            } else if (fieldName.equals(SSHSubmissionConstants.RESOURCE_ID)) {
+                generator.setParameter(SSHSubmissionConstants.RESOURCE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        SSHSubmission sshSubmission = (SSHSubmission) result;
+                        sshSubmissionResourceIDs.add(sshSubmission.getSubmissionID());
+                    }
+                }
+            }else if (fieldName.equals(SSHSubmissionConstants.RESOURCE_JOB_MANAGER)) {
+                generator.setParameter(SSHSubmissionConstants.RESOURCE_JOB_MANAGER, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        SSHSubmission sshSubmission = (SSHSubmission) result;
+                        sshSubmissionResourceIDs.add(sshSubmission.getSubmissionID());
+                    }
+                }
+            }else if (fieldName.equals(SSHSubmissionConstants.SSH_PORT)) {
+                generator.setParameter(SSHSubmissionConstants.SSH_PORT, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        SSHSubmission sshSubmission = (SSHSubmission) result;
+                        sshSubmissionResourceIDs.add(sshSubmission.getSubmissionID());
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported field name for SSH Submission resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for SSH Submission 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 sshSubmissionResourceIDs;
+    }
+
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            SSHSubmission existingSSHSubmission = em.find(SSHSubmission.class, submissionID);
+            em.close();
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (existingSSHSubmission !=  null){
+                existingSSHSubmission.setSubmissionID(submissionID);
+                existingSSHSubmission.setResourceID(resourceID);
+                existingSSHSubmission.setSshPort(sshPort);
+                existingSSHSubmission.setResourceJobManager(resourceJobManager);
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
+                existingSSHSubmission.setComputeResource(computeResource);
+
+                em.merge(existingSSHSubmission);
+            }else {
+                SSHSubmission sshSubmission = new SSHSubmission();
+                sshSubmission.setResourceID(resourceID);
+                sshSubmission.setSubmissionID(submissionID);
+                sshSubmission.setSshPort(sshPort);
+                sshSubmission.setResourceJobManager(resourceJobManager);
+                ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
+                sshSubmission.setComputeResource(computeResource);
+                em.persist(sshSubmission);
+            }
+            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 {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            SSHSubmission sshSubmission = em.find(SSHSubmission.class, identifier);
+            em.close();
+            return sshSubmission != 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 getResourceID() {
+        return resourceID;
+    }
+
+    public void setResourceID(String resourceID) {
+        this.resourceID = resourceID;
+    }
+
+    public String getSubmissionID() {
+        return submissionID;
+    }
+
+    public void setSubmissionID(String submissionID) {
+        this.submissionID = submissionID;
+    }
+
+    public String getResourceJobManager() {
+        return resourceJobManager;
+    }
+
+    public void setResourceJobManager(String resourceJobManager) {
+        this.resourceJobManager = resourceJobManager;
+    }
+
+    public int getSshPort() {
+        return sshPort;
+    }
+
+    public void setSshPort(int sshPort) {
+        this.sshPort = sshPort;
+    }
+
+    public ComputeHostResource getComputeHostResource() {
+        return computeHostResource;
+    }
+
+    public void setComputeHostResource(ComputeHostResource computeHostResource) {
+        this.computeHostResource = computeHostResource;
+    }
+}


Mime
View raw message