001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community License, Version 2.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/ecl2.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.kfs.sys.document.service.impl;
017    
018    import java.util.ArrayList;
019    import java.util.Collection;
020    import java.util.Iterator;
021    
022    import org.kuali.kfs.sys.document.dataaccess.FinancialSystemDocumentDao;
023    import org.kuali.kfs.sys.document.service.FinancialSystemDocumentService;
024    import org.kuali.rice.kew.exception.WorkflowException;
025    import org.kuali.rice.kns.document.Document;
026    import org.kuali.rice.kns.service.DocumentService;
027    import org.springframework.transaction.annotation.Transactional;
028    
029    /**
030     * This class is a Financial System specific Document Service class to allow for the {@link #findByDocumentHeaderStatusCode(Class, String)} method.
031     */
032    @Transactional
033    public class FinancialSystemDocumentServiceImpl implements FinancialSystemDocumentService {
034        private FinancialSystemDocumentDao financialSystemDocumentDao;
035        private DocumentService documentService;
036        
037        /**
038         * @see org.kuali.kfs.sys.document.service.FinancialSystemDocumentService#findByDocumentHeaderStatusCode(java.lang.Class, java.lang.String)
039         */
040        public <T extends Document> Collection<T> findByDocumentHeaderStatusCode(Class<T> clazz, String statusCode) throws WorkflowException {
041            Collection<T> foundDocuments = getFinancialSystemDocumentDao().findByDocumentHeaderStatusCode(clazz, statusCode);
042            Collection<T> returnDocuments = new ArrayList<T>();
043            for (Iterator<T> iter = foundDocuments.iterator(); iter.hasNext();) {
044                Document doc = (Document) iter.next();
045                returnDocuments.add((T)getDocumentService().getByDocumentHeaderId(doc.getDocumentNumber()));
046            }
047            return returnDocuments;
048        }
049    
050        public FinancialSystemDocumentDao getFinancialSystemDocumentDao() {
051            return financialSystemDocumentDao;
052        }
053    
054        public void setFinancialSystemDocumentDao(FinancialSystemDocumentDao financialSystemDocumentDao) {
055            this.financialSystemDocumentDao = financialSystemDocumentDao;
056        }
057    
058        public DocumentService getDocumentService() {
059            return documentService;
060        }
061    
062        public void setDocumentService(DocumentService documentService) {
063            this.documentService = documentService;
064        }
065    
066        
067    }