Search in sources :

Example 1 with TblModuleManifestLog

use of com.intel.mtwilson.as.data.TblModuleManifestLog in project OpenAttestation by OpenAttestation.

the class TblModuleManifestLogJpaController method destroy.

public void destroy(Integer id) throws NonexistentEntityException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        TblModuleManifestLog tblModuleManifestLog;
        try {
            tblModuleManifestLog = em.getReference(TblModuleManifestLog.class, id);
            tblModuleManifestLog.getId();
        } catch (EntityNotFoundException enfe) {
            throw new NonexistentEntityException("The tblModuleManifestLog with id " + id + " no longer exists.", enfe);
        }
        TblTaLog taLogId = tblModuleManifestLog.getTaLogId();
        if (taLogId != null) {
            taLogId.getTblModuleManifestLogCollection().remove(tblModuleManifestLog);
            em.merge(taLogId);
        }
        em.remove(tblModuleManifestLog);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException) TblModuleManifestLog(com.intel.mtwilson.as.data.TblModuleManifestLog)

Example 2 with TblModuleManifestLog

use of com.intel.mtwilson.as.data.TblModuleManifestLog in project OpenAttestation by OpenAttestation.

the class TblModuleManifestLogJpaController method getTblModuleManifestLogCount.

public int getTblModuleManifestLogCount() {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<TblModuleManifestLog> rt = cq.from(TblModuleManifestLog.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) TblModuleManifestLog(com.intel.mtwilson.as.data.TblModuleManifestLog)

Example 3 with TblModuleManifestLog

use of com.intel.mtwilson.as.data.TblModuleManifestLog in project OpenAttestation by OpenAttestation.

the class TblModuleManifestLogJpaController method edit.

public void edit(TblModuleManifestLog tblModuleManifestLog) throws NonexistentEntityException, ASDataException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        TblModuleManifestLog persistentTblModuleManifestLog = em.find(TblModuleManifestLog.class, tblModuleManifestLog.getId());
        TblTaLog taLogIdOld = persistentTblModuleManifestLog.getTaLogId();
        TblTaLog taLogIdNew = tblModuleManifestLog.getTaLogId();
        if (taLogIdNew != null) {
            taLogIdNew = em.getReference(taLogIdNew.getClass(), taLogIdNew.getId());
            tblModuleManifestLog.setTaLogId(taLogIdNew);
        }
        tblModuleManifestLog = em.merge(tblModuleManifestLog);
        if (taLogIdOld != null && !taLogIdOld.equals(taLogIdNew)) {
            taLogIdOld.getTblModuleManifestLogCollection().remove(tblModuleManifestLog);
            taLogIdOld = em.merge(taLogIdOld);
        }
        if (taLogIdNew != null && !taLogIdNew.equals(taLogIdOld)) {
            taLogIdNew.getTblModuleManifestLogCollection().add(tblModuleManifestLog);
            em.merge(taLogIdNew);
        }
        em.getTransaction().commit();
    } catch (Exception ex) {
        String msg = ex.getLocalizedMessage();
        if (msg == null || msg.length() == 0) {
            Integer id = tblModuleManifestLog.getId();
            if (findTblModuleManifestLog(id) == null) {
                throw new NonexistentEntityException("The tblModuleManifestLog with id " + id + " no longer exists.");
            }
        }
        throw new ASDataException(ex);
    } finally {
        em.close();
    }
}
Also used : ASDataException(com.intel.mtwilson.as.controller.exceptions.ASDataException) EntityManager(javax.persistence.EntityManager) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) TblModuleManifestLog(com.intel.mtwilson.as.data.TblModuleManifestLog) NoResultException(javax.persistence.NoResultException) ASDataException(com.intel.mtwilson.as.controller.exceptions.ASDataException) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 4 with TblModuleManifestLog

use of com.intel.mtwilson.as.data.TblModuleManifestLog in project OpenAttestation by OpenAttestation.

the class TblModuleManifestLogJpaController method findTblModuleManifestLogEntities.

private List<TblModuleManifestLog> findTblModuleManifestLogEntities(boolean all, int maxResults, int firstResult) {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(TblModuleManifestLog.class));
        Query q = em.createQuery(cq);
        if (!all) {
            q.setMaxResults(maxResults);
            q.setFirstResult(firstResult);
        }
        return q.getResultList();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) TblModuleManifestLog(com.intel.mtwilson.as.data.TblModuleManifestLog)

Example 5 with TblModuleManifestLog

use of com.intel.mtwilson.as.data.TblModuleManifestLog in project OpenAttestation by OpenAttestation.

the class TblModuleManifestLogJpaController method findByTaLogIdAndName.

public TblModuleManifestLog findByTaLogIdAndName(TblTaLog tblTaLog, String componentName) {
    EntityManager em = getEntityManager();
    try {
        Query query = em.createNamedQuery("TblModuleManifestLog.findByTaLogIdAndName");
        query.setParameter("taLogId", tblTaLog);
        query.setParameter("name", componentName);
        TblModuleManifestLog singleResult = (TblModuleManifestLog) query.getSingleResult();
        return singleResult;
    } catch (NoResultException e) {
        return null;
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException) TblModuleManifestLog(com.intel.mtwilson.as.data.TblModuleManifestLog)

Aggregations

TblModuleManifestLog (com.intel.mtwilson.as.data.TblModuleManifestLog)6 EntityManager (javax.persistence.EntityManager)5 Query (javax.persistence.Query)3 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)3 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)2 TblTaLog (com.intel.mtwilson.as.data.TblTaLog)2 EntityNotFoundException (javax.persistence.EntityNotFoundException)2 NoResultException (javax.persistence.NoResultException)2 TblHostSpecificManifestJpaController (com.intel.mtwilson.as.controller.TblHostSpecificManifestJpaController)1 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)1 TblModuleManifest (com.intel.mtwilson.as.data.TblModuleManifest)1