Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.GraphDatabaseService


  }

  public static void analyzeSchema() throws FrameworkException {

    final App app                                     = StructrApp.getInstance();
    final GraphDatabaseService graphDb                = app.command(GraphDatabaseCommand.class).execute();
    final NodeServiceCommand nodeServiceCommand       = app.command(CreateNodeCommand.class);
    final ConfigurationProvider configuration         = Services.getInstance().getConfigurationProvider();
    final Set<NodeInfo> nodeTypes                     = new LinkedHashSet<>();
    final Map<Long, TypeInfo> nodeTypeInfoMap         = new LinkedHashMap<>();
    final Set<RelationshipInfo> relationships         = new LinkedHashSet<>();
View Full Code Here


public class MemoryDatastoreFactory implements DatastoreFactory<EmbeddedNeo4jDatastore> {

    @Override
    public EmbeddedNeo4jDatastore createGraphDatabaseService(URI uri, Properties properties) {
        GraphDatabaseService graphDatabaseService = new TestGraphDatabaseFactory().newImpermanentDatabase();
        return new EmbeddedNeo4jDatastore(graphDatabaseService);
    }
View Full Code Here

public class GraphDbDatastoreFactory implements DatastoreFactory<GraphDbNeo4jDatastore> {

    @Override
    public GraphDbNeo4jDatastore createGraphDatabaseService(URI uri, Properties properties) throws MalformedURLException {
        String graphDbPropertyName = GraphDatabaseService.class.getName();
        GraphDatabaseService graphDatabaseService = (GraphDatabaseService) properties.get(graphDbPropertyName);
        if (graphDatabaseService == null) {
            throw new XOException("Property " + graphDbPropertyName + " is not specified.");
        }
        return new GraphDbNeo4jDatastore(graphDatabaseService);
    }
View Full Code Here

        GraphDatabaseBuilder databaseBuilder = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(uri.toURL().getPath());
        Properties neo4jProperties = Neo4jPropertyHelper.getNeo4jProperties(properties);
        for (String name : neo4jProperties.stringPropertyNames()) {
            databaseBuilder.setConfig(name, neo4jProperties.getProperty(name));
        }
        GraphDatabaseService graphDatabaseService = databaseBuilder.newGraphDatabase();
        return new EmbeddedNeo4jDatastore(graphDatabaseService);
    }
View Full Code Here

public class MemoryDatastoreFactory implements DatastoreFactory<EmbeddedNeo4jDatastore> {

    @Override
    public EmbeddedNeo4jDatastore createGraphDatabaseService(URI uri) {
        GraphDatabaseService graphDatabaseService = new TestGraphDatabaseFactory().newImpermanentDatabase();
        return new EmbeddedNeo4jDatastore(graphDatabaseService);
    }
View Full Code Here

public class FileDatastoreFactory implements DatastoreFactory<EmbeddedNeo4jDatastore> {

    @Override
    public EmbeddedNeo4jDatastore createGraphDatabaseService(URI uri) throws MalformedURLException {
        GraphDatabaseService graphDatabaseService = new GraphDatabaseFactory().newEmbeddedDatabase(uri.toURL().getPath());
        registerShutdownHook(graphDatabaseService);
        return new EmbeddedNeo4jDatastore(graphDatabaseService);
    }
View Full Code Here

    super.setUp();
    this.databasePath = getNeoPath().getAbsolutePath();
  }

  private void checkIndexAndFeatureCount(String layerName) throws IOException {
    GraphDatabaseService database = new GraphDatabaseFactory().newEmbeddedDatabase(databasePath);
    try (Transaction tx = database.beginTx()) {
      SpatialDatabaseService spatial = new SpatialDatabaseService(database);
      Layer layer = spatial.getLayer(layerName);
      if (layer.getIndex().count() < 1) {
        System.out.println("Warning: index count zero: " + layer.getName());
      }
      System.out.println("Layer '" + layer.getName() + "' has " + layer.getIndex().count() + " entries in the index");
      DataStore store = new Neo4jSpatialDataStore(database);
      SimpleFeatureCollection features = store.getFeatureSource(layer.getName()).getFeatures();
      System.out.println("Layer '" + layer.getName() + "' has " + features.size() + " features");
      assertEquals("FeatureCollection.size for layer '" + layer.getName() + "' not the same as index count", layer.getIndex()
          .count(), features.size());
      if (layer instanceof OSMLayer)
        checkOSMAPI(layer);
            tx.success();
    } finally {
      database.shutdown();
    }
  }
View Full Code Here

    importer.setCharset(Charset.forName("UTF-8"));
    BatchInserter batchInserter = BatchInserters.inserter(databasePath);
    importer.importFile(batchInserter, "map.osm", false);
    batchInserter.shutdown();

    GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(databasePath);
    importer.reIndex(db);
    db.shutdown();
    // END SNIPPET: importOsm
  }
View Full Code Here

    System.out.println("\n=== Simple test map.osm ===");
    importMapOSM();

    // START SNIPPET: searchBBox
    GraphDatabaseService database = new GraphDatabaseFactory().newEmbeddedDatabase(databasePath);
    try {
      SpatialDatabaseService spatialService = new SpatialDatabaseService(database);
      Layer layer = spatialService.getLayer("map.osm");
      LayerIndexReader spatialIndex = layer.getIndex();
      System.out.println("Have " + spatialIndex.count() + " geometries in " + spatialIndex.getBoundingBox());

      Envelope bbox = new Envelope(12.94, 12.96, 56.04, 56.06);
            try (Transaction tx = database.beginTx()) {
                List<SpatialDatabaseRecord> results = GeoPipeline
                    .startIntersectWindowSearch(layer, bbox)
                    .toSpatialDatabaseRecordList();

                doGeometryTestsOnResults(bbox, results);
                tx.success();
            }
    } finally {
      database.shutdown();
    }
    // END SNIPPET: searchBBox

    checkIndexAndFeatureCount("map.osm");
  }
View Full Code Here

    deleteDatabase(true);

    System.out.println("\n=== Test Import Shapefile ===");

    // START SNIPPET: importShapefile
    GraphDatabaseService database = new GraphDatabaseFactory().newEmbeddedDatabase(databasePath);
    try {
      ShapefileImporter importer = new ShapefileImporter(database);
      importer.importFile("shp/highway.shp", "highway", Charset.forName("UTF-8"));
    } finally {
      database.shutdown();
    }
    // END SNIPPET: importShapefile

    checkIndexAndFeatureCount("highway");
  }
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.GraphDatabaseService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.