use of com.intel.mtwilson.as.data.TblMle in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaController method create.
public void create(TblPcrManifest tblPcrManifest) {
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 = tblPcrManifest.getUpdatedBy();
if (updatedBy != null) {
updatedBy = em.getReference(updatedBy.getClass(), updatedBy.getId());
tblPcrManifest.setUpdatedBy(updatedBy);
}
TblDbPortalUser createdBy = tblPcrManifest.getCreatedBy();
if (createdBy != null) {
createdBy = em.getReference(createdBy.getClass(), createdBy.getId());
tblPcrManifest.setCreatedBy(createdBy);
}*/
TblMle mleId = tblPcrManifest.getMleId();
if (mleId != null) {
mleId = em.getReference(mleId.getClass(), mleId.getId());
tblPcrManifest.setMleId(mleId);
}
em.persist(tblPcrManifest);
/*
if (updatedBy != null) {
updatedBy.getTblPcrManifestCollection().add(tblPcrManifest);
em.merge(updatedBy);
}
if (createdBy != null) {
createdBy.getTblPcrManifestCollection().add(tblPcrManifest);
em.merge(createdBy);
}*/
if (mleId != null) {
mleId.getTblPcrManifestCollection().add(tblPcrManifest);
em.merge(mleId);
}
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblMle in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaController method edit.
public void edit(TblPcrManifest tblPcrManifest) throws NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblPcrManifest persistentTblPcrManifest = em.find(TblPcrManifest.class, tblPcrManifest.getId());
// @since 1.1 we are relying on the audit log for "created on", "created by", etc. type information
/*
TblDbPortalUser updatedByOld = persistentTblPcrManifest.getUpdatedBy();
TblDbPortalUser updatedByNew = tblPcrManifest.getUpdatedBy();
TblDbPortalUser createdByOld = persistentTblPcrManifest.getCreatedBy();
TblDbPortalUser createdByNew = tblPcrManifest.getCreatedBy();
*/
TblMle mleIdOld = persistentTblPcrManifest.getMleId();
TblMle mleIdNew = tblPcrManifest.getMleId();
/*
if (updatedByNew != null) {
updatedByNew = em.getReference(updatedByNew.getClass(), updatedByNew.getId());
tblPcrManifest.setUpdatedBy(updatedByNew);
}
if (createdByNew != null) {
createdByNew = em.getReference(createdByNew.getClass(), createdByNew.getId());
tblPcrManifest.setCreatedBy(createdByNew);
}*/
if (mleIdNew != null) {
mleIdNew = em.getReference(mleIdNew.getClass(), mleIdNew.getId());
tblPcrManifest.setMleId(mleIdNew);
}
tblPcrManifest = em.merge(tblPcrManifest);
/*
if (updatedByOld != null && !updatedByOld.equals(updatedByNew)) {
updatedByOld.getTblPcrManifestCollection().remove(tblPcrManifest);
updatedByOld = em.merge(updatedByOld);
}
if (updatedByNew != null && !updatedByNew.equals(updatedByOld)) {
updatedByNew.getTblPcrManifestCollection().add(tblPcrManifest);
em.merge(updatedByNew);
}
if (createdByOld != null && !createdByOld.equals(createdByNew)) {
createdByOld.getTblPcrManifestCollection().remove(tblPcrManifest);
createdByOld = em.merge(createdByOld);
}
if (createdByNew != null && !createdByNew.equals(createdByOld)) {
createdByNew.getTblPcrManifestCollection().add(tblPcrManifest);
em.merge(createdByNew);
}
*/
if (mleIdOld != null && !mleIdOld.equals(mleIdNew)) {
mleIdOld.getTblPcrManifestCollection().remove(tblPcrManifest);
mleIdOld = em.merge(mleIdOld);
}
if (mleIdNew != null && !mleIdNew.equals(mleIdOld)) {
mleIdNew.getTblPcrManifestCollection().add(tblPcrManifest);
em.merge(mleIdNew);
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblPcrManifest.getId();
if (findTblPcrManifest(id) == null) {
throw new NonexistentEntityException("The tblPcrManifest 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 MwMleSourceJpaController method edit.
public void edit(MwMleSource mwMleSource) throws NonexistentEntityException, Exception {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
MwMleSource persistentMwMleSource = em.find(MwMleSource.class, mwMleSource.getId());
TblMle mleIdOld = persistentMwMleSource.getMleId();
TblMle mleIdNew = mwMleSource.getMleId();
if (mleIdNew != null) {
mleIdNew = em.getReference(mleIdNew.getClass(), mleIdNew.getId());
mwMleSource.setMleId(mleIdNew);
}
mwMleSource = em.merge(mwMleSource);
if (mleIdOld != null && !mleIdOld.equals(mleIdNew)) {
mleIdOld.getMwMleSourceCollection().remove(mwMleSource);
mleIdOld = em.merge(mleIdOld);
}
if (mleIdNew != null && !mleIdNew.equals(mleIdOld)) {
mleIdNew.getMwMleSourceCollection().add(mwMleSource);
em.merge(mleIdNew);
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = mwMleSource.getId();
if (findMwMleSource(id) == null) {
throw new NonexistentEntityException("The mwMleSource with id " + id + " no longer exists.");
}
}
throw ex;
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblMle in project OpenAttestation by OpenAttestation.
the class HostBOTest method testAddHost.
@Test
public void testAddHost() {
TxtHost host = mockHost();
when(hostsJpaController.findByName(anyString())).thenReturn(null);
when(hostsJpaController.findByIPAddress(anyString())).thenReturn(null);
TblMle biosMle = new TblMle(1, "DELL", "A08", "PCR", "BIOS", "0");
TblMle vmmMle = new TblMle(2, "XEN", "4.3", "PCR", "VMM", "18");
when(mleJpaController.findBiosMle(anyString(), anyString(), anyString())).thenReturn(biosMle);
when(mleJpaController.findVmmMle(anyString(), anyString(), anyString(), anyString())).thenReturn(vmmMle);
String response = hostBO.addHost(host);
assertTrue(response.equalsIgnoreCase("true"));
}
use of com.intel.mtwilson.as.data.TblMle in project OpenAttestation by OpenAttestation.
the class HostBO method findVmmMleForHost.
private TblMle findVmmMleForHost(TxtHost host) throws IOException {
TblMleJpaController tblMleJpaController = getMleJpaController();
TblMle vmmMleId = tblMleJpaController.findVmmMle(host.getVmm().getName(), host.getVmm().getVersion(), host.getVmm().getOsName(), host.getVmm().getOsVersion());
if (vmmMleId == null) {
throw new ASException(ErrorCode.AS_VMM_INCORRECT, host.getVmm().getName(), host.getVmm().getVersion());
}
return vmmMleId;
}
Aggregations