Skip to content

Commit

Permalink
Extend Geomaps service (#633).
Browse files Browse the repository at this point in the history
Geomaps API:
{{{
import de.deepamehta.plugins.geomaps.model.GeoCoordinate;

GeoCoordinate geoCoordinate(Topic geoCoordTopic)
}}}
Returns the geo coordinate encoded in a Geo Coordinate topic.

See #633.
  • Loading branch information
jri committed Aug 8, 2014
1 parent 7c37c74 commit 4d351e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Expand Up @@ -77,11 +77,12 @@ synchronized void activatePlugin(PluginImpl plugin) {
}

synchronized void deactivatePlugin(PluginImpl plugin) {
// Note: when plugin activation failed its listeners are not registered and it is not in the pool of activated
// Note: if plugin activation failed its listeners are not registered and it is not in the pool of activated
// plugins. Unregistering the listeners and removing from pool would fail.
if (_isPluginActivated(plugin.getUri())) {
String pluginUri = plugin.getUri();
if (_isPluginActivated(pluginUri)) {
plugin.unregisterListeners();
removeFromActivatedPlugins(plugin.getUri());
removeFromActivatedPlugins(pluginUri);
} else {
logger.info("Deactivation of " + plugin + " ABORTED -- it was not successfully activated");
}
Expand Down Expand Up @@ -192,7 +193,7 @@ private void addToActivatedPlugins(PluginImpl plugin) {

private void removeFromActivatedPlugins(String pluginUri) {
if (activatedPlugins.remove(pluginUri) == null) {
throw new RuntimeException("Removing plugin \"" + pluginUri + "\" from map of activated plugins failed: " +
throw new RuntimeException("Removing plugin \"" + pluginUri + "\" from pool of activated plugins failed: " +
"not found in " + activatedPlugins);
}
}
Expand Down
Expand Up @@ -113,11 +113,7 @@ public GeoCoordinate getGeoCoordinate(Topic geoTopic) {
try {
Topic geoCoordTopic = getGeoCoordinateTopic(geoTopic);
if (geoCoordTopic != null) {
CompositeValue comp = geoCoordTopic.getCompositeValue();
return new GeoCoordinate(
comp.getDouble("dm4.geomaps.longitude"),
comp.getDouble("dm4.geomaps.latitude")
);
return geoCoordinate(geoCoordTopic);
} else {
return null;
}
Expand All @@ -126,6 +122,15 @@ public GeoCoordinate getGeoCoordinate(Topic geoTopic) {
}
}

@Override
public GeoCoordinate geoCoordinate(Topic geoCoordTopic) {
CompositeValue comp = geoCoordTopic.getCompositeValue();
return new GeoCoordinate(
comp.getDouble("dm4.geomaps.longitude"),
comp.getDouble("dm4.geomaps.latitude")
);
}

@PUT
@Path("/{id}/topic/{geo_coord_id}")
@Override
Expand Down
Expand Up @@ -24,6 +24,11 @@ public interface GeomapsService extends PluginService {
*/
GeoCoordinate getGeoCoordinate(Topic geoTopic);

/**
* Returns the geo coordinate encoded in a Geo Coordinate topic.
*/
GeoCoordinate geoCoordinate(Topic geoCoordTopic);

/**
* Adds a Geo Coordinate topic to a geomap.
*/
Expand Down

0 comments on commit 4d351e6

Please sign in to comment.