001    package edu.nrao.sss.model.proposal;
002    
003    import java.util.List;
004    
005    import edu.nrao.sss.model.RepositoryException;
006    
007    /**
008     * A provider of proposals.
009     * <p>
010     * <b>CVS Info:</b>
011     * <table style="margin-left:2em">
012     *   <tr><td>$Revision: 161 $</td></tr>
013     *   <tr><td>$Date: 2006-12-15 11:48:34 -0700 (Fri, 15 Dec 2006) $</td></tr>
014     *   <tr><td>$Author: btruitt $</td></tr>
015     * </table></p>
016     * 
017     * @author David M. Harland
018     * @since 2006-08-03
019     */
020    public interface ProposalProvider
021    {
022      /**
023       * Returns the {@code Proposal} with the given {@code id}, if any.
024       * <p>
025       * If this provider holds no {@code Proposal} with an ID of {@code id},
026       * <i>null</i> is returned.</p>
027       * 
028       * @param id the identifier (primary key) for a {@code Proposal} in this
029       *           repository.
030       *            
031       * @return the {@code Proposal} with the given {@code id}, or
032       *         <i>null</i>, if this provider holds no such {@code Proposal}.
033       * 
034       * @throws RepositoryException if anything goes wrong while trying to fetch
035       *                             proposals from this provider.
036       */
037      public Proposal findById(long id) throws RepositoryException;
038    
039      /**
040       * Returns the {@code Proposal} with the given {@code proposalId}, if any.
041       * <p>
042       * If this provider holds no {@code Proposal} with the given proposal ID,
043       * <i>null</i> is returned.</p>
044       * 
045       * @param proposalCode the identifier for a {@code Proposal} in this
046       *                     repository.
047       *            
048       * @return the {@code Proposal} with the given {@code id}, or
049       *         <i>null</i>, if this provider holds no such {@code Proposal}.
050       * 
051       * @throws RepositoryException if anything goes wrong while trying to fetch
052       *                             proposals from this provider.
053       */
054      public Proposal findByCode(String proposalCode) throws RepositoryException;
055    
056      /**
057        * @return a List (possibly empty) of Proposals that uid is an editor of.
058        * This method should not return null.
059        */
060      public List<Proposal> findByUserId(long uid) throws RepositoryException;
061      
062      /**
063       * This method returns a List of Projects owned by <code>userId</code> that 
064       * have a status of <code>status</code>.
065       * @return A list of projects. The list may be empty, but should not be null!
066       * @throws RepositoryException
067       */
068      public List<Proposal> findProposals(Long userId, ProposalStatus status)
069        throws RepositoryException;
070    
071      /**
072       * returns a non-null (but possibly empty) list of Proposals that have the 
073       * Proposal Status of <code>status</code>
074       * @param status the status to search for.
075       * @return a non-null list of Proposals.
076       * @throws RepositoryException
077       */
078      public List<Proposal> findProposals(ProposalStatus status)
079        throws RepositoryException;
080      
081      /**
082       * Returns a list of all proposals held by this provider.
083       * 
084       * @return a list of all proposals held by this provider.  If the provider
085       *         has no proposals the returned list will be empty.
086       * 
087       * @throws RepositoryException if anything goes wrong while trying to fetch
088       *                             proposals from this provider.
089       */
090      public List<Proposal> getAllProposals() throws RepositoryException;
091    }