mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-19 04:58:00 +00:00
WIP: frontend hangs while getting records from backend
This commit is contained in:
parent
7d8df398e7
commit
ddada80add
@ -10,12 +10,16 @@ import hirs.attestationca.portal.page.PageController;
|
||||
import hirs.attestationca.portal.page.params.NoPageParams;
|
||||
import hirs.data.persist.ReferenceDigestRecord;
|
||||
import hirs.data.persist.ReferenceDigestValue;
|
||||
import hirs.data.persist.certificate.Certificate;
|
||||
import hirs.persist.CriteriaModifier;
|
||||
import hirs.persist.DBReferenceDigestManager;
|
||||
import hirs.persist.DBReferenceEventManager;
|
||||
import hirs.persist.ReferenceDigestManager;
|
||||
import hirs.persist.ReferenceEventManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -135,17 +139,27 @@ public class TpmEventsPageController
|
||||
method = RequestMethod.GET)
|
||||
public DataTableResponse<ReferenceDigestRecord> getTableData(
|
||||
final DataTableInput input) {
|
||||
LOGGER.debug("Handling request for summary list: " + input);
|
||||
LOGGER.info("Handling request for summary list: " + input);
|
||||
|
||||
String orderColumnName = input.getOrderColumnName();
|
||||
LOGGER.debug("Ordering on column: " + orderColumnName);
|
||||
LOGGER.info("Ordering on column: " + orderColumnName);
|
||||
|
||||
// check that the alert is not archived and that it is in the specified report
|
||||
CriteriaModifier criteriaModifier = new CriteriaModifier() {
|
||||
@Override
|
||||
public void modify(final Criteria criteria) {
|
||||
criteria.add(Restrictions.isNull(Certificate.ARCHIVE_FIELD));
|
||||
}
|
||||
};
|
||||
|
||||
LOGGER.info("Querying with the following datatableinput: " + input.toString());
|
||||
FilteredRecordsList<ReferenceDigestRecord> referenceDigestRecords
|
||||
= OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
ReferenceDigestRecord.class,
|
||||
referenceDigestManager,
|
||||
input, orderColumnName);
|
||||
input, orderColumnName, criteriaModifier);
|
||||
LOGGER.info("ReferenceDigestManager returned: "
|
||||
+ Arrays.toString(referenceDigestRecords.toArray()));
|
||||
FilteredRecordsList<HashMap<ReferenceDigestRecord, ReferenceDigestValue>>
|
||||
mappedRecordValues = mapRecordToValues(referenceDigestRecords);
|
||||
|
||||
|
@ -35,6 +35,7 @@ import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -766,6 +767,10 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||
searchClass = this.clazz;
|
||||
}
|
||||
|
||||
LOGGER.info(clazz.getName() + " querying for "
|
||||
+ Arrays.toString(searchableColumns.entrySet().toArray())
|
||||
+ " with search strings \"" + search + "\"");
|
||||
|
||||
//Object that will store query values
|
||||
FilteredRecordsList<T> aqr = new FilteredRecordsList<>();
|
||||
|
||||
@ -786,6 +791,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||
Long recordsFiltered = totalResultCount;
|
||||
Conjunction and = Restrictions.conjunction();
|
||||
if (totalResultCount != 0) {
|
||||
LOGGER.info("Total result count greater than 0");
|
||||
//Builds the search criteria from all of the searchable columns
|
||||
if (searchableColumns != null) {
|
||||
// Search for all words in all searchable columns
|
||||
@ -804,10 +810,18 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info("Search columns filtered");
|
||||
//Retrieves a count of all the records after being filtered
|
||||
criteria.setProjection(Projections.countDistinct("id"))
|
||||
.add(and);
|
||||
recordsFiltered = (Long) criteria.uniqueResult();
|
||||
try {
|
||||
LOGGER.info("Get unique result from criteria object");
|
||||
recordsFiltered = (Long) criteria.uniqueResult();
|
||||
} catch (HibernateException e) {
|
||||
LOGGER.info(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
LOGGER.info("Error while getting unique result: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (recordsFiltered != 0) {
|
||||
@ -867,6 +881,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
LOGGER.info(clazz.getName() + " found " + aqr.getRecordsTotal() + " records");
|
||||
return aqr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user