com.dhtmlx.connector
Class DBDataWrapper

java.lang.Object
  extended by com.dhtmlx.connector.DataWrapper
      extended by com.dhtmlx.connector.DBDataWrapper
Direct Known Subclasses:
MSSQLDBDataWrapper, MySQLDBDataWrapper, OracleDBDataWrapper, PGSQLDBDataWrapper

public abstract class DBDataWrapper
extends DataWrapper

The Class DBDataWrapper. Class implements DataWrapper for common DB type


Field Summary
private  java.lang.String sequence_name
          The sequence name.
private  java.util.HashMap<OperationType,java.lang.String> sqls
          The set of defined sql strings
 
Fields inherited from class com.dhtmlx.connector.DataWrapper
config, connection
 
Constructor Summary
DBDataWrapper()
           
 
Method Summary
 void attach(OperationType name, java.lang.String sql)
          Attach.
 void begin_transaction()
          Begin transaction.
protected  java.lang.String build_order(java.util.ArrayList<SortingRule> sorts)
          Convert sorting rules to sql string
protected  java.lang.String build_where(java.util.ArrayList<FilteringRule> rules, java.lang.String relation)
          Convert filtering rules to sql string
 void commit_transaction()
          Commit transaction.
private  java.lang.String delete_query(DataAction data, DataRequest source)
          Generate SQL for delete operation
 void delete(DataAction data, DataRequest source)
          Delete data from storage
abstract  java.lang.String escape(java.lang.String data)
          Escape the data, befor using in SQL
protected  java.sql.Connection get_connection()
          Gets the connection.
abstract  java.lang.String get_new_id(ConnectorResultSet result)
          Gets the new id
 java.lang.String get_size(DataRequest source)
          Gets the size of the data in storage.
 java.lang.String get_sql(OperationType name, java.util.HashMap<java.lang.String,java.lang.String> data)
          Gets the sql string for named operation
 ConnectorResultSet get_variants(DataRequest source)
          Gets the all variations of defined field in the storage
protected  java.sql.Statement getStatement()
          Gets the statement
protected  java.lang.String insert_query(DataAction data, DataRequest source)
          Generate sql for insert query.
 void insert(DataAction data, DataRequest source)
          Insert data in storage
 ConnectorResultSet query(java.lang.String data)
          Executes DB query.
 void rollback_transaction()
          Rollback transaction.
protected  java.lang.String select_query(java.lang.String select, java.lang.String from, java.lang.String where, java.lang.String sort, java.lang.String start, java.lang.String count)
          Generates sql for select query
 ConnectorResultSet select(DataRequest source)
          Select data from storage
 void sequence(java.lang.String sequence_name)
          Sets sequence Sequence used in Oracle to implement auto-id generation
private  java.lang.String update_query(DataAction data, DataRequest source)
          Builds the update sql query.
 void update(DataAction data, DataRequest source)
          Update data in storage
 
Methods inherited from class com.dhtmlx.connector.DataWrapper
init, is_global_transaction, is_record_transaction, set_transaction_mode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sequence_name

private java.lang.String sequence_name
The sequence name.


sqls

private java.util.HashMap<OperationType,java.lang.String> sqls
The set of defined sql strings

Constructor Detail

DBDataWrapper

public DBDataWrapper()
Method Detail

escape

public abstract java.lang.String escape(java.lang.String data)
Escape the data, befor using in SQL

Parameters:
data - the incoming data
Returns:
the escaped string

get_new_id

public abstract java.lang.String get_new_id(ConnectorResultSet result)
                                     throws ConnectorOperationException
Gets the new id

Parameters:
result - the resultset, which contains the new ID
Returns:
the new id value
Throws:
ConnectorOperationException - the connector operation exception

sequence

public void sequence(java.lang.String sequence_name)
Sets sequence Sequence used in Oracle to implement auto-id generation

Parameters:
sequence_name - the name of sequence

get_connection

protected java.sql.Connection get_connection()
Gets the connection.

Returns:
the db connection

attach

public void attach(OperationType name,
                   java.lang.String sql)
Attach.

Parameters:
name - the name
sql - the sql

get_sql

public java.lang.String get_sql(OperationType name,
                                java.util.HashMap<java.lang.String,java.lang.String> data)
                         throws ConnectorConfigException
Description copied from class: DataWrapper
Gets the sql string for named operation

Overrides:
get_sql in class DataWrapper
Parameters:
name - the name of operation
data - the hash of data, will be used to fill vars in sql
Returns:
the sql string
Throws:
ConnectorConfigException - the connector config exception

delete

