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.businessobject.AccountingLine;
23 import org.kuali.ole.sys.document.service.AccountingLineRenderingTransformation;
24 import org.kuali.ole.sys.document.web.ReadOnlyable;
25 import org.kuali.ole.sys.document.web.RenderableElement;
26 import org.kuali.ole.sys.document.web.TableJoining;
27
28
29
30
31 public class AllReadOnlyNoActionsAccountingLineRenderingTransformationImpl implements AccountingLineRenderingTransformation {
32
33
34
35
36
37 public void transformElements(List<TableJoining> elements, AccountingLine accountingLine) {
38 if (allReadOnly(elements)) {
39 removeActionBlocks(elements);
40 }
41 }
42
43
44
45
46
47
48 protected boolean allReadOnly(List<TableJoining> elements) {
49 for (TableJoining element : elements) {
50 if (element instanceof ReadOnlyable && !((ReadOnlyable)element).isReadOnly()) {
51 return false;
52 }
53 }
54 return true;
55 }
56
57
58
59
60
61 protected void removeActionBlocks(List<? extends TableJoining> elements) {
62 Set<TableJoining> elementsToRemove = new HashSet<TableJoining>();
63 for (TableJoining element : elements) {
64 element.removeAllActionBlocks();
65 if (element instanceof RenderableElement && ((RenderableElement)element).isActionBlock()) {
66 elementsToRemove.add(element);
67 }
68 }
69 elements.removeAll(elementsToRemove);
70 }
71
72 }