public DisplayNames display( String sorted, String type, String ip, TransactionReport report, String queryName) { Map<String, TransactionType> types = report.getMachines().get(ip).getTypes(); TransactionName all = new TransactionName("TOTAL"); all.setTotalPercent(1); if (types != null) { TransactionType names = types.get(type); if (names != null) { for (Entry<String, TransactionName> entry : names.getNames().entrySet()) { String transTypeName = entry.getValue().getId(); boolean isAdd = (queryName == null || queryName.length() == 0 || isFit(queryName, transTypeName)); if (isAdd) { m_results.add(new TransactionNameModel(entry.getKey(), entry.getValue())); mergeName(all, entry.getValue()); } } } } if (sorted == null) { sorted = "avg"; } Collections.sort(m_results, new TransactionNameComparator(sorted)); long total = all.getTotalCount(); for (TransactionNameModel nameModel : m_results) { TransactionName transactionName = nameModel.getDetail(); transactionName.setTotalPercent(transactionName.getTotalCount() / (double) total); } m_results.add(0, new TransactionNameModel("TOTAL", all)); return this; }
@Override public int compare(TransactionNameModel m1, TransactionNameModel m2) { if (m_sorted.equals("name") || m_sorted.equals("type")) { return m1.getType().compareTo(m2.getType()); } if (m_sorted.equals("total")) { return (int) (m2.getDetail().getTotalCount() - m1.getDetail().getTotalCount()); } if (m_sorted.equals("failure")) { return (int) (m2.getDetail().getFailCount() - m1.getDetail().getFailCount()); } if (m_sorted.equals("failurePercent")) { return (int) (m2.getDetail().getFailPercent() * 100 - m1.getDetail().getFailPercent() * 100); } if (m_sorted.equals("avg")) { return (int) (m2.getDetail().getAvg() * 100 - m1.getDetail().getAvg() * 100); } if (m_sorted.equals("95line")) { return (int) (m2.getDetail().getLine95Value() * 100 - m1.getDetail().getLine95Value() * 100); } return 0; }