use of com.intel.mtwilson.as.data.TblHostSpecificManifest in project OpenAttestation by OpenAttestation.
the class TblHostSpecificManifestJpaController method findTblHostSpecificManifestEntities.
private List<TblHostSpecificManifest> findTblHostSpecificManifestEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(TblHostSpecificManifest.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.TblHostSpecificManifest in project OpenAttestation by OpenAttestation.
the class TblHostSpecificManifestJpaController method destroy.
public void destroy(Integer id) throws NonexistentEntityException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblHostSpecificManifest tblHostSpecificManifest;
try {
tblHostSpecificManifest = em.getReference(TblHostSpecificManifest.class, id);
tblHostSpecificManifest.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The tblHostSpecificManifest with id " + id + " no longer exists.", enfe);
}
TblModuleManifest moduleManifestID = tblHostSpecificManifest.getModuleManifestID();
if (moduleManifestID != null) {
moduleManifestID.getTblHostSpecificManifestCollection().remove(tblHostSpecificManifest);
em.merge(moduleManifestID);
}
em.remove(tblHostSpecificManifest);
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblHostSpecificManifest in project OpenAttestation by OpenAttestation.
the class TblHostSpecificManifestJpaController method findByHostID.
public TblHostSpecificManifest findByHostID(int hostId) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblHostSpecificManifest.findByHostID");
query.setParameter("hostID", hostId);
TblHostSpecificManifest tblHostSpecificManifest = (TblHostSpecificManifest) query.getSingleResult();
return tblHostSpecificManifest;
} catch (NoResultException e) {
log.error("NoResultException: No Host specific manifest for Host [{}]", String.valueOf(hostId));
return null;
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblHostSpecificManifest in project OpenAttestation by OpenAttestation.
the class TblHostSpecificManifestJpaController method getTblHostSpecificManifestCount.
public int getTblHostSpecificManifestCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<TblHostSpecificManifest> rt = cq.from(TblHostSpecificManifest.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.TblHostSpecificManifest in project OpenAttestation by OpenAttestation.
the class HostBO method deleteHostSpecificManifest.
// PREMIUM FEATURE ?
private void deleteHostSpecificManifest(TblHosts tblHosts) throws NonexistentEntityException, IOException {
//TblHostSpecificManifestJpaController tblHostSpecificManifestJpaController = My.jpa().mwHostSpecificManifest();
TblHostSpecificManifestJpaController tblHostSpecificManifestJpaController = getHostSpecificManifestJpaController();
for (TblModuleManifest moduleManifest : tblHosts.getVmmMleId().getTblModuleManifestCollection()) {
if (moduleManifest.getUseHostSpecificDigestValue() != null && moduleManifest.getUseHostSpecificDigestValue().booleanValue()) {
// For open source we used to have multiple module manifests for the same hosts. So, the below query by hostID was returning multiple results.
TblHostSpecificManifest hostSpecificManifest = tblHostSpecificManifestJpaController.findByModuleAndHostID(tblHosts.getId(), moduleManifest.getId());
if (hostSpecificManifest != null) {
log.debug("Deleting Host specific manifest." + moduleManifest.getComponentName() + ":" + hostSpecificManifest.getDigestValue());
tblHostSpecificManifestJpaController.destroy(hostSpecificManifest.getId());
}
}
}
}
Aggregations