fix typo and alignment; fix bug with cursor and getDrugByCIP13

This commit is contained in:
jacques 2020-07-07 21:36:34 +02:00
parent cb73cdce70
commit f966e32065

View file

@ -67,10 +67,12 @@ class DBMedoc extends SQLiteOpenHelper{
}
@Override
public void onCreate(SQLiteDatabase db) {}
public void onCreate(SQLiteDatabase db) {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
private void copyDatabase(String dbPath) {
Log.d(TAG, "try to copy database");
@ -108,6 +110,7 @@ class DBMedoc extends SQLiteOpenHelper{
/**
* Lookup in the DB for a record corresponding to cpi1
*
* @param cip13 string representing the object we're looking for
* @return return a medicament object
*/
@ -117,31 +120,25 @@ class DBMedoc extends SQLiteOpenHelper{
SQLiteDatabase db = this.getReadableDatabase();
// Build query
Cursor cursor = db.query(TABLE_NAME, // Which table
/*Cursor cursor = db.query(TABLE_NAME, // Which table
COLUMNS_NAMES, // column names
" cip13 =?", // selections
new String[]{cip13}, // selections args
null, // group by
null, // having
null, // order by
null); // limits
if (cursor != null)
cursor.moveToFirst();
null); // limits*/
Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_NAME + " where cip13 = " + cip13, null);
if (cursor.getCount() != 0) {
// Build medicament object
Medicament medicament = new Medicament();
// medicament.setId(Integer.parseInt(cursor.getString(0)));
assert cursor != null;
medicament.setCis(cursor.getString(0));
medicament.setCip13(cursor.getString(1));
medicament.setMode_administration(cursor.getString(2));
medicament.setNom(cursor.getString(3));
medicament.setPresentation(cursor.getString(4));
/*medicament.setStock(Double.parseDouble(cursor.getString(5)));
medicament.setPrise(Double.parseDouble(cursor.getString(6)));
medicament.setWarnThreshold(Integer.parseInt(cursor.getString(7)));
medicament.setAlertThreshold(Integer.parseInt(cursor.getString(8)));*/
// Set default values
medicament.setStock(0);
@ -156,5 +153,7 @@ class DBMedoc extends SQLiteOpenHelper{
cursor.close();
return medicament;
} else
return null;
}
}