use of ca.etsmtl.applets.etsmobile.model.Cours in project ETSMobile-Android2 by ApplETS.
the class NoteManager method deleteExpiredCours.
/**
* Deletes courses in DB that doesn't exist on API
*
* @param
*/
public void deleteExpiredCours(ListeDeCours listeDeCours) {
DatabaseHelper dbHelper = new DatabaseHelper(context);
HashMap<String, Cours> coursHashMap = new HashMap<String, Cours>();
for (Cours cours : listeDeCours.liste) {
cours.id = cours.sigle + cours.session;
coursHashMap.put(cours.id, cours);
}
ArrayList<Cours> dbCours = new ArrayList<Cours>();
try {
dbCours = (ArrayList<Cours>) dbHelper.getDao(Cours.class).queryForAll();
ArrayList<ListeDesElementsEvaluation> dbliste = (ArrayList<ListeDesElementsEvaluation>) dbHelper.getDao(ListeDesElementsEvaluation.class).queryForAll();
for (Cours coursNew : dbCours) {
if (!coursHashMap.containsKey(coursNew.id)) {
Dao<Cours, String> coursDao = dbHelper.getDao(Cours.class);
coursDao.deleteById(coursNew.id);
deleteExpiredListeDesElementsEvaluation(coursNew.id);
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
use of ca.etsmtl.applets.etsmobile.model.Cours in project ETSMobile-Android2 by ApplETS.
the class NoteManager method updateCours.
public void updateCours(List<Cours> coursList) {
DatabaseHelper dbHelper = new DatabaseHelper(context);
try {
for (Cours cours : coursList) {
// Id field upgraded to make difference between upgrading row or creating row
cours.id = cours.sigle + cours.session;
dbHelper.getDao(Cours.class).createOrUpdate(cours);
}
} catch (SQLException e) {
Log.e("SQL Exception", e.getMessage());
}
}
use of ca.etsmtl.applets.etsmobile.model.Cours in project ETSMobile-Android2 by ApplETS.
the class NoteManager method getCours.
public ArrayList<Cours> getCours() {
DatabaseHelper dbHelper = new DatabaseHelper(context);
ArrayList<Cours> coursList = null;
try {
coursList = (ArrayList<Cours>) dbHelper.getDao(Cours.class).queryForAll();
} catch (SQLException e) {
Log.e("SQL Exception", e.getMessage());
}
return coursList;
}
Aggregations