public DisplayNames() {
}
public DisplayNames display(String sorted, String type, String ip, TransactionReport report, String queryName) {
Map<String, TransactionType> types = report.findOrCreateMachine(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;
}