Search in sources :

Example 1 with WhereCondition

use of de.greenrobot.dao.query.WhereCondition in project Gadgetbridge by Freeyourgadget.

the class AbstractSampleProvider method getActivityTypeConditions.

private WhereCondition getActivityTypeConditions(QueryBuilder qb, int[] dbActivityTypes) {
    // check would have worked just fine.
    if (dbActivityTypes.length == 0) {
        return null;
    }
    Property rawKindProperty = getRawKindSampleProperty();
    if (rawKindProperty == null) {
        return null;
    }
    if (dbActivityTypes.length == 1) {
        return rawKindProperty.eq(dbActivityTypes[0]);
    }
    if (dbActivityTypes.length == 2) {
        return qb.or(rawKindProperty.eq(dbActivityTypes[0]), rawKindProperty.eq(dbActivityTypes[1]));
    }
    final int offset = 2;
    int len = dbActivityTypes.length - offset;
    WhereCondition[] trailingConditions = new WhereCondition[len];
    for (int i = 0; i < len; i++) {
        trailingConditions[i] = rawKindProperty.eq(dbActivityTypes[i + offset]);
    }
    return qb.or(rawKindProperty.eq(dbActivityTypes[0]), rawKindProperty.eq(dbActivityTypes[1]), trailingConditions);
}
Also used : WhereCondition(de.greenrobot.dao.query.WhereCondition) Property(de.greenrobot.dao.Property)

Example 2 with WhereCondition

use of de.greenrobot.dao.query.WhereCondition in project Gadgetbridge by Freeyourgadget.

the class AbstractSampleProvider method getClauseForActivityType.

private WhereCondition[] getClauseForActivityType(QueryBuilder qb, int activityTypes) {
    if (activityTypes == ActivityKind.TYPE_ALL) {
        return NO_CONDITIONS;
    }
    int[] dbActivityTypes = ActivityKind.mapToDBActivityTypes(activityTypes, this);
    WhereCondition activityTypeCondition = getActivityTypeConditions(qb, dbActivityTypes);
    return new WhereCondition[] { activityTypeCondition };
}
Also used : WhereCondition(de.greenrobot.dao.query.WhereCondition)

Aggregations

WhereCondition (de.greenrobot.dao.query.WhereCondition)2 Property (de.greenrobot.dao.Property)1