use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class PoiTypeAdapter method notifyTagRemoved.
public void notifyTagRemoved(PoiTypeTag poiTypeTag) {
PoiType poiType = poiTypeTag.getPoiType();
Long id = poiType != null ? poiType.getId() : null;
if (id == null) {
return;
}
poiType = getItemById(id);
if (poiType != null) {
poiType.getTags().remove(poiTypeTag);
int position = filteredValues.indexOf(poiType);
if (position != -1) {
notifyItemChanged(position);
}
}
}
use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class PoiTypeAdapter method undoLastRemoval.
public void undoLastRemoval() {
final PoiType item = lastRemovedItem;
if (item != null) {
lastRemovedItem = null;
addItem(item);
}
}
use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class PoiManagerTest method testBulkSaveAndBulkUpdate.
@Test
public void testBulkSaveAndBulkUpdate() {
PoiManager poiManager = component.getPoiManager();
PoiType poiType = poiManager.savePoiType(getPoiType());
// try to save and then update 1000 pois.
// 1000 because it can happen in real life and pose problems if we try to do an "IN" sql clause
List<Poi> pois = new ArrayList<>(1000);
for (int i = 0; i < 1000; i++) {
pois.add(getPoi(poiType, i));
}
poiManager.savePois(pois);
for (Poi poi : pois) {
assertThat(poi.getId()).isNotNull();
}
for (Poi poi : pois) {
Map<String, String> tags = new HashMap<>();
tags.put("tag2", "value2");
poi.getTags().clear();
poi.applyChanges(tags);
}
List<Poi> savedPois = poiManager.savePois(pois);
for (Poi poi : savedPois) {
assertThat(poi.getTags()).hasSize(1);
PoiTag tag = poi.getTags().iterator().next();
assertThat(tag.getKey()).isEqualTo("tag2");
assertThat(tag.getValue()).isEqualTo("value2");
}
}
Aggregations