use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblModuleManifestJpaController method edit_v2.
public void edit_v2(TblModuleManifest tblModuleManifest, EntityManager em) throws IllegalOrphanException, NonexistentEntityException, ASDataException {
try {
TblModuleManifest persistentTblModuleManifest = em.find(TblModuleManifest.class, tblModuleManifest.getId());
TblMle mleIdOld = persistentTblModuleManifest.getMleId();
TblMle mleIdNew = tblModuleManifest.getMleId();
TblEventType eventIDOld = persistentTblModuleManifest.getEventID();
TblEventType eventIDNew = tblModuleManifest.getEventID();
TblPackageNamespace nameSpaceIDOld = persistentTblModuleManifest.getNameSpaceID();
TblPackageNamespace nameSpaceIDNew = tblModuleManifest.getNameSpaceID();
Collection<TblHostSpecificManifest> tblHostSpecificManifestCollectionOld = persistentTblModuleManifest.getTblHostSpecificManifestCollection();
Collection<TblHostSpecificManifest> tblHostSpecificManifestCollectionNew = tblModuleManifest.getTblHostSpecificManifestCollection();
List<String> illegalOrphanMessages = null;
for (TblHostSpecificManifest tblHostSpecificManifestCollectionOldTblHostSpecificManifest : tblHostSpecificManifestCollectionOld) {
if (!tblHostSpecificManifestCollectionNew.contains(tblHostSpecificManifestCollectionOldTblHostSpecificManifest)) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("You must retain TblHostSpecificManifest " + tblHostSpecificManifestCollectionOldTblHostSpecificManifest + " since its moduleManifestID field is not nullable.");
}
}
if (illegalOrphanMessages != null) {
throw new IllegalOrphanException(illegalOrphanMessages);
}
if (mleIdNew != null) {
mleIdNew = em.getReference(mleIdNew.getClass(), mleIdNew.getId());
tblModuleManifest.setMleId(mleIdNew);
}
if (eventIDNew != null) {
eventIDNew = em.getReference(eventIDNew.getClass(), eventIDNew.getId());
tblModuleManifest.setEventID(eventIDNew);
}
if (nameSpaceIDNew != null) {
nameSpaceIDNew = em.getReference(nameSpaceIDNew.getClass(), nameSpaceIDNew.getId());
tblModuleManifest.setNameSpaceID(nameSpaceIDNew);
}
Collection<TblHostSpecificManifest> attachedTblHostSpecificManifestCollectionNew = new ArrayList<TblHostSpecificManifest>();
for (TblHostSpecificManifest tblHostSpecificManifestCollectionNewTblHostSpecificManifestToAttach : tblHostSpecificManifestCollectionNew) {
tblHostSpecificManifestCollectionNewTblHostSpecificManifestToAttach = em.getReference(tblHostSpecificManifestCollectionNewTblHostSpecificManifestToAttach.getClass(), tblHostSpecificManifestCollectionNewTblHostSpecificManifestToAttach.getId());
attachedTblHostSpecificManifestCollectionNew.add(tblHostSpecificManifestCollectionNewTblHostSpecificManifestToAttach);
}
tblHostSpecificManifestCollectionNew = attachedTblHostSpecificManifestCollectionNew;
tblModuleManifest.setTblHostSpecificManifestCollection(tblHostSpecificManifestCollectionNew);
tblModuleManifest = em.merge(tblModuleManifest);
if (mleIdOld != null && !mleIdOld.equals(mleIdNew)) {
mleIdOld.getTblModuleManifestCollection().remove(tblModuleManifest);
mleIdOld = em.merge(mleIdOld);
}
if (mleIdNew != null && !mleIdNew.equals(mleIdOld)) {
mleIdNew.getTblModuleManifestCollection().add(tblModuleManifest);
em.merge(mleIdNew);
}
if (eventIDOld != null && !eventIDOld.equals(eventIDNew)) {
eventIDOld.getTblModuleManifestCollection().remove(tblModuleManifest);
eventIDOld = em.merge(eventIDOld);
}
if (eventIDNew != null && !eventIDNew.equals(eventIDOld)) {
eventIDNew.getTblModuleManifestCollection().add(tblModuleManifest);
em.merge(eventIDNew);
}
if (nameSpaceIDOld != null && !nameSpaceIDOld.equals(nameSpaceIDNew)) {
nameSpaceIDOld.getTblModuleManifestCollection().remove(tblModuleManifest);
nameSpaceIDOld = em.merge(nameSpaceIDOld);
}
if (nameSpaceIDNew != null && !nameSpaceIDNew.equals(nameSpaceIDOld)) {
nameSpaceIDNew.getTblModuleManifestCollection().add(tblModuleManifest);
em.merge(nameSpaceIDNew);
}
for (TblHostSpecificManifest tblHostSpecificManifestCollectionNewTblHostSpecificManifest : tblHostSpecificManifestCollectionNew) {
if (!tblHostSpecificManifestCollectionOld.contains(tblHostSpecificManifestCollectionNewTblHostSpecificManifest)) {
TblModuleManifest oldModuleManifestIDOfTblHostSpecificManifestCollectionNewTblHostSpecificManifest = tblHostSpecificManifestCollectionNewTblHostSpecificManifest.getModuleManifestID();
tblHostSpecificManifestCollectionNewTblHostSpecificManifest.setModuleManifestID(tblModuleManifest);
tblHostSpecificManifestCollectionNewTblHostSpecificManifest = em.merge(tblHostSpecificManifestCollectionNewTblHostSpecificManifest);
if (oldModuleManifestIDOfTblHostSpecificManifestCollectionNewTblHostSpecificManifest != null && !oldModuleManifestIDOfTblHostSpecificManifestCollectionNewTblHostSpecificManifest.equals(tblModuleManifest)) {
oldModuleManifestIDOfTblHostSpecificManifestCollectionNewTblHostSpecificManifest.getTblHostSpecificManifestCollection().remove(tblHostSpecificManifestCollectionNewTblHostSpecificManifest);
em.merge(oldModuleManifestIDOfTblHostSpecificManifestCollectionNewTblHostSpecificManifest);
}
}
}
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblModuleManifest.getId();
if (findTblModuleManifest(id) == null) {
throw new NonexistentEntityException("The tblModuleManifest with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
}
}
use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class MwMleSourceJpaController method destroy.
public void destroy(Integer id) throws NonexistentEntityException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
MwMleSource mwMleSource;
try {
mwMleSource = em.getReference(MwMleSource.class, id);
mwMleSource.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The mwMleSource with id " + id + " no longer exists.", enfe);
}
TblMle mleId = mwMleSource.getMleId();
if (mleId != null) {
mleId.getMwMleSourceCollection().remove(mwMleSource);
em.merge(mleId);
}
em.remove(mwMleSource);
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException 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.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblLocationPcrJpaController method edit.
public void edit(TblLocationPcr tblLocationPcr) throws NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
em.merge(tblLocationPcr);
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblLocationPcr.getId();
if (findTblLocationPcr(id) == null) {
throw new NonexistentEntityException("The tblLocationPcr with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblMleJpaController method edit.
public void edit(TblMle tblMle) throws IllegalOrphanException, NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblMle persistentTblMle = em.find(TblMle.class, tblMle.getId());
Collection<TblHosts> tblHostsCollectionOld = persistentTblMle.getTblHostsCollection();
Collection<TblHosts> tblHostsCollectionNew = tblMle.getTblHostsCollection();
Collection<TblHosts> tblHostsCollection1Old = persistentTblMle.getTblHostsCollection1();
Collection<TblHosts> tblHostsCollection1New = tblMle.getTblHostsCollection1();
Collection<TblPcrManifest> tblPcrManifestCollectionOld = persistentTblMle.getTblPcrManifestCollection();
Collection<TblPcrManifest> tblPcrManifestCollectionNew = tblMle.getTblPcrManifestCollection();
List<String> illegalOrphanMessages = null;
for (TblHosts tblHostsCollectionOldTblHosts : tblHostsCollectionOld) {
if (!tblHostsCollectionNew.contains(tblHostsCollectionOldTblHosts)) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("You must retain TblHosts " + tblHostsCollectionOldTblHosts + " since its vmmMleId field is not nullable.");
}
}
for (TblHosts tblHostsCollection1OldTblHosts : tblHostsCollection1Old) {
if (!tblHostsCollection1New.contains(tblHostsCollection1OldTblHosts)) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("You must retain TblHosts " + tblHostsCollection1OldTblHosts + " since its biosMleId field is not nullable.");
}
}
for (TblPcrManifest tblPcrManifestCollectionOldTblPcrManifest : tblPcrManifestCollectionOld) {
if (!tblPcrManifestCollectionNew.contains(tblPcrManifestCollectionOldTblPcrManifest)) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("You must retain TblPcrManifest " + tblPcrManifestCollectionOldTblPcrManifest + " since its mleId field is not nullable.");
}
}
if (illegalOrphanMessages != null) {
throw new IllegalOrphanException(illegalOrphanMessages);
}
Collection<TblHosts> attachedTblHostsCollectionNew = new ArrayList<TblHosts>();
for (TblHosts tblHostsCollectionNewTblHostsToAttach : tblHostsCollectionNew) {
tblHostsCollectionNewTblHostsToAttach = em.getReference(tblHostsCollectionNewTblHostsToAttach.getClass(), tblHostsCollectionNewTblHostsToAttach.getId());
attachedTblHostsCollectionNew.add(tblHostsCollectionNewTblHostsToAttach);
}
tblHostsCollectionNew = attachedTblHostsCollectionNew;
tblMle.setTblHostsCollection(tblHostsCollectionNew);
Collection<TblHosts> attachedTblHostsCollection1New = new ArrayList<TblHosts>();
for (TblHosts tblHostsCollection1NewTblHostsToAttach : tblHostsCollection1New) {
tblHostsCollection1NewTblHostsToAttach = em.getReference(tblHostsCollection1NewTblHostsToAttach.getClass(), tblHostsCollection1NewTblHostsToAttach.getId());
attachedTblHostsCollection1New.add(tblHostsCollection1NewTblHostsToAttach);
}
tblHostsCollection1New = attachedTblHostsCollection1New;
tblMle.setTblHostsCollection1(tblHostsCollection1New);
Collection<TblPcrManifest> attachedTblPcrManifestCollectionNew = new ArrayList<TblPcrManifest>();
for (TblPcrManifest tblPcrManifestCollectionNewTblPcrManifestToAttach : tblPcrManifestCollectionNew) {
tblPcrManifestCollectionNewTblPcrManifestToAttach = em.getReference(tblPcrManifestCollectionNewTblPcrManifestToAttach.getClass(), tblPcrManifestCollectionNewTblPcrManifestToAttach.getId());
attachedTblPcrManifestCollectionNew.add(tblPcrManifestCollectionNewTblPcrManifestToAttach);
}
tblPcrManifestCollectionNew = attachedTblPcrManifestCollectionNew;
tblMle.setTblPcrManifestCollection(tblPcrManifestCollectionNew);
tblMle = em.merge(tblMle);
for (TblHosts tblHostsCollectionNewTblHosts : tblHostsCollectionNew) {
if (!tblHostsCollectionOld.contains(tblHostsCollectionNewTblHosts)) {
TblMle oldVmmMleIdOfTblHostsCollectionNewTblHosts = tblHostsCollectionNewTblHosts.getVmmMleId();
tblHostsCollectionNewTblHosts.setVmmMleId(tblMle);
tblHostsCollectionNewTblHosts = em.merge(tblHostsCollectionNewTblHosts);
if (oldVmmMleIdOfTblHostsCollectionNewTblHosts != null && !oldVmmMleIdOfTblHostsCollectionNewTblHosts.equals(tblMle)) {
oldVmmMleIdOfTblHostsCollectionNewTblHosts.getTblHostsCollection().remove(tblHostsCollectionNewTblHosts);
em.merge(oldVmmMleIdOfTblHostsCollectionNewTblHosts);
}
}
}
for (TblHosts tblHostsCollection1NewTblHosts : tblHostsCollection1New) {
if (!tblHostsCollection1Old.contains(tblHostsCollection1NewTblHosts)) {
TblMle oldBiosMleIdOfTblHostsCollection1NewTblHosts = tblHostsCollection1NewTblHosts.getBiosMleId();
tblHostsCollection1NewTblHosts.setBiosMleId(tblMle);
tblHostsCollection1NewTblHosts = em.merge(tblHostsCollection1NewTblHosts);
if (oldBiosMleIdOfTblHostsCollection1NewTblHosts != null && !oldBiosMleIdOfTblHostsCollection1NewTblHosts.equals(tblMle)) {
oldBiosMleIdOfTblHostsCollection1NewTblHosts.getTblHostsCollection1().remove(tblHostsCollection1NewTblHosts);
em.merge(oldBiosMleIdOfTblHostsCollection1NewTblHosts);
}
}
}
for (TblPcrManifest tblPcrManifestCollectionNewTblPcrManifest : tblPcrManifestCollectionNew) {
if (!tblPcrManifestCollectionOld.contains(tblPcrManifestCollectionNewTblPcrManifest)) {
TblMle oldMleIdOfTblPcrManifestCollectionNewTblPcrManifest = tblPcrManifestCollectionNewTblPcrManifest.getMleId();
tblPcrManifestCollectionNewTblPcrManifest.setMleId(tblMle);
tblPcrManifestCollectionNewTblPcrManifest = em.merge(tblPcrManifestCollectionNewTblPcrManifest);
if (oldMleIdOfTblPcrManifestCollectionNewTblPcrManifest != null && !oldMleIdOfTblPcrManifestCollectionNewTblPcrManifest.equals(tblMle)) {
oldMleIdOfTblPcrManifestCollectionNewTblPcrManifest.getTblPcrManifestCollection().remove(tblPcrManifestCollectionNewTblPcrManifest);
em.merge(oldMleIdOfTblPcrManifestCollectionNewTblPcrManifest);
}
}
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblMle.getId();
if (findTblMle(id) == null) {
throw new NonexistentEntityException("The tblMle with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
em.close();
}
}
Aggregations