TSK-1344: Added public method Report#createRow to allow manual addition of report rows
This commit is contained in:
parent
4fea8b5402
commit
d62184df2c
|
|
@ -34,8 +34,8 @@ public abstract class Report<I extends QueryItem, H extends ColumnHeader<? super
|
||||||
|
|
||||||
protected Report(List<H> columnHeaders, String[] rowDesc) {
|
protected Report(List<H> columnHeaders, String[] rowDesc) {
|
||||||
this.rowDesc = rowDesc;
|
this.rowDesc = rowDesc;
|
||||||
sumRow = createRow("Total", columnHeaders.size());
|
|
||||||
this.columnHeaders = new ArrayList<>(columnHeaders);
|
this.columnHeaders = new ArrayList<>(columnHeaders);
|
||||||
|
sumRow = createRow("Total");
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Map<String, Row<I>> getRows() {
|
public final Map<String, Row<I>> getRows() {
|
||||||
|
|
@ -69,16 +69,14 @@ public abstract class Report<I extends QueryItem, H extends ColumnHeader<? super
|
||||||
public final void addItem(I item) {
|
public final void addItem(I item) {
|
||||||
Row<I> row = null;
|
Row<I> row = null;
|
||||||
if (columnHeaders.isEmpty()) {
|
if (columnHeaders.isEmpty()) {
|
||||||
row = reportRows.computeIfAbsent(item.getKey(), key -> createRow(key, columnHeaders.size()));
|
row = reportRows.computeIfAbsent(item.getKey(), this::createRow);
|
||||||
row.updateTotalValue(item);
|
row.updateTotalValue(item);
|
||||||
sumRow.updateTotalValue(item);
|
sumRow.updateTotalValue(item);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < columnHeaders.size(); i++) {
|
for (int i = 0; i < columnHeaders.size(); i++) {
|
||||||
if (columnHeaders.get(i).fits(item)) {
|
if (columnHeaders.get(i).fits(item)) {
|
||||||
if (row == null) {
|
if (row == null) {
|
||||||
row =
|
row = reportRows.computeIfAbsent(item.getKey(), this::createRow);
|
||||||
reportRows.computeIfAbsent(
|
|
||||||
item.getKey(), key -> createRow(key, columnHeaders.size()));
|
|
||||||
}
|
}
|
||||||
row.addItem(item, i);
|
row.addItem(item, i);
|
||||||
sumRow.addItem(item, i);
|
sumRow.addItem(item, i);
|
||||||
|
|
@ -104,6 +102,10 @@ public abstract class Report<I extends QueryItem, H extends ColumnHeader<? super
|
||||||
sumRow.setDisplayName(displayMap);
|
sumRow.setDisplayName(displayMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final Row<I> createRow(String key) {
|
||||||
|
return createRow(key, columnHeaders.size());
|
||||||
|
}
|
||||||
|
|
||||||
protected Row<I> createRow(String key, int columnSize) {
|
protected Row<I> createRow(String key, int columnSize) {
|
||||||
return new SingleRow<>(key, columnSize);
|
return new SingleRow<>(key, columnSize);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue