001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.purap.web.struts.action;
017:
018: import java.util.Iterator;
019: import java.util.Properties;
020: import java.util.TreeMap;
021:
022: import javax.servlet.http.HttpServletRequest;
023: import javax.servlet.http.HttpServletResponse;
024:
025: import org.apache.commons.lang.StringUtils;
026: import org.apache.struts.action.ActionForm;
027: import org.apache.struts.action.ActionForward;
028: import org.apache.struts.action.ActionMapping;
029: import org.kuali.RiceKeyConstants;
030: import org.kuali.RicePropertyConstants;
031: import org.kuali.core.UserSession;
032: import org.kuali.core.bo.Note;
033: import org.kuali.core.question.ConfirmationQuestion;
034: import org.kuali.core.service.BusinessObjectService;
035: import org.kuali.core.service.DataDictionaryService;
036: import org.kuali.core.service.DocumentService;
037: import org.kuali.core.service.KualiConfigurationService;
038: import org.kuali.core.service.KualiRuleService;
039: import org.kuali.core.service.NoteService;
040: import org.kuali.core.util.GlobalVariables;
041: import org.kuali.core.util.ObjectUtils;
042: import org.kuali.core.util.UrlFactory;
043: import org.kuali.core.web.struts.form.KualiDocumentFormBase;
044: import org.kuali.kfs.KFSConstants;
045: import org.kuali.kfs.context.SpringContext;
046: import org.kuali.module.purap.PurapConstants;
047: import org.kuali.module.purap.PurapKeyConstants;
048: import org.kuali.module.purap.PurapPropertyConstants;
049: import org.kuali.module.purap.PurapConstants.AccountsPayableDocumentStrings;
050: import org.kuali.module.purap.PurapConstants.CMDocumentsStrings;
051: import org.kuali.module.purap.document.AccountsPayableDocument;
052: import org.kuali.module.purap.document.AccountsPayableDocumentBase;
053: import org.kuali.module.purap.document.PurchasingAccountsPayableDocument;
054: import org.kuali.module.purap.rule.event.CancelAccountsPayableEvent;
055: import org.kuali.module.purap.rule.event.PreCalculateAccountsPayableEvent;
056: import org.kuali.module.purap.service.AccountsPayableDocumentSpecificService;
057: import org.kuali.module.purap.service.AccountsPayableService;
058: import org.kuali.module.purap.service.PurapService;
059: import org.kuali.module.purap.util.PurQuestionCallback;
060: import org.kuali.module.purap.web.struts.form.AccountsPayableFormBase;
061: import org.kuali.module.vendor.VendorConstants;
062: import org.kuali.module.vendor.bo.VendorAddress;
063: import org.kuali.rice.KNSServiceLocator;
064:
065: import edu.iu.uis.eden.exception.WorkflowException;
066:
067: /**
068: * Struts Action for Accounts Payable documents.
069: */
070: public class AccountsPayableActionBase extends
071: PurchasingAccountsPayableActionBase {
072: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
073: .getLogger(AccountsPayableActionBase.class);
074:
075: /**
076: * Performs refresh of objects after a lookup.
077: *
078: * @see org.kuali.core.web.struts.action.KualiDocumentActionBase#refresh(org.apache.struts.action.ActionMapping,
079: * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
080: */
081: public ActionForward refresh(ActionMapping mapping,
082: ActionForm form, HttpServletRequest request,
083: HttpServletResponse response) throws Exception {
084: AccountsPayableFormBase baseForm = (AccountsPayableFormBase) form;
085: AccountsPayableDocumentBase document = (AccountsPayableDocumentBase) baseForm
086: .getDocument();
087:
088: if (StringUtils.equals(baseForm.getRefreshCaller(),
089: VendorConstants.VENDOR_ADDRESS_LOOKUPABLE_IMPL)) {
090: if (StringUtils
091: .isNotBlank(request
092: .getParameter(RicePropertyConstants.DOCUMENT
093: + "."
094: + PurapPropertyConstants.VENDOR_ADDRESS_ID))) {
095: Integer vendorAddressGeneratedId = document
096: .getVendorAddressGeneratedIdentifier();
097: VendorAddress refreshVendorAddress = new VendorAddress();
098: refreshVendorAddress
099: .setVendorAddressGeneratedIdentifier(vendorAddressGeneratedId);
100: refreshVendorAddress = (VendorAddress) SpringContext
101: .getBean(BusinessObjectService.class).retrieve(
102: refreshVendorAddress);
103: document.templateVendorAddress(refreshVendorAddress);
104: }
105: }
106:
107: return super .refresh(mapping, form, request, response);
108: }
109:
110: /**
111: * Checks the continuation account indicator and generates warnings if continuation accounts were used to replace original
112: * accounts on the document.
113: *
114: * @see org.kuali.core.web.struts.action.KualiDocumentActionBase#loadDocument(org.kuali.core.web.struts.form.KualiDocumentFormBase)
115: */
116: @Override
117: protected void loadDocument(
118: KualiDocumentFormBase kualiDocumentFormBase)
119: throws WorkflowException {
120: super .loadDocument(kualiDocumentFormBase);
121: AccountsPayableDocument document = (AccountsPayableDocument) kualiDocumentFormBase
122: .getDocument();
123:
124: SpringContext.getBean(AccountsPayableService.class)
125: .generateExpiredOrClosedAccountWarning(document);
126: SpringContext.getBean(AccountsPayableService.class)
127: .updateItemList(document);
128: ((AccountsPayableFormBase) kualiDocumentFormBase)
129: .updateItemCounts();
130: }
131:
132: /**
133: * Perform calculation on item line.
134: *
135: * @param mapping An ActionMapping
136: * @param form An ActionForm
137: * @param request The HttpServletRequest
138: * @param response The HttpServletResponse
139: * @return An ActionForward
140: */
141: public ActionForward calculate(ActionMapping mapping,
142: ActionForm form, HttpServletRequest request,
143: HttpServletResponse response) throws Exception {
144: AccountsPayableFormBase apForm = (AccountsPayableFormBase) form;
145: AccountsPayableDocument apDoc = (AccountsPayableDocument) apForm
146: .getDocument();
147:
148: // call precalculate
149: if (SpringContext.getBean(KualiRuleService.class).applyRules(
150: new PreCalculateAccountsPayableEvent(apDoc))) {
151: customCalculate(apDoc);
152:
153: // doesn't really matter what happens above we still reset the calculate flag
154: apForm.setCalculated(true);
155: }
156:
157: return mapping.findForward(KFSConstants.MAPPING_BASIC);
158: }
159:
160: /**
161: * An overridable area to do calculate-specific tasks.
162: *
163: * @param apDoc An AccountsPayableDocument
164: */
165: protected void customCalculate(AccountsPayableDocument apDoc) {
166: // do nothing by default
167: }
168:
169: /**
170: * Checks if calculation is required. Currently it is required when it has not already been calculated and full document entry
171: * status has not already passed.
172: *
173: * @param apForm A Form, which must inherit from <code>AccountsPayableFormBase</code>
174: * @return true if calculation is required, false otherwise
175: */
176: protected boolean requiresCaculate(AccountsPayableFormBase apForm) {
177: boolean requiresCalculate = true;
178: PurchasingAccountsPayableDocument purapDocument = (PurchasingAccountsPayableDocument) apForm
179: .getDocument();
180: requiresCalculate = !apForm.isCalculated()
181: && !SpringContext.getBean(PurapService.class)
182: .isFullDocumentEntryCompleted(purapDocument);
183:
184: return requiresCalculate;
185: }
186:
187: /**
188: * Returns the current action name.
189: *
190: * @return A String. Set to null!
191: */
192: public String getActionName() {
193:
194: return null;
195: }
196:
197: /**
198: * @see org.kuali.core.web.struts.action.KualiDocumentActionBase#route(org.apache.struts.action.ActionMapping,
199: * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
200: */
201: @Override
202: public ActionForward route(ActionMapping mapping, ActionForm form,
203: HttpServletRequest request, HttpServletResponse response)
204: throws Exception {
205:
206: AccountsPayableFormBase apForm = (AccountsPayableFormBase) form;
207:
208: // if form is not yet calculated, return and prompt user to calculate
209: if (requiresCaculate(apForm)) {
210: GlobalVariables.getErrorMap().putError(
211: KFSConstants.DOCUMENT_ERRORS,
212: PurapKeyConstants.ERROR_APPROVE_REQUIRES_CALCULATE);
213:
214: return mapping.findForward(KFSConstants.MAPPING_BASIC);
215: }
216:
217: // recalculate
218: customCalculate((AccountsPayableDocument) apForm.getDocument());
219:
220: // route
221: ActionForward forward = super .route(mapping, form, request,
222: response);
223:
224: // if successful, then redirect back to init
225: if (GlobalVariables.getMessageList().contains(
226: RiceKeyConstants.MESSAGE_ROUTE_SUCCESSFUL)) {
227: String basePath = SpringContext.getBean(
228: KualiConfigurationService.class).getPropertyString(
229: KFSConstants.APPLICATION_URL_KEY);
230:
231: Properties parameters = new Properties();
232: parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER,
233: KFSConstants.DOC_HANDLER_METHOD);
234: parameters.put(KFSConstants.PARAMETER_COMMAND, "initiate");
235: parameters.put(KFSConstants.DOCUMENT_TYPE_NAME, apForm
236: .getDocTypeName());
237:
238: String lookupUrl = UrlFactory.parameterizeUrl(basePath
239: + "/" + "purap" + this .getActionName() + ".do",
240: parameters);
241:
242: forward = new ActionForward(lookupUrl, true);
243: }
244:
245: return forward;
246: }
247:
248: /**
249: * @see org.kuali.core.web.struts.action.KualiDocumentActionBase#save(org.apache.struts.action.ActionMapping,
250: * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
251: */
252: @Override
253: public ActionForward save(ActionMapping mapping, ActionForm form,
254: HttpServletRequest request, HttpServletResponse response)
255: throws Exception {
256: AccountsPayableFormBase apForm = (AccountsPayableFormBase) form;
257: if (!requiresCaculate(apForm)) {
258:
259: return super .save(mapping, form, request, response);
260: }
261: GlobalVariables.getErrorMap().putError(
262: KFSConstants.DOCUMENT_ERRORS,
263: PurapKeyConstants.ERROR_SAVE_REQUIRES_CALCULATE);
264:
265: return mapping.findForward(KFSConstants.MAPPING_BASIC);
266:
267: }
268:
269: /**
270: * A wrapper method which prompts for a reason to hold a payment request or credit memo.
271: *
272: * @param mapping An ActionMapping
273: * @param form An ActionForm
274: * @param request The HttpServletRequest
275: * @param response The HttpServletResponse
276: * @param questionType A String used to distinguish which question is being asked
277: * @param notePrefix A String explaining what action was taken, to be prepended to the note containing the reason, which gets
278: * written to the document
279: * @param operation A one-word String description of the action to be taken, to be substituted into the message. (Can be an
280: * empty String for some messages.)
281: * @param messageKey A key to the message which will appear on the question screen
282: * @param callback A PurQuestionCallback
283: * @return An ActionForward
284: * @throws Exception
285: */
286: protected ActionForward askQuestionWithInput(ActionMapping mapping,
287: ActionForm form, HttpServletRequest request,
288: HttpServletResponse response, String questionType,
289: String notePrefix, String operation, String messageKey,
290: PurQuestionCallback callback) throws Exception {
291: TreeMap<String, PurQuestionCallback> questionsAndCallbacks = new TreeMap<String, PurQuestionCallback>();
292: questionsAndCallbacks.put(questionType, callback);
293:
294: return askQuestionWithInput(mapping, form, request, response,
295: questionType, notePrefix, operation, messageKey,
296: questionsAndCallbacks, "", mapping
297: .findForward(KFSConstants.MAPPING_BASIC));
298: }
299:
300: /**
301: * Builds and asks questions which require text input by the user for a payment request or a credit memo.
302: *
303: * @param mapping An ActionMapping
304: * @param form An ActionForm
305: * @param request The HttpServletRequest
306: * @param response The HttpServletResponse
307: * @param questionType A String used to distinguish which question is being asked
308: * @param notePrefix A String explaining what action was taken, to be prepended to the note containing the reason, which gets
309: * written to the document
310: * @param operation A one-word String description of the action to be taken, to be substituted into the message. (Can be an
311: * empty String for some messages.)
312: * @param messageKey A (whole) key to the message which will appear on the question screen
313: * @param questionsAndCallbacks A TreeMap associating the type of question to be asked and the type of callback which should
314: * happen in that case
315: * @param messagePrefix The most general part of a key to a message text to be retrieved from KualiConfigurationService,
316: * Describes a collection of questions.
317: * @param redirect An ActionForward to return to if done with questions
318: * @return An ActionForward
319: * @throws Exception
320: */
321: private ActionForward askQuestionWithInput(ActionMapping mapping,
322: ActionForm form, HttpServletRequest request,
323: HttpServletResponse response, String questionType,
324: String notePrefix, String operation, String messageKey,
325: TreeMap<String, PurQuestionCallback> questionsAndCallbacks,
326: String messagePrefix, ActionForward redirect)
327: throws Exception {
328: KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
329: AccountsPayableDocumentBase apDocument = (AccountsPayableDocumentBase) kualiDocumentFormBase
330: .getDocument();
331:
332: String question = (String) request
333: .getParameter(KFSConstants.QUESTION_INST_ATTRIBUTE_NAME);
334: String reason = request
335: .getParameter(KFSConstants.QUESTION_REASON_ATTRIBUTE_NAME);
336: String noteText = "";
337:
338: KualiConfigurationService kualiConfiguration = SpringContext
339: .getBean(KualiConfigurationService.class);
340: String firstQuestion = questionsAndCallbacks.firstKey();
341: PurQuestionCallback callback = null;
342: Iterator questions = questionsAndCallbacks.keySet().iterator();
343: String mapQuestion = null;
344: String key = null;
345:
346: // Start in logic for confirming the close.
347: if (question == null) {
348: key = getQuestionProperty(messageKey, messagePrefix,
349: kualiConfiguration, firstQuestion);
350: String message = StringUtils.replace(key, "{0}", operation);
351:
352: // Ask question if not already asked.
353: return this .performQuestionWithInput(mapping, form,
354: request, response, firstQuestion, message,
355: KFSConstants.CONFIRMATION_QUESTION, questionType,
356: "");
357: } else {
358: // find callback for this question
359: while (questions.hasNext()) {
360: mapQuestion = (String) questions.next();
361:
362: if (StringUtils.equals(mapQuestion, question)) {
363: callback = questionsAndCallbacks.get(mapQuestion);
364: break;
365: }
366: }
367: key = getQuestionProperty(messageKey, messagePrefix,
368: kualiConfiguration, mapQuestion);
369:
370: Object buttonClicked = request
371: .getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
372: if (question.equals(mapQuestion)
373: && buttonClicked.equals(ConfirmationQuestion.NO)) {
374: // If 'No' is the button clicked, just reload the doc
375:
376: String nextQuestion = null;
377: // ask another question if more left
378: if (questions.hasNext()) {
379: nextQuestion = (String) questions.next();
380: key = getQuestionProperty(messageKey,
381: messagePrefix, kualiConfiguration,
382: nextQuestion);
383:
384: return this .performQuestionWithInput(mapping, form,
385: request, response, nextQuestion, key,
386: KFSConstants.CONFIRMATION_QUESTION,
387: questionType, "");
388: } else {
389:
390: return mapping
391: .findForward(KFSConstants.MAPPING_BASIC);
392: }
393: }
394: // Have to check length on value entered.
395: String introNoteMessage = notePrefix
396: + KFSConstants.BLANK_SPACE;
397:
398: // Build out full message.
399: noteText = introNoteMessage + reason;
400: int noteTextLength = noteText.length();
401:
402: // Get note text max length from DD.
403: int noteTextMaxLength = SpringContext.getBean(
404: DataDictionaryService.class).getAttributeMaxLength(
405: Note.class, KFSConstants.NOTE_TEXT_PROPERTY_NAME)
406: .intValue();
407: if (StringUtils.isBlank(reason)
408: || (noteTextLength > noteTextMaxLength)) {
409: // Figure out exact number of characters that the user can enter.
410: int reasonLimit = noteTextMaxLength - noteTextLength;
411: if (reason == null) {
412: // Prevent a NPE by setting the reason to a blank string.
413: reason = "";
414: }
415:
416: return this
417: .performQuestionWithInputAgainBecauseOfErrors(
418: mapping,
419: form,
420: request,
421: response,
422: mapQuestion,
423: key,
424: KFSConstants.CONFIRMATION_QUESTION,
425: questionType,
426: "",
427: reason,
428: PurapKeyConstants.ERROR_PAYMENT_REQUEST_REASON_REQUIRED,
429: KFSConstants.QUESTION_REASON_ATTRIBUTE_NAME,
430: new Integer(reasonLimit).toString());
431: }
432: }
433:
434: // make callback
435: if (ObjectUtils.isNotNull(callback)) {
436: callback.doPostQuestion(apDocument, noteText);
437: }
438: String nextQuestion = null;
439: // ask another question if more left
440: if (questions.hasNext()) {
441: nextQuestion = (String) questions.next();
442: key = getQuestionProperty(messageKey, messagePrefix,
443: kualiConfiguration, nextQuestion);
444:
445: return this .performQuestionWithInput(mapping, form,
446: request, response, nextQuestion, key,
447: KFSConstants.CONFIRMATION_QUESTION, questionType,
448: "");
449: }
450:
451: return redirect;
452: }
453:
454: /**
455: * Used to look up messages to be displayed, from the KualiConfigurationService, given either a whole key or two parts of a key
456: * that may be concatenated together.
457: *
458: * @param messageKey String. One of the message keys in PurapKeyConstants.
459: * @param messagePrefix String. A prefix to the question key, such as "ap.question." that, concatenated with the question,
460: * comprises the whole key of the message.
461: * @param kualiConfiguration An instance of KualiConfigurationService
462: * @param question String. The most specific part of the message key in PurapKeyConstants.
463: * @return The message to be displayed given the key
464: */
465: private String getQuestionProperty(String messageKey,
466: String messagePrefix,
467: KualiConfigurationService kualiConfiguration,
468: String question) {
469:
470: return kualiConfiguration.getPropertyString((StringUtils
471: .isEmpty(messagePrefix)) ? messageKey : messagePrefix
472: + question);
473: }
474:
475: /**
476: * @see org.kuali.core.web.struts.action.KualiDocumentActionBase#cancel(org.apache.struts.action.ActionMapping,
477: * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
478: */
479: @Override
480: public ActionForward cancel(ActionMapping mapping, ActionForm form,
481: HttpServletRequest request, HttpServletResponse response)
482: throws Exception {
483: AccountsPayableFormBase apForm = (AccountsPayableFormBase) form;
484: AccountsPayableDocument document = (AccountsPayableDocument) apForm
485: .getDocument();
486:
487: // validate cancel rules
488: boolean rulePassed = KNSServiceLocator.getKualiRuleService()
489: .applyRules(new CancelAccountsPayableEvent(document));
490:
491: if (!rulePassed) {
492:
493: return mapping.findForward(KFSConstants.MAPPING_BASIC);
494: }
495:
496: return askCancelQuestion(mapping, form, request, response);
497: }
498:
499: /**
500: * Constructs and asks the question as to whether the user wants to cancel, for payment requests and credit memos.
501: *
502: * @param mapping An ActionMapping
503: * @param form An ActionForm
504: * @param request The HttpServletRequest
505: * @param response The HttpServletResponse
506: * @return An ActionForward
507: * @throws Exception
508: */
509: private ActionForward askCancelQuestion(ActionMapping mapping,
510: ActionForm form, HttpServletRequest request,
511: HttpServletResponse response) throws Exception {
512: AccountsPayableFormBase apForm = (AccountsPayableFormBase) form;
513: String operation = "Cancel ";
514: PurQuestionCallback callback = cancelCallbackMethod();
515: TreeMap<String, PurQuestionCallback> questionsAndCallbacks = new TreeMap<String, PurQuestionCallback>();
516: questionsAndCallbacks.put("cancelAP", callback);
517: AccountsPayableDocument apDoc = (AccountsPayableDocument) apForm
518: .getDocument();
519: // check to see whether we should ask close/reopen question
520: if (apDoc.getDocumentSpecificService()
521: .shouldPurchaseOrderBeReversed(apDoc)) {
522: PurQuestionCallback callback2 = cancelPOActionCallbackMethod();
523: questionsAndCallbacks.put("actionOnPoCancel", callback2);
524: }
525:
526: return askQuestionWithInput(mapping, form, request, response,
527: CMDocumentsStrings.CANCEL_CM_QUESTION,
528: AccountsPayableDocumentStrings.CANCEL_NOTE_PREFIX,
529: operation,
530: PurapKeyConstants.CREDIT_MEMO_QUESTION_CANCEL_DOCUMENT,
531: questionsAndCallbacks,
532: PurapKeyConstants.AP_QUESTION_PREFIX, mapping
533: .findForward(KFSConstants.MAPPING_PORTAL));
534: }
535:
536: /**
537: * Returns a question callback for the Cancel Purchase Order action.
538: *
539: * @return A PurQuestionCallback with a post-question activity appropriate to the Cancel PO action
540: */
541: protected PurQuestionCallback cancelPOActionCallbackMethod() {
542:
543: return new PurQuestionCallback() {
544: public void doPostQuestion(
545: AccountsPayableDocument document, String noteText)
546: throws Exception {
547: // base impl do nothing
548: }
549: };
550: }
551:
552: /**
553: * Returns a question callback for the Cancel action.
554: *
555: * @return A PurQuestionCallback which does post-question tasks appropriate to Cancellation.
556: */
557: protected PurQuestionCallback cancelCallbackMethod() {
558:
559: return new PurQuestionCallback() {
560: public void doPostQuestion(
561: AccountsPayableDocument document, String noteText)
562: throws Exception {
563: DocumentService documentService = SpringContext
564: .getBean(DocumentService.class);
565: AccountsPayableDocumentSpecificService apDocumentSpecificService = document
566: .getDocumentSpecificService();
567: // one way or another we will have to fake the user session so get the current one
568: UserSession originalUserSession = GlobalVariables
569: .getUserSession();
570:
571: if (SpringContext.getBean(PurapService.class)
572: .isFullDocumentEntryCompleted(document)) {
573: // for now this works but if place of full entry changes it may need to be based on something else since may
574: // need disapprove
575: // if past full entry and workflow not in final state
576: if (!document.getDocumentHeader()
577: .getWorkflowDocument().stateIsFinal()) {
578: try {
579: // need to run a super user cancel since person canceling may not have an action requested on the
580: // document
581: GlobalVariables
582: .setUserSession(new UserSession(
583: PurapConstants.SYSTEM_AP_USER));
584: documentService
585: .super UserDisapproveDocument(
586: documentService
587: .getByDocumentHeaderId(document
588: .getDocumentNumber()),
589: "Document Cancelled by user "
590: + originalUserSession
591: .getUniversalUser()
592: .getPersonName()
593: + " ("
594: + originalUserSession
595: .getUniversalUser()
596: .getPersonUserIdentifier()
597: + ")");
598: } finally {
599: GlobalVariables
600: .setUserSession(originalUserSession);
601: }
602: } else {
603: // call gl method here (no reason for post processing since workflow done)
604: SpringContext.getBean(
605: AccountsPayableService.class)
606: .cancelAccountsPayableDocument(
607: document, "");
608: }
609: } else {
610: try {
611: // need to run a super user cancel since person canceling may not have an action requested on the document
612: GlobalVariables.setUserSession(new UserSession(
613: PurapConstants.SYSTEM_AP_USER));
614: documentService
615: .super UserCancelDocument(
616: documentService
617: .getByDocumentHeaderId(document
618: .getDocumentNumber()),
619: "Document Cancelled by user "
620: + originalUserSession
621: .getUniversalUser()
622: .getPersonName()
623: + " ("
624: + originalUserSession
625: .getUniversalUser()
626: .getPersonUserIdentifier()
627: + ")");
628: } finally {
629: GlobalVariables
630: .setUserSession(originalUserSession);
631: }
632: }
633: Note noteObj = documentService.createNoteFromDocument(
634: document, noteText);
635: documentService.addNoteToDocument(document, noteObj);
636: SpringContext.getBean(NoteService.class).save(noteObj);
637: }
638: };
639: }
640: }
|