public void delete(DataAction data,
                   DataRequest source)
            throws ConnectorOperationException
Description copied from class: DataWrapper
Delete data from storage

Specified by:
delete in class DataWrapper
Parameters:
data - the data wrapped in DataAction object
source - the source defined by DataRequest object
Throws:
ConnectorOperationException - the connector operation exception

delete_query

private java.lang.String delete_query(DataAction data,
                                      DataRequest source)
Generate SQL for delete operation

Parameters:
data - the data
source - the source
Returns:
the sql string

insert_query

protected java.lang.String insert_query(DataAction data,
                                        DataRequest source)
Generate sql for insert query.

Parameters:
data - the data
source - the source
Returns:
the sql string

get_size

public java.lang.String get_size(DataRequest source)
                          throws ConnectorOperationException
Description copied from class: DataWrapper
Gets the size of the data in storage.

Specified by:
get_size in class DataWrapper
Parameters:
source - the source defined by DataRequest object
Returns:
the size of collection in storage
Throws:
ConnectorOperationException - the connector operation exception

get_variants

public ConnectorResultSet get_variants(DataRequest source)
                                throws ConnectorOperationException
Description copied from class: DataWrapper
Gets the all variations of defined field in the storage

Specified by:
get_variants in class DataWrapper
Parameters:
source - the source defined by DataRequest object
Returns:
the set of variations
Throws:
ConnectorOperationException - the connector operation exception

insert

public void insert(DataAction data,
                   DataRequest source)
            throws ConnectorOperationException
Description copied from class: DataWrapper
Insert data in storage

Specified by:
insert in class DataWrapper
Parameters:
data - the data wrapped in DataAction object
source - the source defined by DataRequest object
Throws:
ConnectorOperationException - the connector operation exception

select

public ConnectorResultSet select(DataRequest source)
                          throws ConnectorOperationException
Description copied from class: DataWrapper
Select data from storage

Specified by:
select in class DataWrapper
Parameters:
source - the source defined by DataRequest object
Returns:
the connector result set
Throws:
ConnectorOperationException - the connector operation exception

select_query

protected java.lang.String select_query(java.lang.String select,
                                        java.lang.String from,
                                        java.lang.String where,
                                        java.lang.String sort,
                                        java.lang.String start,
                                        java.lang.String count)
Generates sql for select query

Parameters:
select - the list of fields
from - the name of table
where - the filtering rules
sort - the sorting rules
start - the start index
count - the count of records to fetch
Returns:
the string

build_where

protected java.lang.String build_where(java.util.ArrayList<FilteringRule> rules,
                                       java.lang.String relation)
Convert filtering rules to sql string

Parameters:
rules - the set of filtering rules
relation - the name of relation id field
Returns:
the sql string

build_order

protected java.lang.String build_order(java.util.ArrayList<SortingRule> sorts)
Convert sorting rules to sql string

Parameters:
sorts - the set of sorting rules
Returns:
the sql string

update

public void update(DataAction data,
                   DataRequest source)
            throws ConnectorOperationException
Description copied from class: DataWrapper
Update data in storage

Specified by:
update in class DataWrapper
Parameters:
data - the data wrapped in DataAction object
source - the source defined by DataRequest object
Throws:
ConnectorOperationException - the connector operation exception

update_query

private java.lang.String update_query(DataAction data,
                                      DataRequest source)
Builds the update sql query.

Parameters:
data - the data
source - the source
Returns:
the string

begin_transaction

public void begin_transaction()
                       throws ConnectorOperationException
Description copied from class: DataWrapper
Begin transaction.

Overrides:
begin_transaction in class DataWrapper
Throws:
ConnectorOperationException - the connector operation exception

commit_transaction

public void commit_transaction()
                        throws ConnectorOperationException
Description copied from class: DataWrapper
Commit transaction.

Overrides:
commit_transaction in class DataWrapper
Throws:
ConnectorOperationException - the connector operation exception

rollback_transaction

public void rollback_transaction()
                          throws ConnectorOperationException
Description copied from class: DataWrapper
Rollback transaction.

Overrides:
rollback_transaction in class DataWrapper
Throws:
ConnectorOperationException - the connector operation exception

getStatement

protected java.sql.Statement getStatement()
                                   throws java.sql.SQLException
Gets the statement

Returns:
the statement
Throws:
java.sql.SQLException - the SQL exception

query

public ConnectorResultSet query(java.lang.String data)
                         throws ConnectorOperationException
Executes DB query.

Parameters:
data - the data
Returns:
the connector result set
Throws:
ConnectorOperationException - the connector operation exception