Search in sources :

Example 1 with PoiForEditionLoadedEvent

use of io.jawg.osmcontributor.model.events.PoiForEditionLoadedEvent in project osm-contributor by jawg.

the class PoiManager method loadPoiForCreation.

/**
 * Send a {@link PoiForEditionLoadedEvent} containing the suggestions for the PoiTypeTags and a new Poi to complete.
 *
 * @param event Event containing the position, level and PoiType of the Poi to create.
 */
private void loadPoiForCreation(PleaseLoadPoiForCreationEvent event) {
    Poi poi = new Poi();
    Set<Double> level = new HashSet<>();
    level.add(event.getLevel());
    poi.setLevel(level);
    poi.setLatitude(event.getLat());
    poi.setLongitude(event.getLng());
    poi.setType(poiTypeDao.queryForId(event.getPoiType()));
    Map<String, String> defaultTags = new HashMap<>();
    for (PoiTypeTag poiTypeTag : poi.getType().getTags()) {
        if (poiTypeTag.getValue() != null) {
            // default tags should be set in the corresponding POI
            defaultTags.put(poiTypeTag.getKey(), poiTypeTag.getValue());
        }
    }
    poi.applyChanges(defaultTags);
    bus.post(new PoiForEditionLoadedEvent(poi, suggestionsForTagsValue(poi.getType().getTags())));
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Poi(io.jawg.osmcontributor.model.entities.Poi) PoiForEditionLoadedEvent(io.jawg.osmcontributor.model.events.PoiForEditionLoadedEvent) PoiTypeTag(io.jawg.osmcontributor.model.entities.PoiTypeTag) HashSet(java.util.HashSet)

Example 2 with PoiForEditionLoadedEvent

use of io.jawg.osmcontributor.model.events.PoiForEditionLoadedEvent in project osm-contributor by jawg.

the class PoiManager method loadPoiForEdition.

// *********************************
// ************ private ************
// *********************************
/**
 * Send a {@link PoiForEditionLoadedEvent} containing the Poi to edit and the suggestions for the PoiTypeTags.
 *
 * @param id The id of the Poi to edit.
 */
private void loadPoiForEdition(Long id) {
    Poi poi = queryForId(id);
    bus.post(new PoiForEditionLoadedEvent(poi, suggestionsForTagsValue(poi.getType().getTags())));
}
Also used : Poi(io.jawg.osmcontributor.model.entities.Poi) PoiForEditionLoadedEvent(io.jawg.osmcontributor.model.events.PoiForEditionLoadedEvent)

Aggregations

Poi (io.jawg.osmcontributor.model.entities.Poi)2 PoiForEditionLoadedEvent (io.jawg.osmcontributor.model.events.PoiForEditionLoadedEvent)2 PoiTypeTag (io.jawg.osmcontributor.model.entities.PoiTypeTag)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1