View Javadoc
1   /*
2    * Copyright 2007-2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.module.purap.document.web.struts;
17  
18  import org.apache.struts.action.ActionForm;
19  import org.apache.struts.action.ActionForward;
20  import org.apache.struts.action.ActionMapping;
21  import org.kuali.ole.module.purap.document.ElectronicInvoiceRejectDocument;
22  import org.kuali.ole.sys.OLEConstants;
23  import org.kuali.ole.sys.document.web.struts.FinancialSystemTransactionalDocumentActionBase;
24  import org.kuali.rice.krad.bo.Note;
25  import org.kuali.rice.krad.bo.PersistableBusinessObject;
26  import org.kuali.rice.krad.util.GlobalVariables;
27  
28  import javax.servlet.http.HttpServletRequest;
29  import javax.servlet.http.HttpServletResponse;
30  import java.util.List;
31  
32  /**
33   * Struts Action for Electronic invoice document.
34   */
35  public class ElectronicInvoiceRejectAction extends FinancialSystemTransactionalDocumentActionBase {
36  
37      public ActionForward startResearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
38  
39          ElectronicInvoiceRejectForm electronicInvoiceRejectForm = (ElectronicInvoiceRejectForm) form;
40          ElectronicInvoiceRejectDocument eirDocument = (ElectronicInvoiceRejectDocument) electronicInvoiceRejectForm.getDocument();
41          eirDocument.setInvoiceResearchIndicator(true);
42  
43          Note noteObj = getDocumentService().createNoteFromDocument(eirDocument, "Research started by: " + GlobalVariables.getUserSession().getPerson().getName());
44          PersistableBusinessObject noteParent = eirDocument.getNoteTarget();
45          List<Note> noteList = getNoteService().getByRemoteObjectId(noteParent.getObjectId());
46          noteList.add(noteObj);
47          getNoteService().saveNoteList(noteList);
48          getNoteService().save(noteObj);
49          getDocumentService().saveDocument(eirDocument);
50  
51          return mapping.findForward(OLEConstants.MAPPING_BASIC);
52      }
53  
54      public ActionForward completeResearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
55  
56          ElectronicInvoiceRejectForm electronicInvoiceRejectForm = (ElectronicInvoiceRejectForm) form;
57          ElectronicInvoiceRejectDocument eirDocument = (ElectronicInvoiceRejectDocument) electronicInvoiceRejectForm.getDocument();
58          eirDocument.setInvoiceResearchIndicator(false);
59  
60          Note noteObj = getDocumentService().createNoteFromDocument(eirDocument, "Research completed by: " + GlobalVariables.getUserSession().getPerson().getName());
61          PersistableBusinessObject noteParent = eirDocument.getNoteTarget();
62          List<Note> noteList = this.getNoteService().getByRemoteObjectId(noteParent.getObjectId());
63          noteList.add(noteObj);
64          getNoteService().saveNoteList(noteList);
65  
66          getNoteService().save(noteObj);
67          getDocumentService().saveDocument(eirDocument);
68  
69          return mapping.findForward(OLEConstants.MAPPING_BASIC);
70  
71      }
72  
73  }
74