use of com.j256.ormlite.stmt.Where in project ETSMobile-Android2 by ApplETS.
the class NoteManager method deleteExpiredListeDesElementsEvaluation.
/**
* Deletes marks in DB that doesn't exist on API
*
* @param
*/
private void deleteExpiredListeDesElementsEvaluation(String id) {
DatabaseHelper dbHelper = new DatabaseHelper(context);
try {
Dao<ListeDesElementsEvaluation, String> listeDesElementsEvaluationDao = dbHelper.getDao(ListeDesElementsEvaluation.class);
ListeDesElementsEvaluation listeDesElementsEvaluation = listeDesElementsEvaluationDao.queryForId(id);
if (listeDesElementsEvaluation != null) {
Dao<ElementEvaluation, String> elementsEvaluationDao = dbHelper.getDao(ElementEvaluation.class);
DeleteBuilder<ElementEvaluation, String> deleteBuilder = elementsEvaluationDao.deleteBuilder();
Where where = deleteBuilder.where();
where.eq("listeDesElementsEvaluation_id", listeDesElementsEvaluation);
deleteBuilder.delete();
}
listeDesElementsEvaluationDao.deleteById(id);
} catch (SQLException e) {
e.printStackTrace();
}
}
use of com.j256.ormlite.stmt.Where in project ETSMobile-Android2 by ApplETS.
the class NoteManager method deleteExpiredElementsEvaluation.
/**
* Deletes marks in DB that doesn't exist on API
*
* @param
*/
public void deleteExpiredElementsEvaluation(ListeDesElementsEvaluation listeDesElementsEvaluation) {
DatabaseHelper dbHelper = new DatabaseHelper(context);
HashMap<String, ElementEvaluation> elementEvaluationHashMap = new HashMap<String, ElementEvaluation>();
for (ElementEvaluation elem : listeDesElementsEvaluation.liste) {
String id = listeDesElementsEvaluation.id + elem.nom;
elementEvaluationHashMap.put(id, elem);
}
List<ElementEvaluation> elementEvaluationList = null;
try {
Dao<ElementEvaluation, String> elementsEvaluationDao = dbHelper.getDao(ElementEvaluation.class);
QueryBuilder<ElementEvaluation, String> builder = elementsEvaluationDao.queryBuilder();
Where where = builder.where();
where.eq("listeDesElementsEvaluation_id", listeDesElementsEvaluation);
elementEvaluationList = builder.query();
for (ElementEvaluation element : elementEvaluationList) {
if (!elementEvaluationHashMap.containsKey(element.id))
elementsEvaluationDao.deleteById(element.id);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
use of com.j256.ormlite.stmt.Where in project ETSMobile-Android2 by ApplETS.
the class NoteManager method getElementsEvaluation.
public List<ElementEvaluation> getElementsEvaluation(ListeDesElementsEvaluation listeDesElementsEvaluation) {
DatabaseHelper dbHelper = new DatabaseHelper(context);
List<ElementEvaluation> elementEvaluationList = null;
try {
Dao<ElementEvaluation, String> elementsEvaluationDao = dbHelper.getDao(ElementEvaluation.class);
QueryBuilder<ElementEvaluation, String> builder = elementsEvaluationDao.queryBuilder();
Where where = builder.where();
where.eq("listeDesElementsEvaluation_id", listeDesElementsEvaluation);
elementEvaluationList = builder.query();
} catch (SQLException e) {
Log.e("SQL Exception", e.getMessage());
}
return elementEvaluationList;
}
Aggregations