head	1.1;
access;
symbols
	HELM_PEER_PORT_BRANCH:1.1.0.2;
locks; strict;
comment	@# @;


1.1
date	2001.02.09.23.30.14;	author dlr;	state dead;
branches
	1.1.2.1;
next	;

1.1.2.1
date	2001.02.09.23.30.14;	author dlr;	state Exp;
branches;
next	1.1.2.2;

1.1.2.2
date	2001.02.13.00.55.53;	author dlr;	state Exp;
branches;
next	1.1.2.3;

1.1.2.3
date	2001.02.13.03.03.05;	author dlr;	state Exp;
branches;
next	1.1.2.4;

1.1.2.4
date	2001.02.16.03.04.58;	author dlr;	state dead;
branches;
next	;


desc
@@


1.1
log
@file BaseNewsItemPeer.java was initially added on branch HELM_PEER_PORT_BRANCH.
@
text
@@


1.1.2.1
log
@Newly generated for elicia.
@
text
@a0 769
package org.tigris.helm.om.peer;

// JDK classes
import java.util.*;
import java.math.*;

// Village classes
import com.workingdogs.village.*;

// Turbine classes
import org.apache.turbine.om.peer.*;
import org.apache.turbine.util.*;
import org.apache.turbine.util.db.*;
import org.apache.turbine.util.db.map.*;
import org.apache.turbine.util.db.pool.DBConnection;

import org.tigris.helm.om.NewsItem;

// Local classes
import org.tigris.helm.om.map.*;
import org.tigris.helm.om.*;

/**
  * This class was autogenerated by Torque on:
  *
  * [Fri Feb 09 15:29:27 PST 2001]
  *
  */
public abstract class BaseNewsItemPeer extends BasePeer
{
    /** the mapbuilder for this class */
    private static final NewsItemMapBuilder mapBuilder = 
        (NewsItemMapBuilder)getMapBuilder(NewsItemMapBuilder.CLASS_NAME);

    /** the table name for this class */
    public static final String TABLE_NAME = mapBuilder.getTable();

    /** the column name for the NEWS_ID field */
    public static final String NEWS_ID = mapBuilder.getNewsItem_NewsId();
    /** the column name for the PROJECT_ID field */
    public static final String PROJECT_ID = mapBuilder.getNewsItem_ProjectId();
    /** the column name for the EVENT_DATE field */
    public static final String EVENT_DATE = mapBuilder.getNewsItem_EventDate();
    /** the column name for the HEADLINE field */
    public static final String HEADLINE = mapBuilder.getNewsItem_Headline();
    /** the column name for the BODY field */
    public static final String BODY = mapBuilder.getNewsItem_Body();
    /** the column name for the PROPOSED_BY field */
    public static final String PROPOSED_BY = mapBuilder.getNewsItem_ProposedBy();
    /** the column name for the APPROVED_BY field */
    public static final String APPROVED_BY = mapBuilder.getNewsItem_ApprovedBy();
    /** the column name for the PUBLISH_ON field */
    public static final String PUBLISH_ON = mapBuilder.getNewsItem_PublishOn();
    /** the column name for the REMOVE_ON field */
    public static final String REMOVE_ON = mapBuilder.getNewsItem_RemoveOn();
    /** the column name for the PRIORITY field */
    public static final String PRIORITY = mapBuilder.getNewsItem_Priority();

    /** number of columns for this peer */
    public static final int numColumns =  10;;

    /** Method to do inserts */
    public static Object doInsert( Criteria criteria ) throws Exception
    {
        criteria.setDbName(mapBuilder.getDatabaseMap().getName());
                                                                                                                                                         return BasePeer.doInsert( criteria );
    }

    /** 
     * Method to do inserts.  This method is to be used during a transaction,
     * otherwise use the doInsert(Criteria) method.  It will take care of 
     * the connection details internally. 
     */
    public static Object doInsert( Criteria criteria, DBConnection dbCon ) throws Exception
    {
        criteria.setDbName(mapBuilder.getDatabaseMap().getName());
                                                                                                                                                         return BasePeer.doInsert( criteria, dbCon );
    }

