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.PurapParameterConstants;
19 import org.kuali.ole.module.purap.document.ContractManagerAssignmentDocument;
20 import org.kuali.ole.module.purap.document.RequisitionDocument;
21 import org.kuali.ole.sys.OLEPropertyConstants;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.ole.vnd.businessobject.CommodityContractManager;
24 import org.kuali.ole.vnd.businessobject.ContractManager;
25 import org.kuali.rice.core.web.format.DateViewDateObjectFormatter;
26 import org.kuali.rice.core.web.format.Formatter;
27 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
28 import org.kuali.rice.kew.api.exception.WorkflowException;
29 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
30
31 import java.util.LinkedHashMap;
32 import java.util.List;
33
34
35
36
37 public class ContractManagerAssignmentDetail extends PersistableBusinessObjectBase {
38
39 private String documentNumber;
40 private Integer requisitionIdentifier;
41 private Integer contractManagerCode;
42 private String deliveryCampusCode;
43 private String vendorName;
44
45 private RequisitionDocument requisition;
46 private ContractManager contractManager;
47 private ContractManagerAssignmentDocument contractManagerAssignmentDocument;
48
49 private String createDate;
50
51
52
53
54 public ContractManagerAssignmentDetail() {
55
56 }
57
58
59
60
61
62
63
64 public ContractManagerAssignmentDetail(ContractManagerAssignmentDocument acmDocument, RequisitionDocument requisitionDocument) {
65 this.documentNumber = acmDocument.getDocumentNumber();
66 this.contractManagerAssignmentDocument = acmDocument;
67 this.requisition = requisitionDocument;
68 this.requisitionIdentifier = requisitionDocument.getPurapDocumentIdentifier();
69 this.deliveryCampusCode = requisitionDocument.getDeliveryCampusCode();
70 this.vendorName = requisitionDocument.getVendorName();
71 }
72
73 public String getDocumentNumber() {
74 return documentNumber;
75 }
76
77 public void setDocumentNumber(String documentNumber) {
78 this.documentNumber = documentNumber;
79 }
80
81 public Integer getRequisitionIdentifier() {
82 return requisitionIdentifier;
83 }
84
85 public void setRequisitionIdentifier(Integer requisitionIdentifier) {
86 this.requisitionIdentifier = requisitionIdentifier;
87 }
88
89
90
91
92
93
94
95
96
97
98
99
100 public Integer getContractManagerCode() {
101 String paramName = PurapParameterConstants.ENABLE_DEFAULT_CONTRACT_MANAGER_IND;
102 String paramValue = SpringContext.getBean(ParameterService.class).getParameterValueAsString(ContractManagerAssignmentDocument.class, paramName);
103 if (paramValue.equals("Y") && (contractManagerCode == null) && getFirstLineItem().getCommodityCode() != null) {
104 List<CommodityContractManager> commodityContractManagers = getFirstLineItem().getCommodityCode().getCommodityContractManagers();
105 if (commodityContractManagers != null && commodityContractManagers.size() > 0) {
106 int count = 0;
107 Integer matchingContractManagerCode = null;
108 for (CommodityContractManager commodityContractManager : commodityContractManagers) {
109 if (this.getRequisition().getDeliveryCampusCode().equals(commodityContractManager.getCampusCode())) {
110 count = count + 1;
111 matchingContractManagerCode = commodityContractManager.getContractManagerCode();
112 }
113 }
114 if (count == 1) {
115 setContractManagerCode(matchingContractManagerCode);
116 return contractManagerCode;
117 }
118 }
119 }
120 return contractManagerCode;
121 }
122
123 public void setContractManagerCode(Integer contractManagerCode) {
124 this.contractManagerCode = contractManagerCode;
125 }
126
127 public ContractManager getContractManager() {
128 return contractManager;
129 }
130
131
132
133
134 public void setContractManager(ContractManager contractManager) {
135 this.contractManager = contractManager;
136 }
137
138 public RequisitionDocument getRequisition() {
139 return requisition;
140 }
141
142
143
144
145 public void setRequisition(RequisitionDocument requisition) {
146 this.requisition = requisition;
147 }
148
149 public ContractManagerAssignmentDocument getContractManagerAssignmentDocument() {
150 return contractManagerAssignmentDocument;
151 }
152
153 public void setContractManagerAssignmentDocument(ContractManagerAssignmentDocument contractManagerAssignmentDocument) {
154 this.contractManagerAssignmentDocument = contractManagerAssignmentDocument;
155 }
156
157
158
159
160
161
162
163
164 public String getCreateDate() throws WorkflowException {
165 if (createDate == null) {
166 Formatter formatter = new DateViewDateObjectFormatter();
167 createDate = (String) formatter.format(getRequisition().getFinancialSystemDocumentHeader().getWorkflowDocument().getDateCreated().toDate());
168 }
169 return createDate;
170 }
171
172 public void setCreateDate(String createDate) {
173 this.createDate = createDate;
174 }
175
176 private PurchasingItemBase getFirstLineItem() {
177 return (PurchasingItemBase) this.getRequisition().getItem(0);
178 }
179
180 public String getDeliveryCampusCode() {
181 return deliveryCampusCode;
182 }
183
184 public void setDeliveryCampusCode(String deliveryCampusCode) {
185 this.deliveryCampusCode = deliveryCampusCode;
186 }
187
188 public String getVendorName() {
189 return vendorName;
190 }
191
192 public void setVendorName(String vendorName) {
193 this.vendorName = vendorName;
194 }
195
196
197
198
199 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
200 LinkedHashMap m = new LinkedHashMap();
201 m.put(OLEPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
202 if (this.requisitionIdentifier != null) {
203 m.put("requisitionIdentifier", this.requisitionIdentifier.toString());
204 }
205 return m;
206 }
207
208 }