001package edu.pdx.cs410J.family;
002
003import java.io.*;
004import java.rmi.*;
005import java.util.*;
006
007/**
008 * This interface specifies a factory that is responsible for creating,
009 * storing and querying {@link Person} objects.
010 */
011public interface RemoteFamilyTree extends Remote {
012
013  /**
014   * Creates a new <code>Person</code> of a given gender
015   *
016   * @throws FamilyTreeException
017   *         If <code>gender</code> is neither {@link Person#MALE} nor
018   *         {@link Person#FEMALE}.
019   */
020  public RemotePerson createPerson(Person.Gender gender)
021    throws RemoteException;
022
023  /**
024   * Gets the person with the given id.  If no person with that id
025   * exists, then <code>null</code> is returned.
026   */
027  public RemotePerson getPerson(int id) throws RemoteException;
028
029  /**
030   * Gets the person with the given first and last name.  If no person
031   * with that name is found, then <code>null</code> is returned.
032   *
033   * @throws IllegalArgumentException
034   *         If more than one person in the family tree has that
035   *         name. 
036   */
037  public RemotePerson getPerson(String firstName, String lastName)
038    throws RemoteException;
039
040  /**
041   * Shuts down this <code>PersonFactory</code>.  Modified
042   * <code>Person</code>s are written to persistent storage as
043   * appropriate.
044   */
045  public void shutdown() throws IOException, RemoteException;
046
047  /**
048   * Returns the marriage between two people.  If the two people have
049   * never been married, then <code>null</code> is returned.
050   *
051   * @throws IllegalArgumentException
052   *         If no person with husbandId or no person with wifeId
053   *         exists in the family tree
054   */
055  public RemoteMarriage getMarriage(int husbandId, int wifeId) 
056    throws RemoteException; 
057
058  /**
059   * Creates a new marriage between two people
060   * 
061   * @throws IllegalArgumentException
062   *         If no person with husbandId or no person with wifeId
063   *         exists in the family tree or if either spouse does not
064   *         have the proper gender.
065   */
066  public RemoteMarriage createMarriage(int husbandId, int wifeId) 
067    throws RemoteException;
068
069  /**
070   * Returns the people in the family tree that are living
071   * (i&#46;e&#46; have a date of birth, but no date of death)
072   */
073  public Collection<RemotePerson> getLiving() throws RemoteException;
074
075  /**
076   * Returns the people in the family tree were alive at a certain
077   * time 
078   */
079  public Collection<RemotePerson> getLiving(Date date) throws RemoteException;
080
081}