001    package edu.nrao.sss.model.project;
002    
003    import java.util.List;
004    
005    import edu.nrao.sss.model.RepositoryException;
006    import edu.nrao.sss.util.EventSetStatus;
007    
008    /**
009     * A provider of projects.
010     * <p>
011     * <b>CVS Info:</b>
012     * <table style="margin-left:2em">
013     *   <tr><td>$Revision: 840 $</td></tr>
014     *   <tr><td>$Date: 2007-08-21 11:16:41 -0600 (Tue, 21 Aug 2007) $</td></tr>
015     *   <tr><td>$Author: dharland $</td></tr>
016     * </table></p>
017     *  
018     * @author David M. Harland
019     * @since 2006-08-03
020     */
021    public interface ProjectProvider
022    {
023      /**
024       * Returns the {@code Project} with the given {@code id}, if any.
025       * <p>
026       * If this provider holds no {@code Project} with an ID of {@code id},
027       * <i>null</i> is returned.</p>
028       * 
029       * @param id The identifier (primary key) for a {@code Project} in this
030       *           repository.
031       *            
032       * @return The {@code Project} with the given {@code id}, or
033       *         <i>null</i>, if this provider holds no such {@code Project}.
034       * 
035       * @throws RepositoryException if anything goes wrong while trying to fetch
036       *                             projects from this provider.
037       */
038      public Project findById(long id) throws RepositoryException;
039      
040      /**
041       * Returns the {@code Project} with the given {@code code}, if any.
042       * @param code the Project code to be searched for.
043       * @throws RepositoryException if anything goes wrong while trying to fetch
044       *                             projects from this provider.
045       */
046      public Project findByCode(String code) throws RepositoryException;
047      
048      /**
049       * Return a List of Projects that are owned (a.k.a. editable) by the User
050       * <code>uid</code>
051       */
052      public List<Project> findByUserId(long uid) throws RepositoryException;
053      
054      /**
055       * This method returns a List of Projects owned by <code>userId</code> that 
056       * have a proposal code of <code>proposalCode</code>.
057       * @param userId user id of the user that owns this project.
058       * @param proposalCode the proposalCode to be searched for.
059       * @return A list of projects. The list may be empty, but should not be null!
060       * @throws RepositoryException
061       */
062      public List<Project> findProjects(Long userId, String proposalCode)
063        throws RepositoryException;
064      
065      /**
066       * Returns the a list of test projects owned by the user with the given ID.
067       * <p>
068       * If this provider holds no test projects for the given owner,
069       * an empty list is returned.</p>
070       * 
071       * @param userId ID of the user who owns projects.
072       *            
073       * @return a list of test projects owned by the user with the given ID,
074       *         or an empty list if this provider has no such projects.
075       * 
076       * @throws RepositoryException if anything goes wrong while trying to fetch
077       *                             projects from this provider.
078       */
079      public List<Project> findTestProjects(Long userId)
080        throws RepositoryException;
081    
082      /**
083       * Returns the a list of projects held by this provider that have the
084       * given status and are owned by the user with the given ID.
085       * <p>
086       * If this provider holds no projects with the given status and owner,
087       * an empty list is returned.</p>
088       * 
089       * @param userId ID of the user who owns projects.
090       * 
091       * @param status the execution status of a project.
092       *            
093       * @return a list of projects whose execution status equals {@code status},
094       *         or an empty list if this provider has no such projects.
095       * 
096       * @throws RepositoryException if anything goes wrong while trying to fetch
097       *                             projects from this provider.
098       */
099      public List<Project> findProjects(Long userId, EventSetStatus status)
100        throws RepositoryException;
101      
102      /**
103       * Returns the a list of projects held by this provider that have the
104       * given status.
105       * <p>
106       * If this provider holds no projects with the given status,
107       * an empty list is returned.</p>
108       * 
109       * @param status the execution status of a project.
110       *            
111       * @return a list of projects whose execution status equals {@code status},
112       *         or an empty list if this provider has no such projects.
113       * 
114       * @throws RepositoryException if anything goes wrong while trying to fetch
115       *                             projects from this provider.
116       */
117      public List<Project> findProjects(EventSetStatus status)
118        throws RepositoryException;
119      
120      /**
121       * Returns a list of all projects held by this provider.
122       * 
123       * @return a list of all projects held by this provider.  If the provider
124       *         has no projects the returned list will be empty.
125       * 
126       * @throws RepositoryException if anything goes wrong while trying to fetch
127       *                             projects from this provider.
128       */
129      public List<Project> getAllProjects() throws RepositoryException;
130    
131    }