1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.web.struts;
17
18 import org.kuali.ole.integration.purap.CapitalAssetLocation;
19 import org.kuali.ole.module.purap.PurapConstants;
20 import org.kuali.ole.module.purap.PurapConstants.RequisitionStatuses;
21 import org.kuali.ole.module.purap.businessobject.*;
22 import org.kuali.ole.module.purap.document.RequisitionDocument;
23 import org.kuali.rice.kew.api.WorkflowDocument;
24 import org.kuali.rice.kns.web.ui.ExtraButton;
25 import org.kuali.rice.kns.web.ui.HeaderField;
26 import org.kuali.rice.krad.util.KRADConstants;
27 import org.kuali.rice.krad.util.ObjectUtils;
28
29 import javax.servlet.http.HttpServletRequest;
30 import java.math.BigDecimal;
31 import java.util.List;
32
33
34
35
36 public class RequisitionForm extends PurchasingFormBase {
37
38 protected String shopUrl;
39
40
41
42
43 public RequisitionForm() {
44 super();
45 }
46
47
48
49
50
51
52
53 @Override
54 protected String getDefaultDocumentTypeName() {
55 return "OLE_REQS";
56 }
57
58 public RequisitionDocument getRequisitionDocument() {
59 return (RequisitionDocument) getDocument();
60 }
61
62 public void setRequisitionDocument(RequisitionDocument requisitionDocument) {
63 setDocument(requisitionDocument);
64 }
65
66
67
68
69
70
71 @Override
72 public void populateHeaderFields(WorkflowDocument workflowDocument) {
73 super.populateHeaderFields(workflowDocument);
74
75 if (ObjectUtils.isNotNull(this.getRequisitionDocument().getPurapDocumentIdentifier())) {
76 getDocInfo().add(new HeaderField("DataDictionary.RequisitionDocument.attributes.purapDocumentIdentifier", ((RequisitionDocument) this.getDocument()).getPurapDocumentIdentifier().toString()));
77 } else {
78 getDocInfo().add(new HeaderField("DataDictionary.RequisitionDocument.attributes.purapDocumentIdentifier", PurapConstants.PURAP_APPLICATION_DOCUMENT_ID_NOT_AVAILABLE));
79 }
80
81 String applicationDocumentStatus = PurapConstants.PURAP_APPLICATION_DOCUMENT_STATUS_NOT_AVAILABLE;
82
83 if (ObjectUtils.isNotNull(this.getRequisitionDocument().getApplicationDocumentStatus())) {
84 applicationDocumentStatus = workflowDocument.getApplicationDocumentStatus();
85 }
86
87 getDocInfo().add(new HeaderField("DataDictionary.RequisitionDocument.attributes.applicationDocumentStatus", applicationDocumentStatus));
88 }
89
90
91
92
93 @Override
94 public boolean shouldMethodToCallParameterBeUsed(String methodToCallParameterName, String methodToCallParameterValue, HttpServletRequest request) {
95 if (KRADConstants.DISPATCH_REQUEST_PARAMETER.equals(methodToCallParameterName) &&
96 ("displayB2BRequisition".equals(methodToCallParameterValue))) {
97 return true;
98 }
99 return super.shouldMethodToCallParameterBeUsed(methodToCallParameterName, methodToCallParameterValue, request);
100 }
101
102 @Override
103 public Class getCapitalAssetLocationClass() {
104 return RequisitionCapitalAssetLocation.class;
105 }
106
107 @Override
108 public Class getItemCapitalAssetClass() {
109 return RequisitionItemCapitalAsset.class;
110 }
111
112
113
114
115 @Override
116 public PurApItem setupNewPurchasingItemLine() {
117 return new RequisitionItem();
118 }
119
120
121
122
123 @Override
124 public RequisitionAccount setupNewPurchasingAccountingLine() {
125 return new RequisitionAccount();
126 }
127
128
129
130
131 @Override
132 public RequisitionAccount setupNewAccountDistributionAccountingLine() {
133 RequisitionAccount account = setupNewPurchasingAccountingLine();
134 account.setAccountLinePercent(new BigDecimal(100));
135 return account;
136 }
137
138 @Override
139 public CapitalAssetLocation setupNewPurchasingCapitalAssetLocationLine() {
140 return new RequisitionCapitalAssetLocation();
141 }
142
143 public String getShopUrl() {
144 return shopUrl;
145 }
146
147 public void setShopUrl(String shopUrl) {
148 this.shopUrl = shopUrl;
149 }
150
151
152
153
154
155
156
157
158 @Override
159 public List<ExtraButton> getExtraButtons() {
160 super.getExtraButtons();
161 for (int i = 0; i < extraButtons.size(); i++) {
162 ExtraButton extraButton = extraButtons.get(i);
163 if ("methodToCall.calculate".equalsIgnoreCase(extraButton.getExtraButtonProperty())) {
164 if (canUserCalculate() == false) {
165 extraButtons.remove(i);
166 return extraButtons;
167 }
168 }
169 }
170 return extraButtons;
171 }
172
173 @Override
174 public boolean canUserCalculate() {
175 return documentActions != null && documentActions.containsKey(KRADConstants.KUALI_ACTION_CAN_EDIT) &&
176 !getRequisitionDocument().isDocumentStoppedInRouteNode(RequisitionStatuses.NODE_ORG_REVIEW);
177 }
178 }