use of com.intel.mtwilson.as.data.TblPackageNamespace 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();
}
}
use of com.intel.mtwilson.as.data.TblPackageNamespace in project OpenAttestation by OpenAttestation.
the class TblPackageNamespaceJpaController method findTblPackageNamespaceEntities.
private List<TblPackageNamespace> findTblPackageNamespaceEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(TblPackageNamespace.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
Aggregations