    /** Add all the columns needed to create a new object */
    public static void addSelectColumns (Criteria criteria) throws Exception
    {
            criteria.addSelectColumn( NEWS_ID );
            criteria.addSelectColumn( PROJECT_ID );
            criteria.addSelectColumn( EVENT_DATE );
            criteria.addSelectColumn( HEADLINE );
            criteria.addSelectColumn( BODY );
            criteria.addSelectColumn( PROPOSED_BY );
            criteria.addSelectColumn( APPROVED_BY );
            criteria.addSelectColumn( PUBLISH_ON );
            criteria.addSelectColumn( REMOVE_ON );
            criteria.addSelectColumn( PRIORITY );
        }


    /** Create a new object of type cls from a resultset row starting
      * from a specified offset.  This is done so that you can select
      * other rows than just those needed for this object.  You may
      * for example want to create two objects from the same row.
      */
    public static NewsItem row2Object (Record row, int offset, Class cls ) throws Exception
    {
        NewsItem obj = (NewsItem)cls.newInstance();
                                        obj.setNewsId(row.getValue(offset+0).asInt());
                                            obj.setProjectId(row.getValue(offset+1).asInt());
                                            obj.setEventDate(row.getValue(offset+2).asDate());
                                            obj.setHeadline(row.getValue(offset+3).asString());
                                            obj.setBody(row.getValue(offset+4).asString());
                                            obj.setProposedBy(row.getValue(offset+5).asInt());
                                            obj.setApprovedBy(row.getValue(offset+6).asInt());
                                            obj.setPublishOn(row.getValue(offset+7).asDate());
                                            obj.setRemoveOn(row.getValue(offset+8).asDate());
                                            obj.setPriority(row.getValue(offset+9).asInt());
                                        obj.setModified(false);
                obj.setNew(false);
        return obj;
    }

    /** Method to do selects */
    public static Vector doSelect( Criteria criteria ) throws Exception
    {
        criteria.setDbName(mapBuilder.getDatabaseMap().getName());
        return doSelect (criteria,"org.tigris.helm.om.NewsItem", null);
    }

    /** 
     * Method to do selects.  This method is to be used during a transaction,
     * otherwise use the doSelect(Criteria) method.  It will take care of 
     * the connection details internally. 
     */
    public static Vector doSelect( Criteria criteria, DBConnection dbCon ) throws Exception
    {
        criteria.setDbName(mapBuilder.getDatabaseMap().getName());
        return doSelect (criteria,"org.tigris.helm.om.NewsItem", dbCon);
    }

    /** Method to do selects. The returned vector will have object
      * of className
      */
    public static Vector doSelect( Criteria criteria, String className, DBConnection dbCon) throws Exception
    {
        addSelectColumns ( criteria );

                                                                                                                                                 
        // BasePeer returns a Vector of Value (Village) arrays.  The array
        // order follows the order columns were placed in the Select clause.
        Vector rows = null;
        if (dbCon == null)
        {
            rows = BasePeer.doSelect(criteria);
        }
        else
        {
            rows = BasePeer.doSelect(criteria, dbCon);
        }
        Vector results = new Vector();

        // populate the object(s)
        for ( int i=0; i<rows.size(); i++ )
        {
            Record row = (Record)rows.elementAt(i);
            results.add (row2Object (row,1,Class.forName (className)));
         }
         return results;
    }

    /**
     * Method to do updates. 
     *
     * @@param Criteria object containing data that is used to create the UPDATE statement.
     */
    public static void doUpdate(Criteria criteria) throws Exception
    {
        criteria.setDbName(mapBuilder.getDatabaseMap().getName());
        Criteria selectCriteria = new
            Criteria(mapBuilder.getDatabaseMap().getName(), 2);
                                selectCriteria.put( NEWS_ID, criteria.remove(NEWS_ID) );
                                                                                                                                                                                                                                      BasePeer.doUpdate( selectCriteria, criteria );
    }

    /** 
     * Method to do updates.  This method is to be used during a transaction,
     * otherwise use the doUpdate(Criteria) method.  It will take care of 
     * the connection details internally. 
     *
     * @@param Criteria object containing data that is used to create the UPDATE statement.
     */
    public static void doUpdate(Criteria criteria, DBConnection dbCon) throws Exception
    {
        criteria.setDbName(mapBuilder.getDatabaseMap().getName());
        Criteria selectCriteria = new
            Criteria(mapBuilder.getDatabaseMap().getName(), 2);
                                selectCriteria.put( NEWS_ID, criteria.remove(NEWS_ID) );
                                                                                                                                                                                                                                      BasePeer.doUpdate( selectCriteria, criteria, dbCon );
     }

