Search in sources :

Example 1 with QueryBuilder

use of com.j256.ormlite.stmt.QueryBuilder in project krypton-android by kryptco.

the class Approval method isGitTagApprovedNow.

public static synchronized boolean isGitTagApprovedNow(Dao<Approval, Long> db, UUID pairingUUID, Long temporaryApprovalSeconds) throws SQLException {
    deleteExpiredApprovals(db, temporaryApprovalSeconds);
    QueryBuilder query = db.queryBuilder();
    return query.where().eq("pairing_uuid", pairingUUID).and().eq("type", ApprovalType.GIT_TAG_SIGNATURES).countOf() > 0;
}
Also used : QueryBuilder(com.j256.ormlite.stmt.QueryBuilder)

Example 2 with QueryBuilder

use of com.j256.ormlite.stmt.QueryBuilder in project krypton-android by kryptco.

the class Approval method isSSHAnyHostApprovedNow.

public static synchronized boolean isSSHAnyHostApprovedNow(Dao<Approval, Long> db, UUID pairingUUID, Long temporaryApprovalSeconds) throws SQLException {
    deleteExpiredApprovals(db, temporaryApprovalSeconds);
    QueryBuilder query = db.queryBuilder();
    return query.where().eq("pairing_uuid", pairingUUID).and().eq("type", ApprovalType.SSH_ANY_HOST).countOf() > 0;
}
Also used : QueryBuilder(com.j256.ormlite.stmt.QueryBuilder)

Example 3 with QueryBuilder

use of com.j256.ormlite.stmt.QueryBuilder in project ETSMobile-Android2 by ApplETS.

the class BottinFragment method updateUI.

@SuppressWarnings({ "rawtypes", "unchecked" })
void updateUI() {
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    try {
        DatabaseHelper dbHelper = new DatabaseHelper(activity);
        // Création du queryBuilder, permettant de lister les employés par leur nom de service
        QueryBuilder<FicheEmploye, String> queryBuilder = (QueryBuilder<FicheEmploye, String>) dbHelper.getDao(FicheEmploye.class).queryBuilder();
        queryBuilder.orderBy("Service", true);
        PreparedQuery<FicheEmploye> preparedQuery = queryBuilder.prepare();
        List<FicheEmploye> listEmployes = dbHelper.getDao(FicheEmploye.class).query(preparedQuery);
        // Si le contenu n'est pas vide, l'ajouter au listDataHeader et listDataChild
        if (listEmployes.size() > 0) {
            String nomService = "";
            String previousNomService = "";
            listDataHeader.clear();
            ArrayList<FicheEmploye> listEmployesOfService = new ArrayList<>();
            // Pour le premier élément dans la liste
            FicheEmploye employe = listEmployes.get(0);
            nomService = employe.Service;
            listDataHeader.add(nomService);
            listEmployesOfService.add(employe);
            previousNomService = nomService;
            // Pour les prochains éléments dans la liste
            for (int i = 1; i < listEmployes.size(); i++) {
                employe = listEmployes.get(i);
                nomService = employe.Service;
                if (!listDataHeader.contains(nomService)) {
                    listDataHeader.add(nomService);
                    Collections.sort(listEmployesOfService, new Comparator<FicheEmploye>() {

                        @Override
                        public int compare(FicheEmploye f1, FicheEmploye f2) {
                            return f1.Nom.compareTo(f2.Nom);
                        }
                    });
                    listDataChild.put(previousNomService, listEmployesOfService);
                    listEmployesOfService = new ArrayList<>();
                    previousNomService = nomService;
                }
                listEmployesOfService.add(employe);
            }
            // Pour les derniers éléments dans la liste
            listDataChild.put(previousNomService, listEmployesOfService);
            if (activity != null) {
                activity.runOnUiThread(new Runnable() {

                    public void run() {
                        listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);
                        expListView.setAdapter(listAdapter);
                        listAdapter.notifyDataSetChanged();
                    }
                });
            }
            // Rétablissement du filtre de recherche
            CharSequence searchText = searchView.getQuery();
            if (searchText.length() != 0)
                onQueryTextChange(searchText.toString());
        // Si le contenu est vide, télécharger le bottin
        } else {
            // Le contenu est vide.
            afficherRafraichissementEtRechargerBottin();
        }
    } catch (Exception e) {
        Log.e("BD FicheEmploye", "" + e.getMessage());
    }
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity) ArrayList(java.util.ArrayList) ExpandableListAdapter(ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListAdapter) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye) DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper)

Example 4 with QueryBuilder

use of com.j256.ormlite.stmt.QueryBuilder in project krypton-android by kryptco.

the class Approval method isGitCommitApprovedNow.

public static synchronized boolean isGitCommitApprovedNow(Dao<Approval, Long> db, UUID pairingUUID, Long temporaryApprovalSeconds) throws SQLException {
    deleteExpiredApprovals(db, temporaryApprovalSeconds);
    QueryBuilder query = db.queryBuilder();
    return query.where().eq("pairing_uuid", pairingUUID).and().eq("type", ApprovalType.GIT_COMMIT_SIGNATURES).countOf() > 0;
}
Also used : QueryBuilder(com.j256.ormlite.stmt.QueryBuilder)

Example 5 with QueryBuilder

use of com.j256.ormlite.stmt.QueryBuilder in project krypton-android by kryptco.

the class Approval method isReadTeamDataApproved.

public static synchronized boolean isReadTeamDataApproved(Dao<Approval, Long> db, UUID pairingUUID, Long temporaryApprovalSeconds) throws SQLException {
    deleteExpiredApprovals(db, temporaryApprovalSeconds);
    QueryBuilder query = db.queryBuilder();
    return query.where().eq("pairing_uuid", pairingUUID).and().eq("type", ApprovalType.READ_TEAM_DATA).countOf() > 0;
}
Also used : QueryBuilder(com.j256.ormlite.stmt.QueryBuilder)

Aggregations

QueryBuilder (com.j256.ormlite.stmt.QueryBuilder)5 DatabaseHelper (ca.etsmtl.applets.etsmobile.db.DatabaseHelper)3 ElementEvaluation (ca.etsmtl.applets.etsmobile.model.ElementEvaluation)2 Where (com.j256.ormlite.stmt.Where)2 SQLException (java.sql.SQLException)2 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)1 FicheEmploye (ca.etsmtl.applets.etsmobile.model.FicheEmploye)1 ExpandableListAdapter (ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListAdapter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1