package org.thdl.roster.om;

import java.util.*;
import org.apache.torque.om.BaseObject;
import org.apache.torque.util.BasePeer;
import org.apache.torque.util.Criteria;
import org.apache.torque.TorqueException;
import org.thdl.users.*;

/** 
 * The skeleton for this class was autogenerated by Torque on:
 *
 * [Thu Feb 27 12:26:47 EST 2003]
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 */
public class Person extends org.thdl.roster.om.Member implements RosterMember, java.io.Serializable
{
//attributes
//accessors
	public void setMemberData (RosterMemberData memberData)  throws RosterMemberTypeException
	{
		if ( memberData instanceof PersonData )
		{
			try { 
				PersonData pd = (PersonData) memberData;
				setPersonData( pd );
			}
			catch ( 	TorqueException te )
			{
				throw new RosterMemberTypeException( te.getMessage() );
			}
		}
		else
		{
			throw new RosterMemberTypeException( "MemberData must be a PersonData for this object" );
		}
	}
	public RosterMemberData getMemberData() throws RosterMemberTypeException
	{
		try { 
			return getPersonData();
		}
		catch ( 	TorqueException te )
		{
			throw new RosterMemberTypeException( te.getMessage() );
		}
	}
//helpers
    public Member copy() throws TorqueException
    {
      Person person = new Person();
		person = (Person) copyInto( person );
		person.setPersonData( getPersonData().copy() );
		return person;
    }

//constructors
    public Person() throws TorqueException
    {
		super();
		setMemberType(MemberPeer.CLASSKEY_PERSON);
		setPersonData( new PersonData() );
		setContactInfo( new ContactInfo() );
		setResearchInterest( new ResearchInterest() );
		setPublication( new Publication() );
		//setDocument( new Document() );
    }
	 public Person( ThdlUser user ) throws TorqueException
	 {
		 this();
		 getPersonData().setThdlUserId( new Integer( user.getId() ) );
		 getPersonData().setFirstname( user.getFirstname() );
		 getPersonData().setMiddlename( user.getMiddlename() );
		 getPersonData().setLastname( user.getLastname() );
		 //getPersonData().setEmail( user.getEmail() );
	 }
}
