1 package org.kuali.ole.deliver;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.ole.deliver.form.OleLoanForm;
5 import org.kuali.ole.describe.form.EditorForm;
6 import org.kuali.ole.krad.OleComponent;
7 import org.kuali.ole.krad.OleComponentUtils;
8 import org.kuali.rice.krad.uif.component.Component;
9 import org.kuali.rice.krad.uif.container.Group;
10 import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
11 import org.kuali.rice.krad.uif.view.View;
12
13 import java.util.Iterator;
14 import java.util.List;
15
16
17
18
19
20
21
22
23 public class OleGroup extends Group {
24 private static final Logger LOG = Logger
25 .getLogger(OleGroup.class);
26
27 private static String ALTER_DUE_DATE_ID = "AlterDueDateSection-HorizontalBoxSection";
28
29 private static String RENEWAL_ID = "RenewalDueDateSection-HorizontalBoxSection";
30
31 private static String PROXY_PATRON_ID = "RealPatronSection-HorizontalBoxSection";
32
33 private static String DAMAGED_ITEM_ID = "DamagedItem-HorizontalBoxSection";
34
35 private static String MISSING_PIECE_ID = "MissingPiece-HorizontalBoxSection";
36
37 private static String CLAIMS_RETURN_ID = "ClaimsReturn-HorizontalBoxSection";
38
39 private static String OVERRIDE_LOGIN = "OverRideLogInSectionLink";
40
41 private static String PATRON_NOTE_ID = "PatronUserNote-HorizontalBoxSection";
42
43 private static String CONFIRM_CIRULATION_LOCATION = "ConfirmCirculationLocationChange";
44
45 private static String MISSING_PIECE_RECORD_NOTE = "OLELoanView-RecordNote-MissingPiece-MessageBox";
46
47 private static String DAMAGED_RECORD_NOTE = "OLELoanView-RecordNote-Damaged-MessageBox";
48
49 private static String LOAN_CLAIMS_OPTIONS = "loanClaimsOption";
50
51
52
53
54
55
56
57
58
59
60
61
62
63 @Override
64 public void performInitialization(View view, Object form) {
65
66 super.performInitialization(view, form);
67
68 boolean alterDueDate = ((OleLoanForm) form).isAlterDueDateFlag();
69 boolean renewDueDateFlag = ((OleLoanForm) form).isRenewDueDateFlag();
70 boolean realPatronFlag = ((OleLoanForm) form).isRealPatronFlag();
71 boolean missingPieceDialog = ((OleLoanForm) form).isMissingPieceDialog();
72 boolean damagedItemDialog = ((OleLoanForm) form).isDamagedItemDialog();
73 boolean claimsReturnFlag = ((OleLoanForm) form).isClaimsReturnFlag();
74 boolean overrideFlag = ((OleLoanForm) form).isOverrideFlag();
75 boolean patronNoteFlag = ((OleLoanForm) form).isPatronNoteFlag();
76 boolean changeLocationFlag = ((OleLoanForm) form).isChangeLocationFlag();
77 boolean displayMissingPieceNotePopup = ((OleLoanForm) form).isDisplayMissingPieceNotePopup();
78 boolean displayDamagedRecordNotePopup = ((OleLoanForm) form).isDisplayDamagedRecordNotePopup();
79 boolean claimsFlag = ((OleLoanForm) form).isClaimsFlag();
80 LOG.info("alterDueDate " + alterDueDate);
81 List<? extends Component> items = getItems();
82 Iterator<? extends Component> itemIterator = items.iterator();
83 while (itemIterator.hasNext()) {
84 Component component = itemIterator.next();
85 if (component == null) {
86 continue;
87 }
88
89 LOG.info("checking component " + component.getId());
90
91
92 if (ALTER_DUE_DATE_ID.equals(component.getId())
93 && !alterDueDate) {
94 LOG.info("Omitting "+component.getId()+" from lifecycle");
95 itemIterator.remove();
96 }else if(RENEWAL_ID.equals(component.getId())
97 && !renewDueDateFlag){
98 LOG.info("Omitting "+component.getId()+" from lifecycle");
99 itemIterator.remove();
100 }else if(PROXY_PATRON_ID.equals(component.getId())
101 && !realPatronFlag){
102 LOG.info("Omitting "+component.getId()+" from lifecycle");
103 itemIterator.remove();
104 }else if(DAMAGED_ITEM_ID.equals(component.getId())
105 && !damagedItemDialog){
106 LOG.info("Omitting "+component.getId()+" from lifecycle");
107 itemIterator.remove();
108 }else if(MISSING_PIECE_ID.equals(component.getId())
109 && !missingPieceDialog){
110 LOG.info("Omitting "+component.getId()+" from lifecycle");
111 itemIterator.remove();
112 }else if(CLAIMS_RETURN_ID.equals(component.getId())
113 && !claimsReturnFlag){
114 LOG.info("Omitting "+component.getId()+" from lifecycle");
115 itemIterator.remove();
116 }else if(OVERRIDE_LOGIN.equals(component.getId())
117 && !overrideFlag){
118 LOG.info("Omitting "+component.getId()+" from lifecycle");
119 itemIterator.remove();
120 }else if(PATRON_NOTE_ID.equals(component.getId())
121 && !patronNoteFlag){
122 LOG.info("Omitting "+component.getId()+" from lifecycle");
123 itemIterator.remove();
124 }else if(CONFIRM_CIRULATION_LOCATION.equals(component.getId())
125 && !changeLocationFlag){
126 LOG.info("Omitting "+component.getId()+" from lifecycle");
127 itemIterator.remove();
128 }else if(MISSING_PIECE_RECORD_NOTE.equals(component.getId())
129 && !displayMissingPieceNotePopup){
130 LOG.info("Omitting "+component.getId()+" from lifecycle");
131 itemIterator.remove();
132 }else if(DAMAGED_RECORD_NOTE.equals(component.getId())
133 && !displayDamagedRecordNotePopup){
134 LOG.info("Omitting "+component.getId()+" from lifecycle");
135 itemIterator.remove();
136 }else if(LOAN_CLAIMS_OPTIONS.equals(component.getId())
137 && !claimsFlag){
138 LOG.info("Omitting "+component.getId()+" from lifecycle");
139 itemIterator.remove();
140 }
141 }
142 }
143
144
145
146
147
148
149 @Override
150 protected <T> void copyProperties(T component) {
151 List<? extends Component> srcitems = getItems();
152
153
154 setItems(null);
155 super.copyProperties(component);
156 setItems(srcitems);
157
158 Group groupCopy = (Group) component;
159 groupCopy.setItems(OleComponentUtils.filterItems(srcitems));
160 }
161
162 }