Code Search for Developers
 
 
  

BaseSeat.java from iTicket at Krugle


Show BaseSeat.java syntax highlighted

package ch.iticket.db;


import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.torque.TorqueException;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;



                      

/**
 * This class was autogenerated by Torque on:
 *
 * [Sat Jun 03 21:14:21 CEST 2006]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Seat
 */
public abstract class BaseSeat extends BaseObject
{
    /** The Peer class */
    private static final SeatPeer peer =
        new SeatPeer();

        
    /** The value for the nr field */
    private long nr;
      
    /** The value for the categoryNr field */
    private long categoryNr;
      
    /** The value for the aircraftDescriptionNr field */
    private long aircraftDescriptionNr;
  
            
    /**
     * Get the Nr
     *
     * @return long
     */
    public long getNr()
    {
        return nr;
    }

                                              
    /**
     * Set the value of Nr
     *
     * @param v new value
     */
    public void setNr(long v) throws TorqueException
    {
    
                  if (this.nr != v)
              {
            this.nr = v;
            setModified(true);
        }
    
          
                                  
                  // update associated Boarding
        if (collBoardings != null)
        {
            for (int i = 0; i < collBoardings.size(); i++)
            {
                ((Boarding) collBoardings.get(i))
                    .setSeatNr(v);
            }
        }
                                }
          
    /**
     * Get the CategoryNr
     *
     * @return long
     */
    public long getCategoryNr()
    {
        return categoryNr;
    }

                              
    /**
     * Set the value of CategoryNr
     *
     * @param v new value
     */
    public void setCategoryNr(long v) throws TorqueException
    {
    
                  if (this.categoryNr != v)
              {
            this.categoryNr = v;
            setModified(true);
        }
    
                                  
                if (aCategory != null && !(aCategory.getNr() == v))
                {
            aCategory = null;
        }
      
              }
          
    /**
     * Get the AircraftDescriptionNr
     *
     * @return long
     */
    public long getAircraftDescriptionNr()
    {
        return aircraftDescriptionNr;
    }

                              
    /**
     * Set the value of AircraftDescriptionNr
     *
     * @param v new value
     */
    public void setAircraftDescriptionNr(long v) throws TorqueException
    {
    
                  if (this.aircraftDescriptionNr != v)
              {
            this.aircraftDescriptionNr = v;
            setModified(true);
        }
    
                                  
                if (aAircraftdescription != null && !(aAircraftdescription.getNr() == v))
                {
            aAircraftdescription = null;
        }
      
              }
  
      
        
                  
    
        private Aircraftdescription aAircraftdescription;

    /**
     * Declares an association between this object and a Aircraftdescription object
     *
     * @param v Aircraftdescription
     * @throws TorqueException
     */
    public void setAircraftdescription(Aircraftdescription v) throws TorqueException
    {
            if (v == null)
        {
                          setAircraftDescriptionNr( 0);
              }
        else
        {
            setAircraftDescriptionNr(v.getNr());
        }
            aAircraftdescription = v;
    }

                        
    /**
     * Returns the associated Aircraftdescription object.
           * If it was not retrieved before, the object is retrieved from
     * the database
           *
     * @return the associated Aircraftdescription object
           * @throws TorqueException
           */
    public Aircraftdescription getAircraftdescription()
              throws TorqueException
          {
              if (aAircraftdescription == null && (this.aircraftDescriptionNr != 0))
        {
                              aAircraftdescription = AircraftdescriptionPeer.retrieveByPK(SimpleKey.keyFor(this.aircraftDescriptionNr));
                  
            /* The following can be used instead of the line above to
               guarantee the related object contains a reference
               to this object, but this level of coupling
               may be undesirable in many circumstances.
               As it can lead to a db query with many results that may
               never be used.
               Aircraftdescription obj = AircraftdescriptionPeer.retrieveByPK(this.aircraftDescriptionNr);
               obj.add${pCollName}(this);
            */
        }
              return aAircraftdescription;
    }

