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;
}
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;
}
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);
}
}
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);
}
}
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);
}
}
Aggregations