    /** 
     * Method to do deletes.
     *
     * @@param Criteria object containing data that is used DELETE from database.
     */
     public static void doDelete(Criteria criteria) throws Exception
     {
         criteria.setDbName(mapBuilder.getDatabaseMap().getName());
                                                                                                                                                          BasePeer.doDelete ( criteria );
     }

    /** 
     * Method to do deletes.  This method is to be used during a transaction,
     * otherwise use the doInsert(Criteria) method.  It will take care of 
     * the connection details internally. 
     *
     * @@param Criteria object containing data that is used DELETE from database.
     */
     public static void doDelete(Criteria criteria, DBConnection dbCon) throws Exception
     {
         criteria.setDbName(mapBuilder.getDatabaseMap().getName());
                                                                                                                                                          BasePeer.doDelete ( criteria, dbCon );
     }

    /** Method to do inserts */
    public static void doInsert( NewsItem obj ) throws Exception
    {
                obj.setPrimaryKey(doInsert(buildCriteria(obj)));
                obj.setNew(false);
    }

    /**
     * @@param obj the data object to update in the database.
     */
    public static void doUpdate(NewsItem obj) throws Exception
    {
        doUpdate(buildCriteria(obj));
    }
    /**
     * @@param obj the data object to delete in the database.
     */
    public static void doDelete(NewsItem obj) throws Exception
    {
        doDelete(buildCriteria(obj));
    }

    /** 
     * Method to do inserts.  This method is to be used during a transaction,
     * otherwise use the doInsert(NewsItem) method.  It will take 
     * care of the connection details internally. 
     *
     * @@param obj the data object to insert into the database.
     */
    public static void doInsert( NewsItem obj, DBConnection dbCon) throws Exception
    {
                obj.setPrimaryKey(doInsert(buildCriteria(obj), dbCon));
                obj.setNew(false);
    }

    /**
     * Method to do update.  This method is to be used during a transaction,
     * otherwise use the doUpdate(NewsItem) method.  It will take 
     * care of the connection details internally. 
     *
     * @@param obj the data object to update in the database.
     */
    public static void doUpdate(NewsItem obj, DBConnection dbCon) throws Exception
    {
        doUpdate(buildCriteria(obj), dbCon);
    }
    /**
     * Method to delete.  This method is to be used during a transaction,
     * otherwise use the doDelete(NewsItem) method.  It will take 
     * care of the connection details internally. 
     *
     * @@param obj the data object to delete in the database.
     */
    public static void doDelete(NewsItem obj, DBConnection dbCon) throws Exception
    {
        doDelete(buildCriteria(obj), dbCon);
    }

    /** Build a Criteria object from the data object for this peer */
    public static Criteria buildCriteria( NewsItem obj )
    {
        Criteria criteria = new Criteria();
                            if ( !obj.isNew() )
	                criteria.add( NEWS_ID, obj.getNewsId() );
                                criteria.add( PROJECT_ID, obj.getProjectId() );
                                criteria.add( EVENT_DATE, obj.getEventDate() );
                                criteria.add( HEADLINE, obj.getHeadline() );
                                criteria.add( BODY, obj.getBody() );
                                criteria.add( PROPOSED_BY, obj.getProposedBy() );
                                criteria.add( APPROVED_BY, obj.getApprovedBy() );
                                criteria.add( PUBLISH_ON, obj.getPublishOn() );
                                criteria.add( REMOVE_ON, obj.getRemoveOn() );
                                criteria.add( PRIORITY, obj.getPriority() );
                return criteria;
    }

    /** 
     * Retrieve a single object by pk where multiple PK's are separated
     * by colons
     *
     * @@param int news_id
     */
    public static NewsItem retrieveById(Object pkid) 
        throws Exception
    {
        StringTokenizer stok = new StringTokenizer((String)pkid, ":");
        if ( stok.countTokens() < 1 )
        {   
            throw new TurbineException(
                "id tokens did not match number of primary keys" );
        }
           int news_id = Integer.parseInt(stok.nextToken());;

       return retrieveByPK(
             news_id
              );
    }

