/*
* $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 DbDocAglutinator
extends DbTab
implements DbTableInterface
{
static Logger logger = Logger.getLogger( DbDocAglutinator.class );
public final static String XGM_FORM_DOC_AGLUTINATOR =
"xgm-form-doc-aglutinator.xml";
public final static String XGM_FORM_DOC_AGLUTINATOR_FRAME =
"form-doc-aglutinator-frame";
public final static String XGM_LIST_DOC_AGLUTINATOR =
"xgm-list-doc-aglutinator.xml";
public final static String XGM_LIST_DOC_AGLUTINATOR_FRAME =
"list-doc-aglutinator-frame";
public final static String T_NAME = "doc_aglutinator";
public final static String[] FIELDS =
{ "doc_aglutinator_id",
"main_tipo_ent_id",
"main_tipo_doc_id",
"main_doc_id",
"description",
"obs",
"parent_doc_aglutinator_id" };
public final static int DOC_AGLUTINATOR_ID = 0;
public final static int MAIN_TIPO_ENT_ID = 1;
public final static int MAIN_TIPO_DOC_ID = 2;
public final static int MAIN_DOC_ID = 3;
public final static int DESCRIPTION = 4;
public final static int OBS = 5;
public final static int PARENT_DOC_AGLUTINATOR_ID = 6;
public final static String FN_DOC_AGLUTINATOR_ID = "doc_aglutinator_id";
public final static String FN_MAIN_TIPO_ENT_ID = "main_tipo_ent_id";
public final static String FN_MAIN_TIPO_DOC_ID = "main_tipo_doc_id";
public final static String FN_MAIN_DOC_ID = "main_doc_id";
public final static String FN_DESCRIPTION = "description";
public final static String FN_OBS = "obs";
public final static String FN_PARENT_DOC_AGLUTINATOR_ID = "parent_doc_aglutinator_id";
XmlTreeNode xtnTabLayout = null;
XmlTreeNode xtnFormLayout = null;
////////////////////////////////////////////////////////////
public DbDocAglutinator()
throws SQLException
{
super( T_NAME );
setDataModel( getDataModel() );
}
////////////////////////////////////////////////////////////
public DbDocAglutinator( ResultSet rs )
throws SQLException
{
this();
setTuple( rs );
}
////////////////////////////////////////////////////////////
public DbDocAglutinator( Tuple t )
throws SQLException
{
this();
setTuple( t );
}
////////////////////////////////////////////////////////////
public static DbDocAglutinator getTable( Object... pkey )
throws SQLException, MpToolsException
{
DbDocAglutinator table = new DbDocAglutinator();
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 DbDocAglutinator getSingleRecord(
String where, Object... args )
throws SQLException, DatabaseException
{
DbDocAglutinator obj = new DbDocAglutinator();
StringBuffer select = new StringBuffer();
select.append( "select * from " + DbDocAglutinator.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 DbDocAglutinator( rs );
else
obj = null;
rs.close();
ps.close();
return obj;
}
////////////////////////////////////////////////////////////
public static java.util.List<DbDocAglutinator> getList(
String where, String order, Object... args )
throws SQLException, DatabaseException
{
DbDocAglutinator obj = new DbDocAglutinator();
java.util.List<Tuple> lst =
obj.selectWithArgs( false, where, order, args );
java.util.List<DbDocAglutinator> lstObj = new Vector<DbDocAglutinator>( DbWorkingTable.ARR_INIT_CAP, DbWorkingTable.ARR_CAP_INCR );
for( Tuple t : lst )
{
obj = new DbDocAglutinator();
obj.setTuple( t );
lstObj.add( obj );
}
return lstObj;
}
////////////////////////////////////////////////////////////
public static java.util.List<DbDocAglutinator> getList(
boolean validateMaxRows, String where, String order, Object... args )
throws SQLException, DatabaseException
{
DbDocAglutinator obj = new DbDocAglutinator();
java.util.List<Tuple> lst =
obj.selectWithArgs( validateMaxRows, where, order, args );
java.util.List<DbDocAglutinator> lstObj = new Vector<DbDocAglutinator>( DbWorkingTable.ARR_INIT_CAP, DbWorkingTable.ARR_CAP_INCR );
for( Tuple t : lst )
{
obj = new DbDocAglutinator();
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(), "DbDocAglutinator.class", tcdm );
return tdm;
}
////////////////////////////////////////////////////////////
public DbTableInterface createTab( String tableName, ResultSet rs)
throws SQLException
{
DbDocAglutinator dbDocAglutinator = new DbDocAglutinator( rs );
return dbDocAglutinator;
}
////////////////////////////////////////////////////////////
public XmlTreeNode getTabLayout()
throws XgmException
{
if( xtnTabLayout == null )
{
try
{
String s = XgmFactory.getInstance().readLayout( XGM_FORM_DOC_AGLUTINATOR );
xtnFormLayout = new XmlTreeNode();
xtnFormLayout.fromXml( s );
s = XgmFactory.getInstance().readLayout( XGM_LIST_DOC_AGLUTINATOR );
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_AGLUTINATOR );
xtnFormLayout = new XmlTreeNode();
xtnFormLayout.fromXml( s );
s = XgmFactory.getInstance().readLayout( XGM_FORM_DOC_AGLUTINATOR );
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_AGLUTINATOR;
}
////////////////////////////////////////////////////////////
public String getFormLayoutFilename()
{
return XGM_FORM_DOC_AGLUTINATOR;
}
////////////////////////////////////////////////////////////
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_aglutinator where doc_aglutinator_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 DbDocAglutinator getById(
Integer docAglutinatorId )
throws SQLException, DatabaseException
{
return
DbDocAglutinator.getSingleRecord(
DbDocAglutinator.FN_DOC_AGLUTINATOR_ID + " = ?",
docAglutinatorId );
}
////////////////////////////////////////////////////////////
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_aglutinator where (doc_aglutinator_id > ?) order by doc_aglutinator_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_aglutinator where (doc_aglutinator_id < ?) order by doc_aglutinator_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 getDocAglutinatorId()
{
return getDocAglutinatorId( getTuple() );
}
////////////////////////////////////////////////////////////
public static Integer getDocAglutinatorId( Tuple tuple )
{
Integer value = (Integer) tuple.get( DOC_AGLUTINATOR_ID );
return value;
}
////////////////////////////////////////////////////////////
public void setDocAglutinatorId( Integer value )
{
setDocAglutinatorId( getTuple(), value );
}
////////////////////////////////////////////////////////////
public void setDocAglutinatorId( Integer value, boolean changed )
{
setDocAglutinatorId( getTuple(), value );
setChangedField( DOC_AGLUTINATOR_ID, changed );
}
////////////////////////////////////////////////////////////
public static void setDocAglutinatorId( Tuple tuple, Integer value )
{
setValue( tuple, DOC_AGLUTINATOR_ID, value );
}
////////////////////////////////////////////////////////////
public Integer getMainTipoEntId()
{
return getMainTipoEntId( getTuple() );
}
////////////////////////////////////////////////////////////
public static Integer getMainTipoEntId( Tuple tuple )
{
Integer value = (Integer) tuple.get( MAIN_TIPO_ENT_ID );
return value;
}
////////////////////////////////////////////////////////////
public void setMainTipoEntId( Integer value )
{
setMainTipoEntId( getTuple(), value );
}
////////////////////////////////////////////////////////////
public void setMainTipoEntId( Integer value, boolean changed )
{
setMainTipoEntId( getTuple(), value );
setChangedField( MAIN_TIPO_ENT_ID, changed );
}
////////////////////////////////////////////////////////////
public static void setMainTipoEntId( Tuple tuple, Integer value )
{
setValue( tuple, MAIN_TIPO_ENT_ID, value );
}
////////////////////////////////////////////////////////////
public Integer getMainTipoDocId()
{
return getMainTipoDocId( getTuple() );
}
////////////////////////////////////////////////////////////
public static Integer getMainTipoDocId( Tuple tuple )
{
Integer value = (Integer) tuple.get( MAIN_TIPO_DOC_ID );
return value;
}
////////////////////////////////////////////////////////////
public void setMainTipoDocId( Integer value )
{
setMainTipoDocId( getTuple(), value );
}
////////////////////////////////////////////////////////////
public void setMainTipoDocId( Integer value, boolean changed )
{
setMainTipoDocId( getTuple(), value );
setChangedField( MAIN_TIPO_DOC_ID, changed );
}
////////////////////////////////////////////////////////////
public static void setMainTipoDocId( Tuple tuple, Integer value )
{
setValue( tuple, MAIN_TIPO_DOC_ID, value );
}
////////////////////////////////////////////////////////////
public Integer getMainDocId()
{
return getMainDocId( getTuple() );
}
////////////////////////////////////////////////////////////
public static Integer getMainDocId( Tuple tuple )
{
Integer value = (Integer) tuple.get( MAIN_DOC_ID );
return value;
}
////////////////////////////////////////////////////////////
public void setMainDocId( Integer value )
{
setMainDocId( getTuple(), value );
}
////////////////////////////////////////////////////////////
public void setMainDocId( Integer value, boolean changed )
{
setMainDocId( getTuple(), value );
setChangedField( MAIN_DOC_ID, changed );
}
////////////////////////////////////////////////////////////
public static void setMainDocId( Tuple tuple, Integer value )
{
setValue( tuple, MAIN_DOC_ID, value );
}
////////////////////////////////////////////////////////////
public String getDescription()
{
return getDescription( getTuple() );
}
////////////////////////////////////////////////////////////
public static String getDescription( Tuple tuple )
{
String value = (String) tuple.get( DESCRIPTION );
return value;
}
////////////////////////////////////////////////////////////
public void setDescription( String value )
{
setDescription( getTuple(), value );
}
////////////////////////////////////////////////////////////
public void setDescription( String value, boolean changed )
{
setDescription( getTuple(), value );
setChangedField( DESCRIPTION, changed );
}
////////////////////////////////////////////////////////////
public static void setDescription( Tuple tuple, String value )
{
setValue( tuple, DESCRIPTION, value );
}
////////////////////////////////////////////////////////////
public String getObs()
{
return getObs( getTuple() );
}
////////////////////////////////////////////////////////////
public static String getObs( Tuple tuple )
{
String value = (String) tuple.get( OBS );
return value;
}
////////////////////////////////////////////////////////////
public void setObs( String value )
{
setObs( getTuple(), value );
}
////////////////////////////////////////////////////////////
public void setObs( String value, boolean changed )
{
setObs( getTuple(), value );
setChangedField( OBS, changed );
}
////////////////////////////////////////////////////////////
public static void setObs( Tuple tuple, String value )
{
setValue( tuple, OBS, value );
}
////////////////////////////////////////////////////////////
public Integer getParentDocAglutinatorId()
{
return getParentDocAglutinatorId( getTuple() );
}
////////////////////////////////////////////////////////////
public static Integer getParentDocAglutinatorId( Tuple tuple )
{
Integer value = (Integer) tuple.get( PARENT_DOC_AGLUTINATOR_ID );
return value;
}
////////////////////////////////////////////////////////////
public void setParentDocAglutinatorId( Integer value )
{
setParentDocAglutinatorId( getTuple(), value );
}
////////////////////////////////////////////////////////////
public void setParentDocAglutinatorId( Integer value, boolean changed )
{
setParentDocAglutinatorId( getTuple(), value );
setChangedField( PARENT_DOC_AGLUTINATOR_ID, changed );
}
////////////////////////////////////////////////////////////
public static void setParentDocAglutinatorId( Tuple tuple, Integer value )
{
setValue( tuple, PARENT_DOC_AGLUTINATOR_ID, value );
}
////////////////////////////////////////////////////////////
// Get/Set methods: END
////////////////////////////////////////////////////////////
}
|