Search in sources :

Example 11 with SchedulerServiceDatabaseException

use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.

the class SchedulerServiceDatabaseImpl method countEvents.

public int countEvents() throws SchedulerServiceDatabaseException {
    EntityManager em = emf.createEntityManager();
    Query query = em.createNamedQuery("Event.countAll");
    try {
        Number total = (Number) query.getSingleResult();
        return total.intValue();
    } catch (Exception e) {
        logger.error("Could not find the number of events.", e);
        throw new SchedulerServiceDatabaseException(e);
    } finally {
        em.close();
    }
}
Also used : SchedulerServiceDatabaseException(org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException) EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException) SchedulerServiceDatabaseException(org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException)

Example 12 with SchedulerServiceDatabaseException

use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.

the class SchedulerServiceDatabaseImpl method getTransactionLastModified.

@Override
public Date getTransactionLastModified(String id) throws NotFoundException, SchedulerServiceDatabaseException {
    EntityManager em = null;
    try {
        em = emf.createEntityManager();
        Opt<TransactionDto> entity = getTransactionDto(id, em);
        if (entity.isNone())
            throw new NotFoundException("Transaction with ID " + id + " does not exist");
        return entity.get().getLastModifiedDate();
    } catch (NotFoundException e) {
        throw e;
    } catch (Exception e) {
        logger.error("Could not retrieve last modified date for transaction with id '{}': {}", id, getStackTrace(e));
        throw new SchedulerServiceDatabaseException(e);
    } finally {
        if (em != null)
            em.close();
    }
}
Also used : SchedulerServiceDatabaseException(org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException) EntityManager(javax.persistence.EntityManager) NotFoundException(org.opencastproject.util.NotFoundException) NoResultException(javax.persistence.NoResultException) SchedulerServiceDatabaseException(org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException)

Example 13 with SchedulerServiceDatabaseException

use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.

the class SchedulerServiceDatabaseImpl method countUnconfirmedResponses.

public long countUnconfirmedResponses() throws SchedulerServiceDatabaseException {
    EntityManager em = null;
    try {
        em = emf.createEntityManager();
        Query q = em.createNamedQuery("ExtendedEvent.countUnconfirmed");
        Number countResult = (Number) q.getSingleResult();
        return countResult.longValue();
    } catch (Exception e) {
        throw new SchedulerServiceDatabaseException(e);
    } finally {
        if (em != null)
            em.close();
    }
}
Also used : SchedulerServiceDatabaseException(org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException) EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException) SchedulerServiceDatabaseException(org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException)

Example 14 with SchedulerServiceDatabaseException

use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.

the class SchedulerServiceDatabaseImpl method countDailyConfirmedResponses.

public long countDailyConfirmedResponses() throws SchedulerServiceDatabaseException {
    EntityManager em = null;
    try {
        em = emf.createEntityManager();
        Query q = em.createNamedQuery("ExtendedEvent.countConfirmedByDateRange");
        setDateForDailyQuery(q);
        Number countResult = (Number) q.getSingleResult();
        return countResult.longValue();
    } catch (Exception e) {
        throw new SchedulerServiceDatabaseException(e);
    } finally {
        if (em != null)
            em.close();
    }
}
Also used : SchedulerServiceDatabaseException(org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException) EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException) SchedulerServiceDatabaseException(org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException)

Example 15 with SchedulerServiceDatabaseException

use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.

the class SchedulerServiceDatabaseImpl method countTotalResponses.

public long countTotalResponses() throws SchedulerServiceDatabaseException {
    EntityManager em = null;
    try {
        em = emf.createEntityManager();
        Query q = em.createNamedQuery("ExtendedEvent.countRespones");
        Number countResult = (Number) q.getSingleResult();
        return countResult.longValue();
    } catch (Exception e) {
        throw new SchedulerServiceDatabaseException(e);
    } finally {
        if (em != null)
            em.close();
    }
}
Also used : SchedulerServiceDatabaseException(org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException) EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException) SchedulerServiceDatabaseException(org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException)

Aggregations

EntityManager (javax.persistence.EntityManager)17 NoResultException (javax.persistence.NoResultException)17 SchedulerServiceDatabaseException (org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException)17 NotFoundException (org.opencastproject.util.NotFoundException)17 Query (javax.persistence.Query)10 EntityTransaction (javax.persistence.EntityTransaction)4 Date (java.util.Date)3 Fn (com.entwinemedia.fn.Fn)1 HashMap (java.util.HashMap)1