1 package org.kuali.ole.select.controller;
2
3 import org.apache.commons.collections.CollectionUtils;
4 import org.apache.commons.lang.StringUtils;
5 import org.apache.commons.lang.time.DateUtils;
6 import org.kuali.ole.DocumentUniqueIDPrefix;
7 import org.kuali.ole.OLEConstants;
8 import org.kuali.ole.OLEKeyConstants;
9 import org.kuali.ole.describe.keyvalue.LocationValuesBuilder;
10 import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
11 import org.kuali.ole.docstore.common.document.*;
12 import org.kuali.ole.docstore.common.document.content.instance.OleHoldings;
13 import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor;
14 import org.kuali.ole.select.bo.OLESerialReceivingDocument;
15 import org.kuali.ole.select.bo.OLESerialReceivingHistory;
16 import org.kuali.ole.select.bo.OLESerialReceivingType;
17 import org.kuali.ole.select.bo.OLESerialRelatedPODocument;
18 import org.kuali.ole.select.document.OlePurchaseOrderDocument;
19 import org.kuali.ole.select.form.OLESerialReceivingForm;
20 import org.kuali.ole.service.impl.OLESerialReceivingService;
21 import org.kuali.ole.service.impl.OLESerialReceivingServiceImpl;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.ole.util.DocstoreUtil;
24 import org.kuali.rice.core.api.config.property.ConfigContext;
25 import org.kuali.rice.core.api.datetime.DateTimeService;
26 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
27 import org.kuali.rice.kew.actionitem.ActionItem;
28 import org.kuali.rice.kew.actionlist.service.ActionListService;
29 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
30 import org.kuali.rice.kew.actionrequest.service.ActionRequestService;
31 import org.kuali.rice.kew.api.KewApiConstants;
32 import org.kuali.rice.kew.api.document.DocumentStatus;
33 import org.kuali.rice.kew.service.KEWServiceLocator;
34 import org.kuali.rice.kim.api.identity.Person;
35 import org.kuali.rice.kim.api.identity.PersonService;
36 import org.kuali.rice.krad.UserSession;
37 import org.kuali.rice.krad.bo.Note;
38 import org.kuali.rice.krad.service.BusinessObjectService;
39 import org.kuali.rice.krad.service.DocumentService;
40 import org.kuali.rice.krad.util.GlobalVariables;
41 import org.kuali.rice.krad.web.controller.TransactionalDocumentControllerBase;
42 import org.kuali.rice.krad.web.form.DocumentFormBase;
43 import org.kuali.rice.krad.web.form.UifFormBase;
44 import org.springframework.stereotype.Controller;
45 import org.springframework.validation.BindingResult;
46 import org.springframework.web.bind.annotation.ModelAttribute;
47 import org.springframework.web.bind.annotation.RequestMapping;
48 import org.springframework.web.servlet.ModelAndView;
49
50 import javax.servlet.http.HttpServletRequest;
51 import javax.servlet.http.HttpServletResponse;
52 import java.sql.Timestamp;
53 import java.util.*;
54
55
56
57
58
59
60
61
62 @Controller
63 @RequestMapping(value = "/serialReceiving")
64 public class OLESerialReceivingController extends TransactionalDocumentControllerBase {
65 @Override
66 protected OLESerialReceivingForm createInitialForm(HttpServletRequest request) {
67 return new OLESerialReceivingForm();
68 }
69
70 private DocstoreClientLocator docstoreClientLocator;
71
72 DocumentService documentService = SpringContext.getBean(DocumentService.class);
73
74 public DocstoreClientLocator getDocstoreClientLocator() {
75
76 if (docstoreClientLocator == null) {
77 docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class);
78
79 }
80 return docstoreClientLocator;
81 }
82
83 BusinessObjectService businessObject = SpringContext.getBean(BusinessObjectService.class);
84
85 @RequestMapping(params = "methodToCall=receive")
86 public ModelAndView receive(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
87 HttpServletRequest request, HttpServletResponse response) {
88 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
89 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
90 try {
91 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
92 if (statusCode.equalsIgnoreCase(DocumentStatus.INITIATED.getCode()) || statusCode.equalsIgnoreCase(DocumentStatus.SAVED.getCode())) {
93 Date date = new Date(System.currentTimeMillis());
94 String interval = oleSerialReceivingDocument.getActionInterval();
95 if (StringUtils.isNotBlank(interval)) {
96 boolean actIntvlFlag = isNumber(interval);
97 if (actIntvlFlag) {
98 Integer actIntvl = Integer.parseInt(oleSerialReceivingDocument.getActionInterval());
99 Date actDate = DateUtils.addDays(date, actIntvl);
100 oleSerialReceivingDocument.setActionDate(new Timestamp(actDate.getTime()));
101 }
102 }
103 if (oleSerialReceivingDocument.getUnboundLocation() != null && !isValidLocation(oleSerialReceivingDocument.getUnboundLocation())) {
104 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_UNBOUND_LOCATION_FIELD, OLEKeyConstants.SERIAL_UNBOUND_LOCATION);
105 }
106 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
107 if (oleSerialReceivingDocument.isClaim()) {
108 oleSerialReceivingService.validateClaim(oleSerialReceivingDocument);
109 }
110 if (GlobalVariables.getMessageMap().getErrorCount() > 0) {
111 return getUIFModelAndView(oleSerialReceivingForm);
112 }
113 String treatmentNote = oleSerialReceivingDocument.getTreatmentInstructionNote();
114 if (StringUtils.isBlank(treatmentNote)) {
115 oleSerialReceivingDocument.setTreatmentNoteFlag(false);
116 oleSerialReceivingService.updateEnumValues(oleSerialReceivingDocument);
117 oleSerialReceivingService.createOrUpdateReceivingRecordType(oleSerialReceivingDocument);
118 oleSerialReceivingService.updateEnumCaptionValues(oleSerialReceivingDocument, null);
119 oleSerialReceivingService.validateSerialReceivingDocument(oleSerialReceivingDocument);
120 if (GlobalVariables.getMessageMap().getErrorCount() > 0) {
121 oleSerialReceivingDocument.setItemCheckFlag(false);
122 return getUIFModelAndView(oleSerialReceivingForm);
123 } else {
124 oleSerialReceivingDocument.setItemCheckFlag(true);
125 }
126 oleSerialReceivingService.receiveRecord(oleSerialReceivingDocument, OLEConstants.RECEIVED);
127 save(oleSerialReceivingForm, result, request, response);
128 } else {
129 oleSerialReceivingDocument.setTreatmentNoteFlag(true);
130 oleSerialReceivingDocument.setTreatmentDialogNote(treatmentNote);
131 }
132 } else {
133 oleSerialReceivingDocument.setItemCheckFlag(false);
134 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE, OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE);
135 }
136 } catch (Exception ex) {
137 ex.printStackTrace();
138 throw new RuntimeException(ex);
139 }
140 return getUIFModelAndView(oleSerialReceivingForm);
141 }
142 @Override
143 @RequestMapping(params = "methodToCall=route")
144 public ModelAndView route(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
145 HttpServletRequest request, HttpServletResponse response){
146 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
147 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
148 Note note = documentService.createNoteFromDocument(oleSerialReceivingDocument, OLEConstants.SRR_ROUTE_NOTES);;
149 oleSerialReceivingDocument.addNote(note);
150 ModelAndView modelAndView = super.route(oleSerialReceivingForm, result, request, response);
151 return modelAndView;
152 }
153
154 @Override
155 @RequestMapping(params = "methodToCall=docHandler")
156 public ModelAndView docHandler(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
157 HttpServletRequest request, HttpServletResponse response) throws Exception {
158 long begin = System.currentTimeMillis();
159 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
160 ModelAndView modelAndView = super.docHandler(oleSerialReceivingForm, result, request, response);
161 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
162 String vendorId = oleSerialReceivingDocument.getVendorId();
163 oleSerialReceivingDocument.getDocumentHeader().setDocumentDescription(OLEConstants.SERIAL_REC_DESC + oleSerialReceivingForm.getDocument().getDocumentNumber());
164 if (oleSerialReceivingDocument.getUrgentNote() != null) {
165 oleSerialReceivingDocument.setUrgentNoteFlag(true);
166 oleSerialReceivingDocument.setUrgentDialogNote(oleSerialReceivingDocument.getUrgentNote());
167 } else {
168 oleSerialReceivingDocument.setUrgentNoteFlag(false);
169 }
170 if (StringUtils.isBlank(oleSerialReceivingDocument.getSerialReceivingRecordId())) {
171 oleSerialReceivingDocument.setPublicDisplay(true);
172 }
173 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
174 oleSerialReceivingService.readReceivingRecordType(oleSerialReceivingDocument);
175 oleSerialReceivingService.updateEnumCaptionValues(oleSerialReceivingDocument, null);
176 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
177 oleSerialReceivingDocument.setStatusCode(statusCode);
178
179 String bibId;
180 String instanceId;
181 String holdingsId;
182 if (request.getParameter(OLEConstants.BIB_ID) != null) {
183 bibId = request.getParameter(OLEConstants.BIB_ID);
184 } else {
185 bibId = oleSerialReceivingDocument.getBibId();
186 }
187 if (request.getParameter(OLEConstants.INSTANCE_ID) != null) {
188 instanceId = request.getParameter(OLEConstants.INSTANCE_ID);
189 holdingsId = request.getParameter(OLEConstants.INSTANCE_ID);
190 } else {
191 instanceId = oleSerialReceivingDocument.getInstanceId();
192 holdingsId = oleSerialReceivingDocument.getInstanceId();
193 }
194 if (bibId != null) {
195 oleSerialReceivingDocument.setBibId(bibId);
196 oleSerialReceivingDocument.setLocalId(DocumentUniqueIDPrefix.getDocumentId(bibId));
197 } else if (oleSerialReceivingDocument.getBibId() != null) {
198
199 oleSerialReceivingDocument.setLocalId(DocumentUniqueIDPrefix.getDocumentId(oleSerialReceivingDocument.getBibId()));
200 }
201
202
203
204 BibTree bibTree = getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(bibId);
205
206
207 DocstoreUtil docstoreUtil = new DocstoreUtil();
208
209 String locationName = null;
210 String copyNumber = null;
211 String callNumber = null;
212 String holdingId = null;
213 if (bibTree != null) {
214 if (bibTree.getHoldingsTrees() != null) {
215 for (HoldingsTree holdingsTree : bibTree.getHoldingsTrees()) {
216 if (holdingsTree.getHoldings().getId().equals(holdingsId)) {
217 OleHoldings oleHoldings = new HoldingOlemlRecordProcessor().fromXML(holdingsTree.getHoldings().getContent());
218
219 locationName = docstoreUtil.getLocation(oleHoldings.getLocation(), new StringBuffer(""));
220
221
222
223 callNumber = oleHoldings != null && oleHoldings.getCallNumber() != null && oleHoldings.getCallNumber().getNumber() != null ? oleHoldings.getCallNumber().getNumber() : "";
224 copyNumber = oleHoldings != null && oleHoldings.getCopyNumber() != null ? oleHoldings.getCopyNumber() : "";
225 holdingId = holdingsTree.getHoldings().getId();
226 }
227 }
228 }
229 oleSerialReceivingDocument.setBoundLocation(locationName != null ? locationName : "");
230
231 oleSerialReceivingDocument.setCorporateAuthor(bibTree.getBib() != null ? bibTree.getBib().getAuthor() : "");
232
233
234 String title = "";
235 if(bibTree.getBib() != null && bibTree.getBib().getTitle() != null){
236 title = bibTree.getBib().getTitle();
237 title = title.replaceAll("<","<");
238 title = title.replaceAll(">",">");
239 }
240 oleSerialReceivingDocument.setTitle(title);
241
242
243 oleSerialReceivingDocument.setIssn(bibTree.getBib() != null ? bibTree.getBib().getIssn() : "");
244
245 oleSerialReceivingDocument.setPublisher(bibTree.getBib() != null ? bibTree.getBib().getPublisher() : "");
246 oleSerialReceivingDocument.setCopyNumber(copyNumber != null ? copyNumber : "");
247 oleSerialReceivingDocument.setCallNumber(callNumber != null ? callNumber : "");
248 if (StringUtils.isNotBlank(instanceId)) {
249
250 oleSerialReceivingDocument.setInstanceId(holdingsId);
251
252 } else {
253
254 oleSerialReceivingDocument.setInstanceId(holdingId);
255 }
256 oleSerialReceivingDocument.setTempInstanceId(oleSerialReceivingDocument.getInstanceId());
257 }
258 if ((oleSerialReceivingDocument.getPoId() == null || oleSerialReceivingDocument.getPoId().isEmpty())) {
259 oleSerialReceivingService.updatePOVendorDetail(oleSerialReceivingDocument);
260 } else {
261 Map<String, String> parentCriterial = new HashMap<>();
262 String poDocNum = oleSerialReceivingDocument.getPoId();
263
264 parentCriterial.put("purapDocumentIdentifier", poDocNum);
265 List<OlePurchaseOrderDocument> olePurchaseOrderDocument = (List<OlePurchaseOrderDocument>) getBusinessObjectService().findMatching(OlePurchaseOrderDocument.class, parentCriterial);
266 if (olePurchaseOrderDocument != null)
267 oleSerialReceivingDocument.setPoIdLink(oleSerialReceivingDocument.formPoIdLinkUsingPoDocumentNumber(olePurchaseOrderDocument.get(0).getDocumentNumber()));
268 }
269 String principalName = GlobalVariables.getUserSession().getPrincipalName();
270 oleSerialReceivingDocument.setOperatorId(principalName);
271 if (oleSerialReceivingDocument.getSerialReceivingRecord() == null || oleSerialReceivingDocument.getSerialReceivingRecord().isEmpty()) {
272 oleSerialReceivingDocument.setSerialReceivingRecord(oleSerialReceivingDocument.getSerialReceivingRecordId());
273 }
274
275
276
277
278
279
280 if (vendorId != null && vendorId.length() > 0) {
281 oleSerialReceivingService.populateVendorNameFromVendorId(vendorId, oleSerialReceivingDocument);
282 }
283 List<OLESerialReceivingHistory> oleSerialReceivingHistoryList = oleSerialReceivingDocument.getOleSerialReceivingHistoryList() != null ?
284 oleSerialReceivingDocument.getOleSerialReceivingHistoryList() : new ArrayList<OLESerialReceivingHistory>();
285 oleSerialReceivingService.sortById(oleSerialReceivingHistoryList);
286 oleSerialReceivingService.listOutHistoryBasedOnReceivingRecord(oleSerialReceivingDocument);
287 if (oleSerialReceivingDocument.getOleSerialReceivingHistoryList() != null && oleSerialReceivingDocument.getOleSerialReceivingHistoryList().size() > 0) {
288 for (int serialReceivingHistoryList = 0; serialReceivingHistoryList < oleSerialReceivingDocument.getOleSerialReceivingHistoryList().size(); serialReceivingHistoryList++) {
289 oleSerialReceivingService.setEnumerationAndChronologyValues(oleSerialReceivingDocument.getOleSerialReceivingHistoryList().get(serialReceivingHistoryList));
290 }
291 }
292 long end = System.currentTimeMillis();
293 long total = end - begin;
294 LOG.info("Time taken Inside docHandler"+total);
295 return modelAndView;
296 }
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315 @RequestMapping(params = "methodToCall=returnToSearch")
316 public ModelAndView returnToSearch(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
317 HttpServletRequest request, HttpServletResponse response) {
318 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
319 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
320 return getUIFModelAndView(oleSerialReceivingForm);
321 }
322
323 @RequestMapping(params = "methodToCall=confirmReturnToSearch")
324 public ModelAndView confirmReturnToSearch(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
325 HttpServletRequest request, HttpServletResponse response) {
326 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
327 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
328 oleSerialReceivingDocument.setConfirmMessage(OLEConstants.CONFIRM_MSG_RETURN_TO_SEARCH);
329 oleSerialReceivingDocument.setReturnToSearch(true);
330 return getUIFModelAndView(oleSerialReceivingForm);
331 }
332
333
334 @RequestMapping(params = "methodToCall=specialIssue")
335 public ModelAndView specialIssue(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
336 HttpServletRequest request, HttpServletResponse response) {
337 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
338 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
339 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
340 if (oleSerialReceivingDocument.getUnboundLocation() != null && !isValidLocation(oleSerialReceivingDocument.getUnboundLocation())) {
341 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_UNBOUND_LOCATION_FIELD, OLEKeyConstants.SERIAL_UNBOUND_LOCATION);
342 return getUIFModelAndView(oleSerialReceivingForm);
343 }
344 if (statusCode.equalsIgnoreCase(DocumentStatus.INITIATED.getCode()) || statusCode.equalsIgnoreCase(DocumentStatus.SAVED.getCode())) {
345 oleSerialReceivingDocument.setSpecialIssueFlag(true);
346 } else {
347 oleSerialReceivingDocument.setItemCheckFlag(false);
348 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE, OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE);
349 }
350 return getUIFModelAndView(oleSerialReceivingForm);
351 }
352
353 @RequestMapping(params = "methodToCall=claim")
354 public ModelAndView claim(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
355 HttpServletRequest request, HttpServletResponse response) {
356 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
357 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
358 try {
359 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
360 if (statusCode.equalsIgnoreCase(DocumentStatus.INITIATED.getCode()) || statusCode.equalsIgnoreCase(DocumentStatus.SAVED.getCode())) {
361 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
362 oleSerialReceivingService.updateEnumValues(oleSerialReceivingDocument);
363 oleSerialReceivingService.createOrUpdateReceivingRecordType(oleSerialReceivingDocument);
364 oleSerialReceivingDocument.setClaimIntervalInformation(oleSerialReceivingDocument.getClaimDialogNote());
365 oleSerialReceivingService.receiveRecord(oleSerialReceivingDocument, OLEConstants.CLAIMED);
366 save(oleSerialReceivingForm, result, request, response);
367 } else {
368 oleSerialReceivingDocument.setItemCheckFlag(false);
369 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE, OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE);
370 }
371 } catch (Exception ex) {
372 ex.printStackTrace();
373 throw new RuntimeException(ex);
374 }
375 return getUIFModelAndView(oleSerialReceivingForm);
376 }
377
378 @Override
379 @RequestMapping(params = "methodToCall=save")
380 public ModelAndView save(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
381 HttpServletRequest request, HttpServletResponse response) throws Exception {
382 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
383 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
384 List<OLESerialReceivingHistory> oleSerialReceivingHistoryLists = oleSerialReceivingDocument.getOleSerialReceivingHistoryList();
385 if (oleSerialReceivingHistoryLists != null) {
386 for(int serialReceivingHistory=0; serialReceivingHistory<oleSerialReceivingHistoryLists.size(); serialReceivingHistory++) {
387 if (StringUtils.isBlank(oleSerialReceivingHistoryLists.get(serialReceivingHistory).getEnumerationCaption())
388 && StringUtils.isBlank(oleSerialReceivingHistoryLists.get(serialReceivingHistory).getChronologyCaption())) {
389 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ENUM_OR_CHRON_REQUIRED, OLEKeyConstants.SERIAL_RECEIVE_ENUM_OR_CHRON_REQUIRED);
390 oleSerialReceivingForm.setJumpToId(OLEConstants.SERIAL_RECEIVING_MAIN_PAGE);
391 return getUIFModelAndView(form);
392 }
393 }
394 }
395 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
396 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
397 if (statusCode.equalsIgnoreCase(DocumentStatus.INITIATED.getCode()) || statusCode.equalsIgnoreCase(DocumentStatus.SAVED.getCode())) {
398 Date date = new Date(System.currentTimeMillis());
399 String interval = oleSerialReceivingDocument.getActionInterval();
400 if (StringUtils.isNotBlank(interval)) {
401 boolean actIntvlFlag = isNumber(interval);
402 if (actIntvlFlag && oleSerialReceivingDocument.getActionDate() == null) {
403 Integer actIntvl = Integer.parseInt(oleSerialReceivingDocument.getActionInterval());
404 Date actDate = DateUtils.addDays(date, actIntvl);
405 oleSerialReceivingDocument.setActionDate(new Timestamp(actDate.getTime()));
406 }
407 }
408 ModelAndView modelAndView;
409 if (oleSerialReceivingDocument.isClaim()) {
410 if (StringUtils.isBlank(interval)) {
411 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ACTIONINTERVAL, OLEKeyConstants.SERIAL_RECEIVE_ACTIONINTERVAL);
412 }
413 if (oleSerialReceivingDocument.getActionDate() == null) {
414 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_ACTIONDATE, OLEKeyConstants.SERIAL_RECEIVE_ACTIONDATE);
415 }
416 if (StringUtils.isBlank(oleSerialReceivingDocument.getVendorId())) {
417 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ID, OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ID);
418 }
419 }
420 if (oleSerialReceivingDocument.getUnboundLocation() != null && !isValidLocation(oleSerialReceivingDocument.getUnboundLocation())) {
421 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_UNBOUND_LOCATION_FIELD, OLEKeyConstants.SERIAL_UNBOUND_LOCATION);
422 }
423 if (GlobalVariables.getMessageMap().getErrorCount() > 0) {
424 return getUIFModelAndView(oleSerialReceivingForm);
425 }
426 if (oleSerialReceivingDocument.getVendorAliasName() != null && oleSerialReceivingDocument.getVendorAliasName().length() > 0) {
427 oleSerialReceivingService.validateVendorDetailsForSave(oleSerialReceivingDocument);
428 }
429 oleSerialReceivingService.updateEnumValues(oleSerialReceivingDocument);
430 oleSerialReceivingService.createOrUpdateReceivingRecordType(oleSerialReceivingDocument);
431 modelAndView = super.save(oleSerialReceivingForm, result, request, response);
432 if (oleSerialReceivingDocument.getSerialReceivingRecord() == null || oleSerialReceivingDocument.getSerialReceivingRecord().isEmpty()) {
433 oleSerialReceivingDocument.setSerialReceivingRecord(oleSerialReceivingDocument.getSerialReceivingRecordId());
434 }
435 oleSerialReceivingService.updateSerialIdInCopy(oleSerialReceivingDocument);
436 oleSerialReceivingDocument.setTempInstanceId(oleSerialReceivingDocument.getInstanceId());
437 List<OLESerialReceivingHistory> oleSerialReceivingHistoryList = oleSerialReceivingDocument.getOleSerialReceivingHistoryList() != null ?
438 oleSerialReceivingDocument.getOleSerialReceivingHistoryList() : new ArrayList<OLESerialReceivingHistory>();
439 oleSerialReceivingService.sortById(oleSerialReceivingHistoryList);
440 oleSerialReceivingService.listOutHistoryBasedOnReceivingRecord(oleSerialReceivingDocument);
441 assignActionRequests(oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getDocumentId());
442 return modelAndView;
443 } else {
444 oleSerialReceivingDocument.setItemCheckFlag(false);
445 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE, OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE);
446 return getUIFModelAndView(form);
447 }
448 }
449
450 public static boolean isNumber(String actionInterval) {
451 String actStr = actionInterval;
452 for (int i = 0; i < actStr.length(); i++) {
453 if (!Character.isDigit(actStr.charAt(i)))
454 return false;
455 }
456 return true;
457 }
458
459 @RequestMapping(params = "methodToCall=saveNote")
460 public ModelAndView saveNote(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
461 HttpServletRequest request, HttpServletResponse response) throws Exception {
462 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
463 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
464 String spclIssueNote = oleSerialReceivingDocument.getSpecialIssueNote();
465 if (spclIssueNote != null && !spclIssueNote.isEmpty()) {
466 oleSerialReceivingDocument.setEnumerationCaptionLevel1(spclIssueNote);
467 }
468 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
469 oleSerialReceivingService.receiveRecord(oleSerialReceivingDocument, OLEConstants.RECEIVED);
470 save(form, result, request, response);
471 oleSerialReceivingDocument.setSpecialIssueFlag(false);
472 return getUIFModelAndView(oleSerialReceivingForm);
473 }
474
475 @RequestMapping(params = "methodToCall=claimNote")
476 public ModelAndView claimNote(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
477 HttpServletRequest request, HttpServletResponse response) throws Exception {
478 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
479 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
480 try {
481 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
482 if (statusCode.equalsIgnoreCase(DocumentStatus.INITIATED.getCode()) || statusCode.equalsIgnoreCase(DocumentStatus.SAVED.getCode())) {
483 Date date = new Date(System.currentTimeMillis());
484 String interval = oleSerialReceivingDocument.getActionInterval();
485 if (StringUtils.isNotBlank(interval)) {
486 boolean actIntvlFlag = isNumber(interval);
487 if (actIntvlFlag && oleSerialReceivingDocument.getActionDate() == null) {
488 Integer actIntvl = Integer.parseInt(oleSerialReceivingDocument.getActionInterval());
489 Date actDate = DateUtils.addDays(date, actIntvl);
490 oleSerialReceivingDocument.setActionDate(new Timestamp(actDate.getTime()));
491 }
492 }
493
494
495
496
497
498
499
500
501
502 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
503 oleSerialReceivingService.validateClaim(oleSerialReceivingDocument);
504 if (GlobalVariables.getMessageMap().getErrorCount() > 0) {
505 return getUIFModelAndView(oleSerialReceivingForm);
506 }
507 oleSerialReceivingDocument.setClaimNoteFlag(true);
508 oleSerialReceivingDocument.setClaimAgainNoteFlag(false);
509 oleSerialReceivingDocument.setClaimDialogNote(oleSerialReceivingDocument.getClaimIntervalInformation());
510 } else {
511 oleSerialReceivingDocument.setItemCheckFlag(false);
512 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE, OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE);
513 }
514 } catch (Exception ex) {
515 ex.printStackTrace();
516 throw new RuntimeException(ex);
517 }
518 return getUIFModelAndView(oleSerialReceivingForm);
519 }
520
521
522 @RequestMapping(params = "methodToCall=acknowledgeNote")
523 public ModelAndView acknowledgeNote(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
524 HttpServletRequest request, HttpServletResponse response) {
525 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
526 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
527 try {
528 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
529 oleSerialReceivingService.updateEnumValues(oleSerialReceivingDocument);
530 oleSerialReceivingService.createOrUpdateReceivingRecordType(oleSerialReceivingDocument);
531 oleSerialReceivingService.validateSerialReceivingDocument(oleSerialReceivingDocument);
532 if (GlobalVariables.getMessageMap().getErrorCount() > 0) {
533 oleSerialReceivingDocument.setItemCheckFlag(false);
534 return getUIFModelAndView(oleSerialReceivingForm);
535 }
536
537 oleSerialReceivingService.receiveRecord(oleSerialReceivingDocument, OLEConstants.RECEIVED);
538 save(oleSerialReceivingForm, result, request, response);
539 } catch (Exception ex) {
540 ex.printStackTrace();
541 throw new RuntimeException(ex);
542 }
543 return getUIFModelAndView(oleSerialReceivingForm);
544 }
545
546
547 @RequestMapping(params = "methodToCall=acknowledgeUrgentNote")
548 public ModelAndView acknowledgeUrgentNote(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
549 HttpServletRequest request, HttpServletResponse response) {
550 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
551 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
552 oleSerialReceivingDocument.setUrgentNote(oleSerialReceivingDocument.getUrgentDialogNote());
553 return getUIFModelAndView(oleSerialReceivingForm);
554 }
555
556 @RequestMapping(params = "methodToCall=receiveHistory")
557 public ModelAndView receiveHistory(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
558 HttpServletRequest request, HttpServletResponse response) {
559 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
560 try {
561 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
562 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
563 if (statusCode.equalsIgnoreCase(DocumentStatus.SAVED.getCode())) {
564 Date date = new Date(System.currentTimeMillis());
565 for (OLESerialReceivingHistory oleSerialReceivingHistory : oleSerialReceivingDocument.getOleSerialReceivingHistoryList()) {
566 if (oleSerialReceivingHistory.getSerialReceivingRecordHistoryId().equalsIgnoreCase(oleSerialReceivingDocument.getSerialReceiptHistoryId())) {
567 oleSerialReceivingHistory.setReceiptStatus(OLEConstants.RECEIVED);
568 oleSerialReceivingHistory.setReceiptDate(new Timestamp(date.getTime()));
569 }
570 }
571 save(oleSerialReceivingForm, result, request, response);
572 } else {
573 oleSerialReceivingDocument.setItemCheckFlag(false);
574 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE, OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE);
575 }
576 } catch (Exception ex) {
577 ex.printStackTrace();
578 throw new RuntimeException(ex);
579 }
580 return getUIFModelAndView(oleSerialReceivingForm);
581 }
582
583
584 @RequestMapping(params = "methodToCall=claimHistory")
585 public ModelAndView claimHistory(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
586 HttpServletRequest request, HttpServletResponse response) {
587 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
588 try {
589 Date date = new Date(System.currentTimeMillis());
590 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
591 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
592 if (statusCode.equalsIgnoreCase(DocumentStatus.SAVED.getCode())) {
593 for (OLESerialReceivingHistory oleSerialReceivingHistory : oleSerialReceivingDocument.getOleSerialReceivingHistoryList()) {
594 if (oleSerialReceivingHistory.getSerialReceivingRecordHistoryId().equalsIgnoreCase(oleSerialReceivingDocument.getSerialReceiptHistoryId())) {
595 oleSerialReceivingHistory.setReceiptStatus(OLEConstants.CLAIMED);
596 oleSerialReceivingHistory.setClaimDate(new Timestamp(date.getTime()));
597 oleSerialReceivingHistory.setClaimType(oleSerialReceivingDocument.getClaimType());
598 oleSerialReceivingHistory.setClaimNote(oleSerialReceivingDocument.getClaimDialogNote());
599 if (oleSerialReceivingHistory.getClaimCount() != null && !oleSerialReceivingHistory.getClaimCount().isEmpty()) {
600 Integer count = Integer.parseInt(oleSerialReceivingHistory.getClaimCount());
601 count++;
602 oleSerialReceivingHistory.setClaimCount(count.toString());
603 } else {
604 oleSerialReceivingHistory.setClaimCount("1");
605 }
606
607 }
608 }
609 save(oleSerialReceivingForm, result, request, response);
610 } else {
611 oleSerialReceivingDocument.setItemCheckFlag(false);
612 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE, OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE);
613 }
614 } catch (Exception ex) {
615 ex.printStackTrace();
616 throw new RuntimeException(ex);
617 }
618 return getUIFModelAndView(oleSerialReceivingForm);
619 }
620
621 @RequestMapping(params = "methodToCall=claimAgainNote")
622 public ModelAndView claimAgainNote(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
623 HttpServletRequest request, HttpServletResponse response) throws Exception {
624 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
625 try {
626 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
627 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
628 if (statusCode.equalsIgnoreCase(DocumentStatus.SAVED.getCode())) {
629 for (OLESerialReceivingHistory oleSerialReceivingHistory : oleSerialReceivingDocument.getOleSerialReceivingHistoryList()) {
630 if (oleSerialReceivingHistory.getSerialReceivingRecordHistoryId().equalsIgnoreCase(oleSerialReceivingDocument.getSerialReceiptHistoryId())) {
631 oleSerialReceivingDocument.setClaimAgainNoteFlag(true);
632 oleSerialReceivingDocument.setClaimNoteFlag(false);
633 oleSerialReceivingDocument.setClaimType(oleSerialReceivingHistory.getClaimType());
634 oleSerialReceivingDocument.setClaimDialogNote(oleSerialReceivingHistory.getClaimNote());
635 }
636 }
637 } else {
638 oleSerialReceivingDocument.setItemCheckFlag(false);
639 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE, OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE);
640 }
641 } catch (Exception ex) {
642 ex.printStackTrace();
643 throw new RuntimeException(ex);
644 }
645 return getUIFModelAndView(oleSerialReceivingForm);
646 }
647
648 @RequestMapping(params = "methodToCall=unReceiveHistory")
649 public ModelAndView unReceiveHistory(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
650 HttpServletRequest request, HttpServletResponse response) {
651 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
652 try {
653 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
654 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
655 if (statusCode.equalsIgnoreCase(DocumentStatus.SAVED.getCode())) {
656 for (OLESerialReceivingHistory oleSerialReceivingHistory : oleSerialReceivingDocument.getOleSerialReceivingHistoryList()) {
657 if (oleSerialReceivingHistory.getSerialReceivingRecordHistoryId().equalsIgnoreCase(oleSerialReceivingDocument.getSerialReceiptHistoryId())) {
658 getBusinessObjectService().delete(oleSerialReceivingHistory);
659 oleSerialReceivingDocument.getOleSerialReceivingHistoryList().remove(oleSerialReceivingHistory);
660 break;
661 }
662 }
663 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
664 oleSerialReceivingService.listOutHistoryBasedOnReceivingRecord(oleSerialReceivingDocument);
665 } else {
666 oleSerialReceivingDocument.setItemCheckFlag(false);
667 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE, OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE);
668 }
669 } catch (Exception ex) {
670 ex.printStackTrace();
671 throw new RuntimeException(ex);
672 }
673 return getUIFModelAndView(oleSerialReceivingForm);
674 }
675
676 @RequestMapping(params = "methodToCall=cancelClaim")
677 public ModelAndView cancelClaim(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
678 HttpServletRequest request, HttpServletResponse response) {
679 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
680 try {
681 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
682 String statusCode = oleSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getStatus().getCode();
683 if (statusCode.equalsIgnoreCase(DocumentStatus.SAVED.getCode())) {
684 for (OLESerialReceivingHistory oleSerialReceivingHistory : oleSerialReceivingDocument.getOleSerialReceivingHistoryList()) {
685 if (oleSerialReceivingHistory.getSerialReceivingRecordHistoryId().equalsIgnoreCase(oleSerialReceivingDocument.getSerialReceiptHistoryId())) {
686 oleSerialReceivingHistory.setReceiptStatus(OLEConstants.RCV_CANCELLED);
687 break;
688 }
689 }
690 } else {
691 oleSerialReceivingDocument.setItemCheckFlag(false);
692 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE, OLEKeyConstants.SERIAL_RECEIVE_EN_ROUTE);
693 }
694 } catch (Exception ex) {
695 ex.printStackTrace();
696 throw new RuntimeException(ex);
697 }
698 return getUIFModelAndView(oleSerialReceivingForm);
699 }
700
701
702 @RequestMapping(params = "methodToCall=selectVendor")
703 public ModelAndView selectVendor(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
704 HttpServletRequest request, HttpServletResponse response) {
705 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
706 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
707 if (oleSerialReceivingDocument.getVendorAliasName() != null && oleSerialReceivingDocument.getVendorAliasName().length() > 0) {
708 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
709 oleSerialReceivingService.validateVendorDetailsForSelect(oleSerialReceivingDocument);
710 } else {
711 oleSerialReceivingDocument.setVendorId(null);
712 GlobalVariables.getMessageMap().putError(OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ALIAS_NOT_FOUND, OLEKeyConstants.SERIAL_RECEIVE_VENDOR_ALIAS_NOT_FOUND);
713 }
714 return getUIFModelAndView(oleSerialReceivingForm);
715 }
716
717 @RequestMapping(params = "methodToCall=searchVendor")
718 public ModelAndView searchVendor(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
719 HttpServletRequest request, HttpServletResponse response) {
720 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
721 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
722 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
723 oleSerialReceivingService.populateVendorAliasNameFromVendorName(oleSerialReceivingDocument);
724 return getUIFModelAndView(oleSerialReceivingForm);
725 }
726
727
728
729
730
731
732
733
734 @RequestMapping(params = "methodToCall=disapprove")
735 public ModelAndView disapprove(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
736 HttpServletRequest request, HttpServletResponse response) throws Exception {
737 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
738 OLESerialReceivingDocument oldSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
739 ModelAndView modelAndView = super.disapprove(form, result, request, response);
740 form.setDocId(null);
741 form.setCommand(KewApiConstants.INITIATE_COMMAND);
742 super.docHandler(form, result, request, response);
743 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
744 String user = oldSerialReceivingDocument.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
745 Person person = SpringContext.getBean(PersonService.class).getPerson(user);
746 GlobalVariables.setUserSession(new UserSession(person.getPrincipalName()));
747 DocumentService documentService = GlobalResourceLoader.getService(OLEConstants.DOCUMENT_HEADER_SERVICE);
748 OLESerialReceivingDocument newDocument = (OLESerialReceivingDocument) documentService.getNewDocument("OLE_SER_RECV_REC");
749 newDocument.getDocumentHeader().setDocumentDescription(OLEConstants.SERIAL_REC_DESC + form.getDocument().getDocumentNumber());
750 oleSerialReceivingService.disapproveCreateNewWithExisting(newDocument, oldSerialReceivingDocument);
751 documentService.saveDocument(newDocument);
752 form.setDocument(newDocument);
753 return modelAndView;
754 }
755
756 @RequestMapping(params = "methodToCall=linkPO")
757 public ModelAndView linkPO(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
758 HttpServletRequest request, HttpServletResponse response) {
759 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
760 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
761 List<OLESerialRelatedPODocument> oleSerialRelatedPODocuments = oleSerialReceivingDocument.getOleSerialRelatedPODocuments();
762 for (OLESerialRelatedPODocument oleSerialRelatedPODocument : oleSerialRelatedPODocuments) {
763 if (oleSerialRelatedPODocument.isSelectPO()) {
764 oleSerialReceivingDocument.setPoId(oleSerialRelatedPODocument.getPoId());
765 oleSerialReceivingDocument.setPoIdLink(oleSerialRelatedPODocument.getPoIdLink());
766 oleSerialReceivingDocument.setVendorId(oleSerialRelatedPODocument.getVendorId());
767 oleSerialReceivingDocument.setVendorAliasName(oleSerialRelatedPODocument.getVendorAliasName());
768 oleSerialReceivingDocument.setVendorName(oleSerialRelatedPODocument.getVendorName());
769 oleSerialReceivingDocument.setActionInterval(oleSerialRelatedPODocument.getActionInterval());
770 break;
771 }
772 }
773 return getUIFModelAndView(oleSerialReceivingForm);
774 }
775
776 @RequestMapping(params = "methodToCall=noLinkPO")
777 public ModelAndView noLinkPO(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
778 HttpServletRequest request, HttpServletResponse response) {
779 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
780 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
781 return getUIFModelAndView(oleSerialReceivingForm);
782 }
783
784 @RequestMapping(params = "methodToCall=linkPOErrMsg")
785 public ModelAndView linkPOErrMsg(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
786 HttpServletRequest request, HttpServletResponse response) {
787 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
788 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
789 oleSerialReceivingDocument.setSerialPOErrMsg("Select At least One PO");
790 return getUIFModelAndView(oleSerialReceivingForm);
791 }
792
793 @RequestMapping(params = "methodToCall=refreshReceivingRecordType")
794 public ModelAndView refreshReceivingRecordType(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
795 HttpServletRequest request, HttpServletResponse response) {
796 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
797 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
798 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
799 oleSerialReceivingService.readReceivingRecordType(oleSerialReceivingDocument);
800 oleSerialReceivingService.updateEnumCaptionValues(oleSerialReceivingDocument, null);
801 return getUIFModelAndView(oleSerialReceivingForm);
802 }
803
804
805
806
807
808 private void assignActionRequests(String routeHeaderId) {
809 LOG.debug("Inside assignActionRequests");
810 Timestamp currentTime = SpringContext.getBean(DateTimeService.class).getCurrentTimestamp();
811 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
812 String principalId = oleSerialReceivingService.getParameter("SAVE_ACTION_USR");
813
814 if (principalId == null || principalId.isEmpty()) {
815 principalId = ConfigContext.getCurrentContextConfig().getProperty("save.action.usr");
816 }
817 ActionListService actionListSrv = KEWServiceLocator.getActionListService();
818 ActionRequestService actionReqSrv = KEWServiceLocator.getActionRequestService();
819 List<ActionRequestValue> actionReqValues = actionReqSrv.findAllPendingRequests(routeHeaderId);
820 for (ActionRequestValue actionRequest : actionReqValues) {
821 List<ActionItem> actionItems = actionRequest.getActionItems();
822 for (ActionItem actionItem : actionItems) {
823 actionItem.setPrincipalId(principalId);
824 actionItem.setDateAssigned(currentTime);
825 actionListSrv.saveActionItem(actionItem);
826 }
827 actionRequest.setPrincipalId(principalId);
828 actionRequest.setCreateDate(currentTime);
829 actionReqSrv.saveActionRequest(actionRequest);
830 }
831 LOG.debug("Leaving assignActionRequests");
832 }
833
834 @RequestMapping(params = "methodToCall=saveEnumerationChronology")
835 public ModelAndView saveEnumerationChronology(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
836 HttpServletRequest request, HttpServletResponse response) {
837 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
838 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
839 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
840 for (OLESerialReceivingHistory oleSerialReceivingHistory : oleSerialReceivingDocument.getOleSerialReceivingHistoryList()) {
841 if (StringUtils.isNotBlank(oleSerialReceivingHistory.getSerialReceivingRecordHistoryId())
842 && StringUtils.isNotBlank(oleSerialReceivingDocument.getSerialReceiptHistoryId()) ) {
843 if (oleSerialReceivingHistory.getSerialReceivingRecordHistoryId().equalsIgnoreCase(oleSerialReceivingDocument.getSerialReceiptHistoryId())) {
844 oleSerialReceivingService.updateEnumerationAndChronologyValues(oleSerialReceivingDocument,oleSerialReceivingHistory);
845 oleSerialReceivingService.setEnumerationAndChronologyValues(oleSerialReceivingHistory);
846 }
847 }
848 }
849 try {
850 if(CollectionUtils.isNotEmpty(oleSerialReceivingDocument.getOleSerialReceivingHistoryList())){
851 getBusinessObjectService().save(oleSerialReceivingDocument.getOleSerialReceivingHistoryList());
852 }
853 } catch (Exception ex){
854 throw ex;
855 }
856
857 return getUIFModelAndView(oleSerialReceivingForm);
858 }
859
860 @RequestMapping(params = "methodToCall=resetEnumerationAndChronology")
861 public ModelAndView resetEnumerationAndChronology(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
862 HttpServletRequest request, HttpServletResponse response) {
863 return getUIFModelAndView(form);
864 }
865
866 @RequestMapping(params = "methodToCall=setEnumerationChronology")
867 public ModelAndView setEnumerationChronology(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
868 HttpServletRequest request, HttpServletResponse response) {
869 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
870 OLESerialReceivingService oleSerialReceivingService = new OLESerialReceivingServiceImpl();
871 OLESerialReceivingDocument oleSerialReceivingDocument = (OLESerialReceivingDocument) oleSerialReceivingForm.getDocument();
872 for (OLESerialReceivingHistory oleSerialReceivingHistory : oleSerialReceivingDocument.getOleSerialReceivingHistoryList()) {
873 if (StringUtils.isNotBlank(oleSerialReceivingHistory.getSerialReceivingRecordHistoryId())
874 && StringUtils.isNotBlank(oleSerialReceivingDocument.getSerialReceiptHistoryId()) ) {
875 if (oleSerialReceivingHistory.getSerialReceivingRecordHistoryId().equalsIgnoreCase(oleSerialReceivingDocument.getSerialReceiptHistoryId())) {
876 oleSerialReceivingService.setEnumerationAndChronologyValues(oleSerialReceivingDocument,oleSerialReceivingHistory);
877 }
878 }
879 }
880 return getUIFModelAndView(oleSerialReceivingForm);
881 }
882 private boolean isValidLocation(String location) {
883 List<String> locationList = LocationValuesBuilder.retrieveLocationDetailsForSuggest(location);
884 if (locationList != null && locationList.size() > 0) {
885 for (String locationValue : locationList) {
886 if (locationValue.equalsIgnoreCase(location)) {
887 return true;
888 }
889 }
890 }
891 return false;
892 }
893
894 @RequestMapping(params = "methodToCall=loadHistoryRecords")
895 public ModelAndView loadHistoryRecords(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
896 HttpServletRequest request, HttpServletResponse response) {
897 OLESerialReceivingForm oleSerialReceivingForm = (OLESerialReceivingForm) form;
898 return getUIFModelAndView(oleSerialReceivingForm);
899 }
900
901 }