/** Submit a query to the archive and insert the logs in the main window */ private void submitQuery() { if (!checkFields()) { JOptionPane.showMessageDialog( this, "Error getting values from the form", "Input error!", JOptionPane.ERROR_MESSAGE); return; } loggingClient.reportStatus("Submitting a query"); guiSwitches.execute(); // Clear the logs and disconnect from the NC StringBuilder from = new StringBuilder(fromYY.getText()); from.append('-'); if (fromMM.getText().length() == 1) { from.append('0'); } from.append(fromMM.getText()); from.append('-'); if (fromDD.getText().length() == 1) { from.append('0'); } from.append(fromDD.getText()); from.append('T'); if (fromHr.getText().length() == 1) { from.append('0'); } from.append(fromHr.getText()); from.append(':'); if (fromMin.getText().length() == 1) { from.append('0'); } from.append(fromMin.getText()); from.append(':'); if (fromSec.getText().length() == 1) { from.append('0'); } from.append(fromSec.getText()); StringBuilder to = new StringBuilder(toYY.getText()); to.append('-'); if (toMM.getText().length() == 1) { to.append('0'); } to.append(toMM.getText()); to.append('-'); if (toDD.getText().length() == 1) { to.append('0'); } to.append(toDD.getText()); to.append('T'); if (toHr.getText().length() == 1) { to.append('0'); } to.append(toHr.getText()); to.append(':'); if (toMin.getText().length() == 1) { to.append('0'); } to.append(toMin.getText()); to.append(':'); if (toSec.getText().length() == 1) { to.append('0'); } to.append(toSec.getText()); short minType = (short) LogTypeHelper.values()[minLogLevelCB.getSelectedIndex()].acsCoreLevel.value; short maxType = (short) LogTypeHelper.values()[maxLogLevelCB.getSelectedIndex()].acsCoreLevel.value; String routine = routineName.getText(); if (routine.length() == 0) { routine = "*"; } String source = sourceName.getText(); if (source.length() == 0) { source = "*"; } String process = procName.getText(); if (process.length() == 0) { process = "*"; } int maxRows = Integer.parseInt(rowLimit.getText()); // The collection where the logs read from the DB are stored Collection logs = null; updateStatusLbl("Submitting query"); try { logs = archive.getLogs( from.toString() + ".000", to.toString() + ".000", minType, maxType, routine, source, process, maxRows); } catch (Throwable t) { System.err.println("Error executing the query: " + t.getMessage()); t.printStackTrace(System.err); JOptionPane.showMessageDialog( this, formatErrorMsg("Error executing the query:\n" + t.getMessage()), "Database error!", JOptionPane.ERROR_MESSAGE); loggingClient.reportStatus("Query terminated with error"); } if (logs != null && !logs.isEmpty()) { loggingClient.reportStatus("Num. of logs read from DB: " + logs.size()); LogMatcher matcher = new LogMatcher(); matcher.setAudience(loggingClient.getEngine().getAudience()); matcher.setFilters(loggingClient.getEngine().getFilters()); matcher.setDiscardLevel(loggingClient.getEngine().getDiscardLevel()); Iterator iter = logs.iterator(); int count = 0; while (iter.hasNext() && !terminateThread) { if ((++count) % 1000 == 0) { updateStatusLbl("Flushing logs " + count + "/" + logs.size()); } String str = (String) iter.next(); ILogEntry logEntry = null; try { logEntry = parser.parse(str); } catch (Exception e) { errorListener.errorReceived(str); continue; } if (matcher.match(logEntry)) { logListener.logEntryReceived(logEntry); } } logs.clear(); logs = null; } updateStatusLbl(""); // Update the state of the switches guiSwitches.checkControlsState(); }