use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class TblTaLogJpaController method findLogsByHostId.
public List<TblTaLog> findLogsByHostId(int hostId, Date lastUpdatedTs) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblTaLog.findLogsByHostId");
query.setParameter("hostID", hostId);
query.setParameter("updatedOn", lastUpdatedTs);
List<TblTaLog> logs = query.getResultList();
return logs;
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class ReportsBOTest method testGetTrustReportWithError.
@Test
public void testGetTrustReportWithError() {
Collection<Hostname> hostNames = new ArrayList<Hostname>();
hostNames.add(new Hostname(SERVER_NAME));
when(tblHostsJpaController.findByName(anyString())).thenReturn(mockFindByName());
List<TblTaLog> taLogs = new ArrayList<TblTaLog>();
TblTaLog taLog1 = new TblTaLog(Integer.valueOf(1), 1, 1, "0", "31B97D97B4679917EC3C1D943635693FFBAB4143", false, new Date());
TblTaLog taLog2 = new TblTaLog(Integer.valueOf(2), 1, 2, "18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", false, new Date());
taLog1.setError("BIOS:1,VMM:1");
taLog2.setError("BIOS:1,VMM:1");
taLogs.add(taLog1);
taLogs.add(taLog2);
when(tblTaLogJpaController.findTrustStatusByHostId(anyInt(), anyInt())).thenReturn(taLogs);
HostsTrustReportType hostsTrustReportType = reportsBO.getTrustReport(hostNames);
assertNotNull(hostsTrustReportType);
assertTrue(hostsTrustReportType.getHost().size() > 0);
}
use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class ReportsBOTest method testGetAttestationReport.
@Test
public void testGetAttestationReport() throws NumberFormatException, IOException {
when(tblHostsJpaController.findByName(anyString())).thenReturn(mockFindByName());
when(tblTaLogJpaController.findLastStatusTs(any(Integer.class))).thenReturn(new Date());
List<TblTaLog> taLogs = new ArrayList<TblTaLog>();
taLogs.add(new TblTaLog(Integer.valueOf(1), 1, 1, "18", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", true, new Date()));
when(tblTaLogJpaController.findLogsByHostId(anyInt(), any(Date.class))).thenReturn(taLogs);
AttestationReport attestationReport = reportsBO.getAttestationReport(new Hostname(SERVER_NAME), false);
assertNotNull(attestationReport);
assertTrue(attestationReport.getPcrLogs().size() > 0);
}
use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class TblModuleManifestLogJpaController method edit.
public void edit(TblModuleManifestLog tblModuleManifestLog) throws NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblModuleManifestLog persistentTblModuleManifestLog = em.find(TblModuleManifestLog.class, tblModuleManifestLog.getId());
TblTaLog taLogIdOld = persistentTblModuleManifestLog.getTaLogId();
TblTaLog taLogIdNew = tblModuleManifestLog.getTaLogId();
if (taLogIdNew != null) {
taLogIdNew = em.getReference(taLogIdNew.getClass(), taLogIdNew.getId());
tblModuleManifestLog.setTaLogId(taLogIdNew);
}
tblModuleManifestLog = em.merge(tblModuleManifestLog);
if (taLogIdOld != null && !taLogIdOld.equals(taLogIdNew)) {
taLogIdOld.getTblModuleManifestLogCollection().remove(tblModuleManifestLog);
taLogIdOld = em.merge(taLogIdOld);
}
if (taLogIdNew != null && !taLogIdNew.equals(taLogIdOld)) {
taLogIdNew.getTblModuleManifestLogCollection().add(tblModuleManifestLog);
em.merge(taLogIdNew);
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblModuleManifestLog.getId();
if (findTblModuleManifestLog(id) == null) {
throw new NonexistentEntityException("The tblModuleManifestLog with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class TblTaLogJpaController method findTblTaLogEntities.
private List<TblTaLog> findTblTaLogEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(TblTaLog.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
Aggregations