View Javadoc
1   /*
2    * Copyright 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.sys.document.service.impl;
17  
18  import java.util.ArrayList;
19  import java.util.Collection;
20  import java.util.Iterator;
21  
22  import org.kuali.ole.sys.businessobject.FinancialSystemDocumentHeader;
23  import org.kuali.ole.sys.document.FinancialSystemTransactionalDocument;
24  import org.kuali.ole.sys.document.dataaccess.FinancialSystemDocumentDao;
25  import org.kuali.ole.sys.document.service.FinancialSystemDocumentService;
26  import org.kuali.rice.kew.api.exception.WorkflowException;
27  import org.kuali.rice.krad.document.Document;
28  import org.kuali.rice.krad.service.DocumentAdHocService;
29  import org.kuali.rice.krad.service.DocumentService;
30  import org.springframework.transaction.annotation.Transactional;
31  
32  /**
33   * This class is a Financial System specific Document Service class to allow for the
34   * {@link #findByDocumentHeaderStatusCode(Class, String)} method.
35   */
36  @Transactional
37  public class FinancialSystemDocumentServiceImpl implements FinancialSystemDocumentService {
38      private FinancialSystemDocumentDao financialSystemDocumentDao;
39      private DocumentService documentService;
40      protected DocumentAdHocService documentAdHocService;
41  
42      /**
43       * @see org.kuali.ole.sys.document.service.FinancialSystemDocumentService#findByDocumentHeaderStatusCode(java.lang.Class,
44       *      java.lang.String)
45       */
46      @Override
47      public <T extends Document> Collection<T> findByDocumentHeaderStatusCode(Class<T> clazz, String statusCode) throws WorkflowException {
48          Collection<T> foundDocuments = getFinancialSystemDocumentDao().findByDocumentHeaderStatusCode(clazz, statusCode);
49          for (Document doc : foundDocuments)
50              documentAdHocService.addAdHocs(doc);
51  
52          Collection<T> returnDocuments = new ArrayList<T>();
53          for (Iterator<T> iter = foundDocuments.iterator(); iter.hasNext();) {
54              Document doc = (Document) iter.next();
55              returnDocuments.add((T) getDocumentService().getByDocumentHeaderId(doc.getDocumentNumber()));
56          }
57          return returnDocuments;
58      }
59  
60      public void prepareToCopy(FinancialSystemDocumentHeader oldDocumentHeader, FinancialSystemTransactionalDocument document) {
61          // This method serves as a plugin to add logic to the copy functionality, when needed.
62      }
63  
64      public FinancialSystemDocumentDao getFinancialSystemDocumentDao() {
65          return financialSystemDocumentDao;
66      }
67  
68      public void setFinancialSystemDocumentDao(FinancialSystemDocumentDao financialSystemDocumentDao) {
69          this.financialSystemDocumentDao = financialSystemDocumentDao;
70      }
71  
72      public DocumentService getDocumentService() {
73          return documentService;
74      }
75  
76      public void setDocumentService(DocumentService documentService) {
77          this.documentService = documentService;
78      }
79  
80      public void setDocumentAdHocService(DocumentAdHocService documentAdHocService) {
81          this.documentAdHocService = documentAdHocService;
82      }
83  
84  
85  }