use of com.intel.mtwilson.as.data.TblMle 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.TblMle in project OpenAttestation by OpenAttestation.
the class TblModuleManifestJpaController method create.
public void create(TblModuleManifest tblModuleManifest) {
if (tblModuleManifest.getTblHostSpecificManifestCollection() == null) {
tblModuleManifest.setTblHostSpecificManifestCollection(new ArrayList<TblHostSpecificManifest>());
}
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
// @since 1.1 we are relying on the audit log for "created on", "created by", etc. type information
/*
TblDbPortalUser updatedBy = tblModuleManifest.getUpdatedBy();
if (updatedBy != null) {
updatedBy = em.getReference(updatedBy.getClass(), updatedBy.getId());
tblModuleManifest.setUpdatedBy(updatedBy);
}
TblDbPortalUser createdBy = tblModuleManifest.getCreatedBy();
if (createdBy != null) {
createdBy = em.getReference(createdBy.getClass(), createdBy.getId());
tblModuleManifest.setCreatedBy(createdBy);
}
*/
TblMle mleId = tblModuleManifest.getMleId();
if (mleId != null) {
mleId = em.getReference(mleId.getClass(), mleId.getId());
tblModuleManifest.setMleId(mleId);
}
TblEventType eventID = tblModuleManifest.getEventID();
if (eventID != null) {
eventID = em.getReference(eventID.getClass(), eventID.getId());
tblModuleManifest.setEventID(eventID);
}
TblPackageNamespace nameSpaceID = tblModuleManifest.getNameSpaceID();
if (nameSpaceID != null) {
nameSpaceID = em.getReference(nameSpaceID.getClass(), nameSpaceID.getId());
tblModuleManifest.setNameSpaceID(nameSpaceID);
}
Collection<TblHostSpecificManifest> attachedTblHostSpecificManifestCollection = new ArrayList<TblHostSpecificManifest>();
for (TblHostSpecificManifest tblHostSpecificManifestCollectionTblHostSpecificManifestToAttach : tblModuleManifest.getTblHostSpecificManifestCollection()) {
tblHostSpecificManifestCollectionTblHostSpecificManifestToAttach = em.getReference(tblHostSpecificManifestCollectionTblHostSpecificManifestToAttach.getClass(), tblHostSpecificManifestCollectionTblHostSpecificManifestToAttach.getId());
attachedTblHostSpecificManifestCollection.add(tblHostSpecificManifestCollectionTblHostSpecificManifestToAttach);
}
tblModuleManifest.setTblHostSpecificManifestCollection(attachedTblHostSpecificManifestCollection);
em.persist(tblModuleManifest);
/*
if (updatedBy != null) {
updatedBy.getTblModuleManifestCollection().add(tblModuleManifest);
em.merge(updatedBy);
}
if (createdBy != null) {
createdBy.getTblModuleManifestCollection().add(tblModuleManifest);
em.merge(createdBy);
}*/
if (mleId != null) {
mleId.getTblModuleManifestCollection().add(tblModuleManifest);
em.merge(mleId);
}
if (eventID != null) {
eventID.getTblModuleManifestCollection().add(tblModuleManifest);
em.merge(eventID);
}
if (nameSpaceID != null) {
nameSpaceID.getTblModuleManifestCollection().add(tblModuleManifest);
em.merge(nameSpaceID);
}
for (TblHostSpecificManifest tblHostSpecificManifestCollectionTblHostSpecificManifest : tblModuleManifest.getTblHostSpecificManifestCollection()) {
TblModuleManifest oldModuleManifestIDOfTblHostSpecificManifestCollectionTblHostSpecificManifest = tblHostSpecificManifestCollectionTblHostSpecificManifest.getModuleManifestID();
tblHostSpecificManifestCollectionTblHostSpecificManifest.setModuleManifestID(tblModuleManifest);
tblHostSpecificManifestCollectionTblHostSpecificManifest = em.merge(tblHostSpecificManifestCollectionTblHostSpecificManifest);
if (oldModuleManifestIDOfTblHostSpecificManifestCollectionTblHostSpecificManifest != null) {
oldModuleManifestIDOfTblHostSpecificManifestCollectionTblHostSpecificManifest.getTblHostSpecificManifestCollection().remove(tblHostSpecificManifestCollectionTblHostSpecificManifest);
em.merge(oldModuleManifestIDOfTblHostSpecificManifestCollectionTblHostSpecificManifest);
}
}
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblMle in project OpenAttestation by OpenAttestation.
the class TblHostsJpaController method destroy.
public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblHosts tblHosts;
try {
tblHosts = em.getReference(TblHosts.class, id);
tblHosts.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The tblHosts with id " + id + " no longer exists.", enfe);
}
TblMle vmmMleId = tblHosts.getVmmMleId();
if (vmmMleId != null) {
vmmMleId.getTblHostsCollection().remove(tblHosts);
em.merge(vmmMleId);
}
TblMle biosMleId = tblHosts.getBiosMleId();
if (biosMleId != null) {
biosMleId.getTblHostsCollection().remove(tblHosts);
em.merge(biosMleId);
}
em.remove(tblHosts);
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblMle in project OpenAttestation by OpenAttestation.
the class TblHostsJpaController method edit.
public void edit(TblHosts tblHosts) throws IllegalOrphanException, NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblHosts persistentTblHosts = em.find(TblHosts.class, tblHosts.getId());
TblMle vmmMleIdOld = persistentTblHosts.getVmmMleId();
TblMle vmmMleIdNew = tblHosts.getVmmMleId();
TblMle biosMleIdOld = persistentTblHosts.getBiosMleId();
TblMle biosMleIdNew = tblHosts.getBiosMleId();
if (vmmMleIdNew != null) {
vmmMleIdNew = em.getReference(vmmMleIdNew.getClass(), vmmMleIdNew.getId());
tblHosts.setVmmMleId(vmmMleIdNew);
}
if (biosMleIdNew != null) {
biosMleIdNew = em.getReference(biosMleIdNew.getClass(), biosMleIdNew.getId());
tblHosts.setBiosMleId(biosMleIdNew);
}
// encrypt addon connection string, persist, then restore the plaintext
String addOnConnectionString = tblHosts.getAddOnConnectionInfo();
if (addOnConnectionString != null) {
tblHosts = em.merge(tblHosts);
} else {
tblHosts = em.merge(tblHosts);
}
if (vmmMleIdOld != null && !vmmMleIdOld.equals(vmmMleIdNew)) {
vmmMleIdOld.getTblHostsCollection().remove(tblHosts);
vmmMleIdOld = em.merge(vmmMleIdOld);
}
if (vmmMleIdNew != null && !vmmMleIdNew.equals(vmmMleIdOld)) {
vmmMleIdNew.getTblHostsCollection().add(tblHosts);
em.merge(vmmMleIdNew);
}
if (biosMleIdOld != null && !biosMleIdOld.equals(biosMleIdNew)) {
biosMleIdOld.getTblHostsCollection().remove(tblHosts);
biosMleIdOld = em.merge(biosMleIdOld);
}
if (biosMleIdNew != null && !biosMleIdNew.equals(biosMleIdOld)) {
biosMleIdNew.getTblHostsCollection().add(tblHosts);
em.merge(biosMleIdNew);
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblHosts.getId();
if (findTblHosts(id) == null) {
throw new NonexistentEntityException("The tblHosts with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblMle 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();
}
}
Aggregations