use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaController method findTblPcrManifestEntities.
private List<TblPcrManifest> findTblPcrManifestEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(TblPcrManifest.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaController method destroy.
public void destroy(Integer id) throws NonexistentEntityException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblPcrManifest tblPcrManifest;
try {
tblPcrManifest = em.getReference(TblPcrManifest.class, id);
tblPcrManifest.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The tblPcrManifest with id " + id + " no longer exists.", enfe);
}
// @since 1.1 we are relying on the audit log for "created on", "created by", etc. type information
/*
TblDbPortalUser updatedBy = tblPcrManifest.getUpdatedBy();
if (updatedBy != null) {
updatedBy.getTblPcrManifestCollection().remove(tblPcrManifest);
em.merge(updatedBy);
}
TblDbPortalUser createdBy = tblPcrManifest.getCreatedBy();
if (createdBy != null) {
createdBy.getTblPcrManifestCollection().remove(tblPcrManifest);
em.merge(createdBy);
}
*/
TblMle mleId = tblPcrManifest.getMleId();
if (mleId != null) {
mleId.getTblPcrManifestCollection().remove(tblPcrManifest);
em.merge(mleId);
}
em.remove(tblPcrManifest);
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaController method getTblPcrManifestCount.
public int getTblPcrManifestCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<TblPcrManifest> rt = cq.from(TblPcrManifest.class);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class TblMleJpaController method create.
public void create(TblMle tblMle) {
if (tblMle.getTblHostsCollection() == null) {
tblMle.setTblHostsCollection(new ArrayList<TblHosts>());
}
if (tblMle.getTblHostsCollection1() == null) {
tblMle.setTblHostsCollection1(new ArrayList<TblHosts>());
}
if (tblMle.getTblPcrManifestCollection() == null) {
tblMle.setTblPcrManifestCollection(new ArrayList<TblPcrManifest>());
}
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
Collection<TblHosts> attachedTblHostsCollection = new ArrayList<TblHosts>();
for (TblHosts tblHostsCollectionTblHostsToAttach : tblMle.getTblHostsCollection()) {
tblHostsCollectionTblHostsToAttach = em.getReference(tblHostsCollectionTblHostsToAttach.getClass(), tblHostsCollectionTblHostsToAttach.getId());
attachedTblHostsCollection.add(tblHostsCollectionTblHostsToAttach);
}
tblMle.setTblHostsCollection(attachedTblHostsCollection);
Collection<TblHosts> attachedTblHostsCollection1 = new ArrayList<TblHosts>();
for (TblHosts tblHostsCollection1TblHostsToAttach : tblMle.getTblHostsCollection1()) {
tblHostsCollection1TblHostsToAttach = em.getReference(tblHostsCollection1TblHostsToAttach.getClass(), tblHostsCollection1TblHostsToAttach.getId());
attachedTblHostsCollection1.add(tblHostsCollection1TblHostsToAttach);
}
tblMle.setTblHostsCollection1(attachedTblHostsCollection1);
Collection<TblPcrManifest> attachedTblPcrManifestCollection = new ArrayList<TblPcrManifest>();
for (TblPcrManifest tblPcrManifestCollectionTblPcrManifestToAttach : tblMle.getTblPcrManifestCollection()) {
tblPcrManifestCollectionTblPcrManifestToAttach = em.getReference(tblPcrManifestCollectionTblPcrManifestToAttach.getClass(), tblPcrManifestCollectionTblPcrManifestToAttach.getId());
attachedTblPcrManifestCollection.add(tblPcrManifestCollectionTblPcrManifestToAttach);
}
tblMle.setTblPcrManifestCollection(attachedTblPcrManifestCollection);
em.persist(tblMle);
for (TblHosts tblHostsCollectionTblHosts : tblMle.getTblHostsCollection()) {
TblMle oldVmmMleIdOfTblHostsCollectionTblHosts = tblHostsCollectionTblHosts.getVmmMleId();
tblHostsCollectionTblHosts.setVmmMleId(tblMle);
tblHostsCollectionTblHosts = em.merge(tblHostsCollectionTblHosts);
if (oldVmmMleIdOfTblHostsCollectionTblHosts != null) {
oldVmmMleIdOfTblHostsCollectionTblHosts.getTblHostsCollection().remove(tblHostsCollectionTblHosts);
em.merge(oldVmmMleIdOfTblHostsCollectionTblHosts);
}
}
for (TblHosts tblHostsCollection1TblHosts : tblMle.getTblHostsCollection1()) {
TblMle oldBiosMleIdOfTblHostsCollection1TblHosts = tblHostsCollection1TblHosts.getBiosMleId();
tblHostsCollection1TblHosts.setBiosMleId(tblMle);
tblHostsCollection1TblHosts = em.merge(tblHostsCollection1TblHosts);
if (oldBiosMleIdOfTblHostsCollection1TblHosts != null) {
oldBiosMleIdOfTblHostsCollection1TblHosts.getTblHostsCollection1().remove(tblHostsCollection1TblHosts);
em.merge(oldBiosMleIdOfTblHostsCollection1TblHosts);
}
}
for (TblPcrManifest tblPcrManifestCollectionTblPcrManifest : tblMle.getTblPcrManifestCollection()) {
TblMle oldMleIdOfTblPcrManifestCollectionTblPcrManifest = tblPcrManifestCollectionTblPcrManifest.getMleId();
tblPcrManifestCollectionTblPcrManifest.setMleId(tblMle);
tblPcrManifestCollectionTblPcrManifest = em.merge(tblPcrManifestCollectionTblPcrManifest);
if (oldMleIdOfTblPcrManifestCollectionTblPcrManifest != null) {
oldMleIdOfTblPcrManifestCollectionTblPcrManifest.getTblPcrManifestCollection().remove(tblPcrManifestCollectionTblPcrManifest);
em.merge(oldMleIdOfTblPcrManifestCollectionTblPcrManifest);
}
}
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaController method findPcrManifestById.
public TblPcrManifest findPcrManifestById(Integer id) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblPcrManifest.findById");
query.setParameter("id", id);
query.setHint(QueryHints.REFRESH, HintValues.TRUE);
query.setHint(QueryHints.CACHE_USAGE, CacheUsage.DoNotCheckCache);
TblPcrManifest manifest = (TblPcrManifest) query.getSingleResult();
return manifest;
} finally {
em.close();
}
}
Aggregations