use of com.intel.mtwilson.as.data.TblModuleManifest in project OpenAttestation by OpenAttestation.
the class TblHostSpecificManifestJpaController method create.
public void create(TblHostSpecificManifest tblHostSpecificManifest) {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblModuleManifest moduleManifestID = tblHostSpecificManifest.getModuleManifestID();
if (moduleManifestID != null) {
moduleManifestID = em.getReference(moduleManifestID.getClass(), moduleManifestID.getId());
tblHostSpecificManifest.setModuleManifestID(moduleManifestID);
}
em.persist(tblHostSpecificManifest);
if (moduleManifestID != null) {
moduleManifestID.getTblHostSpecificManifestCollection().add(tblHostSpecificManifest);
em.merge(moduleManifestID);
}
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblModuleManifest 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.TblModuleManifest in project OpenAttestation by OpenAttestation.
the class TblModuleManifestJpaController method getTblModuleManifestCount.
public int getTblModuleManifestCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<TblModuleManifest> rt = cq.from(TblModuleManifest.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.TblModuleManifest in project OpenAttestation by OpenAttestation.
the class TblModuleManifestJpaController method findByComponentVlaue.
public List<TblModuleManifest> findByComponentVlaue(String digestValue) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblModuleManifest.findByModuleValue");
query.setParameter("digestValue", digestValue);
List<TblModuleManifest> pcrList = query.getResultList();
return pcrList;
} catch (NoResultException e) {
log.error(String.format("Module information with name {} not found in the DB.", digestValue));
return null;
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblModuleManifest in project OpenAttestation by OpenAttestation.
the class TblPackageNamespaceJpaController method create.
public void create(TblPackageNamespace tblPackageNamespace) {
if (tblPackageNamespace.getTblModuleManifestCollection() == null) {
tblPackageNamespace.setTblModuleManifestCollection(new ArrayList<TblModuleManifest>());
}
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
Collection<TblModuleManifest> attachedTblModuleManifestCollection = new ArrayList<TblModuleManifest>();
for (TblModuleManifest tblModuleManifestCollectionTblModuleManifestToAttach : tblPackageNamespace.getTblModuleManifestCollection()) {
tblModuleManifestCollectionTblModuleManifestToAttach = em.getReference(tblModuleManifestCollectionTblModuleManifestToAttach.getClass(), tblModuleManifestCollectionTblModuleManifestToAttach.getId());
attachedTblModuleManifestCollection.add(tblModuleManifestCollectionTblModuleManifestToAttach);
}
tblPackageNamespace.setTblModuleManifestCollection(attachedTblModuleManifestCollection);
em.persist(tblPackageNamespace);
for (TblModuleManifest tblModuleManifestCollectionTblModuleManifest : tblPackageNamespace.getTblModuleManifestCollection()) {
TblPackageNamespace oldNameSpaceIDOfTblModuleManifestCollectionTblModuleManifest = tblModuleManifestCollectionTblModuleManifest.getNameSpaceID();
tblModuleManifestCollectionTblModuleManifest.setNameSpaceID(tblPackageNamespace);
tblModuleManifestCollectionTblModuleManifest = em.merge(tblModuleManifestCollectionTblModuleManifest);
if (oldNameSpaceIDOfTblModuleManifestCollectionTblModuleManifest != null) {
oldNameSpaceIDOfTblModuleManifestCollectionTblModuleManifest.getTblModuleManifestCollection().remove(tblModuleManifestCollectionTblModuleManifest);
em.merge(oldNameSpaceIDOfTblModuleManifestCollectionTblModuleManifest);
}
}
em.getTransaction().commit();
} finally {
em.close();
}
}
Aggregations