    /** 
     * Retrieve a single object by pk
     *
     * @@param int news_id
     */
    public static NewsItem retrieveByPK(
                      int news_id
                                                                                                                                         ) throws Exception
    {
        Criteria criteria = new Criteria();
                       if( news_id > 0 )
                  criteria.add( NewsItemPeer.NEWS_ID, news_id );
                                                                                                  Vector NewsItemVector = doSelect(criteria);
        if (NewsItemVector.size() != 1)
        {
            throw new Exception("Failed to select one and only one row.");
        }
        else
        {
            return (NewsItem) NewsItemVector.firstElement();
        }
    }


       
        
                       
     
          


   /**
    * selects a collection of NewsItem objects pre-filled with their
    * Project objects.
    */
    public static Vector doSelectJoinProject(Criteria c)
        throws Exception
    {
         c.setDbName(mapBuilder.getDatabaseMap().getName());

        addSelectColumns(c);
        int offset = numColumns + 1;
        ProjectPeer.addSelectColumns(c);

                                                                                                                                                         
        Vector rows = BasePeer.doSelect(c);
        Vector results = new Vector();

        for (int i=0; i<rows.size(); i++)
        {
            NewsItem obj1 = 
                row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            1, Class.forName("org.tigris.helm.om.NewsItem") );
            Project obj2 = ProjectPeer
                .row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            offset, Class.forName("org.tigris.helm.om.Project") );
            
