Search in sources :

Example 21 with DatabaseHelper

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();
    }
}
Also used : DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper) HashMap(java.util.HashMap) SQLException(java.sql.SQLException) Where(com.j256.ormlite.stmt.Where) ElementEvaluation(ca.etsmtl.applets.etsmobile.model.ElementEvaluation)

Example 22 with DatabaseHelper

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;
}
Also used : DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper) SQLException(java.sql.SQLException) Where(com.j256.ormlite.stmt.Where) ElementEvaluation(ca.etsmtl.applets.etsmobile.model.ElementEvaluation)

Example 23 with DatabaseHelper

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;
}
Also used : DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper) SQLException(java.sql.SQLException) Programme(ca.etsmtl.applets.etsmobile.model.Programme)

Example 24 with DatabaseHelper

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());
    }
}
Also used : DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper) SQLException(java.sql.SQLException)

Example 25 with DatabaseHelper

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();
}
Also used : DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper) DateTime(org.joda.time.DateTime)

Aggregations

DatabaseHelper (ca.etsmtl.applets.etsmobile.db.DatabaseHelper)32 SQLException (java.sql.SQLException)27 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)9 ElementEvaluation (ca.etsmtl.applets.etsmobile.model.ElementEvaluation)4 FicheEmploye (ca.etsmtl.applets.etsmobile.model.FicheEmploye)4 ListeDesElementsEvaluation (ca.etsmtl.applets.etsmobile.model.ListeDesElementsEvaluation)4 Seances (ca.etsmtl.applets.etsmobile.model.Seances)4 Cours (ca.etsmtl.applets.etsmobile.model.Cours)3 Event (ca.etsmtl.applets.etsmobile.model.Event)3 ListeDeCours (ca.etsmtl.applets.etsmobile.model.ListeDeCours)3 Where (com.j256.ormlite.stmt.Where)3 JoursRemplaces (ca.etsmtl.applets.etsmobile.model.JoursRemplaces)2 MonETSNotification (ca.etsmtl.applets.etsmobile.model.MonETSNotification)2 Sponsor (ca.etsmtl.applets.etsmobile.model.Sponsor)2 Trimestre (ca.etsmtl.applets.etsmobile.model.Trimestre)2 ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces (ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces)2 ca.etsmtl.applets.etsmobile.model.listeSeances (ca.etsmtl.applets.etsmobile.model.listeSeances)2 ExpandableListAdapter (ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListAdapter)2 SeanceComparator (ca.etsmtl.applets.etsmobile.util.SeanceComparator)2