Search in sources :

Example 1 with WhereSelectionBuilder

use of de.westnordost.streetcomplete.data.WhereSelectionBuilder in project StreetComplete by westnordost.

the class AOsmQuestDao method getAll.

public List<OsmQuest> getAll(BoundingBox bbox, QuestStatus status, String questTypeName, Element.Type elementType, Long elementId) {
    WhereSelectionBuilder qb = new WhereSelectionBuilder();
    addBBox(bbox, qb);
    addQuestStatus(status, qb);
    addQuestType(questTypeName, qb);
    addElementType(elementType, qb);
    addElementId(elementId, qb);
    return getAllThings(getMergedViewName(), null, qb, this::createObjectFrom);
}
Also used : WhereSelectionBuilder(de.westnordost.streetcomplete.data.WhereSelectionBuilder)

Example 2 with WhereSelectionBuilder

use of de.westnordost.streetcomplete.data.WhereSelectionBuilder in project StreetComplete by westnordost.

the class OsmQuestDao method getNextNewAt.

public OsmQuest getNextNewAt(long questId, final List<String> questTypesNames) {
    OsmQuest quest = get(questId);
    if (quest == null)
        return null;
    WhereSelectionBuilder qb = new WhereSelectionBuilder();
    addQuestStatus(QuestStatus.NEW, qb);
    addElementType(quest.getElementType(), qb);
    addElementId(quest.getElementId(), qb);
    addQuestTypes(questTypesNames, qb);
    List<OsmQuest> allNext = getAllThings(getMergedViewName(), null, qb, this::createObjectFrom);
    Collections.sort(allNext, (o1, o2) -> {
        String o1Name = o1.getType().getClass().getSimpleName();
        String o2Name = o2.getType().getClass().getSimpleName();
        return questTypesNames.indexOf(o1Name) - questTypesNames.indexOf(o2Name);
    });
    return allNext.isEmpty() ? null : allNext.get(0);
}
Also used : OsmQuest(de.westnordost.streetcomplete.data.osm.OsmQuest) WhereSelectionBuilder(de.westnordost.streetcomplete.data.WhereSelectionBuilder)

Example 3 with WhereSelectionBuilder

use of de.westnordost.streetcomplete.data.WhereSelectionBuilder in project StreetComplete by westnordost.

the class OsmNoteQuestDao method getAllPositions.

public List<LatLon> getAllPositions(BoundingBox bbox) {
    String[] cols = { NoteTable.Columns.LATITUDE, NoteTable.Columns.LONGITUDE };
    WhereSelectionBuilder qb = new WhereSelectionBuilder();
    addBBox(bbox, qb);
    return getAllThings(getMergedViewName(), cols, qb, cursor -> new OsmLatLon(cursor.getDouble(0), cursor.getDouble(1)));
}
Also used : WhereSelectionBuilder(de.westnordost.streetcomplete.data.WhereSelectionBuilder) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 4 with WhereSelectionBuilder

use of de.westnordost.streetcomplete.data.WhereSelectionBuilder in project StreetComplete by westnordost.

the class AOsmQuestDao method getAll.

public List<OsmQuest> getAll(BoundingBox bbox, QuestStatus status, List<String> questTypesNames) {
    WhereSelectionBuilder qb = new WhereSelectionBuilder();
    addBBox(bbox, qb);
    addQuestStatus(status, qb);
    addQuestTypes(questTypesNames, qb);
    return getAllThings(getMergedViewName(), null, qb, this::createObjectFrom);
}
Also used : WhereSelectionBuilder(de.westnordost.streetcomplete.data.WhereSelectionBuilder)

Example 5 with WhereSelectionBuilder

use of de.westnordost.streetcomplete.data.WhereSelectionBuilder in project StreetComplete by westnordost.

the class CreateNoteDao method getAll.

public List<CreateNote> getAll(BoundingBox bbox) {
    SQLiteDatabase db = dbHelper.getReadableDatabase();
    WhereSelectionBuilder builder = new WhereSelectionBuilder();
    if (bbox != null) {
        builder.appendAnd("(" + CreateNoteTable.Columns.LATITUDE + " BETWEEN ? AND ?)", String.valueOf(bbox.getMinLatitude()), String.valueOf(bbox.getMaxLatitude()));
        builder.appendAnd("(" + CreateNoteTable.Columns.LONGITUDE + " BETWEEN ? AND ?)", String.valueOf(bbox.getMinLongitude()), String.valueOf(bbox.getMaxLongitude()));
    }
    List<CreateNote> result = new ArrayList<>();
    try (Cursor cursor = db.query(CreateNoteTable.NAME, null, builder.getWhere(), builder.getArgs(), null, null, null, null)) {
        if (cursor.moveToFirst()) {
            while (!cursor.isAfterLast()) {
                result.add(createObjectFrom(cursor));
                cursor.moveToNext();
            }
        }
    }
    return result;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) WhereSelectionBuilder(de.westnordost.streetcomplete.data.WhereSelectionBuilder) Cursor(android.database.Cursor)

Aggregations

WhereSelectionBuilder (de.westnordost.streetcomplete.data.WhereSelectionBuilder)5 Cursor (android.database.Cursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)1 OsmQuest (de.westnordost.streetcomplete.data.osm.OsmQuest)1 ArrayList (java.util.ArrayList)1