use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.
the class ByteDaoImpl method delete.
/**
* <h2>SQL delete</h2>
* <pre>DELETE FROM byte_bean WHERE value=${value} and value2=${value2}</pre>
*
* <h2>Where parameters:</h2>
* <dl>
* <dt>${value}</dt><dd>is mapped to method's parameter <strong>value</strong></dd>
* <dt>${value2}</dt><dd>is mapped to method's parameter <strong>value2</strong></dd>
* </dl>
*
* @param value
* is used as where parameter <strong>${value}</strong>
* @param value2
* is used as where parameter <strong>${value2}</strong>
*
* @return number of deleted records
*/
@Override
public long delete(byte[] value, Byte[] value2) {
if (deletePreparedStatement3 == null) {
// generate static SQL for statement
String _sql = "DELETE FROM byte_bean WHERE value=? and value2=?";
deletePreparedStatement3 = KriptonDatabaseWrapper.compile(_context, _sql);
}
KriptonContentValues _contentValues = contentValuesForUpdate(deletePreparedStatement3);
_contentValues.addWhereArgs((value == null ? "" : new String(value, StandardCharsets.UTF_8)));
_contentValues.addWhereArgs((value2 == null ? "" : new String(serializer1(value2), StandardCharsets.UTF_8)));
// log section BEGIN
if (_context.isLogEnabled()) {
// display log
Logger.info("DELETE FROM byte_bean WHERE value=? and value2=?");
// log for where parameters -- BEGIN
int _whereParamCounter = 0;
for (String _whereParamItem : _contentValues.whereArgs()) {
Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
}
// log for where parameters -- END
}
// log section END
int result = KriptonDatabaseWrapper.updateDelete(deletePreparedStatement3, _contentValues);
return result;
}
use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.
the class ByteDaoImpl method selectOne.
/**
* <h2>Select SQL:</h2>
*
* <pre>SELECT id, value, value2 FROM byte_bean WHERE value=${value} and value2=${value2}</pre>
*
* <h2>Projected columns:</h2>
* <dl>
* <dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
* <dt>value</dt><dd>is associated to bean's property <strong>value</strong></dd>
* <dt>value2</dt><dd>is associated to bean's property <strong>value2</strong></dd>
* </dl>
*
* <h2>Query's parameters:</h2>
* <dl>
* <dt>${value}</dt><dd>is binded to method's parameter <strong>value</strong></dd>
* <dt>${value2}</dt><dd>is binded to method's parameter <strong>value2</strong></dd>
* </dl>
*
* @param value
* is binded to <code>${value}</code>
* @param value2
* is binded to <code>${value2}</code>
* @param listener
* is the ByteBean listener
*/
@Override
public void selectOne(byte[] value, Byte[] value2, OnReadBeanListener<ByteBean> listener) {
KriptonContentValues _contentValues = contentValues();
// query SQL is statically defined
String _sql = SELECT_ONE_SQL3;
// add where arguments
_contentValues.addWhereArgs((value == null ? "" : new String(value, StandardCharsets.UTF_8)));
_contentValues.addWhereArgs((value2 == null ? "" : new String(serializer1(value2), StandardCharsets.UTF_8)));
String[] _sqlArgs = _contentValues.whereArgsAsArray();
// log section BEGIN
if (_context.isLogEnabled()) {
// manage log
Logger.info(_sql);
// log for where parameters -- BEGIN
int _whereParamCounter = 0;
for (String _whereParamItem : _contentValues.whereArgs()) {
Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
}
// log for where parameters -- END
}
// log section END
try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
// log section BEGIN
if (_context.isLogEnabled()) {
Logger.info("Rows found: %s", _cursor.getCount());
}
// log section END
ByteBean resultBean = new ByteBean();
if (_cursor.moveToFirst()) {
int index0 = _cursor.getColumnIndex("id");
int index1 = _cursor.getColumnIndex("value");
int index2 = _cursor.getColumnIndex("value2");
int rowCount = _cursor.getCount();
do {
// reset mapping
// id does not need reset
resultBean.setValue(null);
resultBean.setValue2(null);
// generate mapping
resultBean.setId(_cursor.getLong(index0));
if (!_cursor.isNull(index1)) {
resultBean.setValue(_cursor.getBlob(index1));
}
if (!_cursor.isNull(index2)) {
resultBean.setValue2(ByteBeanTable.parseValue2(_cursor.getBlob(index2)));
}
listener.onRead(resultBean, _cursor.getPosition(), rowCount);
} while (_cursor.moveToNext());
}
}
}
use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.
the class BeanDaoImpl method insertURL.
/**
* <h2>SQL insert</h2>
* <pre>INSERT INTO bean (value_url) VALUES (${valueUrl})</pre>
*
* <h2>Inserted columns:</strong></h2>
* <dl>
* <dt>valueUrl</dt><dd>is binded to query's parameter <strong>${valueUrl}</strong> and method's parameter <strong>valueUrl</strong></dd>
* </dl>
*
* @param valueUrl
* is binded to column value <strong>value_url</strong>
*
* @return <strong>id</strong> of inserted record
*/
@Override
public long insertURL(URL valueUrl) {
if (insertURLPreparedStatement62 == null) {
// generate static SQL for statement
String _sql = "INSERT INTO bean (value_url) VALUES (?)";
insertURLPreparedStatement62 = KriptonDatabaseWrapper.compile(_context, _sql);
}
KriptonContentValues _contentValues = contentValuesForUpdate(insertURLPreparedStatement62);
_contentValues.put("value_url", UrlUtils.write(valueUrl));
// log section BEGIN
if (_context.isLogEnabled()) {
// log for insert -- BEGIN
StringBuffer _columnNameBuffer = new StringBuffer();
StringBuffer _columnValueBuffer = new StringBuffer();
String _columnSeparator = "";
for (String columnName : _contentValues.keys()) {
_columnNameBuffer.append(_columnSeparator + columnName);
_columnValueBuffer.append(_columnSeparator + ":" + columnName);
_columnSeparator = ", ";
}
Logger.info("INSERT INTO bean (%s) VALUES (%s)", _columnNameBuffer.toString(), _columnValueBuffer.toString());
// log for content values -- BEGIN
Triple<String, Object, KriptonContentValues.ParamType> _contentValue;
for (int i = 0; i < _contentValues.size(); i++) {
_contentValue = _contentValues.get(i);
if (_contentValue.value1 == null) {
Logger.info("==> :%s = <null>", _contentValue.value0);
} else {
Logger.info("==> :%s = '%s' (%s)", _contentValue.value0, StringUtils.checkSize(_contentValue.value1), _contentValue.value1.getClass().getCanonicalName());
}
}
// log for content values -- END
// log for insert -- END
// log for where parameters -- BEGIN
int _whereParamCounter = 0;
for (String _whereParamItem : _contentValues.whereArgs()) {
Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
}
// log for where parameters -- END
}
// log section END
// insert operation
long result = KriptonDatabaseWrapper.insert(insertURLPreparedStatement62, _contentValues);
return result;
}
use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.
the class BeanDaoImpl method deleteDate.
/**
* <h2>SQL delete</h2>
* <pre>DELETE FROM bean WHERE value_date=${valueDate}</pre>
*
* <h2>Where parameters:</h2>
* <dl>
* <dt>${valueDate}</dt><dd>is mapped to method's parameter <strong>valueDate</strong></dd>
* </dl>
*
* @param valueDate
* is used as where parameter <strong>${valueDate}</strong>
*
* @return number of deleted records
*/
@Override
public long deleteDate(Date valueDate) {
if (deleteDatePreparedStatement13 == null) {
// generate static SQL for statement
String _sql = "DELETE FROM bean WHERE value_date=?";
deleteDatePreparedStatement13 = KriptonDatabaseWrapper.compile(_context, _sql);
}
KriptonContentValues _contentValues = contentValuesForUpdate(deleteDatePreparedStatement13);
_contentValues.addWhereArgs((valueDate == null ? "" : DateUtils.write(valueDate)));
// log section BEGIN
if (_context.isLogEnabled()) {
// display log
Logger.info("DELETE FROM bean WHERE value_date=?");
// log for where parameters -- BEGIN
int _whereParamCounter = 0;
for (String _whereParamItem : _contentValues.whereArgs()) {
Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
}
// log for where parameters -- END
}
// log section END
int result = KriptonDatabaseWrapper.updateDelete(deleteDatePreparedStatement13, _contentValues);
return result;
}
use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.
the class BeanDaoImpl method insertByteType.
/**
* <h2>SQL insert</h2>
* <pre>INSERT INTO bean (value_byte_type) VALUES (${valueByteType})</pre>
*
* <h2>Inserted columns:</strong></h2>
* <dl>
* <dt>valueByteType</dt><dd>is binded to query's parameter <strong>${valueByteType}</strong> and method's parameter <strong>valueByteType</strong></dd>
* </dl>
*
* @param valueByteType
* is binded to column value <strong>value_byte_type</strong>
*
* @return <strong>id</strong> of inserted record
*/
@Override
public long insertByteType(byte valueByteType) {
if (insertByteTypePreparedStatement40 == null) {
// generate static SQL for statement
String _sql = "INSERT INTO bean (value_byte_type) VALUES (?)";
insertByteTypePreparedStatement40 = KriptonDatabaseWrapper.compile(_context, _sql);
}
KriptonContentValues _contentValues = contentValuesForUpdate(insertByteTypePreparedStatement40);
_contentValues.put("value_byte_type", valueByteType);
// log section BEGIN
if (_context.isLogEnabled()) {
// log for insert -- BEGIN
StringBuffer _columnNameBuffer = new StringBuffer();
StringBuffer _columnValueBuffer = new StringBuffer();
String _columnSeparator = "";
for (String columnName : _contentValues.keys()) {
_columnNameBuffer.append(_columnSeparator + columnName);
_columnValueBuffer.append(_columnSeparator + ":" + columnName);
_columnSeparator = ", ";
}
Logger.info("INSERT INTO bean (%s) VALUES (%s)", _columnNameBuffer.toString(), _columnValueBuffer.toString());
// log for content values -- BEGIN
Triple<String, Object, KriptonContentValues.ParamType> _contentValue;
for (int i = 0; i < _contentValues.size(); i++) {
_contentValue = _contentValues.get(i);
if (_contentValue.value1 == null) {
Logger.info("==> :%s = <null>", _contentValue.value0);
} else {
Logger.info("==> :%s = '%s' (%s)", _contentValue.value0, StringUtils.checkSize(_contentValue.value1), _contentValue.value1.getClass().getCanonicalName());
}
}
// log for content values -- END
// log for insert -- END
// log for where parameters -- BEGIN
int _whereParamCounter = 0;
for (String _whereParamItem : _contentValues.whereArgs()) {
Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
}
// log for where parameters -- END
}
// log section END
// insert operation
long result = KriptonDatabaseWrapper.insert(insertByteTypePreparedStatement40, _contentValues);
return result;
}
Aggregations