use of ca.etsmtl.applets.etsmobile.db.DatabaseHelper 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 ca.etsmtl.applets.etsmobile.db.DatabaseHelper 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;
}
use of ca.etsmtl.applets.etsmobile.db.DatabaseHelper in project ETSMobile-Android2 by ApplETS.
the class ProfilManager method getProgrammes.
public List<Programme> getProgrammes() {
DatabaseHelper dbHelper = new DatabaseHelper(context);
List<Programme> programmeList = null;
try {
programmeList = dbHelper.getDao(Programme.class).queryForAll();
Collections.sort(programmeList, new ProgrammeComparator());
} catch (SQLException e) {
Log.e("SQL Exception", e.getMessage());
}
return programmeList;
}
use of ca.etsmtl.applets.etsmobile.db.DatabaseHelper in project ETSMobile-Android2 by ApplETS.
the class ProfilManager method removeProfil.
// Called when a user disconnects
public void removeProfil() {
DatabaseHelper dbHelper = new DatabaseHelper(context);
try {
// Delete all rows that contains an Etudiant and listeDesProgrammes classes
dbHelper.getDao(Etudiant.class).deleteBuilder().delete();
dbHelper.getDao(Programme.class).deleteBuilder().delete();
} catch (SQLException e) {
Log.e("SQL Exception", e.getMessage());
}
}
use of ca.etsmtl.applets.etsmobile.db.DatabaseHelper in project ETSMobile-Android2 by ApplETS.
the class TodayFragment method update.
@Override
public void update(Observable observable, Object data) {
dateTime = new DateTime();
databaseHelper = new DatabaseHelper(getActivity());
updateUI();
}
Aggregations