use of ca.etsmtl.applets.etsmobile.db.DatabaseHelper in project ETSMobile-Android2 by ApplETS.
the class BottinSyncJob method updateDb.
private void updateDb(final HashMap<String, List<FicheEmploye>> listeEmployeByService) {
Log.d(TAG, "Mise à jour de la BD");
DatabaseHelper dbHelper = new DatabaseHelper(getContext());
try {
Dao<FicheEmploye, ?> ficheEmployeDao = dbHelper.getDao(FicheEmploye.class);
for (FicheEmploye ficheEmploye : ficheEmployeDao.queryForAll()) {
ficheEmployeDao.delete(ficheEmploye);
}
for (String nomService : listeEmployeByService.keySet()) {
List<FicheEmploye> listeEmployes = listeEmployeByService.get(nomService);
if (listeEmployes.size() > 0) {
for (FicheEmploye ficheEmploye : listeEmployeByService.get(nomService)) {
dbHelper.getDao(FicheEmploye.class).create(ficheEmploye);
}
}
}
} catch (SQLException e) {
e.printStackTrace();
Log.e(DatabaseHelper.class.getName(), "SQLException", e);
throw new RuntimeException(e);
}
}
use of ca.etsmtl.applets.etsmobile.db.DatabaseHelper in project ETSMobile-Android2 by ApplETS.
the class WearService method onMessageReceived.
@Override
public void onMessageReceived(MessageEvent messageEvent) {
if (messageEvent.getPath().equals("/today_req")) {
final String message = new String(messageEvent.getData());
List<Seances> seances = new ArrayList<>();
DatabaseHelper databaseHelper = new DatabaseHelper(this);
SimpleDateFormat seancesFormatter = new SimpleDateFormat("yyyy-MM-dd", getResources().getConfiguration().locale);
try {
seances = databaseHelper.getDao(Seances.class).queryBuilder().where().like("dateDebut", seancesFormatter.format(DateTime.now().toDate()) + "%").query();
Collections.sort(seances, new SeanceComparator());
} catch (SQLException e) {
e.printStackTrace();
}
new SendToDataLayerThread("/today_req", seances, this).start();
}
}
Aggregations