            boolean newObject = true;
            for (int j=0; j<results.size(); j++)
            {
                NewsItem temp_obj1 = (NewsItem)results.elementAt(j);
                Project temp_obj2 = temp_obj1.getProject();
                if ( temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey() ) )
                {
                    newObject = false;
                    temp_obj2.addNewsItems(obj1);
                    break;
                }
            }
            if (newObject)
            {
                obj2.initNewsItems();
                obj2.addNewsItems(obj1);
            }
            results.add(obj1);

        }

        return results;
    }
         
                               
     
          


   /**
    * selects a collection of NewsItem objects pre-filled with their
    * User objects.
    */
    public static Vector doSelectJoinUserRelatedByProposedBy(Criteria c)
        throws Exception
    {
         c.setDbName(mapBuilder.getDatabaseMap().getName());

        addSelectColumns(c);
        int offset = numColumns + 1;
        UserPeer.addSelectColumns(c);

                                                                                                                                                         
        Vector rows = BasePeer.doSelect(c);
        Vector results = new Vector();

        for (int i=0; i<rows.size(); i++)
        {
            NewsItem obj1 = 
                row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            1, Class.forName("org.tigris.helm.om.NewsItem") );
            User obj2 = UserPeer
                .row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            offset, Class.forName("org.tigris.helm.om.User") );
            
            boolean newObject = true;
            for (int j=0; j<results.size(); j++)
            {
                NewsItem temp_obj1 = (NewsItem)results.elementAt(j);
                User temp_obj2 = temp_obj1.getUserRelatedByProposedBy();
                if ( temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey() ) )
                {
                    newObject = false;
                    temp_obj2.addNewsItemsRelatedByProposedBy(obj1);
                    break;
                }
            }
            if (newObject)
            {
                obj2.initNewsItemsRelatedByProposedBy();
                obj2.addNewsItemsRelatedByProposedBy(obj1);
            }
            results.add(obj1);

        }

        return results;
    }
         
                               
     
          


   /**
    * selects a collection of NewsItem objects pre-filled with their
    * User objects.
    */
    public static Vector doSelectJoinUserRelatedByApprovedBy(Criteria c)
        throws Exception
    {
         c.setDbName(mapBuilder.getDatabaseMap().getName());

        addSelectColumns(c);
        int offset = numColumns + 1;
        UserPeer.addSelectColumns(c);

                                                                                                                                                         
        Vector rows = BasePeer.doSelect(c);
        Vector results = new Vector();

        for (int i=0; i<rows.size(); i++)
        {
            NewsItem obj1 = 
                row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            1, Class.forName("org.tigris.helm.om.NewsItem") );
            User obj2 = UserPeer
                .row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            offset, Class.forName("org.tigris.helm.om.User") );
            
            boolean newObject = true;
            for (int j=0; j<results.size(); j++)
            {
                NewsItem temp_obj1 = (NewsItem)results.elementAt(j);
                User temp_obj2 = temp_obj1.getUserRelatedByApprovedBy();
                if ( temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey() ) )
                {
                    newObject = false;
                    temp_obj2.addNewsItemsRelatedByApprovedBy(obj1);
                    break;
                }
            }
            if (newObject)
            {
                obj2.initNewsItemsRelatedByApprovedBy();
                obj2.addNewsItemsRelatedByApprovedBy(obj1);
            }
            results.add(obj1);

        }

        return results;
    }
    

  
  
     
                       
          


   /**
    * selects a collection of NewsItem objects pre-filled with 
    * all related objects.
    */
    public static Vector doSelectJoinAllExceptProject(Criteria c) 
        throws Exception
    {
         c.setDbName(mapBuilder.getDatabaseMap().getName());

        addSelectColumns(c);
        int offset2 = numColumns + 1;
                    
                                      
                UserPeer.addSelectColumns(c);
        int offset3 = offset2 + UserPeer.numColumns;
                                          
                UserPeer.addSelectColumns(c);
        int offset4 = offset3 + UserPeer.numColumns;
                                                                                                                                                                               
        Vector rows = BasePeer.doSelect(c);
        Vector results = new Vector();

        for (int i=0; i<rows.size(); i++)
        {
            NewsItem obj1 = 
                row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            1, Class.forName("org.tigris.helm.om.NewsItem") );
                    
                                  
                                                                
                        
                        User obj2 = UserPeer
                .row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            offset2, Class.forName("org.tigris.helm.om.User") );

            
             boolean  newObject = true;
            for (int j=0; j<results.size(); j++)
            {
                NewsItem temp_obj1 = (NewsItem)results.elementAt(j);
                User temp_obj2 = temp_obj1.getUserRelatedByProposedBy();
                if ( temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey() ) )
                {
                    newObject = false;
                    temp_obj2.addNewsItemsRelatedByProposedBy(obj1);
                    break;
                }
            }
            if (newObject)
            {
                obj2.initNewsItemsRelatedByProposedBy();
                obj2.addNewsItemsRelatedByProposedBy(obj1);
            }
                        
                                                                
                        
                        User obj3 = UserPeer
                .row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            offset3, Class.forName("org.tigris.helm.om.User") );

            
             newObject = true;
            for (int j=0; j<results.size(); j++)
            {
                NewsItem temp_obj1 = (NewsItem)results.elementAt(j);
                User temp_obj3 = temp_obj1.getUserRelatedByApprovedBy();
                if ( temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey() ) )
                {
                    newObject = false;
                    temp_obj3.addNewsItemsRelatedByApprovedBy(obj1);
                    break;
                }
            }
            if (newObject)
            {
                obj3.initNewsItemsRelatedByApprovedBy();
                obj3.addNewsItemsRelatedByApprovedBy(obj1);
            }
                        results.add(obj1);

        }

        return results;
    }
 
     
                               
          


   /**
    * selects a collection of NewsItem objects pre-filled with 
    * all related objects.
    */
    public static Vector doSelectJoinAllExceptUserRelatedByProposedBy(Criteria c) 
        throws Exception
    {
         c.setDbName(mapBuilder.getDatabaseMap().getName());

        addSelectColumns(c);
        int offset2 = numColumns + 1;
                    
                ProjectPeer.addSelectColumns(c);
        int offset3 = offset2 + ProjectPeer.numColumns;
                                          
                                      
                                                                                                                                                                           
        Vector rows = BasePeer.doSelect(c);
        Vector results = new Vector();

        for (int i=0; i<rows.size(); i++)
        {
            NewsItem obj1 = 
                row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            1, Class.forName("org.tigris.helm.om.NewsItem") );
                    
                                                
                        
                        Project obj2 = ProjectPeer
                .row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            offset2, Class.forName("org.tigris.helm.om.Project") );

            
             boolean  newObject = true;
            for (int j=0; j<results.size(); j++)
            {
                NewsItem temp_obj1 = (NewsItem)results.elementAt(j);
                Project temp_obj2 = temp_obj1.getProject();
                if ( temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey() ) )
                {
                    newObject = false;
                    temp_obj2.addNewsItems(obj1);
                    break;
                }
            }
            if (newObject)
            {
                obj2.initNewsItems();
                obj2.addNewsItems(obj1);
            }
                        
                                  
                                  results.add(obj1);

        }

        return results;
    }
 
     
                               
          


   /**
    * selects a collection of NewsItem objects pre-filled with 
    * all related objects.
    */
    public static Vector doSelectJoinAllExceptUserRelatedByApprovedBy(Criteria c) 
        throws Exception
    {
         c.setDbName(mapBuilder.getDatabaseMap().getName());

        addSelectColumns(c);
        int offset2 = numColumns + 1;
                    
                ProjectPeer.addSelectColumns(c);
        int offset3 = offset2 + ProjectPeer.numColumns;
                                          
                                      
                                                                                                                                                                           
        Vector rows = BasePeer.doSelect(c);
        Vector results = new Vector();

        for (int i=0; i<rows.size(); i++)
        {
            NewsItem obj1 = 
                row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            1, Class.forName("org.tigris.helm.om.NewsItem") );
                    
                                                
                        
                        Project obj2 = ProjectPeer
                .row2Object((com.workingdogs.village.Record)rows.elementAt(i),
                            offset2, Class.forName("org.tigris.helm.om.Project") );

            
             boolean  newObject = true;
            for (int j=0; j<results.size(); j++)
            {
                NewsItem temp_obj1 = (NewsItem)results.elementAt(j);
                Project temp_obj2 = temp_obj1.getProject();
                if ( temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey() ) )
                {
                    newObject = false;
                    temp_obj2.addNewsItems(obj1);
                    break;
                }
            }
            if (newObject)
            {
                obj2.initNewsItems();
                obj2.addNewsItems(obj1);
            }
                        
                                  
                                  results.add(obj1);

        }

        return results;
    }
  


    
    /** 
     * Retrieve objects by fk
     *
     * @@param int project_id
     */
