Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:svzdvd/net.refractions.udig.c…
Browse files Browse the repository at this point in the history
…atalog.neo4j
  • Loading branch information
craigtaverner committed Aug 18, 2010
2 parents e9f2ea3 + bf1c91a commit fcc691f
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/net/refractions/udig/catalog/neo4j/Activator.java
Expand Up @@ -31,6 +31,9 @@


/**
* Neo4j Plugin Activator.
* It mantains an index of open Neo4j DataStores.
*
* @author Davide Savazzi
*/
public class Activator extends AbstractUIPlugin implements IStartup {
Expand All @@ -48,6 +51,9 @@ public Activator() {

// Public methods

/**
* Return a Neo4j DataStore.
*/
public Neo4jSpatialDataStore getDataStore(Map<String, Serializable> params) throws IOException {
if (dataStorefactory.canProcess(params)) {
String id = dataStorefactory.getDataStoreUniqueIdentifier(params);
Expand All @@ -67,16 +73,16 @@ public Neo4jSpatialDataStore getDataStore(Map<String, Serializable> params) thro
}
}

/**
* Close all open DataStores.
*/
public void stop(BundleContext context) throws Exception {
plugin = null;

synchronized (openDataStores) {
for (String id : openDataStores.keySet()) {
DataStore dataStore = openDataStores.get(id);
dataStore.dispose();

// TODO log is already stopped? it throws NPE...
log("Closed Neo4j Database: " + id);
}
openDataStores.clear();
}
Expand Down Expand Up @@ -106,10 +112,16 @@ public ILayer findLayer(String layerName, List<ILayer> layers) {
return null;
}

/**
* Return a static reference to this Activator
*/
public static Activator getDefault() {
return plugin;
}

/**
* Open an Error Message Dialog
*/
public static void openError(final Display display, final String title, final String message) {
display.asyncExec(new Runnable() {
public void run() {
Expand Down
Expand Up @@ -14,6 +14,8 @@


/**
* IOp implementation to completely delete a Neo4j Layer.
*
* @author Davide Savazzi
*/
public class DeleteNeo4jSpatialLayerOp implements IOp {
Expand Down
Expand Up @@ -84,6 +84,9 @@ public Map<String, Serializable> getConnectionParams() {
return params;
}

/**
* Clear Neo4j Datastore cache.
*/
public void refresh(IProgressMonitor monitor) {
Neo4jSpatialDataStore dataStore = (Neo4jSpatialDataStore) getDataStore(monitor);
dataStore.clearCache();
Expand Down
Expand Up @@ -6,6 +6,9 @@


/**
* Implementation of a Neo4j-Spatial Listener that
* manage an Eclipse IProgressMonitor implementation.
*
* @author Davide Savazzi
*/
public class ProgressMonitorWrapper implements Listener {
Expand Down
Expand Up @@ -7,6 +7,9 @@


/**
* IOp implementation to refresh a Neo4j DataStore.
* Useful after Layer creation or deletion, it deletes Neo4j DataStore internal cache.
*
* @author Davide Savazzi
*/
public class RefreshNeo4jSpatialServiceOp implements IOp {
Expand Down
@@ -1,5 +1,9 @@
package net.refractions.udig.catalog.neo4j.findpath;


/**
* Constants used in uDig Blackboard by the Find Shortest Path tool.
*/
public interface FindPathConstants {

String BLACKBOARD_WAYPOINTS = "neo4j_waypoints";
Expand Down
Expand Up @@ -30,6 +30,11 @@
import org.neo4j.graphdb.Transaction;


/**
* Tool to find the shortest path between selected waypoints, using Dijkstra algorithm.
*
* @author Davide Savazzi
*/
public class FindPathTool extends AbstractActionTool implements FindPathConstants {

// Public methods
Expand Down
Expand Up @@ -16,18 +16,18 @@
import org.neo4j.gis.spatial.Constants;
import org.neo4j.gis.spatial.DefaultLayer;
import org.neo4j.gis.spatial.EditableLayer;
import org.neo4j.gis.spatial.Layer;
import org.neo4j.gis.spatial.LineStringNetworkGenerator;
import org.neo4j.gis.spatial.Search;
import org.neo4j.gis.spatial.SpatialDatabaseRecord;
import org.neo4j.gis.spatial.SpatialDatabaseService;
import org.neo4j.gis.spatial.WKBGeometryEncoder;
import org.neo4j.gis.spatial.geotools.data.Neo4jSpatialDataStore;
import org.neo4j.gis.spatial.query.SearchAll;
import org.neo4j.graphdb.Transaction;


/**
* IOp implementation to create a network of LineStrings.
*
* @author Davide Savazzi
*/
public class GenerateLineStringNetworkOp implements IOp {
Expand Down Expand Up @@ -63,9 +63,11 @@ public void op(Display display, Object target, IProgressMonitor monitor) throws
try {
// TODO put these layer nodes in relationship?

// create Network Points Layer
EditableLayer netPointsLayer = spatialDatabase.getOrCreateEditableLayer(layer.getName() + " - network points");
netPointsLayer.setCoordinateReferenceSystem(layer.getCoordinateReferenceSystem());

// create Network Edges Layer
EditableLayer netEdgesLayer = spatialDatabase.getOrCreateEditableLayer(layer.getName() + " - network edges");
netEdgesLayer.setCoordinateReferenceSystem(layer.getCoordinateReferenceSystem());

Expand Down
Expand Up @@ -19,6 +19,8 @@


/**
* MapGraphic that draws selected waypoints and the shortest path found between them.
*
* TODO style support
*/
public class GraphMapGraphic implements MapGraphic, FindPathConstants {
Expand Down
Expand Up @@ -26,6 +26,8 @@


/**
* Tool to select waypoints on the map.
*
* @author Davide Savazzi
*/
public class WayPointTool extends SimpleTool implements FindPathConstants {
Expand Down
Expand Up @@ -28,6 +28,8 @@


/**
* Wizard to import a Shapefile in a Neo4j DataStore.
*
* @author Davide Savazzi
*/
public class ShpImportWizard extends Wizard implements INewWizard {
Expand Down

0 comments on commit fcc691f

Please sign in to comment.