de.deepamehta.plugins.geomaps
Class GeomapsPlugin

Show UML class diagram
java.lang.Object
  extended by de.deepamehta.core.osgi.PluginActivator
      extended by de.deepamehta.plugins.geomaps.GeomapsPlugin
All Implemented Interfaces:
PluginContext, PostCreateTopicListener, PostUpdateTopicListener, PreSendTopicListener, Listener, PluginService, GeomapsService, BundleActivator

public class GeomapsPlugin
extends PluginActivator
implements GeomapsService, PostCreateTopicListener, PostUpdateTopicListener, PreSendTopicListener


Nested Class Summary
private  class GeomapsPlugin.Address
           
private  class GeomapsPlugin.LonLat
           
 
Field Summary
private  FacetsService facetsService
           
private static String GEOCODER_URL
           
private  Logger logger
           
private  TopicmapsService topicmapsService
           
 
Fields inherited from class de.deepamehta.core.osgi.PluginActivator
bundle, dms
 
Constructor Summary
GeomapsPlugin()
           
 
Method Summary
 void addTopicToGeomap(long geomapId, long topicId)
          Adds a Geo Coordinate topic to a geomap.
private  TopicModel findAddress(Topic topic)
           
private  TopicModel findChildTopic(TopicModel topic, String topicTypeUri)
          Searches a topic's composite value for a topic of a given type.
private  void geocodeAndStoreFacet(GeomapsPlugin.Address address, Topic topic, ClientState clientState, Directives directives)
           
 Geomap getGeomap(long geomapId)
           
 ResultList<RelatedTopic> getGeomapTopics(long geomapId)
           
 Topic getGeoTopic(long topicId)
          Retrieves the domain topic that corresponds to a Geo Coordinate topic.
 void init()
           
 void postCreateTopic(Topic topic, ClientState clientState, Directives directives)
           
 void postUpdateTopic(Topic topic, TopicModel newModel, TopicModel oldModel, ClientState clientState, Directives directives)
           
 void preSendTopic(Topic topic, ClientState clientState)
          Enriches an Address topic with its Geo Coordinate facet.
 void serviceArrived(PluginService service)
           
 void serviceGone(PluginService service)
           
 void setGeomapState(long geomapId, double lon, double lat, int zoom)
           
private  void storeGeoFacet(Topic address, GeomapsPlugin.LonLat geoCoordinate, ClientState clientState, Directives directives)
          Stores a geo facet for an address topic in the DB.
 
Methods inherited from class de.deepamehta.core.osgi.PluginActivator
getBundleContext, postInstall, publishDirectory, setCoreService, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GEOCODER_URL

private static final String GEOCODER_URL
See Also:
Constant Field Values

topicmapsService

private TopicmapsService topicmapsService

facetsService

private FacetsService facetsService

logger

private Logger logger
Constructor Detail

GeomapsPlugin

public GeomapsPlugin()
Method Detail

getGeomap

public Geomap getGeomap(long geomapId)
Specified by:
getGeomap in interface GeomapsService

getGeoTopic

public Topic getGeoTopic(long topicId)
Description copied from interface: GeomapsService
Retrieves the domain topic that corresponds to a Geo Coordinate topic. ### TODO: rename method and argument

Specified by:
getGeoTopic in interface GeomapsService

getGeomapTopics

public ResultList<RelatedTopic> getGeomapTopics(long geomapId)
Specified by:
getGeomapTopics in interface GeomapsService

addTopicToGeomap

public void addTopicToGeomap(long geomapId,
                             long topicId)
Description copied from interface: GeomapsService
Adds a Geo Coordinate topic to a geomap. ### TODO: rename method and argument

Specified by:
addTopicToGeomap in interface GeomapsService

setGeomapState

public void setGeomapState(long geomapId,
                           double lon,
                           double lat,
                           int zoom)
Specified by:
setGeomapState in interface GeomapsService

init

public void init()
Specified by:
init in interface PluginContext
Overrides:
init in class PluginActivator

serviceArrived

public void serviceArrived(PluginService service)
Specified by:
serviceArrived in interface PluginContext
Overrides:
serviceArrived in class PluginActivator

serviceGone

public void serviceGone(PluginService service)
Specified by:
serviceGone in interface PluginContext
Overrides:
serviceGone in class PluginActivator

postCreateTopic

public void postCreateTopic(Topic topic,
                            ClientState clientState,
                            Directives directives)
Specified by:
postCreateTopic in interface PostCreateTopicListener

postUpdateTopic

public void postUpdateTopic(Topic topic,
                            TopicModel newModel,
                            TopicModel oldModel,
                            ClientState clientState,
                            Directives directives)
Specified by:
postUpdateTopic in interface PostUpdateTopicListener

preSendTopic

public void preSendTopic(Topic topic,
                         ClientState clientState)
Enriches an Address topic with its Geo Coordinate facet.

Specified by:
preSendTopic in interface PreSendTopicListener

geocodeAndStoreFacet

private void geocodeAndStoreFacet(GeomapsPlugin.Address address,
                                  Topic topic,
                                  ClientState clientState,
                                  Directives directives)

storeGeoFacet

private void storeGeoFacet(Topic address,
                           GeomapsPlugin.LonLat geoCoordinate,
                           ClientState clientState,
                           Directives directives)
Stores a geo facet for an address topic in the DB.


findAddress

private TopicModel findAddress(Topic topic)

findChildTopic

private TopicModel findChildTopic(TopicModel topic,
                                  String topicTypeUri)
Searches a topic's composite value for a topic of a given type. The search is driven by the topic's type definition. In other words, composite value entries which do not adhere to the topic's type definition are not found. Note: this is an in-memory search; the DB is not accessed.

The first topic found is returned, according to a depth-first search. For multiple-value fields only the first topic is returned.

TODO: make this a generally available method by adding it to the Topic interface?



Copyright © 2013. All Rights Reserved.