View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.module.ar.web.struts;
20  
21  import java.util.ArrayList;
22  import java.util.Collection;
23  
24  import org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument;
25  import org.kuali.kfs.sys.context.SpringContext;
26  import org.kuali.rice.core.api.datetime.DateTimeService;
27  import org.kuali.rice.kns.lookup.LookupResultsService;
28  import org.kuali.rice.kns.web.struts.action.KualiAction;
29  import org.kuali.rice.krad.bo.PersistableBusinessObject;
30  
31  /**
32   * Base methods to support report summary actions
33   */
34  public class ContractsGrantsBillingSummaryActionBase extends KualiAction {
35      private static volatile DateTimeService dateTimeService;
36      private static volatile LookupResultsService lookupResultsService;
37  
38      /**
39       * Gets the invoice documents from sequence number.
40       * @param lookupResultsSequenceNumber The sequence number of search result.
41       * @param personId The principal id of the person who searched.
42       * @return Returns the list of invoice documents.
43       */
44      protected Collection<ContractsGrantsInvoiceDocument> getCGInvoiceDocumentsFromLookupResultsSequenceNumber(String lookupResultsSequenceNumber, String personId) {
45          Collection<ContractsGrantsInvoiceDocument> invoiceDocuments = new ArrayList<ContractsGrantsInvoiceDocument>();
46          try {
47              for (PersistableBusinessObject obj : getLookupResultsService().retrieveSelectedResultBOs(lookupResultsSequenceNumber, ContractsGrantsInvoiceDocument.class, personId)) {
48                  invoiceDocuments.add((ContractsGrantsInvoiceDocument) obj);
49              }
50          }
51          catch (Exception e) { // retrieveSelectedResultBOs throws Exception, hence the Pokemon handler
52              throw new RuntimeException(e);
53          }
54          return invoiceDocuments;
55      }
56  
57  
58      public static DateTimeService getDateTimeService() {
59          if (dateTimeService == null) {
60              dateTimeService = SpringContext.getBean(DateTimeService.class);
61          }
62          return dateTimeService;
63      }
64  
65      public static LookupResultsService getLookupResultsService() {
66          if (lookupResultsService == null) {
67              lookupResultsService = SpringContext.getBean(LookupResultsService.class);
68          }
69          return lookupResultsService;
70      }
71  }