package org.thdl.roster.om;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Date;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;


/**
 * This class was autogenerated by Torque on:
 *
 * [Wed May 14 19:01:42 EDT 2003]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to ResearchInterest
 */
public abstract class BaseResearchInterest extends BaseObject
{
    /** The Peer class */
    private static final ResearchInterestPeer peer =
        new ResearchInterestPeer();

                  
        /**
         * The value for the id field
         */
        private Integer id;
              
        /**
         * The value for the interests field
         */
        private String interests;
              
        /**
         * The value for the activities field
         */
        private String activities;
              
        /**
         * The value for the collaboration_interests field
         */
        private String collaboration_interests;
              
        /**
         * The value for the focus_from field
         */
        private Integer focus_from;
              
        /**
         * The value for the focus_to field
         */
        private Integer focus_to;
      
      
        /**
         * Get the Id
         *
         * @return Integer
         */
        public Integer getId()
        {
            return id;
        }

                                                                              
        /**
         * Set the value of Id
         *
         * @param v new value
         */
        public void setId(Integer v) throws TorqueException
        {
          


         if (!ObjectUtils.equals(this.id, v))
        {
             this.id = v;
            setModified(true);
        }

                  
                                                  
              // update associated Member
              if (collMembers != null)
              {
                  for (int i = 0; i < collMembers.size(); i++)
                  {
                      ((Member) collMembers.get(i))
                          .setResearchInterestId(v);
                  }
              }
                                                              
              // update associated ResearchInterestLanguage
              if (collResearchInterestLanguages != null)
              {
                  for (int i = 0; i < collResearchInterestLanguages.size(); i++)
                  {
                      ((ResearchInterestLanguage) collResearchInterestLanguages.get(i))
                          .setResearchInterestId(v);
                  }
              }
                                                              
              // update associated ResearchInterestCulturalArea
              if (collResearchInterestCulturalAreas != null)
              {
                  for (int i = 0; i < collResearchInterestCulturalAreas.size(); i++)
                  {
                      ((ResearchInterestCulturalArea) collResearchInterestCulturalAreas.get(i))
                          .setResearchInterestId(v);
                  }
              }
                                                              
              // update associated ResearchInterestDiscipline
              if (collResearchInterestDisciplines != null)
              {
                  for (int i = 0; i < collResearchInterestDisciplines.size(); i++)
                  {
                      ((ResearchInterestDiscipline) collResearchInterestDisciplines.get(i))
                          .setResearchInterestId(v);
                  }
              }
                                   }