    /**
     * Return the associated Aircraftdescription object
     * If it was not retrieved before, the object is retrieved from
     * the database using the passed connection
     *
     * @param connection the connection used to retrieve the associated object
     *        from the database, if it was not retrieved before
     * @return the associated Aircraftdescription object
     * @throws TorqueException
     */
    public Aircraftdescription getAircraftdescription(Connection connection)
        throws TorqueException
    {
        if (aAircraftdescription == null && (this.aircraftDescriptionNr != 0))
        {
                          aAircraftdescription = AircraftdescriptionPeer.retrieveByPK(SimpleKey.keyFor(this.aircraftDescriptionNr), connection);
              
            /* The following can be used instead of the line above to
               guarantee the related object contains a reference
               to this object, but this level of coupling
               may be undesirable in many circumstances.
               As it can lead to a db query with many results that may
               never be used.
               Aircraftdescription obj = AircraftdescriptionPeer.retrieveByPK(this.aircraftDescriptionNr, connection);
               obj.add${pCollName}(this);
            */
        }
        return aAircraftdescription;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey, for example
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
         */
    public void setAircraftdescriptionKey(ObjectKey key) throws TorqueException
    {
      
                        setAircraftDescriptionNr(((NumberKey) key).longValue());
                  }
    
        
                  
    
        private Category aCategory;

    /**
     * Declares an association between this object and a Category object
     *
     * @param v Category
     * @throws TorqueException
     */
    public void setCategory(Category v) throws TorqueException
    {
            if (v == null)
        {
                          setCategoryNr( 0);
              }
        else
        {
            setCategoryNr(v.getNr());
        }
            aCategory = v;
    }

                        
    /**
     * Returns the associated Category object.
           * If it was not retrieved before, the object is retrieved from
     * the database
           *
     * @return the associated Category object
           * @throws TorqueException
           */
    public Category getCategory()
              throws TorqueException
          {
              if (aCategory == null && (this.categoryNr != 0))
        {
                              aCategory = CategoryPeer.retrieveByPK(SimpleKey.keyFor(this.categoryNr));
                  
            /* The following can be used instead of the line above to
               guarantee the related object contains a reference
               to this object, but this level of coupling
               may be undesirable in many circumstances.
               As it can lead to a db query with many results that may
               never be used.
               Category obj = CategoryPeer.retrieveByPK(this.categoryNr);
               obj.add${pCollName}(this);
            */
        }
              return aCategory;
    }

    /**
     * Return the associated Category object
     * If it was not retrieved before, the object is retrieved from
     * the database using the passed connection
     *
     * @param connection the connection used to retrieve the associated object
     *        from the database, if it was not retrieved before
     * @return the associated Category object
     * @throws TorqueException
     */
    public Category getCategory(Connection connection)
        throws TorqueException
    {
        if (aCategory == null && (this.categoryNr != 0))
        {
                          aCategory = CategoryPeer.retrieveByPK(SimpleKey.keyFor(this.categoryNr), connection);
              
            /* The following can be used instead of the line above to
               guarantee the related object contains a reference
               to this object, but this level of coupling
               may be undesirable in many circumstances.
               As it can lead to a db query with many results that may
               never be used.
               Category obj = CategoryPeer.retrieveByPK(this.categoryNr, connection);
               obj.add${pCollName}(this);
            */
        }
        return aCategory;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey, for example
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
         */
    public void setCategoryKey(ObjectKey key) throws TorqueException
    {
      
                        setCategoryNr(((NumberKey) key).longValue());
                  }
       
                                
            
          /**
     * Collection to store aggregation of collBoardings
     */
    protected List collBoardings;

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

        
    /**
     * Method called to associate a Boarding object to this object
     * through the Boarding foreign key attribute
     *
     * @param l Boarding
     * @throws TorqueException
     */
    public void addBoarding(Boarding l) throws TorqueException
    {
        getBoardings().add(l);
        l.setSeat((Seat) this);
    }

    /**
     * The criteria used to select the current contents of collBoardings
     */
    private Criteria lastBoardingsCriteria = null;
      
    /**
                   * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getBoardings(new Criteria())
                   *
     * @return the collection of associated objects
           * @throws TorqueException
           */
    public List getBoardings()
              throws TorqueException
          {
                      if (collBoardings == null)
        {
            collBoardings = getBoardings(new Criteria(10));
        }
                return collBoardings;
          }

    /**
           * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Seat has previously
           * been saved, it will retrieve related Boardings from storage.
     * If this Seat is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getBoardings(Criteria criteria) throws TorqueException
    {
              if (collBoardings == null)
        {
            if (isNew())
            {
               collBoardings = new ArrayList();
            }
            else
            {
                        criteria.add(BoardingPeer.SEATNR, getNr() );
                        collBoardings = BoardingPeer.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(BoardingPeer.SEATNR, getNr());
                            if (!lastBoardingsCriteria.equals(criteria))
                {
                    collBoardings = BoardingPeer.doSelect(criteria);
                }
            }
        }
        lastBoardingsCriteria = criteria;

        return collBoardings;
          }

    /**
           * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getBoardings(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 getBoardings(Connection con) throws TorqueException
    {
              if (collBoardings == null)
        {
            collBoardings = getBoardings(new Criteria(10), con);
        }
        return collBoardings;
          }

    /**
           * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Seat has previously
           * been saved, it will retrieve related Boardings from storage.
     * If this Seat 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 getBoardings(Criteria criteria, Connection con)
            throws TorqueException
    {
              if (collBoardings == null)
        {
            if (isNew())
            {
               collBoardings = new ArrayList();
            }
            else
            {
                         criteria.add(BoardingPeer.SEATNR, getNr());
                         collBoardings = BoardingPeer.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(BoardingPeer.SEATNR, getNr());
                             if (!lastBoardingsCriteria.equals(criteria))
                 {
                     collBoardings = BoardingPeer.doSelect(criteria, con);
                 }
             }
         }
         lastBoardingsCriteria = criteria;

         return collBoardings;
           }

                        
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
                 * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Seat is new, it will return
                 * an empty collection; or if this Seat has previously
     * been saved, it will retrieve related Boardings from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Seat.
     */
    protected List getBoardingsJoinSeat(Criteria criteria)
        throws TorqueException
    {
                    if (collBoardings == null)
        {
            if (isNew())
            {
               collBoardings = new ArrayList();
            }
            else
            {
                              criteria.add(BoardingPeer.SEATNR, getNr());
                              collBoardings = BoardingPeer.doSelectJoinSeat(criteria);
            }
        }
        else
        {
            // 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(BoardingPeer.SEATNR, getNr());
                                    if (!lastBoardingsCriteria.equals(criteria))
            {
                collBoardings = BoardingPeer.doSelectJoinSeat(criteria);
            }
        }
        lastBoardingsCriteria = criteria;

        return collBoardings;
                }
                  
                    
                    
                                
                                                              
                                        
                    
                    
          
    /**
                 * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Seat is new, it will return
                 * an empty collection; or if this Seat has previously
     * been saved, it will retrieve related Boardings from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Seat.
     */
    protected List getBoardingsJoinBookingitem(Criteria criteria)
        throws TorqueException
    {
                    if (collBoardings == null)
        {
            if (isNew())
            {
               collBoardings = new ArrayList();
            }
            else
            {
                              criteria.add(BoardingPeer.SEATNR, getNr());
                              collBoardings = BoardingPeer.doSelectJoinBookingitem(criteria);
            }
        }
        else
        {
            // 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(BoardingPeer.SEATNR, getNr());
                                    if (!lastBoardingsCriteria.equals(criteria))
            {
                collBoardings = BoardingPeer.doSelectJoinBookingitem(criteria);
            }
        }
        lastBoardingsCriteria = criteria;

        return collBoardings;
                }
                            


          
    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("Nr");
              fieldNames.add("CategoryNr");
              fieldNames.add("AircraftDescriptionNr");
              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("Nr"))
        {
                return new Long(getNr());
            }
          if (name.equals("CategoryNr"))
        {
                return new Long(getCategoryNr());
            }
          if (name.equals("AircraftDescriptionNr"))
        {
                return new Long(getAircraftDescriptionNr());
            }
          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(SeatPeer.SEATNR))
        {
                return new Long(getNr());
            }
          if (name.equals(SeatPeer.CATEGORYNR))
        {
                return new Long(getCategoryNr());
            }
          if (name.equals(SeatPeer.AIRCRAFTDESCRIPTIONNR))
        {
                return new Long(getAircraftDescriptionNr());
            }
          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 new Long(getNr());
            }
              if (pos == 1)
        {
                return new Long(getCategoryNr());
            }
              if (pos == 2)
        {
                return new Long(getAircraftDescriptionNr());
            }
              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(SeatPeer.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())
                {
                    SeatPeer.doInsert((Seat) this, con);
                    setNew(false);
                }
                else
                {
                    SeatPeer.doUpdate((Seat) this, con);
                }
                }

                                      
                                    if (collBoardings != null)
            {
                for (int i = 0; i < collBoardings.size(); i++)
                {
                    ((Boarding) collBoardings.get(i)).save(con);
                }
            }
                                  alreadyInSave = false;
        }
      }

                        
      /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param key nr ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        throws TorqueException
    {
            setNr(((NumberKey) key).longValue());
        }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
            setNr(Long.parseLong(key));
        }

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

    /**
     * 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 Seat copy() throws TorqueException
    {
        return copyInto(new Seat());
    }
  
    protected Seat copyInto(Seat copyObj) throws TorqueException
    {
          copyObj.setNr(nr);
          copyObj.setCategoryNr(categoryNr);
          copyObj.setAircraftDescriptionNr(aircraftDescriptionNr);
  
                            copyObj.setNr( 0);
                        
                                      
                            
        List v = getBoardings();
                            if (v != null)
        {
            for (int i = 0; i < v.size(); i++)
            {
                Boarding obj = (Boarding) v.get(i);
                copyObj.addBoarding(obj.copy());
            }
        }
        else
        {
            copyObj.collBoardings = 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 SeatPeer getPeer()
    {
        return peer;
    }


    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Seat:\n");
        str.append("Nr = ")
               .append(getNr())
             .append("\n");
        str.append("CategoryNr = ")
               .append(getCategoryNr())
             .append("\n");
        str.append("AircraftDescriptionNr = ")
               .append(getAircraftDescriptionNr())
             .append("\n");
        return(str.toString());
    }
}




See more files for this project here

iTicket

iTicket is an application for booking specific flights. On a quick-check-in terminal the passenger could easily withdraw the ticket.

Project homepage: http://sourceforge.net/projects/iticket
Programming language(s): Java,JSP,XML
License: lgpl21

  map/
    AircraftMapBuilder.java
    AircraftdescriptionMapBuilder.java
    AirportMapBuilder.java
    BoardingMapBuilder.java
    BookerMapBuilder.java
    BookingMapBuilder.java
    BookingitemMapBuilder.java
    CarrierMapBuilder.java
    CategoryMapBuilder.java
    FlightMapBuilder.java
    FlightdescriptionMapBuilder.java
    FlightdescriptiontocategoryMapBuilder.java
    PassengerMapBuilder.java
    PricecategoryMapBuilder.java
    SeatMapBuilder.java
  Aircraft.java
  AircraftPeer.java
  Aircraftdescription.java
  AircraftdescriptionPeer.java
  Airport.java
  AirportPeer.java
  BaseAircraft.java
  BaseAircraftPeer.java
  BaseAircraftdescription.java
  BaseAircraftdescriptionPeer.java
  BaseAirport.java
  BaseAirportPeer.java
  BaseBoarding.java
  BaseBoardingPeer.java
  BaseBooker.java
  BaseBookerPeer.java
  BaseBooking.java
  BaseBookingPeer.java
  BaseBookingitem.java
  BaseBookingitemPeer.java
  BaseCarrier.java
  BaseCarrierPeer.java
  BaseCategory.java
  BaseCategoryPeer.java
  BaseFlight.java
  BaseFlightPeer.java
  BaseFlightdescription.java
  BaseFlightdescriptionPeer.java
  BaseFlightdescriptiontocategory.java
  BaseFlightdescriptiontocategoryPeer.java
  BasePassenger.java
  BasePassengerPeer.java
  BasePricecategory.java
  BasePricecategoryPeer.java
  BaseSeat.java
  BaseSeatPeer.java
  Boarding.java
  BoardingPeer.java
  Booker.java
  BookerPeer.java
  Booking.java
  BookingPeer.java
  Bookingitem.java
  BookingitemPeer.java
  Carrier.java
  CarrierPeer.java
  Category.java
  CategoryPeer.java
  Flight.java
  FlightPeer.java
  Flightdescription.java
  FlightdescriptionPeer.java
  Flightdescriptiontocategory.java
  FlightdescriptiontocategoryPeer.java
  Passenger.java
  PassengerPeer.java
  Pricecategory.java
  PricecategoryPeer.java
  Seat.java
  SeatPeer.java