Search in sources :

Example 6 with GridftpDataMovement

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

the class GridftpDataMovementResource method get.

@Override
public AppCatalogResource get(Object identifier) throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_DATA_MOVEMENT);
        generator.setParameter(GridftpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
        Query q = generator.selectQuery(em);
        GridftpDataMovement gridftpDataMovement = (GridftpDataMovement) q.getSingleResult();
        GridftpDataMovementResource gridftpDataMovementResource = (GridftpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_DATA_MOVEMENT, gridftpDataMovement);
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        return gridftpDataMovementResource;
    } 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) GridftpDataMovement(org.apache.airavata.registry.core.app.catalog.model.GridftpDataMovement) Query(javax.persistence.Query) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)

Aggregations

EntityManager (javax.persistence.EntityManager)6 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)6 GridftpDataMovement (org.apache.airavata.registry.core.app.catalog.model.GridftpDataMovement)6 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)6 Query (javax.persistence.Query)3 AppCatalogQueryGenerator (org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)3 ArrayList (java.util.ArrayList)2 GridftpEndpoint (org.apache.airavata.registry.core.app.catalog.model.GridftpEndpoint)1 GridftpEndpoint_PK (org.apache.airavata.registry.core.app.catalog.model.GridftpEndpoint_PK)1