Search in sources :

Example 11 with QueryBuilder

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

the class AbstractAdoDao method queryForEq.

/**
 * @see Dao#queryForEq(String, Object)
 */
public List<ADO> queryForEq(String fieldName, Object value) {
    try {
        QueryBuilder builder = queryBuilder();
        Where where = builder.where();
        where.eq(fieldName, value);
        where.and().eq(AbstractDomainObject.SNAPSHOT, false).query();
        return builder.query();
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}
Also used : SQLException(java.sql.SQLException) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder) Where(com.j256.ormlite.stmt.Where)

Example 12 with QueryBuilder

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

the class AbstractAdoDao method queryForEq.

public List<ADO> queryForEq(String fieldName, Object value, String orderBy, boolean ascending) {
    try {
        QueryBuilder builder = queryBuilder();
        Where where = builder.where();
        where.eq(fieldName, value);
        where.and().eq(AbstractDomainObject.SNAPSHOT, false).query();
        return builder.orderBy(orderBy, ascending).query();
    } catch (SQLException | IllegalArgumentException e) {
        Log.e(getTableName(), "Could not perform queryForEq");
        throw new RuntimeException(e);
    }
}
Also used : SQLException(java.sql.SQLException) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder) Where(com.j256.ormlite.stmt.Where)

Example 13 with QueryBuilder

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

the class FacilityDao method getActiveLaboratories.

public List<Facility> getActiveLaboratories(boolean includeOtherFacility) {
    try {
        QueryBuilder builder = queryBuilder();
        Where where = builder.where();
        where.eq(Facility.TYPE, FacilityType.LABORATORY);
        where.and().eq(InfrastructureAdo.ARCHIVED, false);
        where.and().eq(AbstractDomainObject.SNAPSHOT, false);
        where.and().ne(Facility.UUID, FacilityDto.OTHER_FACILITY_UUID).query();
        List<Facility> facilities = builder.orderBy(Facility.NAME, true).query();
        if (includeOtherFacility) {
            facilities.add(queryUuid(FacilityDto.OTHER_FACILITY_UUID));
        }
        return facilities;
    } catch (SQLException | IllegalArgumentException e) {
        Log.e(getTableName(), "Could not perform queryForEq");
        throw new RuntimeException(e);
    }
}
Also used : SQLException(java.sql.SQLException) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder) Where(com.j256.ormlite.stmt.Where)

Example 14 with QueryBuilder

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

the class FeatureConfigurationDao method isFeatureDisabled.

public boolean isFeatureDisabled(FeatureType featureType) {
    try {
        QueryBuilder builder = queryBuilder();
        Where where = builder.where();
        where.eq(FeatureConfiguration.FEATURE_TYPE, featureType);
        where.and().eq(FeatureConfiguration.ENABLED, false);
        return builder.countOf() > 0;
    } catch (SQLException e) {
        Log.e(getTableName(), "Could not perform isFeatureDisabled");
        throw new RuntimeException(e);
    }
}
Also used : SQLException(java.sql.SQLException) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder) Where(com.j256.ormlite.stmt.Where)

Example 15 with QueryBuilder

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

the class DiseaseConfigurationDao method getDiseaseConfiguration.

public DiseaseConfiguration getDiseaseConfiguration(Disease disease) {
    try {
        QueryBuilder builder = queryBuilder();
        Where where = builder.where();
        where.eq(DiseaseConfiguration.DISEASE, disease);
        return (DiseaseConfiguration) builder.queryForFirst();
    } catch (SQLException e) {
        Log.e(getTableName(), "Could not perform getDiseaseConfiguration");
        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