//    public static Vector retrieveByProjectId(int project_id)
//    {
        
          
    /** 
     * Retrieve objects by fk
     *
     * @@param int proposed_by
     */
//    public static Vector retrieveByProposedBy(int proposed_by)
//    {
        
    
    /** 
     * Retrieve objects by fk
     *
     * @@param int approved_by
     */
//    public static Vector retrieveByApprovedBy(int approved_by)
//    {
        
        
}








@


1.1.2.2
log
@New Torque-generated classes.
@
text
@d26 1
a26 1
  * [Mon Feb 12 16:46:43 PST 2001]
d52 4
a55 4
    /** the column name for the PUBLISH_DATE field */
    public static final String PUBLISH_DATE = mapBuilder.getNewsItem_PublishDate();
    /** the column name for the REMOVE_DATE field */
    public static final String REMOVE_DATE = mapBuilder.getNewsItem_RemoveDate();
d60 1
a60 6
    public static final int numColumns =  10;

    /** A class that can be returned by this peer. */
    protected static final String CLASSNAME_DEFAULT = 
        "org.tigris.helm.om.NewsItem";

d90 2
a91 2
            criteria.addSelectColumn( PUBLISH_DATE );
            criteria.addSelectColumn( REMOVE_DATE );
d96 19
a114 24
    /** 
     * Create a new object of type cls from a resultset row starting
     * from a specified offset.  This is done so that you can select
     * other rows than just those needed for this object.  You may
     * for example want to create two objects from the same row.
     */
    public static NewsItem row2Object (Record row, 
                                              int offset, 
                                              String cls ) 
        throws Exception
    {
        NewsItem obj = 
            (NewsItem)Class.forName(cls).newInstance();
                                                        obj.setNewsId(row.getValue(offset+0).asInt());
                                                                            obj.setProjectId(row.getValue(offset+1).asInt());
                                                                            obj.setEventDate(row.getValue(offset+2).asDate());
                                                                            obj.setHeadline(row.getValue(offset+3).asString());
                                                                            obj.setBody(row.getValue(offset+4).asString());
                                                                            obj.setProposedBy(row.getValue(offset+5).asInt());
                                                                            obj.setApprovedBy(row.getValue(offset+6).asInt());
                                                                            obj.setPublishDate(row.getValue(offset+7).asDate());
                                                                            obj.setRemoveDate(row.getValue(offset+8).asDate());
                                                                            obj.setPriority(row.getValue(offset+9).asInt());
                                                        obj.setModified(false);
d122 2
a123 10
        return populateObjects( doSelectVillageRecords(criteria) ); 
    }


    /** Method to do selects within a transaction */
    public static Vector doSelect( Criteria criteria, 
                                   DBConnection dbCon ) 
        throws Exception
    {
        return populateObjects( doSelectVillageRecords(criteria, dbCon) ); 
d127 3
a129 2
     * Grabs the raw Village records to be formed into objects.
     * This method handles connections internally 
d131 1
a131 2
    public static Vector doSelectVillageRecords( Criteria criteria ) 
        throws Exception
d134 1
a134 9
        if (criteria.getSelectColumns().size() == 0)
        {
            addSelectColumns ( criteria );
        }

                                                                                                                                                 
        // BasePeer returns a Vector of Value (Village) arrays.  The array
        // order follows the order columns were placed in the Select clause.
        return BasePeer.doSelect(criteria);
d137 4
a140 8

    /** 
     * Grabs the raw Village records to be formed into objects.
     * This method should be used for transactions 
     */
    public static Vector doSelectVillageRecords( Criteria criteria, 
                                                 DBConnection dbCon ) 
        throws Exception
d147 10
a156 11
        return BasePeer.doSelect(criteria, dbCon);
    }

    /** 
     * The returned vector will contain objects of the default type or
     * objects that inherit from the default.
     */
    private static Vector populateObjects(Vector records) 
        throws Exception
    {
        Vector results = new Vector(records.size());
d159 1
a159 1
        for ( int i=0; i<records.size(); i++ )
d161 4
a164 5
            Record row = (Record)records.elementAt(i);

            results.add(row2Object( row,1, CLASSNAME_DEFAULT ));
        }
        return results;
