1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.businessobject;
17
18 import org.kuali.ole.module.purap.document.service.PurchaseOrderService;
19 import org.kuali.ole.sys.OLEConstants;
20 import org.kuali.ole.sys.context.SpringContext;
21 import org.kuali.rice.krad.bo.Note;
22 import org.kuali.rice.krad.document.Document;
23 import org.kuali.rice.krad.util.ObjectUtils;
24
25 import java.sql.Timestamp;
26 import java.util.ArrayList;
27 import java.util.List;
28
29
30
31
32 public class PurchaseOrderView extends AbstractRelatedView {
33
34 private Boolean purchaseOrderCurrentIndicator;
35 private String recurringPaymentTypeCode;
36 private String vendorChoiceCode;
37 private Timestamp recurringPaymentEndDate;
38 private Timestamp purchaseOrderInitialOpenTimestamp;
39
40 private List<Note> notes;
41
42 public boolean isPurchaseOrderCurrentIndicator() {
43 return purchaseOrderCurrentIndicator;
44 }
45
46 public boolean getPurchaseOrderCurrentIndicator() {
47 return purchaseOrderCurrentIndicator;
48 }
49
50 public void setPurchaseOrderCurrentIndicator(boolean purchaseOrderCurrentIndicator) {
51 this.purchaseOrderCurrentIndicator = purchaseOrderCurrentIndicator;
52 }
53
54 public String getRecurringPaymentTypeCode() {
55 return recurringPaymentTypeCode;
56 }
57
58 public void setRecurringPaymentTypeCode(String recurringPaymentTypeCode) {
59 this.recurringPaymentTypeCode = recurringPaymentTypeCode;
60 }
61
62 public String getVendorChoiceCode() {
63 return vendorChoiceCode;
64 }
65
66 public void setVendorChoiceCode(String vendorChoiceCode) {
67 this.vendorChoiceCode = vendorChoiceCode;
68 }
69
70 public Timestamp getRecurringPaymentEndDate() {
71 return recurringPaymentEndDate;
72 }
73
74 public void setRecurringPaymentEndDate(Timestamp recurringPaymentEndDate) {
75 this.recurringPaymentEndDate = recurringPaymentEndDate;
76 }
77
78 public Timestamp getPurchaseOrderInitialOpenTimestamp() {
79 return purchaseOrderInitialOpenTimestamp;
80 }
81
82 public void setPurchaseOrderInitialOpenTimestamp(Timestamp purchaseOrderInitialOpenTimestamp) {
83 this.purchaseOrderInitialOpenTimestamp = purchaseOrderInitialOpenTimestamp;
84 }
85
86
87
88
89 @Override
90 public List<Note> getNotes() {
91 if (this.isPurchaseOrderCurrentIndicator()) {
92 if (notes == null) {
93 notes = new ArrayList<Note>();
94 List<Note> tmpNotes = SpringContext.getBean(PurchaseOrderService.class).getPurchaseOrderNotes(this.getPurapDocumentIdentifier());
95
96
97 for (int i = tmpNotes.size() - 1; i >= 0; i--) {
98 Note note = tmpNotes.get(i);
99 notes.add(note);
100 }
101 }
102 } else {
103 notes = null;
104 }
105 return notes;
106 }
107
108
109
110
111
112
113
114 @Override
115 public Integer getPurapDocumentIdentifier() {
116 return super.getPurapDocumentIdentifier();
117 }
118
119 @Override
120 public String getDocumentIdentifierString() {
121 return super.getDocumentIdentifierString();
122 }
123
124
125
126
127 @Override
128 public String getDocumentNumber() {
129 return super.getDocumentNumber();
130 }
131
132
133
134
135 @Override
136 public String getUrl() {
137 return super.getUrl();
138 }
139
140
141
142
143
144
145 public boolean getNeedWarning() {
146 return getPurchaseOrderInitialOpenTimestamp() == null;
147 }
148
149
150
151
152 @Override
153 public String getDocumentTypeName() {
154 Document document = findDocument(this.getDocumentNumber());
155 if (ObjectUtils.isNotNull(document)) {
156 return document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName();
157 }
158
159 return OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER;
160 }
161 }