Java Code Examples for com.j256.ormlite.dao.Dao#deleteById()
The following examples show how to use
com.j256.ormlite.dao.Dao#deleteById() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NoteManager.java From ETSMobile-Android2 with Apache License 2.0 | 6 votes |
/** * Deletes trimestres in DB that doesn't exist on API * * @param */ public void deleteExpiredTrimestres(ListeDeSessions listeDeSessions) { DatabaseHelper dbHelper = new DatabaseHelper(context); HashMap<String, Trimestre> trimestresHashMap = new HashMap<String, Trimestre>(); for (Trimestre trimestre : listeDeSessions.liste) { trimestresHashMap.put(trimestre.abrege, trimestre); } ArrayList<Trimestre> dbTrimestres = new ArrayList<Trimestre>(); try { dbTrimestres = (ArrayList<Trimestre>) dbHelper.getDao(Trimestre.class).queryForAll(); for (Trimestre trimestreNew : dbTrimestres) { if (!trimestresHashMap.containsKey(trimestreNew.abrege)) { Dao<Trimestre, String> trimestreDao = dbHelper.getDao(Trimestre.class); trimestreDao.deleteById(trimestreNew.abrege); } } } catch (SQLException e) { e.printStackTrace(); } }
Example 2
Source File: NoteManager.java From ETSMobile-Android2 with Apache License 2.0 | 6 votes |
/** * 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(); } }
Example 3
Source File: HoraireManager.java From ETSMobile-Android2 with Apache License 2.0 | 6 votes |
/** * Deletes entries in DB that doesn't exist on API * * @param */ private void deleteExpiredEvent(EventList envEventList) { DatabaseHelper dbHelper = new DatabaseHelper(context); ArrayList<Event> dbEvents = new ArrayList<Event>(); try { dbEvents = (ArrayList<Event>) dbHelper.getDao(Event.class).queryForAll(); for (Event eventsNew : dbEvents) { if (!dbEvents.contains(eventsNew.getId())) { Dao<Event, String> eventDao = dbHelper.getDao(Event.class); eventDao.deleteById(eventsNew.getId()); } } } catch (SQLException e) { e.printStackTrace(); } }
Example 4
Source File: UserDao.java From renrenpay-android with Apache License 2.0 | 5 votes |
public static boolean delete(int id) { try { Dao<User, Integer> dao = DatabaseHelper.getDbHelper().getDao(User.class); return dao.deleteById(id) > 0; } catch(SQLException e) { // ExceptionUtils.report(e); e.printStackTrace(); return false; } }
Example 5
Source File: AbstractDao.java From privacy-friendly-shopping-list with Apache License 2.0 | 5 votes |
protected boolean deleteById(Long id, Class<T> type) { try { Dao<T, Long> dao = database.getDao(type); dao.deleteById(id); PFALogger.debug(getClass().getName(), DELETE_BY_ID, SUCCESSFUL); return true; } catch ( SQLException e ) { PFALogger.error(getClass().getName(), DELETE_BY_ID + ID + id, e); return false; } }
Example 6
Source File: NoteManager.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
/** * 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(); } }
Example 7
Source File: NoteManager.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
/** * 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(); } }
Example 8
Source File: HoraireManager.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
/** * Deletes entries in DB that doesn't exist on API * * @param listeJoursRemplaces */ private void deleteExpiredJoursRemplaces(listeJoursRemplaces listeJoursRemplaces) { DatabaseHelper dbHelper = new DatabaseHelper(context); HashMap<String, JoursRemplaces> listeJoursRemplacesInAPI = new HashMap<String, JoursRemplaces>(); //Building the list of entries in API for (JoursRemplaces JoursRemplacesInAPI : listeJoursRemplaces.listeJours) { listeJoursRemplacesInAPI.put(JoursRemplacesInAPI.dateOrigine, JoursRemplacesInAPI); } ArrayList<JoursRemplaces> listeJoursRemplacesInDB = new ArrayList<JoursRemplaces>(); //Comparing entries on DB and API try { listeJoursRemplacesInDB = (ArrayList<JoursRemplaces>) dbHelper.getDao(JoursRemplaces.class).queryForAll(); for (JoursRemplaces JoursRemplacesInDB : listeJoursRemplacesInDB) { if (!listeJoursRemplacesInAPI.containsKey((String) JoursRemplacesInDB.dateOrigine)) { Dao<JoursRemplaces, String> JoursRemplacesDao = dbHelper.getDao(JoursRemplaces.class); JoursRemplacesDao.deleteById(JoursRemplacesInDB.dateOrigine); } } } catch (SQLException e) { e.printStackTrace(); } }
Example 9
Source File: HoraireManager.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
/** * Deletes entries in DB that doesn't exist on API * * @param listeSeances */ private void deleteExpiredSeances(listeSeances listeSeances) { DatabaseHelper dbHelper = new DatabaseHelper(context); HashMap<String, Seances> listeSeancesInAPI = new HashMap<String, Seances>(); //Building the list of entries in API for (Seances SeancesInAPI : listeSeances.ListeDesSeances) { SeancesInAPI.id = SeancesInAPI.coursGroupe + SeancesInAPI.dateDebut + SeancesInAPI.dateFin + SeancesInAPI.local; listeSeancesInAPI.put(SeancesInAPI.id, SeancesInAPI); } ArrayList<Seances> listeSeancesInDB = new ArrayList<Seances>(); //Comparing entries on DB and API try { listeSeancesInDB = (ArrayList<Seances>) dbHelper.getDao(Seances.class).queryForAll(); for (Seances SeancesInDB : listeSeancesInDB) { if (!listeSeancesInAPI.containsKey((String) SeancesInDB.id)) { Dao<Seances, String> SeancesDao = dbHelper.getDao(Seances.class); SeancesDao.deleteById(SeancesInDB.id); } } } catch (SQLException e) { e.printStackTrace(); } }
Example 10
Source File: HoraireManager.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
/** * Deletes entries in DB that doesn't exist on API * * @param listeHoraireExamensFinaux */ private void deleteExpiredExamensFinaux(listeHoraireExamensFinaux listeHoraireExamensFinaux) { DatabaseHelper dbHelper = new DatabaseHelper(context); HashMap<String, HoraireExamenFinal> listeHoraireExamenFinalInAPI = new HashMap<String, HoraireExamenFinal>(); //Building the list of entries in API for (HoraireExamenFinal horaireExamenFinalInAPI : listeHoraireExamensFinaux.listeHoraire) { horaireExamenFinalInAPI.id = horaireExamenFinalInAPI.sigle + "-" + horaireExamenFinalInAPI.groupe + horaireExamenFinalInAPI.dateExamen + horaireExamenFinalInAPI.heureDebut + horaireExamenFinalInAPI.heureFin; listeHoraireExamenFinalInAPI.put(horaireExamenFinalInAPI.id, horaireExamenFinalInAPI); } ArrayList<HoraireExamenFinal> listeHoraireExamenFinalInDB = new ArrayList<HoraireExamenFinal>(); //Comparing entries on DB and API try { listeHoraireExamenFinalInDB = (ArrayList<HoraireExamenFinal>) dbHelper.getDao(HoraireExamenFinal.class).queryForAll(); for (HoraireExamenFinal horaireExamenFinalInDB : listeHoraireExamenFinalInDB) { if (!listeHoraireExamenFinalInAPI.containsKey((String) horaireExamenFinalInDB.id)) { Dao<HoraireExamenFinal, String> horaireExamenFinalDao = dbHelper.getDao(HoraireExamenFinal.class); horaireExamenFinalDao.deleteById(horaireExamenFinalInDB.id); } } } catch (SQLException e) { e.printStackTrace(); } }
Example 11
Source File: HoraireManager.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
/** * Deletes entries in DB that doesn't exist on API * * @param listeDesActivitesEtProf API list */ private void deleteExpiredHoraireActivite(listeDesActivitesEtProf listeDesActivitesEtProf) { DatabaseHelper dbHelper = new DatabaseHelper(context); HashMap<String, HoraireActivite> listeHoraireActiviteInAPI = new HashMap<String, HoraireActivite>(); //Building the list of entries in API for (HoraireActivite horaireActiviteInAPI : listeDesActivitesEtProf.listeActivites) { horaireActiviteInAPI.id = "" + horaireActiviteInAPI.sigle + horaireActiviteInAPI.groupe + horaireActiviteInAPI.jour + horaireActiviteInAPI.heureDebut + horaireActiviteInAPI.heureFin; listeHoraireActiviteInAPI.put(horaireActiviteInAPI.id, horaireActiviteInAPI); } ArrayList<HoraireActivite> listeHoraireActiviteInDB = new ArrayList<HoraireActivite>(); //Comparing entries on DB and API try { listeHoraireActiviteInDB = (ArrayList<HoraireActivite>) dbHelper.getDao(HoraireActivite.class).queryForAll(); for (HoraireActivite horaireActiviteInDB : listeHoraireActiviteInDB) { if (!listeHoraireActiviteInAPI.containsKey((String) horaireActiviteInDB.id)) { Dao<HoraireActivite, String> horaireActiviteDao = dbHelper.getDao(HoraireActivite.class); horaireActiviteDao.deleteById(horaireActiviteInDB.id); } } } catch (SQLException e) { e.printStackTrace(); } }