DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECTALL_FIELD_NULL, getDefaultPool( plugin ) );
daoUtil.executeQuery( );
while ( daoUtil.next( ) )
{
ReferenceItem item = new ReferenceItem( );
item.setCode( daoUtil.getString( 1 ) );
item.setName( daoUtil.getString( 2 ) );
fieldnullList.add( item );
}
daoUtil.free( );
return fieldnullList;
}
/**
* Find the field id type by label type from adminsql database
* @param strLabelType the name of the type that user choose
* @param plugin Plugin adminsql
* @param strPoolName the name of the pool
* @return id type from label type
*/
public int findFieldTypeIdbyLabel( String strLabelType, Plugin plugin, String strPoolName )
{
DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_FIELD_TYPE_ID, getDefaultPool( plugin ) );
daoUtil.setString( 1, strLabelType );
daoUtil.executeQuery( );
int nIdFieldType = 0;
if ( daoUtil.next( ) )
{
nIdFieldType = daoUtil.getInt( 1 );
}
daoUtil.free( );
plugin = changePool( strPoolName );
return nIdFieldType;
}
/**
* Find the field label type by id type from adminsql database
* @param nId the id of type label
* @param plugin Plugin adminsql
* @param strPoolName name of the pool
* @return the label of the type by id
*/
public String findFieldTypeLabelbyId( int nId, Plugin plugin, String strPoolName )
{
DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_FIELD_TYPE_LABEL_BY_ID, getDefaultPool( plugin ) );
daoUtil.setInt( 1, nId );
daoUtil.executeQuery( );
String strFieldTypeLabel = "";
if ( daoUtil.next( ) )
{
strFieldTypeLabel = daoUtil.getString( 1 );
}
daoUtil.free( );
plugin = changePool( strPoolName );
return strFieldTypeLabel;
}
/**
* Find the field id null by label null from adminsql database
* @param strLabelNull the label of the null value
* @param plugin Plugin adminsql
* @param strPoolName the name of the pool
* @return id null from null type
*/
public int findFieldNullIdbyLabel( String strLabelNull, Plugin plugin, String strPoolName )
{
DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_FIELD_NULL_ID, getDefaultPool( plugin ) );
daoUtil.setString( 1, strLabelNull );
daoUtil.executeQuery( );
int nIdFieldNull = 0;
if ( daoUtil.next( ) )
{
nIdFieldNull = daoUtil.getInt( 1 );
}
daoUtil.free( );
plugin = changePool( strPoolName );
return nIdFieldNull;
}
/**
* Find the field id null by label null from adminsql database
* @param nId the id of the null value
* @param plugin Plugin adminsql
* @param strPoolName the name of the pool
* @return the label of null value by id
*/
public String findFieldNullLabelbyId( int nId, Plugin plugin, String strPoolName )
{
DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_FIELD_NULL_LABEL_BY_ID, getDefaultPool( plugin ) );
daoUtil.setInt( 1, nId );
daoUtil.executeQuery( );
String strFieldNullLabel = "";
if ( daoUtil.next( ) )
{
strFieldNullLabel = daoUtil.getString( 1 );
}
daoUtil.free( );
plugin = changePool( strPoolName );
return strFieldNullLabel;
}
/**
* Find the field id key by label key from adminsql database
* @param strLabelKey the label key of the field
* @param plugin Plugin adminsql
* @param strPoolName the name of the pool
* @return id key from label key
*/
public int findFieldKeyIdbyLabel( String strLabelKey, Plugin plugin, String strPoolName )
{
DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_FIELD_KEY_ID, getDefaultPool( plugin ) );
daoUtil.setString( 1, strLabelKey );
daoUtil.executeQuery( );
int nIdFieldKey = 0;
if ( daoUtil.next( ) )
{
nIdFieldKey = daoUtil.getInt( 1 );
}
daoUtil.free( );
plugin = changePool( strPoolName );
return nIdFieldKey;
}
/**
* Find the field id key by label key from adminsql database
* @param nId the id of the key
* @param plugin Plugin adminsql
* @param strPoolName the name of the pool
* @return the label of key by id
*/
public String findFieldKeyLabelbyId( int nId, Plugin plugin, String strPoolName )
{
DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_FIELD_KEY_LABEL_BY_ID, getDefaultPool( plugin ) );
daoUtil.setInt( 1, nId );
daoUtil.executeQuery( );
String strFieldKeyLabel = "";
if ( daoUtil.next( ) )
{
strFieldKeyLabel = daoUtil.getString( 1 );
}
daoUtil.free( );
plugin = changePool( strPoolName );
return strFieldKeyLabel;
}
private Plugin changePool( String strPoolName )
{
Plugin plugin = PluginService.getPlugin( "adminsql" );
PluginConnectionService connectionService = new PluginConnectionService( strPoolName );
connectionService.setPool( strPoolName );
plugin.setConnectionService( connectionService );
return plugin;
}
private Plugin getDefaultPool( Plugin plugin )
{
PluginConnectionService connectionService = new PluginConnectionService( plugin.getDbPoolName( ) );
connectionService.setPool( "adminsql" );
plugin.setConnectionService( connectionService );
return plugin; //TODO in properties
}
}