d291 2
a292 2
                                criteria.add( PUBLISH_DATE, obj.getPublishDate() );
                                criteria.add( REMOVE_DATE, obj.getRemoveDate() );
d369 3
a371 28
            Record row = (Record)rows.elementAt(i);

            NewsItem obj1 = row2Object( row,1, CLASSNAME_DEFAULT );


                        String className = null;
                                String classKey = row.getValue(ProjectPeer.TYPE)
                .asString();
                                        if (ProjectPeer.CLASSKEY_GROUP.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_GROUP;
            }
                                            else if (ProjectPeer.CLASSKEY_CATEGORY.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_CATEGORY;
            }
                                            else if (ProjectPeer.CLASSKEY_DOMAIN.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_DOMAIN;
            }
                                            else if (ProjectPeer.CLASSKEY_HOST.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_HOST;
            }
                                else
            {
                className = CLASSNAME_DEFAULT;
            }
d373 3
a375 2
                .row2Object(row, offset, className);
                
d424 3
a426 24
            Record row = (Record)rows.elementAt(i);

            NewsItem obj1 = row2Object( row,1, CLASSNAME_DEFAULT );


                        String className = null;
                                String classKey = row.getValue(UserPeer.TYPE)
                .asString();
                                        if (UserPeer.CLASSKEY_GROUP.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_GROUP;
            }
                                            else if (UserPeer.CLASSKEY_DOMAIN.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_DOMAIN;
            }
                                            else if (UserPeer.CLASSKEY_HOST.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_HOST;
            }
                                else
            {
                className = CLASSNAME_DEFAULT;
            }
d428 3
a430 2
                .row2Object(row, offset, className);
                
d479 3
a481 24
            Record row = (Record)rows.elementAt(i);

            NewsItem obj1 = row2Object( row,1, CLASSNAME_DEFAULT );


                        String className = null;
                                String classKey = row.getValue(UserPeer.TYPE)
                .asString();
                                        if (UserPeer.CLASSKEY_GROUP.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_GROUP;
            }
                                            else if (UserPeer.CLASSKEY_DOMAIN.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_DOMAIN;
            }
                                            else if (UserPeer.CLASSKEY_HOST.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_HOST;
            }
                                else
            {
                className = CLASSNAME_DEFAULT;
            }
d483 3
a485 2
                .row2Object(row, offset, className);
                
d542 3
a544 4
            Record row = (Record)rows.elementAt(i);

                NewsItem obj1 = row2Object( row,1, CLASSNAME_DEFAULT );
  
