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