Search in sources :

Example 1 with AppCatalogQueryGenerator

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

the class PreJobCommandResource method getIds.

public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
    List<String> gsiSSHPreJobResourceIDs = new ArrayList<String>();
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        Query q;
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
        List results;
        if (fieldName.equals(PreJobCommandConstants.DEPLOYMENT_ID)) {
            generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID, value);
            q = generator.selectQuery(em);
            results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    PreJobCommand preJobCommand = (PreJobCommand) result;
                    gsiSSHPreJobResourceIDs.add(preJobCommand.getDeploymentId());
                }
            }
        } else if (fieldName.equals(PreJobCommandConstants.COMMAND)) {
            generator.setParameter(PreJobCommandConstants.COMMAND, value);
            q = generator.selectQuery(em);
            results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    PreJobCommand preJobCommand = (PreJobCommand) result;
                    gsiSSHPreJobResourceIDs.add(preJobCommand.getDeploymentId());
                }
            }
        } else {
            em.getTransaction().commit();
            if (em.isOpen()) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                em.close();
            }
            logger.error("Unsupported field name for GSISSH Pre Job resource.", new IllegalArgumentException());
            throw new IllegalArgumentException("Unsupported field name for GSISSH Pre JOb 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 gsiSSHPreJobResourceIDs;
}
Also used : PreJobCommand(org.apache.airavata.registry.core.app.catalog.model.PreJobCommand) 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) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 2 with AppCatalogQueryGenerator

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

the class ResourceJobManagerResource method remove.

@Override
public void remove(Object identifier) throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
        generator.setParameter(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID, identifier);
        Query q = generator.deleteQuery(em);
        q.executeUpdate();
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            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();
        }
    }
}
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)

Example 3 with AppCatalogQueryGenerator

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

the class ResourceJobManagerResource method get.

@Override
public AppCatalogResource get(Object identifier) throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
        generator.setParameter(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID, identifier);
        Query q = generator.selectQuery(em);
        ResourceJobManager resourceJobManager = (ResourceJobManager) q.getSingleResult();
        ResourceJobManagerResource resourceJobManagerResource = (ResourceJobManagerResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.RESOURCE_JOB_MANAGER, resourceJobManager);
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        return resourceJobManagerResource;
    } 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) ResourceJobManager(org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)

Example 4 with AppCatalogQueryGenerator

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

the class ScpDataMovementResource method remove.

@Override
public void remove(Object identifier) throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
        generator.setParameter(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
        Query q = generator.deleteQuery(em);
        q.executeUpdate();
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            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();
        }
    }
}
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)

Example 5 with AppCatalogQueryGenerator

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

the class ScpDataMovementResource method get.

@Override
public AppCatalogResource get(Object identifier) throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
        generator.setParameter(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
        Query q = generator.selectQuery(em);
        ScpDataMovement scpDataMovement = (ScpDataMovement) q.getSingleResult();
        ScpDataMovementResource scpDataMovementResource = (ScpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SCP_DATA_MOVEMENT, scpDataMovement);
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        return scpDataMovementResource;
    } 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) ScpDataMovement(org.apache.airavata.registry.core.app.catalog.model.ScpDataMovement)

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