Search in sources :

Example 1 with GlobusJobSubmission

use of org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission in project airavata by apache.

the class UnicoreJobSubmissionResource 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) ArrayList(java.util.ArrayList) List(java.util.List) 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)

Example 2 with GlobusJobSubmission

use of org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission in project airavata by apache.

the class GlobusGKEndpointResource method save.

public void save() throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        GlobusGKEndpoint existingGlobusEP = em.find(GlobusGKEndpoint.class, new GlobusGKEndPointPK(submissionID, endpoint));
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        GlobusJobSubmission globusJobSubmission = em.find(GlobusJobSubmission.class, submissionID);
        if (existingGlobusEP != null) {
            existingGlobusEP.setSubmissionID(submissionID);
            existingGlobusEP.setEndpoint(endpoint);
            existingGlobusEP.setGlobusSubmission(globusJobSubmission);
            em.merge(existingGlobusEP);
        } else {
            GlobusGKEndpoint globusGKEndpoint = new GlobusGKEndpoint();
            globusGKEndpoint.setSubmissionID(submissionID);
            globusGKEndpoint.setEndpoint(endpoint);
            globusGKEndpoint.setGlobusSubmission(globusJobSubmission);
            em.persist(globusGKEndpoint);
        }
        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();
        }
    }
}
Also used : EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) GlobusGKEndPointPK(org.apache.airavata.registry.core.app.catalog.model.GlobusGKEndPointPK) GlobusJobSubmission(org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission) GlobusGKEndpoint(org.apache.airavata.registry.core.app.catalog.model.GlobusGKEndpoint) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 3 with GlobusJobSubmission

use of org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission in project airavata by apache.

the class GlobusJobSubmissionResource method save.

public void save() throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        GlobusJobSubmission existingGlobusSubmission = em.find(GlobusJobSubmission.class, submissionID);
        em.close();
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        if (existingGlobusSubmission != null) {
            existingGlobusSubmission.setSubmissionID(submissionID);
            existingGlobusSubmission.setResourceJobManager(resourceJobManager);
            existingGlobusSubmission.setSecurityProtocol(securityProtocol);
            em.merge(existingGlobusSubmission);
        } else {
            GlobusJobSubmission globusJobSubmission = new GlobusJobSubmission();
            globusJobSubmission.setSubmissionID(submissionID);
            globusJobSubmission.setSecurityProtocol(securityProtocol);
            globusJobSubmission.setResourceJobManager(resourceJobManager);
            em.persist(globusJobSubmission);
        }
        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();
        }
    }
}
Also used : EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) GlobusJobSubmission(org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 4 with GlobusJobSubmission

use of org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission 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 5 with GlobusJobSubmission

use of org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission 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)7 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)7 GlobusJobSubmission (org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission)7 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)7 Query (javax.persistence.Query)4 AppCatalogQueryGenerator (org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 GlobusGKEndPointPK (org.apache.airavata.registry.core.app.catalog.model.GlobusGKEndPointPK)1 GlobusGKEndpoint (org.apache.airavata.registry.core.app.catalog.model.GlobusGKEndpoint)1