def _renderEvents(self, pdfRenderer, view): """ render a listing of events """ # get options -- TODO: should be refactored with _renderTable (and beyond: should have a generalized system for getting options) options = view.getOptions() displayRowNumbers = False if "displayRowNumbers" in options: displayRowNumbers = normalizeBoolean(options['displayRowNumbers']) data = [] # fix header for events header = ['Time', 'Event'] events = view.getSearchJobEvents() for i, event in enumerate(events): if i >= self._maxRowsPerTable: break if (i > 0) and ((i % 100) == 0): self._keepAllSearchesAlive() data.append([str(event.time), event.raw]) if len(data) == 0: pdfRenderer.renderText("No matching events found.") else: tableData = pt.TableData(columnNames=header, data=data) pdfRenderer.renderTable(tableData, title=view.getTitle(), columnVAlignments=['TOP', 'TOP'], displayLineNumbers=displayRowNumbers)
def _renderTable(self, pdfRenderer, view): """ render a table of results """ # get options options = view.getOptions() if "show" in options and not normalizeBoolean(options['show']): return fieldFormats = view.getFieldFormats() displayRowNumbers = False if "displayRowNumbers" in options: displayRowNumbers = normalizeBoolean(options['displayRowNumbers']) overlay = None if "dataOverlayMode" in options: overlay = options['dataOverlayMode'] if "overlay" in options: overlay = options['overlay'] resultsExist = False # get results object view.getSearchJobObj().setFetchOptions(output_mode="json_cols", time_format=pt.TIME_RAW_FORMAT) results = view.getSearchJobResults() # determine field set explicitFieldList = view.getSearchFieldList() fieldOrder = [] if len(explicitFieldList) > 0: for field in explicitFieldList: if field in results.fieldOrder and field not in fieldOrder: fieldOrder.append(field) if len(fieldOrder) == 0: logger.warning("%s: results.fieldOrder does not contain any explicitly specified fields: %s" % (view.getTitle(), explicitFieldList)) return else: fieldOrder = self._renderTable_restrictFields(results.fieldOrder) if len(fieldOrder) == 0: pdfRenderer.renderText("No results found.") return tableData = pt.TableData(columnNames=fieldOrder) for i, result in enumerate(results): if i >= self._maxRowsPerTable: break if (i > 0) and ((i % 100) == 0): self._keepAllSearchesAlive() resultsExist = True tableData.addRowFromSearchResult(result) if resultsExist: pdfRenderer.renderTable(tableData, title=view.getSubtitle() or view.getTitle(), displayLineNumbers=displayRowNumbers, fieldFormats=fieldFormats, overlayMode=overlay) else: logger.warning("PDFGenHandler::_renderTable> no results for table") pdfRenderer.renderText("No results found.")