DbDocFlags.java :  » ERP-CRM-Financial » Evaristo-4.0 » com » m16e » mpbiz » tables » Java Open Source

Java Open Source » ERP CRM Financial » Evaristo 4.0 
Evaristo 4.0 » com » m16e » mpbiz » tables » DbDocFlags.java
/*
 * $Log$
 *
 * DO NOT CHANGE THIS FILE or CHANGE IT WITH CARE!!!
 * FILE GENERATED BY Gaud ( version 1.4 - build (build 376)
 *
 * on Wed Apr 14 18:19:19 WEST 2010
 *
 *
 *
 */

package com.m16e.mpbiz.tables;

import java.io.*;
import java.math.*;
import java.sql.*;
import java.text.*;
import java.util.*;

import com.m16e.tools.*;
import com.m16e.tools.db.*;
import com.m16e.tools.xgm.*;
import com.m16e.tools.xml.*;
import java.math.BigDecimal;
import org.apache.log4j.Logger;


////////////////////////////////////////////////////////////
public class DbDocFlags
extends DbTab
implements DbTableInterface
{
  static Logger logger = Logger.getLogger( DbDocFlags.class );

  public final static String XGM_FORM_DOC_FLAGS =
    "xgm-form-doc-flags.xml";
  public final static String XGM_FORM_DOC_FLAGS_FRAME =
    "form-doc-flags-frame";
  public final static String XGM_LIST_DOC_FLAGS =
    "xgm-list-doc-flags.xml";
  public final static String XGM_LIST_DOC_FLAGS_FRAME =
    "list-doc-flags-frame";

  public final static String T_NAME = "doc_flags";

  public final static String[] FIELDS = 
    {  "flag_id",
      "flag_name",
      "flag_name_long",
      "field_name" };

  public final static int FLAG_ID = 0;
  public final static int FLAG_NAME = 1;
  public final static int FLAG_NAME_LONG = 2;
  public final static int FIELD_NAME = 3;

  public final static String FN_FLAG_ID = "flag_id";
  public final static String FN_FLAG_NAME = "flag_name";
  public final static String FN_FLAG_NAME_LONG = "flag_name_long";
  public final static String FN_FIELD_NAME = "field_name";

  XmlTreeNode xtnTabLayout = null;
  XmlTreeNode xtnFormLayout = null;

  ////////////////////////////////////////////////////////////
  public DbDocFlags()

    throws SQLException
  {
    super( T_NAME );
    setDataModel( getDataModel() );
  }

  ////////////////////////////////////////////////////////////
  public DbDocFlags( ResultSet rs )
    throws SQLException
  {
    this();
    setTuple( rs );
  }

  ////////////////////////////////////////////////////////////
  public DbDocFlags( Tuple t )
    throws SQLException
  {
    this();
    setTuple( t );
  }

  ////////////////////////////////////////////////////////////
  public static DbDocFlags getTable( Object... pkey )
  throws SQLException, MpToolsException
  {
    DbDocFlags table = new DbDocFlags();
    java.util.List<Integer> lstPK = table.getPrimaryKey();
    int i = 0;
    for( Object o : pkey )
    {
      table.setValue( lstPK.get( i++ ), o );
    }
    if( !table.getById() )
    {
      table = null;
    }
    return table;
  }

  ////////////////////////////////////////////////////////////
  public static DbDocFlags getSingleRecord(
    String where, Object... args )
  throws SQLException, DatabaseException
  {
    DbDocFlags obj = new DbDocFlags();
    StringBuffer select = new StringBuffer();
    select.append( "select * from " + DbDocFlags.T_NAME );
    if( where != null && where.trim().length() > 0 )
    {
      select.append( " where " + where );
    }
    int i = 1;
    PreparedStatement ps =
      MpAppContext.getInstance().getDatabase().getPreparedStatement( select.toString() );
    for( Object arg : args )
    {
      ps.setObject( i++, arg );
    }
    if( logger.isTraceEnabled() )
    {
      logger.trace( "query: \n" + ps.toString() );
    }
    ResultSet rs = ps.executeQuery();
    if( rs.next() )
      obj = new DbDocFlags( rs );
    else
      obj = null;
    rs.close();
    ps.close();
    return obj;
  }

  ////////////////////////////////////////////////////////////
  public static java.util.List<DbDocFlags> getList(
    String where, String order, Object... args )
  throws SQLException, DatabaseException
  {
    DbDocFlags obj = new DbDocFlags();
    java.util.List<Tuple> lst =
      obj.selectWithArgs( false, where, order, args );
    java.util.List<DbDocFlags> lstObj = new Vector<DbDocFlags>( DbWorkingTable.ARR_INIT_CAP, DbWorkingTable.ARR_CAP_INCR );
    for( Tuple t : lst )
    {
      obj = new DbDocFlags();
      obj.setTuple( t );
      lstObj.add( obj );
    }
    return lstObj;
  }

  ////////////////////////////////////////////////////////////
  public static java.util.List<DbDocFlags> getList(
    boolean validateMaxRows, String where, String order, Object... args )
  throws SQLException, DatabaseException
  {
    DbDocFlags obj = new DbDocFlags();
    java.util.List<Tuple> lst =
      obj.selectWithArgs( validateMaxRows, where, order, args );
    java.util.List<DbDocFlags> lstObj = new Vector<DbDocFlags>( DbWorkingTable.ARR_INIT_CAP, DbWorkingTable.ARR_CAP_INCR );
    for( Tuple t : lst )
    {
      obj = new DbDocFlags();
      obj.setTuple( t );
      lstObj.add( obj );
    }
    return lstObj;
  }

  ////////////////////////////////////////////////////////////
  public TupleDataModel getDataModel()
  {
    java.util.List<TupleColDataModel> tcdm = new Vector<TupleColDataModel>( 10, 10 );
    for( int f = 0; f < FIELDS.length; f++ )
    {
      DbField dbField = super.getField( f );
      int len = dbField.getTotalLen();
      switch( dbField.getDbFieldType() )
      {
        case INT:
          len = 8;
          break;
        case DOUBLE:
          len = 15;
          break;
        default:
          if( len > 40 )
            len = 40;
          break;
      }
      tcdm.add( new TupleColDataModel( dbField ) );
    }
    TupleDataModel tdm =
      new TupleDataModel( getDbTable(), "DbDocFlags.class", tcdm );
    return tdm;
  }
  ////////////////////////////////////////////////////////////
  public DbTableInterface createTab(  String tableName, ResultSet rs)
    throws SQLException
  {
    DbDocFlags dbDocFlags = new DbDocFlags( rs );
    return dbDocFlags;
  }

  ////////////////////////////////////////////////////////////
  public XmlTreeNode getTabLayout()
  throws XgmException
  {
    if( xtnTabLayout == null )
    {
      try
      {
        String s = XgmFactory.getInstance().readLayout( XGM_FORM_DOC_FLAGS );
        xtnFormLayout = new XmlTreeNode();
        xtnFormLayout.fromXml( s );
        s = XgmFactory.getInstance().readLayout( XGM_LIST_DOC_FLAGS );
        xtnTabLayout = new XmlTreeNode();
        xtnTabLayout.fromXml( s );
      }
      catch( Exception e )
      {
        String msg = e.getLocalizedMessage();
        logger.error( e.getMessage(), e );
        throw new XgmException( XgmException.IO_ERROR, e.getMessage() );
      }
    }
    return xtnTabLayout;
  }

  ////////////////////////////////////////////////////////////
  public XmlTreeNode getFormLayout()
  throws XgmException
  {
    if( xtnFormLayout == null )
    {
      try
      {
        String s = XgmFactory.getInstance().readLayout( XGM_FORM_DOC_FLAGS );
        xtnFormLayout = new XmlTreeNode();
        xtnFormLayout.fromXml( s );
        s = XgmFactory.getInstance().readLayout( XGM_FORM_DOC_FLAGS );
        xtnFormLayout = new XmlTreeNode();
        xtnFormLayout.fromXml( s );
      }
      catch( Exception e )
      {
        String msg = e.getLocalizedMessage();
        logger.error( e.getMessage(), e );
        throw new XgmException( XgmException.IO_ERROR, e.getMessage() );
      }
    }
    return xtnFormLayout;
  }

  ////////////////////////////////////////////////////////////
  public String getTabLayoutFilename()
  {
    return XGM_LIST_DOC_FLAGS;
  }

  ////////////////////////////////////////////////////////////
  public String getFormLayoutFilename()
  {
    return XGM_FORM_DOC_FLAGS;
  }

  ////////////////////////////////////////////////////////////
  public boolean getById()
  throws SQLException
  {
    Database db = MpAppContext.getInstance().getDatabase();
    Tuple tuple = getTuple();
    java.util.List<Integer> kFields = getPrimaryKey();
    int nCols = getFieldCount();
    PreparedStatement ps =
      db.getPreparedStatement(
        "select * from doc_flags where flag_id = ?" );
    ps.setObject( 1, tuple.get( kFields.get( 0 ) ) );
    if( logger.isTraceEnabled() )
    {
      logger.trace( "query: \n" + ps.toString() );
    }
    boolean found = false;
    ResultSet rs = ps.executeQuery();
    if ( rs.next() )
    {
      found = true;
      for( int f = 0; f < nCols; f++ )
      {
        Object o = rs.getObject( f + 1 );
        if( o instanceof String )
          o = ((String) o).trim();
        tuple.setAll( f, o );
      }
    }
    rs.close();
    ps.close();
    return found;
  }

  ////////////////////////////////////////////////////////////
  public static DbDocFlags getById(
    Integer flagId )
  throws SQLException, DatabaseException
  {
    return
      DbDocFlags.getSingleRecord(
        DbDocFlags.FN_FLAG_ID + " = ?",
        flagId );
  }

  ////////////////////////////////////////////////////////////
  public boolean fetchNext()
  throws SQLException
  {
    Database db = MpAppContext.getInstance().getDatabase();
    Tuple tuple = getTuple();
    java.util.List<Integer> kFields = getPrimaryKey();
    int nCols = getFieldCount();
    PreparedStatement ps =
      db.getPreparedStatement(
        "select * from doc_flags where (flag_id > ?) order by  flag_id limit 1" );
    ps.setObject( 1, tuple.get( kFields.get( 0 ) ) );
    if( logger.isTraceEnabled() )
    {
      logger.trace( "query: \n" + ps.toString() );
    }
    boolean fetched = false;
    ResultSet rs = ps.executeQuery();
    if ( rs.next() )
    {
      fetched = true;
      setTuple( rs );
    }
    rs.close();
    ps.close();
    return fetched;
  }
  ////////////////////////////////////////////////////////////
  public boolean fetchPrev()
  throws SQLException
  {
    Database database = MpAppContext.getInstance().getDatabase();
    Tuple tuple = getTuple();
    java.util.List<Integer> kFields = getPrimaryKey();
    int nCols = getFieldCount();
    PreparedStatement ps =
      database.getPreparedStatement(
        "select * from doc_flags where (flag_id < ?) order by  flag_id desc limit 1" );
    ps.setObject( 1, tuple.get( kFields.get( 0 ) ) );
    if( logger.isTraceEnabled() )
    {
      logger.trace( "query: \n" + ps.toString() );
    }
    boolean fetched = false;
    ResultSet rs = ps.executeQuery();
    if ( rs.next() )
    {
      fetched = true;
      setTuple( rs );
    }
    rs.close();
    ps.close();
    return fetched;
  }
  ////////////////////////////////////////////////////////////
  // Get/Set methods: BEGIN
  ////////////////////////////////////////////////////////////

  ////////////////////////////////////////////////////////////
  public Integer getFlagId()
  {
    return getFlagId( getTuple() );
  }

  ////////////////////////////////////////////////////////////
  public static Integer getFlagId( Tuple tuple )
  {
    Integer value = (Integer) tuple.get( FLAG_ID );
    return value;
  }

  ////////////////////////////////////////////////////////////
  public void setFlagId( Integer value )
  {
    setFlagId( getTuple(), value );
  }

  ////////////////////////////////////////////////////////////
  public void setFlagId( Integer value, boolean changed )
  {
    setFlagId( getTuple(), value );
    setChangedField( FLAG_ID, changed );
  }

  ////////////////////////////////////////////////////////////
  public static void setFlagId( Tuple tuple, Integer value )
  {
    setValue( tuple, FLAG_ID, value );
  }

  ////////////////////////////////////////////////////////////
  public String getFlagName()
  {
    return getFlagName( getTuple() );
  }

  ////////////////////////////////////////////////////////////
  public static String getFlagName( Tuple tuple )
  {
    String value = (String) tuple.get( FLAG_NAME );
    return value;
  }

  ////////////////////////////////////////////////////////////
  public void setFlagName( String value )
  {
    setFlagName( getTuple(), value );
  }

  ////////////////////////////////////////////////////////////
  public void setFlagName( String value, boolean changed )
  {
    setFlagName( getTuple(), value );
    setChangedField( FLAG_NAME, changed );
  }

  ////////////////////////////////////////////////////////////
  public static void setFlagName( Tuple tuple, String value )
  {
    setValue( tuple, FLAG_NAME, value );
  }

  ////////////////////////////////////////////////////////////
  public String getFlagNameLong()
  {
    return getFlagNameLong( getTuple() );
  }

  ////////////////////////////////////////////////////////////
  public static String getFlagNameLong( Tuple tuple )
  {
    String value = (String) tuple.get( FLAG_NAME_LONG );
    return value;
  }

  ////////////////////////////////////////////////////////////
  public void setFlagNameLong( String value )
  {
    setFlagNameLong( getTuple(), value );
  }

  ////////////////////////////////////////////////////////////
  public void setFlagNameLong( String value, boolean changed )
  {
    setFlagNameLong( getTuple(), value );
    setChangedField( FLAG_NAME_LONG, changed );
  }

  ////////////////////////////////////////////////////////////
  public static void setFlagNameLong( Tuple tuple, String value )
  {
    setValue( tuple, FLAG_NAME_LONG, value );
  }

  ////////////////////////////////////////////////////////////
  public String getFieldName()
  {
    return getFieldName( getTuple() );
  }

  ////////////////////////////////////////////////////////////
  public static String getFieldName( Tuple tuple )
  {
    String value = (String) tuple.get( FIELD_NAME );
    return value;
  }

  ////////////////////////////////////////////////////////////
  public void setFieldName( String value )
  {
    setFieldName( getTuple(), value );
  }

  ////////////////////////////////////////////////////////////
  public void setFieldName( String value, boolean changed )
  {
    setFieldName( getTuple(), value );
    setChangedField( FIELD_NAME, changed );
  }

  ////////////////////////////////////////////////////////////
  public static void setFieldName( Tuple tuple, String value )
  {
    setValue( tuple, FIELD_NAME, value );
  }

  ////////////////////////////////////////////////////////////
  // Get/Set methods: END
  ////////////////////////////////////////////////////////////


}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.