private void findNewFindings( org.jcoderz.phoenix.report.jaxb.File newFile, org.jcoderz.phoenix.report.jaxb.File oldFile) { final List<Item> newFindings = new ArrayList<Item>((List<Item>) newFile.getItem()); final List<Item> oldFindings = new ArrayList<Item>((List<Item>) oldFile.getItem()); filterLowSeverity(newFindings); filterLowSeverity(oldFindings); filterFullMatches(newFindings, oldFindings); filterPartialMatches(newFindings, oldFindings); // the rest... flaggAllAsNew(newFindings); for (Item item : oldFindings) { addAsOld(newFile.getItem(), item); } }
/** * Searches for new findings based on the old jcReport and increases the severity of such findings * to NEW. */ public void flagNewFindings() { logger.log(Level.FINE, "Searching for NEW findings..."); try { final JAXBContext ctx = JAXBContext.newInstance(new Class[] {Report.class}); final Report currentReport = (Report) ctx.createUnmarshaller().unmarshal(mOutFile); final Report oldReport = (Report) ctx.createUnmarshaller().unmarshal(mOldReport); for (org.jcoderz.phoenix.report.jaxb.File newFile : (List<org.jcoderz.phoenix.report.jaxb.File>) currentReport.getFile()) { final org.jcoderz.phoenix.report.jaxb.File oldFile = findFile(newFile, oldReport); if (oldFile != null) { findNewFindings(newFile, oldFile); } else { flaggAllAsNew(newFile.getItem()); } } writeResult(currentReport, mOutFile); } catch (Exception ex) { logger.log(Level.WARNING, "Failed to flagNewFindings. Cause " + ex.getMessage(), ex); } }
// This could be done faster, might be restructure the data first for // faster lookup. private org.jcoderz.phoenix.report.jaxb.File findFile( org.jcoderz.phoenix.report.jaxb.File newFile, Report oldReport) { final String className = newFile.getClassname(); final String packageName = newFile.getPackage(); final String fileName = newFile.getName(); org.jcoderz.phoenix.report.jaxb.File result = null; for (org.jcoderz.phoenix.report.jaxb.File file : (List<org.jcoderz.phoenix.report.jaxb.File>) oldReport.getFile()) { if (ObjectUtil.equals(file.getName(), fileName) || (!StringUtil.isEmptyOrNull(className) && packageName != null && ObjectUtil.equals(file.getClassname(), className) && ObjectUtil.equals(file.getPackage(), packageName))) { result = file; break; } } return result; }