1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.service.impl;
17
18 import java.util.HashSet;
19 import java.util.List;
20 import java.util.Set;
21
22 import org.kuali.ole.sys.document.service.AccountingLineTableTransformation;
23 import org.kuali.ole.sys.document.web.AccountingLineTableCell;
24 import org.kuali.ole.sys.document.web.AccountingLineTableRow;
25
26
27
28
29 public class RemoveEmptyCellsAndRowsRenderingTransformationImpl implements AccountingLineTableTransformation {
30
31
32
33
34
35 public void transformRows(List<AccountingLineTableRow> rows) {
36 Set<AccountingLineTableRow> rowsToRemove = new HashSet<AccountingLineTableRow>();
37 for (AccountingLineTableRow row : rows) {
38 removeEmptyCells(row);
39 if (row.isEmpty()) {
40 rowsToRemove.add(row);
41 }
42 }
43 rows.removeAll(rowsToRemove);
44 }
45
46
47
48
49
50 public void removeEmptyCells(AccountingLineTableRow row) {
51 Set<AccountingLineTableCell> cellsToRemove = new HashSet<AccountingLineTableCell>();
52 for (AccountingLineTableCell cell : row.getCells()) {
53 if (cell.isEmpty()) {
54 cellsToRemove.add(cell);
55 }
56 }
57 row.getCells().removeAll(cellsToRemove);
58 }
59 }