d549 4
a553 23

                        String className = null;
                                String classKey = row.getValue(UserPeer.TYPE)
                .asString();
                                        if (UserPeer.CLASSKEY_GROUP.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_GROUP;
            }
                                            else if (UserPeer.CLASSKEY_DOMAIN.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_DOMAIN;
            }
                                            else if (UserPeer.CLASSKEY_HOST.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_HOST;
            }
                                else
            {
                className = CLASSNAME_DEFAULT;
            }
            User obj2 = UserPeer
                .row2Object(row, offset2, className);
                
d574 4
a578 22

                                 classKey = row.getValue(UserPeer.TYPE)
                .asString();
                                        if (UserPeer.CLASSKEY_GROUP.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_GROUP;
            }
                                            else if (UserPeer.CLASSKEY_DOMAIN.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_DOMAIN;
            }
                                            else if (UserPeer.CLASSKEY_HOST.equals(classKey))
                        {
                className = UserPeer.CLASSNAME_HOST;
            }
                                else
            {
                className = CLASSNAME_DEFAULT;
            }
            User obj3 = UserPeer
                .row2Object(row, offset3, className);
                
d630 3
a632 4
            Record row = (Record)rows.elementAt(i);

                NewsItem obj1 = row2Object( row,1, CLASSNAME_DEFAULT );
  
d636 4
a640 27

                        String className = null;
                                String classKey = row.getValue(ProjectPeer.TYPE)
                .asString();
                                        if (ProjectPeer.CLASSKEY_GROUP.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_GROUP;
            }
                                            else if (ProjectPeer.CLASSKEY_CATEGORY.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_CATEGORY;
            }
                                            else if (ProjectPeer.CLASSKEY_DOMAIN.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_DOMAIN;
            }
                                            else if (ProjectPeer.CLASSKEY_HOST.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_HOST;
            }
                                else
            {
                className = CLASSNAME_DEFAULT;
            }
            Project obj2 = ProjectPeer
                .row2Object(row, offset2, className);
                
d694 3
a696 4
            Record row = (Record)rows.elementAt(i);

                NewsItem obj1 = row2Object( row,1, CLASSNAME_DEFAULT );
  
d700 4
a704 27

                        String className = null;
                                String classKey = row.getValue(ProjectPeer.TYPE)
                .asString();
                                        if (ProjectPeer.CLASSKEY_GROUP.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_GROUP;
            }
                                            else if (ProjectPeer.CLASSKEY_CATEGORY.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_CATEGORY;
            }
                                            else if (ProjectPeer.CLASSKEY_DOMAIN.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_DOMAIN;
            }
                                            else if (ProjectPeer.CLASSKEY_HOST.equals(classKey))
                        {
                className = ProjectPeer.CLASSNAME_HOST;
            }
                                else
            {
                className = CLASSNAME_DEFAULT;
            }
            Project obj2 = ProjectPeer
                .row2Object(row, offset2, className);
                
d733 28
a760 2


@


1.1.2.3
log
@Latest Torque-generated code to handle inheritance based on values in a database field column.
@
text
@d26 1
a26 1
  * [Mon Feb 12 19:03:25 PST 2001]
d114 11
a124 11
                                            obj.setNewsId(row.getValue(offset+0).asInt());
                                                    obj.setProjectId(row.getValue(offset+1).asInt());
                                                    obj.setEventDate(row.getValue(offset+2).asDate());
                                                    obj.setHeadline(row.getValue(offset+3).asString());
                                                    obj.setBody(row.getValue(offset+4).asString());
                                                    obj.setProposedBy(row.getValue(offset+5).asInt());
                                                    obj.setApprovedBy(row.getValue(offset+6).asInt());
                                                    obj.setPublishDate(row.getValue(offset+7).asDate());
                                                    obj.setRemoveDate(row.getValue(offset+8).asDate());
                                                    obj.setPriority(row.getValue(offset+9).asInt());
                                            obj.setModified(false);
a125 1

d242 1
a242 1
     * otherwise use the doDelete(Criteria) method.  It will take care of 
d316 1
a316 1
    	                criteria.add( NEWS_ID, obj.getNewsId() );
@


1.1.2.4
log
@Deprecated by Torque modificaitons.
@
text
@@


