public interface IDataManager
IDataManager deals with data in terms of Java Objects - .
IDataManager also allows execution of custom SQL statements. All methods which allow execution of custom SQL statements start with 'execute'.
How to get access to IDataManager: Use to get access to the IDataManager.
Example: {@code: ApplicationManager applicationManager = ApplicationManager.getInstance(); IDataManager dataManager = applicationManager.getDataManager();
SQLite is used as the underlying database.
| Modifier and Type | Interface and Description |
|---|---|
static class |
IDataManager.ORDER_TYPE |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTransaction()
Do not use.
|
IDataStructure |
checkDuplicateGID(IDataStructure dataStructure) |
void |
close() |
int |
count(java.lang.String structureName,
java.lang.String whereClause)
Get the count of the records in the database table which match the where clause.
|
void |
createIndex(java.lang.String indexName,
java.lang.String structureName,
java.lang.String[] fieldNames) |
void |
createSavepoint(java.lang.String savePointName)
Method createSavepoint.
|
void |
createTable(java.lang.String structureName,
java.lang.String[] columnNames,
java.lang.String[] columnTypes,
java.lang.String[] primaryKeys) |
void |
createTable(java.lang.String structureName,
java.lang.String[] columnNames,
java.lang.String[] columnTypes,
java.lang.String[] primaryKeys,
java.lang.String[] uniqueKeys) |
void |
createTable(java.lang.String structureName,
java.lang.String[] columnNames,
java.lang.String[] columnTypes,
java.lang.String[] primaryKeys,
java.lang.String[] uniqueKeys,
boolean[] mandatoryFields,
java.lang.String[] foreignKeys,
java.lang.String headerStructureName,
java.lang.String[] headerStructureKeys) |
void |
delete(IDataStructure dataStructure)
Delete the data structure from the database.
|
void |
delete(java.lang.String structureName)
Deletes all rows in the table.
|
void |
delete(java.lang.String structureName,
java.lang.String whereClause)
Deletes all rows in the table that satisfy the where clause.
|
void |
dropDatabase() |
void |
dropIndex(java.lang.String indexName) |
void |
dropTable(java.lang.String structureName) |
void |
endTransaction()
Do not use.
|
void |
execute(java.lang.String sqlStatement)
Executes a single SQL statement that does not return data.
|
void |
executeBindQuery(java.lang.String sqlStatement,
java.lang.Object[] columnValues)
Executes a single SQL statement that does not return data.
|
Cursor |
executeQuery(java.lang.String sqlStatement)
Executes a single SQL statement returning
Cursor over the result set. |
boolean |
exists() |
IDataStructure[] |
get(java.lang.String structureName)
Get data from the database as
IDataStructure objects for the given table name. |
IDataStructure[] |
get(java.lang.String structureName,
java.lang.Class className)
Do not use.
|
IDataStructure[] |
get(java.lang.String structureName,
java.lang.String whereClause)
Get data from the database as
IDataStructure objects for the given table name. |
IDataStructure[] |
get(java.lang.String structureName,
java.lang.String[] orderByFields)
Get data from the database as
IDataStructure objects for the given table name. |
IDataStructure[] |
get(java.lang.String structureName,
java.lang.String[] orderByFields,
java.lang.Class className)
Do not use.
|
IDataStructure[] |
get(java.lang.String structureName,
java.lang.String[] orderByFields,
IDataManager.ORDER_TYPE orderType) |
IDataStructure[] |
get(java.lang.String structureName,
java.lang.String whereClause,
java.lang.Class className)
Do not use.
|
IDataStructure[] |
get(java.lang.String structureName,
java.lang.String whereClause,
java.lang.String[] orderByFields)
Get data from the database as
IDataStructure objects for the given table name. |
IDataStructure[] |
get(java.lang.String structureName,
java.lang.String whereClause,
java.lang.String[] orderByFields,
java.lang.Class className)
Do not use.
|
IDataStructure[] |
get(java.lang.String structureName,
java.lang.String whereClause,
java.lang.String[] orderByFields,
IDataManager.ORDER_TYPE orderType)
Get data from the database as
IDataStructure objects for the given table name. |
java.util.Hashtable<java.lang.String,IDataStructure[]> |
getAllChildren(IDataStructure headerDataStructure)
Get all the children structures / items from the children tables for the give header data structure.
|
java.util.Hashtable<java.lang.String,JSONArray> |
getAllChildren(com.unvired.model.JSDataStructure headerDataStructure)
Get all the children structures / items from the children tables for the give header data structure.
|
IDataStructure |
getBasedOnGID(IDataStructure dataStructure)
Get the
IDataStructure from the database based on GID. |
IDataStructure[] |
getChildren(java.lang.String structureName,
IDataStructure headerDataStructure)
Get all the children structures / items from the child table for the give header data structure.
|
JSONArray |
getChildren(java.lang.String tableName,
com.unvired.model.JSDataStructure headerDataStructure)
Get all the children structures / items from the child table for the give header data structure.
|
IDataStructure[] |
getChildren(java.lang.String structureName,
java.lang.String[] orderByFields,
IDataStructure headerDataStructure)
Get all the children structures / items from the child table for the give header data structure.
|
IDataStructure[] |
getChildren(java.lang.String structureName,
java.lang.String whereClause,
java.lang.String[] orderByFields,
IDataStructure headerDataStructure)
Get all the children structures / items from the child table for the give header data structure.
|
JSONArray |
getJSON(java.lang.String tableName,
java.lang.String whereClause)
Get data from the database as
JSDataStructure objects for the given table name. |
JSONArray |
getJSONDataStructuresFromCursor(Cursor cursor) |
<T> java.util.List<T> |
getTypedDS(java.lang.String tableName,
java.lang.String whereClause,
java.lang.String[] orderByFields,
java.lang.Class className)
Get data from the database as "typed"
IDataStructure objects for the given table name. |
void |
insert(IDataStructure dataStructure)
Insert the
IDataStructure into the database. |
void |
insertJSON(java.lang.String tableName,
JSONObject jsonObject) |
void |
insertOrUpdateBasedOnGID(IDataStructure dataStructure)
Inserts or updates the
IDataStructure into the database. |
void |
insertOrUpdateBasedOnGIDJSON(java.lang.String tableName,
JSONObject jsonObject) |
java.lang.Object |
max(java.lang.String structureName,
java.lang.String fieldName,
java.lang.String whereClause)
Get the maximum value of the required field in the database table which match the where clause.
|
java.lang.Object |
min(java.lang.String structureName,
java.lang.String fieldName,
java.lang.String whereClause)
Get the minimum value of the required field in the database table which match the where clause.
|
void |
openOrCreate(java.lang.String key) |
void |
printDBSize() |
void |
releaseSavepoint(java.lang.String savePointName)
Method releaseSavepoint.
|
void |
rollbackToSavepoint(java.lang.String savePointName)
Method rollbackToSavepoint.
|
java.lang.Object |
total(java.lang.String structureName,
java.lang.String fieldName,
java.lang.String whereClause)
Get the total value of the required field in the database table which match the where clause.
|
void |
update(IDataStructure dataStructure)
Update the
IDataStructure into the database. |
void |
update(java.lang.String structureName,
java.lang.String[] columnNames,
java.lang.Object[] columnValues,
java.lang.String whereClause)
Update the table rows' columns with the provided values based on the where clause.
|
void |
updateJSON(java.lang.String tableName,
JSONObject jsonObject,
java.lang.String whereClause) |
void openOrCreate(java.lang.String key)
throws DBException
DBExceptionboolean exists()
throws DBException
DBExceptionvoid close()
throws DBException
DBExceptionvoid beginTransaction()
throws DBException
DBExceptionvoid endTransaction()
throws DBException
DBExceptionvoid dropDatabase()
throws DBException
DBExceptionvoid dropTable(java.lang.String structureName)
throws DBException
DBExceptionvoid createTable(java.lang.String structureName,
java.lang.String[] columnNames,
java.lang.String[] columnTypes,
java.lang.String[] primaryKeys)
throws DBException
DBExceptionvoid createTable(java.lang.String structureName,
java.lang.String[] columnNames,
java.lang.String[] columnTypes,
java.lang.String[] primaryKeys,
java.lang.String[] uniqueKeys)
throws DBException
DBExceptionvoid createTable(java.lang.String structureName,
java.lang.String[] columnNames,
java.lang.String[] columnTypes,
java.lang.String[] primaryKeys,
java.lang.String[] uniqueKeys,
boolean[] mandatoryFields,
java.lang.String[] foreignKeys,
java.lang.String headerStructureName,
java.lang.String[] headerStructureKeys)
throws DBException
DBExceptionvoid createIndex(java.lang.String indexName,
java.lang.String structureName,
java.lang.String[] fieldNames)
throws DBException
DBExceptionvoid dropIndex(java.lang.String indexName)
throws DBException
DBExceptionIDataStructure checkDuplicateGID(IDataStructure dataStructure) throws DBException
DBExceptionvoid insert(IDataStructure dataStructure) throws DBException
IDataStructure into the database. Create an instance of the IDataStructure (implementation).
Set the required fields. Insert the data structure.dataStructure - Data Structure (header or item / structure) that is to be inserted in the databaseDBException - Throws a DBException if the DB is inaccessiblevoid insertOrUpdateBasedOnGID(IDataStructure dataStructure) throws DBException
IDataStructure into the database. Data structure is identified based on
the GID fields in the data model and if it exists the data structure is updated, otherwise inserted.
Convenience method used when it is not known if the data structure is already existing in the database.
dataStructure - Data Structure (header or item / structure) that is to be inserted / updates in the databaseDBException - Throws a DBException if the DB is inaccessiblevoid delete(IDataStructure dataStructure) throws DBException
dataStructure - Data Structure (header or item / structure) that is to be inserted / updates in the databaseDBException - Throws a DBException if the DB is inaccessiblevoid delete(java.lang.String structureName)
throws DBException
structureName - Table where data should be deleted.DBException - Throws a DBException if the DB is inaccessiblevoid delete(java.lang.String structureName,
java.lang.String whereClause)
throws DBException
Where clause has to be manually constructed with the correct keywords supported by the database. Ex: WHERE sales_order_status = '1' AND customer_no = 'abc'
structureName - Table where data should be deleted.whereClause - Where clause to filter the rowsDBException - Throws a DBException if the DB is inaccessiblevoid update(IDataStructure dataStructure) throws DBException
IDataStructure into the database. Update an instance of the IDataStructure (implementation).
Set the required fields. Update the data structure.
The data structure can be obtained using get(..) methods before updating.
dataStructure - Data Structure (header or item / structure) that is to be updated in the databaseDBException - Throws a DBException if the DB is inaccessiblevoid update(java.lang.String structureName,
java.lang.String[] columnNames,
java.lang.Object[] columnValues,
java.lang.String whereClause)
throws DBException
Where clause has to be manually constructed with the correct keywords supported by the database. Ex: WHERE sales_order_status = '1' AND customer_no = 'abc'
structureName - Table required to be updatedcolumnNames - Array of column names that has to be updatedcolumnValues - Array of column values for the column nameswhereClause - Where clause to filter the rowsDBException - Throws a DBException if the DB is inaccessibleIDataStructure[] get(java.lang.String structureName) throws DBException
IDataStructure objects for the given table name.structureName - Table name from where data has to be fetchedDBException - Throws a DBException if the DB is inaccessibleIDataStructure[] get(java.lang.String structureName, java.lang.String[] orderByFields) throws DBException
IDataStructure objects for the given table name.
The data structures are ordered by the fields provided in the array.structureName - Table name from where data has to be fetchedorderByFields - String[] Array of fields to order the data fetched from the database. If there are
multiple fields then the data is ordered according to the array index.DBException - Throws a DBException if the DB is inaccessibleIDataStructure[] get(java.lang.String structureName, java.lang.String[] orderByFields, IDataManager.ORDER_TYPE orderType) throws DBException
DBExceptionIDataStructure[] get(java.lang.String structureName, java.lang.String whereClause) throws DBException
IDataStructure objects for the given table name.
Data is fetched based on the 'where clause'. 'where clause' should NOT contain the key
word 'where'. Note all values have to be within single quotes.
Example for 'where clause':
// Raw code
String whereClause = "SALES_ORDER_TYPE = 'ABC' AND TOTAL_AMOUNT > '10000'";
// Using some constants
String whereClause = SALES_ORDER_HEADER.SALES_ORDER_TYPE + " = '" + AppConstants.SALES_ORDER_STANDARD_TYPE + "' AND"
SALES_ORDER_HEADER.TOTAL_AMOUNT + " > '" + totalAmount + "'";
structureName - Table name from where data has to be fetchedwhereClause - Where clause to filter dataDBException - Throws a DBException if the DB is inaccessibleIDataStructure[] get(java.lang.String structureName, java.lang.String whereClause, java.lang.String[] orderByFields) throws DBException
IDataStructure objects for the given table name.
The data structures are ordered by the fields provided in the array.
Data is fetched based on the 'where clause'. The data structures are ordered by the fields provided in the array.
'where clause' should NOT contain the key word 'where'. Note all values have to be within single quotes.
Example for 'where clause':
// Raw code
String whereClause = "SALES_ORDER_TYPE = 'ABC' AND TOTAL_AMOUNT > '10000'";
// Using some constants
String whereClause = SALES_ORDER_HEADER.SALES_ORDER_TYPE + " = '" + AppConstants.SALES_ORDER_STANDARD_TYPE + "' AND"
SALES_ORDER_HEADER.TOTAL_AMOUNT + " > '" + totalAmount + "'";
structureName - Table name from where data has to be fetchedwhereClause - Where clause to filter dataorderByFields - String[] Array of fields to order the data fetched from the database. If there are
multiple fields then the data is ordered according to the array index.DBException - Throws a DBException if the DB is inaccessibleIDataStructure[] get(java.lang.String structureName, java.lang.String whereClause, java.lang.String[] orderByFields, IDataManager.ORDER_TYPE orderType) throws DBException
IDataStructure objects for the given table name.
The data structures are ordered by the fields provided in the array.
Data is fetched based on the 'where clause'. The data structures are ordered by the fields provided in the array.
'where clause' should NOT contain the key word 'where'. Note all values have to be within single quotes.
Example for 'where clause':
// Raw code
String whereClause = "SALES_ORDER_TYPE = 'ABC' AND TOTAL_AMOUNT > '10000'";
// Using some constants
String whereClause = SALES_ORDER_HEADER.SALES_ORDER_TYPE + " = '" + AppConstants.SALES_ORDER_STANDARD_TYPE + "' AND"
SALES_ORDER_HEADER.TOTAL_AMOUNT + " > '" + totalAmount + "'";
structureName - Table name from where data has to be fetchedwhereClause - Where clause to filter dataorderByFields - String[] Array of fields to order the data fetched from the database. If there areorderType - order by ascending or descending.
multiple fields then the data is ordered according to the array index.DBException - Throws a DBException if the DB is inaccessibleIDataStructure[] get(java.lang.String structureName, java.lang.Class className) throws DBException
DBExceptionIDataStructure[] get(java.lang.String structureName, java.lang.String[] orderByFields, java.lang.Class className) throws DBException
DBExceptionIDataStructure[] get(java.lang.String structureName, java.lang.String whereClause, java.lang.Class className) throws DBException
DBExceptionIDataStructure[] get(java.lang.String structureName, java.lang.String whereClause, java.lang.String[] orderByFields, java.lang.Class className) throws DBException
DBExceptionIDataStructure getBasedOnGID(IDataStructure dataStructure) throws DBException
IDataStructure from the database based on GID.dataStructure - Data Structure (header or item / structure) that is to be fetched from the databaseDBException - Throws a DBException if the DB is inaccessibleIDataStructure[] getChildren(java.lang.String structureName, IDataStructure headerDataStructure) throws DBException
structureName - Table name from where data has to be fetchedheaderDataStructure - Header data structureDBException - Throws a DBException if the DB is inaccessibleIDataStructure[] getChildren(java.lang.String structureName, java.lang.String whereClause, java.lang.String[] orderByFields, IDataStructure headerDataStructure) throws DBException
Example for 'where clause':
// Raw code
String whereClause = "SALES_ORDER_TYPE = 'ABC' AND TOTAL_AMOUNT > '10000'";
// Using some constants
String whereClause = SALES_ORDER_HEADER.SALES_ORDER_TYPE + " = '" + AppConstants.SALES_ORDER_STANDARD_TYPE + "' AND"
SALES_ORDER_HEADER.TOTAL_AMOUNT + " > '" + totalAmount + "'";
structureName - Table name from where data has to be fetchedwhereClause - Where clause to filter dataorderByFields - String[] Array of fields to order the data fetched from the database. If there are
multiple fields then the data is ordered according to the array index.headerDataStructure - Header data structureDBException - Throws a DBException if the DB is inaccessibleIDataStructure[] getChildren(java.lang.String structureName, java.lang.String[] orderByFields, IDataStructure headerDataStructure) throws DBException
structureName - Table name from where data has to be fetchedorderByFields - String[] Array of fields to order the data fetched from the database. If there are
multiple fields then the data is ordered according to the array index.headerDataStructure - Header data structureDBException - Throws a DBException if the DB is inaccessiblejava.util.Hashtable<java.lang.String,IDataStructure[]> getAllChildren(IDataStructure headerDataStructure) throws DBException
headerDataStructure - Header data structure.Hashtable. Hashtable of data structure objects from the children tables.
The hashtable contains the child structure / item name as the key and an array of data structures as the value.DBException - Throws a DBException if the DB is inaccessibleint count(java.lang.String structureName,
java.lang.String whereClause)
throws DBException
Example for 'where clause':
// Raw code
String whereClause = "SALES_ORDER_TYPE = 'ABC' AND TOTAL_AMOUNT > '10000'";
// Using some constants
String whereClause = SALES_ORDER_HEADER.SALES_ORDER_TYPE + " = '" + AppConstants.SALES_ORDER_STANDARD_TYPE + "' AND"
SALES_ORDER_HEADER.TOTAL_AMOUNT + " > '" + totalAmount + "'";
structureName - Table name from where data has to be fetchedwhereClause - Where clause to filter dataDBException - Throws a DBException if the DB is inaccessiblejava.lang.Object max(java.lang.String structureName,
java.lang.String fieldName,
java.lang.String whereClause)
throws DBException
Example for 'where clause':
// Raw code
String whereClause = "SALES_ORDER_TYPE = 'ABC' AND TOTAL_AMOUNT > '10000'";
// Using some constants
String whereClause = SALES_ORDER_HEADER.SALES_ORDER_TYPE + " = '" + AppConstants.SALES_ORDER_STANDARD_TYPE + "' AND"
SALES_ORDER_HEADER.TOTAL_AMOUNT + " > '" + totalAmount + "'";
structureName - Table name from where data has to be fetchedfieldName - Field whose max value is requiredwhereClause - Where clause to filter dataDBException - Throws a DBException if the DB is inaccessiblejava.lang.Object min(java.lang.String structureName,
java.lang.String fieldName,
java.lang.String whereClause)
throws DBException
Example for 'where clause':
// Raw code
String whereClause = "SALES_ORDER_TYPE = 'ABC' AND TOTAL_AMOUNT > '10000'";
// Using some constants
String whereClause = SALES_ORDER_HEADER.SALES_ORDER_TYPE + " = '" + AppConstants.SALES_ORDER_STANDARD_TYPE + "' AND"
SALES_ORDER_HEADER.TOTAL_AMOUNT + " > '" + totalAmount + "'";
structureName - Table name from where data has to be fetchedfieldName - Field whose min value is requiredwhereClause - Where clause to filter dataDBException - Throws a DBException if the DB is inaccessiblejava.lang.Object total(java.lang.String structureName,
java.lang.String fieldName,
java.lang.String whereClause)
throws DBException
Example for 'where clause':
// Raw code
String whereClause = "SALES_ORDER_TYPE = 'ABC' AND TOTAL_AMOUNT > '10000'";
// Using some constants
String whereClause = SALES_ORDER_HEADER.SALES_ORDER_TYPE + " = '" + AppConstants.SALES_ORDER_STANDARD_TYPE + "' AND"
SALES_ORDER_HEADER.TOTAL_AMOUNT + " > '" + totalAmount + "'";
structureName - Table name from where data has to be fetchedfieldName - Field whose min value is requiredwhereClause - Where clause to filter dataDBException - Throws a DBException if the DB is inaccessiblevoid execute(java.lang.String sqlStatement)
throws DBException
sqlStatement - Single SQL statement that has to be executedDBException - Throws a DBException if the DB is inaccessiblevoid executeBindQuery(java.lang.String sqlStatement,
java.lang.Object[] columnValues)
throws DBException
sqlStatement - Single SQL statement that has to be executedcolumnValues - Column values that have to be bound to the SQL statementDBException - Throws a DBException if the DB is inaccessibleCursor executeQuery(java.lang.String sqlStatement)
throws DBException
Cursor over the result set.sqlStatement - Single SQL statement that has to be executedandroid.database.Cursor to the result set from the databaseDBException - Throws a DBException if the DB is inaccessiblevoid rollbackToSavepoint(java.lang.String savePointName)
throws DBException
savePointName - StringDBExceptionvoid releaseSavepoint(java.lang.String savePointName)
throws DBException
savePointName - StringDBExceptionvoid createSavepoint(java.lang.String savePointName)
throws DBException
savePointName - StringDBException<T> java.util.List<T> getTypedDS(java.lang.String tableName,
java.lang.String whereClause,
java.lang.String[] orderByFields,
java.lang.Class className)
throws DBException
IDataStructure objects for the given table name.
The data structures are ordered by the fields provided in the array.
Data is fetched based on the 'where clause'. The data structures are ordered by the fields provided in the array.
'where clause' should NOT contain the key word 'where'. Note all values have to be within single quotes.
Example for 'where clause':
// Raw code
String whereClause = "SALES_ORDER_TYPE = 'ABC' AND TOTAL_AMOUNT > '10000'";
// Using some constants
String whereClause = SALES_ORDER_HEADER.SALES_ORDER_TYPE + " = '" + AppConstants.SALES_ORDER_STANDARD_TYPE + "' AND"
SALES_ORDER_HEADER.TOTAL_AMOUNT + " > '" + totalAmount + "'";
tableName - Table name from where data has to be fetchedwhereClause - Where clause to filter dataorderByFields - String[] Array of fields to order the data fetched from the database. If there are
multiple fields then the data is ordered according to the array index.DBException - Throws a DBException if the DB is inaccessiblevoid printDBSize()
void insertJSON(java.lang.String tableName,
JSONObject jsonObject)
throws DBException
DBExceptionJSONArray getJSON(java.lang.String tableName,
java.lang.String whereClause)
throws DBException
JSDataStructure objects for the given table name.
Data is fetched based on the 'where clause'. 'where clause' should NOT contain the key
word 'where'. Note all values have to be within single quotes.tableName - Table name from where data has to be fetchedwhereClause - Where clause to filter dataJSDataStructure objects from the tableDBException - Throws a DBException if the DB is inaccessible.
For example:get(String, String)JSONArray getChildren(java.lang.String tableName,
com.unvired.model.JSDataStructure headerDataStructure)
throws DBException
tableName - Table name from where data has to be fetchedheaderDataStructure - Header data structureDBException - Throws a DBException if the DB is inaccessiblejava.util.Hashtable<java.lang.String,JSONArray> getAllChildren(com.unvired.model.JSDataStructure headerDataStructure)
throws DBException
headerDataStructure - Header data structure.HashtableHashtable of data structure objects from the children tables.
The hashtable contains the child structure / item name as the key and an array of data structures as the value.DBException - Throws a DBException if the DB is inaccessiblevoid updateJSON(java.lang.String tableName,
JSONObject jsonObject,
java.lang.String whereClause)
throws DBException
DBExceptionvoid insertOrUpdateBasedOnGIDJSON(java.lang.String tableName,
JSONObject jsonObject)
throws DBException
DBExceptionJSONArray getJSONDataStructuresFromCursor(Cursor cursor)
throws DBException
DBExceptionCopyright © 2017 Unvired Inc. All Rights Reserved.