        /**
         * Get the Interests
         *
         * @return String
         */
        public String getInterests()
        {
            return interests;
        }

                                            
        /**
         * Set the value of Interests
         *
         * @param v new value
         */
        public void setInterests(String v) 
        {
          


         if (!ObjectUtils.equals(this.interests, v))
        {
             this.interests = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Activities
         *
         * @return String
         */
        public String getActivities()
        {
            return activities;
        }

                                            
        /**
         * Set the value of Activities
         *
         * @param v new value
         */
        public void setActivities(String v) 
        {
          


         if (!ObjectUtils.equals(this.activities, v))
        {
             this.activities = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the CollaborationInterests
         *
         * @return String
         */
        public String getCollaborationInterests()
        {
            return collaboration_interests;
        }

                                            
        /**
         * Set the value of CollaborationInterests
         *
         * @param v new value
         */
        public void setCollaborationInterests(String v) 
        {
          


         if (!ObjectUtils.equals(this.collaboration_interests, v))
        {
             this.collaboration_interests = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the FocusFrom
         *
         * @return Integer
         */
        public Integer getFocusFrom()
        {
            return focus_from;
        }

                                            
        /**
         * Set the value of FocusFrom
         *
         * @param v new value
         */
        public void setFocusFrom(Integer v) 
        {
          


         if (!ObjectUtils.equals(this.focus_from, v))
        {
             this.focus_from = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the FocusTo
         *
         * @return Integer
         */
        public Integer getFocusTo()
        {
            return focus_to;
        }

                                            
        /**
         * Set the value of FocusTo
         *
         * @param v new value
         */
        public void setFocusTo(Integer v) 
        {
          


         if (!ObjectUtils.equals(this.focus_to, v))
        {
             this.focus_to = v;
            setModified(true);
        }

                  
                       }


 
        
                
      
    /**
     * Collection to store aggregation of collMembers
     */
    protected List collMembers;

    /**
     * Temporary storage of collMembers to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initMembers()
    {
        if (collMembers == null)
        {
            collMembers = new ArrayList();
        }
    }

    /**
     * Method called to associate a Member object to this object
     * through the Member foreign key attribute
     *
     * @param l Member
     * @throws TorqueException
     */
    public void addMember(Member l) throws TorqueException
    {
        getMembers().add(l);
        l.setResearchInterest((ResearchInterest) this);
    }

    /**
     * The criteria used to select the current contents of collMembers
     */
    private Criteria lastMembersCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getMembers(new Criteria())
     *
     * @throws TorqueException
     */
    public List getMembers() throws TorqueException
    {
        if (collMembers == null)
        {
            collMembers = getMembers(new Criteria(10));
        }
        return collMembers;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this ResearchInterest has previously
     * been saved, it will retrieve related Members from storage.
     * If this ResearchInterest is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getMembers(Criteria criteria) throws TorqueException
    {
        if (collMembers == null)
        {
            if (isNew())
            {
               collMembers = new ArrayList();
            }
            else
            {
                   criteria.add(MemberPeer.RESEARCH_INTEREST_ID, getId() );
                   collMembers = MemberPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                   criteria.add(MemberPeer.RESEARCH_INTEREST_ID, getId());
                   if (!lastMembersCriteria.equals(criteria))
                {
                    collMembers = MemberPeer.doSelect(criteria);
                }
            }
        }
        lastMembersCriteria = criteria;

        return collMembers;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getMembers(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getMembers(Connection con) throws TorqueException
    {
        if (collMembers == null)
        {
            collMembers = getMembers(new Criteria(10), con);
        }
        return collMembers;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this ResearchInterest has previously
     * been saved, it will retrieve related Members from storage.
     * If this ResearchInterest is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getMembers(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collMembers == null)
        {
            if (isNew())
            {
               collMembers = new ArrayList();
            }
            else
            {
                     criteria.add(MemberPeer.RESEARCH_INTEREST_ID, getId());
                     collMembers = MemberPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                     criteria.add(MemberPeer.RESEARCH_INTEREST_ID, getId());
                     if (!lastMembersCriteria.equals(criteria))
                 {
                     collMembers = MemberPeer.doSelect(criteria, con);
                 }
             }
         }
         lastMembersCriteria = criteria;

         return collMembers;
     }

        

     
      
      
          
                    
                
        
        
    
      
         
          
                    
                
        
        
    
      
      
          
                    
                
        
        
    
      
      
          
                    
                
        
        
    
      
      
          
                    
                
        
        
    
      
      
          
                    
                
        
        
      



             
      
    /**
     * Collection to store aggregation of collResearchInterestLanguages
     */
    protected List collResearchInterestLanguages;

    /**
     * Temporary storage of collResearchInterestLanguages to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initResearchInterestLanguages()
    {
        if (collResearchInterestLanguages == null)
        {
            collResearchInterestLanguages = new ArrayList();
        }
    }

    /**
     * Method called to associate a ResearchInterestLanguage object to this object
     * through the ResearchInterestLanguage foreign key attribute
     *
     * @param l ResearchInterestLanguage
     * @throws TorqueException
     */
    public void addResearchInterestLanguage(ResearchInterestLanguage l) throws TorqueException
    {
        getResearchInterestLanguages().add(l);
        l.setResearchInterest((ResearchInterest) this);
    }

    /**
     * The criteria used to select the current contents of collResearchInterestLanguages
     */
    private Criteria lastResearchInterestLanguagesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getResearchInterestLanguages(new Criteria())
     *
     * @throws TorqueException
     */
    public List getResearchInterestLanguages() throws TorqueException
    {
        if (collResearchInterestLanguages == null)
        {
            collResearchInterestLanguages = getResearchInterestLanguages(new Criteria(10));
        }
        return collResearchInterestLanguages;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this ResearchInterest has previously
     * been saved, it will retrieve related ResearchInterestLanguages from storage.
     * If this ResearchInterest is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getResearchInterestLanguages(Criteria criteria) throws TorqueException
    {
        if (collResearchInterestLanguages == null)
        {
            if (isNew())
            {
               collResearchInterestLanguages = new ArrayList();
            }
            else
            {
                   criteria.add(ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, getId() );
                   collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                   criteria.add(ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, getId());
                   if (!lastResearchInterestLanguagesCriteria.equals(criteria))
                {
                    collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria);
                }
            }
        }
        lastResearchInterestLanguagesCriteria = criteria;

        return collResearchInterestLanguages;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getResearchInterestLanguages(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getResearchInterestLanguages(Connection con) throws TorqueException
    {
        if (collResearchInterestLanguages == null)
        {
            collResearchInterestLanguages = getResearchInterestLanguages(new Criteria(10), con);
        }
        return collResearchInterestLanguages;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this ResearchInterest has previously
     * been saved, it will retrieve related ResearchInterestLanguages from storage.
     * If this ResearchInterest is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getResearchInterestLanguages(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collResearchInterestLanguages == null)
        {
            if (isNew())
            {
               collResearchInterestLanguages = new ArrayList();
            }
            else
            {
                     criteria.add(ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, getId());
                     collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                     criteria.add(ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, getId());
                     if (!lastResearchInterestLanguagesCriteria.equals(criteria))
                 {
                     collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria, con);
                 }
             }
         }
         lastResearchInterestLanguagesCriteria = criteria;

         return collResearchInterestLanguages;
     }

    

     
      
         
          
                    
                
        
        
    
      
      
          
                    
                
        
        
      



             
      
    /**
     * Collection to store aggregation of collResearchInterestCulturalAreas
     */
    protected List collResearchInterestCulturalAreas;

    /**
     * Temporary storage of collResearchInterestCulturalAreas to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initResearchInterestCulturalAreas()
    {
        if (collResearchInterestCulturalAreas == null)
        {
            collResearchInterestCulturalAreas = new ArrayList();
        }
    }

    /**
     * Method called to associate a ResearchInterestCulturalArea object to this object
     * through the ResearchInterestCulturalArea foreign key attribute
     *
     * @param l ResearchInterestCulturalArea
     * @throws TorqueException
     */
    public void addResearchInterestCulturalArea(ResearchInterestCulturalArea l) throws TorqueException
    {
        getResearchInterestCulturalAreas().add(l);
        l.setResearchInterest((ResearchInterest) this);
    }

    /**
     * The criteria used to select the current contents of collResearchInterestCulturalAreas
     */
    private Criteria lastResearchInterestCulturalAreasCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getResearchInterestCulturalAreas(new Criteria())
     *
     * @throws TorqueException
     */
    public List getResearchInterestCulturalAreas() throws TorqueException
    {
        if (collResearchInterestCulturalAreas == null)
        {
            collResearchInterestCulturalAreas = getResearchInterestCulturalAreas(new Criteria(10));
        }
        return collResearchInterestCulturalAreas;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this ResearchInterest has previously
     * been saved, it will retrieve related ResearchInterestCulturalAreas from storage.
     * If this ResearchInterest is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getResearchInterestCulturalAreas(Criteria criteria) throws TorqueException
    {
        if (collResearchInterestCulturalAreas == null)
        {
            if (isNew())
            {
               collResearchInterestCulturalAreas = new ArrayList();
            }
            else
            {
                   criteria.add(ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, getId() );
                   collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                   criteria.add(ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, getId());
                   if (!lastResearchInterestCulturalAreasCriteria.equals(criteria))
                {
                    collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria);
                }
            }
        }
        lastResearchInterestCulturalAreasCriteria = criteria;

        return collResearchInterestCulturalAreas;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getResearchInterestCulturalAreas(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getResearchInterestCulturalAreas(Connection con) throws TorqueException
    {
        if (collResearchInterestCulturalAreas == null)
        {
            collResearchInterestCulturalAreas = getResearchInterestCulturalAreas(new Criteria(10), con);
        }
        return collResearchInterestCulturalAreas;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this ResearchInterest has previously
     * been saved, it will retrieve related ResearchInterestCulturalAreas from storage.
     * If this ResearchInterest is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getResearchInterestCulturalAreas(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collResearchInterestCulturalAreas == null)
        {
            if (isNew())
            {
               collResearchInterestCulturalAreas = new ArrayList();
            }
            else
            {
                     criteria.add(ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, getId());
                     collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                     criteria.add(ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, getId());
                     if (!lastResearchInterestCulturalAreasCriteria.equals(criteria))
                 {
                     collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria, con);
                 }
             }
         }
         lastResearchInterestCulturalAreasCriteria = criteria;

         return collResearchInterestCulturalAreas;
     }

    

     
      
         
          
                    
                
        
        
    
      
      
          
                    
                
        
        
      



             
      
    /**
     * Collection to store aggregation of collResearchInterestDisciplines
     */
    protected List collResearchInterestDisciplines;

    /**
     * Temporary storage of collResearchInterestDisciplines to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initResearchInterestDisciplines()
    {
        if (collResearchInterestDisciplines == null)
        {
            collResearchInterestDisciplines = new ArrayList();
        }
    }

    /**
     * Method called to associate a ResearchInterestDiscipline object to this object
     * through the ResearchInterestDiscipline foreign key attribute
     *
     * @param l ResearchInterestDiscipline
     * @throws TorqueException
     */
    public void addResearchInterestDiscipline(ResearchInterestDiscipline l) throws TorqueException
    {
        getResearchInterestDisciplines().add(l);
        l.setResearchInterest((ResearchInterest) this);
    }

    /**
     * The criteria used to select the current contents of collResearchInterestDisciplines
     */
    private Criteria lastResearchInterestDisciplinesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getResearchInterestDisciplines(new Criteria())
     *
     * @throws TorqueException
     */
    public List getResearchInterestDisciplines() throws TorqueException
    {
        if (collResearchInterestDisciplines == null)
        {
            collResearchInterestDisciplines = getResearchInterestDisciplines(new Criteria(10));
        }
        return collResearchInterestDisciplines;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this ResearchInterest has previously
     * been saved, it will retrieve related ResearchInterestDisciplines from storage.
     * If this ResearchInterest is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getResearchInterestDisciplines(Criteria criteria) throws TorqueException
    {
        if (collResearchInterestDisciplines == null)
        {
            if (isNew())
            {
               collResearchInterestDisciplines = new ArrayList();
            }
            else
            {
                   criteria.add(ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, getId() );
                   collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                   criteria.add(ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, getId());
                   if (!lastResearchInterestDisciplinesCriteria.equals(criteria))
                {
                    collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria);
                }
            }
        }
        lastResearchInterestDisciplinesCriteria = criteria;

        return collResearchInterestDisciplines;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getResearchInterestDisciplines(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getResearchInterestDisciplines(Connection con) throws TorqueException
    {
        if (collResearchInterestDisciplines == null)
        {
            collResearchInterestDisciplines = getResearchInterestDisciplines(new Criteria(10), con);
        }
        return collResearchInterestDisciplines;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this ResearchInterest has previously
     * been saved, it will retrieve related ResearchInterestDisciplines from storage.
     * If this ResearchInterest is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getResearchInterestDisciplines(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collResearchInterestDisciplines == null)
        {
            if (isNew())
            {
               collResearchInterestDisciplines = new ArrayList();
            }
            else
            {
                     criteria.add(ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, getId());
                     collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                     criteria.add(ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, getId());
                     if (!lastResearchInterestDisciplinesCriteria.equals(criteria))
                 {
                     collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria, con);
                 }
             }
         }
         lastResearchInterestDisciplinesCriteria = criteria;

         return collResearchInterestDisciplines;
     }

    

     
      
         
          
                    
                
        
        
    
      
      
          
                    
                
        
        
      



     
    
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
      if (fieldNames == null)
      {
        fieldNames = new ArrayList();
            fieldNames.add("Id");
            fieldNames.add("Interests");
            fieldNames.add("Activities");
            fieldNames.add("CollaborationInterests");
            fieldNames.add("FocusFrom");
            fieldNames.add("FocusTo");
            fieldNames = Collections.unmodifiableList(fieldNames);
      }
      return fieldNames;
    }

    /**
     * Retrieves a field from the object by name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
            if (name.equals("Id"))
    {
              return getId();
          }
            if (name.equals("Interests"))
    {
              return getInterests();
          }
            if (name.equals("Activities"))
    {
              return getActivities();
          }
            if (name.equals("CollaborationInterests"))
    {
              return getCollaborationInterests();
          }
            if (name.equals("FocusFrom"))
    {
              return getFocusFrom();
          }
            if (name.equals("FocusTo"))
    {
              return getFocusTo();
          }
            return null;
    }
    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
            if (name.equals(ResearchInterestPeer.ID))
        {
              return getId();
          }
            if (name.equals(ResearchInterestPeer.INTERESTS))
        {
              return getInterests();
          }
            if (name.equals(ResearchInterestPeer.ACTIVITIES))
        {
              return getActivities();
          }
            if (name.equals(ResearchInterestPeer.COLLABORATION_INTERESTS))
        {
              return getCollaborationInterests();
          }
            if (name.equals(ResearchInterestPeer.FOCUS_FROM))
        {
              return getFocusFrom();
          }
            if (name.equals(ResearchInterestPeer.FOCUS_TO))
        {
              return getFocusTo();
          }
            return null;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
            if (pos == 0)
    {
              return getId();
          }
            if (pos == 1)
    {
              return getInterests();
          }
            if (pos == 2)
    {
              return getActivities();
          }
            if (pos == 3)
    {
              return getCollaborationInterests();
          }
            if (pos == 4)
    {
              return getFocusFrom();
          }
            if (pos == 5)
    {
              return getFocusTo();
          }
                return null;
    }

     


    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
             save(ResearchInterestPeer.getMapBuilder()
                .getDatabaseMap().getName());
     }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
     *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
         try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }

     }

      /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
      /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
        if (!alreadyInSave)
      {
        alreadyInSave = true;



  
        // If this object has been modified, then save it to the database.
        if (isModified())
        {
            if (isNew())
            {
                ResearchInterestPeer.doInsert((ResearchInterest) this, con);
                setNew(false);
            }
            else
            {
                ResearchInterestPeer.doUpdate((ResearchInterest) this, con);
            }
        }

                                    
                
          if (collMembers != null)
          {
              for (int i = 0; i < collMembers.size(); i++)
              {
                  ((Member) collMembers.get(i)).save(con);
              }
          }
                                        
                
          if (collResearchInterestLanguages != null)
          {
              for (int i = 0; i < collResearchInterestLanguages.size(); i++)
              {
                  ((ResearchInterestLanguage) collResearchInterestLanguages.get(i)).save(con);
              }
          }
                                        
                
          if (collResearchInterestCulturalAreas != null)
          {
              for (int i = 0; i < collResearchInterestCulturalAreas.size(); i++)
              {
                  ((ResearchInterestCulturalArea) collResearchInterestCulturalAreas.get(i)).save(con);
              }
          }
                                        
                
          if (collResearchInterestDisciplines != null)
          {
              for (int i = 0; i < collResearchInterestDisciplines.size(); i++)
              {
                  ((ResearchInterestDiscipline) collResearchInterestDisciplines.get(i)).save(con);
              }
          }
                  alreadyInSave = false;
      }
      }


                        
    
    

        /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param  id ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        throws TorqueException
    {
                    setId(new Integer(((NumberKey) key).intValue()));
            }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
                    setId(new Integer(key));
            }


    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
        return SimpleKey.keyFor(getId());
    }

 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     */
    public ResearchInterest copy() throws TorqueException
    {
        return copyInto(new ResearchInterest());
    }

    protected ResearchInterest copyInto(ResearchInterest copyObj) throws TorqueException
    {
        copyObj.setId(id);
        copyObj.setInterests(interests);
        copyObj.setActivities(activities);
        copyObj.setCollaborationInterests(collaboration_interests);
        copyObj.setFocusFrom(focus_from);
        copyObj.setFocusTo(focus_to);

  copyObj.setNew(false);
                                    
                
        List v = getMembers();
        for (int i = 0; i < v.size(); i++)
        {
            Member obj = (Member) v.get(i);
            copyObj.addMember(obj.copy());
            ((Persistent) v.get(i)).setNew(true);
        }
                                              
                
        v = getResearchInterestLanguages();
        for (int i = 0; i < v.size(); i++)
        {
            ResearchInterestLanguage obj = (ResearchInterestLanguage) v.get(i);
            copyObj.addResearchInterestLanguage(obj.copy());
            ((Persistent) v.get(i)).setNew(true);
        }
                                              
                
        v = getResearchInterestCulturalAreas();
        for (int i = 0; i < v.size(); i++)
        {
            ResearchInterestCulturalArea obj = (ResearchInterestCulturalArea) v.get(i);
            copyObj.addResearchInterestCulturalArea(obj.copy());
            ((Persistent) v.get(i)).setNew(true);
        }
                                              
                
        v = getResearchInterestDisciplines();
        for (int i = 0; i < v.size(); i++)
        {
            ResearchInterestDiscipline obj = (ResearchInterestDiscipline) v.get(i);
            copyObj.addResearchInterestDiscipline(obj.copy());
            ((Persistent) v.get(i)).setNew(true);
        }
                copyObj.setNew(true);

                      copyObj.setId((Integer)null);
                                        return copyObj;
    }

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public ResearchInterestPeer getPeer()
    {
        return peer;
    }
}
