Search in sources :

Example 26 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)

Example 27 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 28 with QueryBuilder

use of com.j256.ormlite.stmt.QueryBuilder in project SORMAS-Project by hzi-braunschweig.

the class ContactDao method getByCase.

public List<Contact> getByCase(Case caze) {
    if (caze.isSnapshot()) {
        throw new IllegalArgumentException("Does not support snapshot entities");
    }
    try {
        QueryBuilder qb = queryBuilder();
        qb.where().eq(Contact.CASE_UUID, caze.getUuid()).and().eq(AbstractDomainObject.SNAPSHOT, false);
        qb.orderBy(Contact.LOCAL_CHANGE_DATE, false);
        return qb.query();
    } catch (SQLException e) {
        Log.e(getTableName(), "Could not perform getByCase on Contact");
        throw new RuntimeException(e);
    }
}
Also used : SQLException(java.sql.SQLException) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder)

Example 29 with QueryBuilder

use of com.j256.ormlite.stmt.QueryBuilder in project SORMAS-Project by hzi-braunschweig.

the class ContactDao method getCountByPersonAndDisease.

public int getCountByPersonAndDisease(@NonNull Person person, Disease disease) {
    if (person.isSnapshot()) {
        throw new IllegalArgumentException("Does not support snapshot entities");
    }
    try {
        QueryBuilder qb = queryBuilder();
        Where where = qb.where();
        where.and(where.eq(Contact.PERSON, person), where.eq(AbstractDomainObject.SNAPSHOT, false));
        if (disease != null) {
            where.and(where, where.eq(Contact.DISEASE_COLUMN, disease));
        }
        qb.orderBy(Contact.LOCAL_CHANGE_DATE, false);
        return (int) qb.countOf();
    } catch (SQLException e) {
        Log.e(getTableName(), "Could not perform getCountByPersonAndDisease on Contact");
        throw new RuntimeException(e);
    }
}
Also used : SQLException(java.sql.SQLException) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder) Where(com.j256.ormlite.stmt.Where)

Example 30 with QueryBuilder

use of com.j256.ormlite.stmt.QueryBuilder in project SORMAS-Project by hzi-braunschweig.

the class CaseDao method getNumberOfCasesForEpiWeekAndDisease.

/**
 * Returns the number of cases with the given disease reported by the current user over the course of the given epi week.
 */
public int getNumberOfCasesForEpiWeekAndDisease(EpiWeek epiWeek, Disease disease, User user) {
    if (!(ConfigProvider.hasUserRight(UserRight.WEEKLYREPORT_CREATE))) {
        throw new UnsupportedOperationException("Can only retrieve the number of reported cases by epi week and disease for " + "users that can create weekly reports.");
    }
    try {
        QueryBuilder builder = queryBuilder();
        Where where = builder.where();
        where.and(where.eq(Case.REPORTING_USER, user), where.ge(Case.REPORT_DATE, DateHelper.getEpiWeekStart(epiWeek)), where.le(Case.REPORT_DATE, DateHelper.getEpiWeekEnd(epiWeek)));
        if (disease != null) {
            where.and(where, where.eq(Case.DISEASE, disease));
        }
        return (int) builder.countOf();
    } catch (SQLException e) {
        Log.e(getTableName(), "Could not perform getNumberOfCasesForEpiWeekAndDisease");
        throw new RuntimeException(e);
    }
}
Also used : SQLException(java.sql.SQLException) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder) Where(com.j256.ormlite.stmt.Where)

Aggregations

SQLException (java.sql.SQLException)44 QueryBuilder (com.j256.ormlite.stmt.QueryBuilder)43 Where (com.j256.ormlite.stmt.Where)38 SelectArg (com.j256.ormlite.stmt.SelectArg)9 ArrayList (java.util.ArrayList)6 List (java.util.List)4 DatabaseHelper (ca.etsmtl.applets.etsmobile.db.DatabaseHelper)3 ElementEvaluation (ca.etsmtl.applets.etsmobile.model.ElementEvaluation)2 NonNull (androidx.annotation.NonNull)1 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)1 FicheEmploye (ca.etsmtl.applets.etsmobile.model.FicheEmploye)1 ExpandableListAdapter (ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListAdapter)1 Entry (com.faltenreich.diaguard.shared.data.database.entity.Entry)1 EntryTag (com.faltenreich.diaguard.shared.data.database.entity.EntryTag)1 Food (com.faltenreich.diaguard.shared.data.database.entity.Food)1 Tag (com.faltenreich.diaguard.shared.data.database.entity.Tag)1 Disease (de.symeda.sormas.api.Disease)1 FeatureTypeProperty (de.symeda.sormas.api.feature.FeatureTypeProperty)1 UserRole (de.symeda.sormas.api.user.UserRole)1 Date (java.util.Date)1