Search in sources :

Example 61 with AppCatalogQueryGenerator

use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.

the class GSISSHSubmissionResource method getIds.

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 {
            em.getTransaction().commit();
            if (em.isOpen()) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                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();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            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;
}
Also used : EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) GSISSHSubmission(org.apache.airavata.registry.core.app.catalog.model.GSISSHSubmission) Query(javax.persistence.Query) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 62 with AppCatalogQueryGenerator

use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.

the class GSISSHSubmissionResource method get.

public AppCatalogResource 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();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            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();
        }
    }
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) GSISSHSubmission(org.apache.airavata.registry.core.app.catalog.model.GSISSHSubmission) Query(javax.persistence.Query) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)

Example 63 with AppCatalogQueryGenerator

use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.

the class GlobusGKEndpointResource method get.

public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
    List<AppCatalogResource> resources = new ArrayList<AppCatalogResource>();
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        Query q;
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_GK_ENDPOINT);
        List results;
        if (fieldName.equals(GlobusEPConstants.ENDPOINT)) {
            generator.setParameter(GlobusEPConstants.ENDPOINT, value);
            q = generator.selectQuery(em);
            results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    GlobusGKEndpoint gkEndpoint = (GlobusGKEndpoint) result;
                    GlobusGKEndpointResource gkEndpointResource = (GlobusGKEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, gkEndpoint);
                    resources.add(gkEndpointResource);
                }
            }
        } else if (fieldName.equals(GlobusEPConstants.SUBMISSION_ID)) {
            generator.setParameter(GlobusEPConstants.SUBMISSION_ID, value);
            q = generator.selectQuery(em);
            results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    GlobusGKEndpoint globusGKEndpoint = (GlobusGKEndpoint) result;
                    GlobusGKEndpointResource gkEndpointResource = (GlobusGKEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, globusGKEndpoint);
                    resources.add(gkEndpointResource);
                }
            }
        } else {
            em.getTransaction().commit();
            if (em.isOpen()) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                em.close();
            }
            logger.error("Unsupported field name for Globus Endpoint Resource.", new IllegalArgumentException());
            throw new IllegalArgumentException("Unsupported field name for Globus Endpoint Resource.");
        }
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            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 resources;
}
Also used : Query(javax.persistence.Query) ArrayList(java.util.ArrayList) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ArrayList(java.util.ArrayList) List(java.util.List) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator) GlobusGKEndpoint(org.apache.airavata.registry.core.app.catalog.model.GlobusGKEndpoint)

Example 64 with AppCatalogQueryGenerator

use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.

the class GlobusJobSubmissionResource method get.

public AppCatalogResource get(Object identifier) throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
        generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, identifier);
        Query q = generator.selectQuery(em);
        GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) q.getSingleResult();
        GlobusJobSubmissionResource globusJobSubmissionResource = (GlobusJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_SUBMISSION, globusJobSubmission);
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        return globusJobSubmissionResource;
    } 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();
        }
    }
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) Query(javax.persistence.Query) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator) GlobusJobSubmission(org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission)

Example 65 with AppCatalogQueryGenerator

use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.

the class GlobusJobSubmissionResource method getIds.

public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
    List<String> globusSubmissionResourceIDs = new ArrayList<String>();
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        Query q;
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
        List results;
        if (fieldName.equals(GlobusJobSubmissionConstants.SUBMISSION_ID)) {
            generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, value);
            q = generator.selectQuery(em);
            results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
                    globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
                }
            }
        } else if (fieldName.equals(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP)) {
            generator.setParameter(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP, value);
            q = generator.selectQuery(em);
            results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
                    globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
                }
            }
        } else if (fieldName.equals(GlobusJobSubmissionConstants.SECURITY_PROTOCAL)) {
            generator.setParameter(GlobusJobSubmissionConstants.SECURITY_PROTOCAL, value);
            q = generator.selectQuery(em);
            results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
                    globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
                }
            }
        } else if (fieldName.equals(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER)) {
            generator.setParameter(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER, value);
            q = generator.selectQuery(em);
            results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
                    globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
                }
            }
        } else {
            em.getTransaction().commit();
            if (em.isOpen()) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                em.close();
            }
            logger.error("Unsupported field name for Globus Submission resource.", new IllegalArgumentException());
            throw new IllegalArgumentException("Unsupported field name for Globus Submission resource.");
        }
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            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 globusSubmissionResourceIDs;
}
Also used : EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) Query(javax.persistence.Query) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator) GlobusJobSubmission(org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Aggregations

EntityManager (javax.persistence.EntityManager)176 Query (javax.persistence.Query)176 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)176 AppCatalogQueryGenerator (org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)176 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)176 ArrayList (java.util.ArrayList)80 List (java.util.List)41 HashMap (java.util.HashMap)36 Map (java.util.Map)36 CompositeIdentifier (org.apache.airavata.registry.cpi.CompositeIdentifier)10 ApplicationDeployment (org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment)5 ApplicationInterface (org.apache.airavata.registry.core.app.catalog.model.ApplicationInterface)5 ComputeResource (org.apache.airavata.registry.core.app.catalog.model.ComputeResource)5 StorageResource (org.apache.airavata.registry.core.app.catalog.model.StorageResource)5 ApplicationModule (org.apache.airavata.registry.core.app.catalog.model.ApplicationModule)4 GatewayProfile (org.apache.airavata.registry.core.app.catalog.model.GatewayProfile)4 GlobusJobSubmission (org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission)4 UserResourceProfile (org.apache.airavata.registry.core.app.catalog.model.UserResourceProfile)4 ApplicationIntInput (org.apache.airavata.registry.core.app.catalog.model.ApplicationIntInput)3 ApplicationIntOutput (org.apache.airavata.registry.core.app.catalog.model.ApplicationIntOutput)3