001/*
002 * The Kuali Financial System, a comprehensive financial management system for higher education.
003 * 
004 * Copyright 2005-2014 The Kuali Foundation
005 * 
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU Affero General Public License as
008 * published by the Free Software Foundation, either version 3 of the
009 * License, or (at your option) any later version.
010 * 
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU Affero General Public License for more details.
015 * 
016 * You should have received a copy of the GNU Affero General Public License
017 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
018 */
019package org.kuali.kfs.sys.document.service;
020
021import java.util.Collection;
022import java.util.Set;
023
024import org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader;
025import org.kuali.kfs.sys.document.FinancialSystemTransactionalDocument;
026import org.kuali.rice.kew.api.document.DocumentStatus;
027import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria;
028import org.kuali.rice.kew.api.exception.WorkflowException;
029import org.kuali.rice.krad.bo.DocumentHeader;
030import org.kuali.rice.krad.document.Document;
031
032/**
033 * This class is the financial system specific document service interface
034 */
035public interface FinancialSystemDocumentService {
036
037    /**
038     * Looks up all Documents of the given class that are in the state of the given KFS document status code
039     * @param clazz the class of the document to look up
040     * @param statusCode the KFS status code to look up
041     * @return a Collection of matching documents
042     * @throws WorkflowException if the workflow document cannot be accessed for any reason
043     */
044    public <T extends Document> Collection<T> findByDocumentHeaderStatusCode(Class<T> clazz, String statusCode) throws WorkflowException;
045
046    /**
047     * Looks up all Documents of the given class that have the given workflow DocumentStatus
048     * @param clazz the class of the document to look up
049     * @param docStatus the KEW status code to look up
050     * @return a Collection of matching documents
051     * @throws WorkflowException if the workflow document cannot be accessed for any reason
052     */
053    public <T extends Document> Collection<T> findByWorkflowStatusCode(Class<T> clazz, DocumentStatus docStatus) throws WorkflowException;
054
055    /**
056     * Looks up all Documents of the given class that have the given application document status
057     * @param clazz the class of the document to look up
058     * @param applicationDocumentStatus the application document status to look up
059     * @return a Collection of matching documents
060     * @throws WorkflowException if the workflow document cannot be accessed for any reason
061     */
062    public <T extends Document> Collection<T> findByApplicationDocumentStatus(Class<T> clazz, String applicationDocumentStatus) throws WorkflowException;
063    /**
064     * This method retrieves the financial system document headers of all the documents having application document status passed in.
065     *
066     * @param applicationDocumentStatus
067     * @return document headers list
068     */
069    public Collection<FinancialSystemDocumentHeader> findByApplicationDocumentStatus(String applicationDocumentStatus);
070    public void prepareToCopy(FinancialSystemDocumentHeader oldDocumentHeader, FinancialSystemTransactionalDocument document);
071    public Collection<FinancialSystemDocumentHeader> findByWorkflowStatusCode(DocumentStatus docStatus);
072    /**
073     * This method takes a document number in and returns the relevant document header
074     *
075     * @param documentNumber
076     * @return document header
077     */
078    public FinancialSystemDocumentHeader findByDocumentNumber(String documentNumber);
079
080    /**
081     * Convenience method which turns the DocumentStatusCategory.PENDING document statuses into a Set of the status codes as Strings
082     * As of the time of this commenting, the pending statuses are Initiated (I), Saved (S), Enroute (R), and Exception (E)
083     * @return a Set of Statuses "in progress"/"pending" documents might have
084     */
085    public Set<String> getPendingDocumentStatuses();
086
087    /**
088     * Convenience method which turns the DocumentStatusCategory.SUCCESSFUL document statuses into a Set of status codes as Strings
089     * As of the time of this commenting, the successful statuses are Processed (P) and Final (F)
090     * @return a Set of Statuses which are considered "successful"
091     */
092    public Set<String> getSuccessfulDocumentStatuses();
093
094    /**
095     * Convenience method which turns the DocumentStatusCategory.UNSUCCESSFUL document statuses into a Set of status codes as Strings
096     * As of the time of this commenting, the unsuccessful statuses are Canceled (X), Disapproved (D), and Recalled (L)
097     * @return a Set of Statuses which are considered "unsuccessful"
098     */
099    public Set<String> getUnsuccessfulDocumentStatuses();
100
101    /**
102     * @param id
103     * @return documentHeader of the document which corrects the document with the given documentId
104     */
105    public DocumentHeader getCorrectingDocumentHeader(String documentId);
106
107    /**
108     * @deprecated this method was created to support document searches for batch document processing.  Instead of using document searches,
109     *             the FinancialSystemDocumentHeader should now have properties which allow the selection of documents without a document search.
110     *             This method will be removed in KFS 6
111     */
112    @Deprecated
113    public int getFetchMoreIterationLimit();
114    /**
115     * @deprecated this method was created to support document searches for batch document processing.  Instead of using document searches,
116     *             the FinancialSystemDocumentHeader should now have properties which allow the selection of documents without a document search.
117     *             This method will be removed in KFS 6
118     */
119    @Deprecated
120    public int getMaxResultCap(DocumentSearchCriteria criteria);
121
122}