public void updateGraph(
      List<ClusterRectangle> clusterRectangles, List<Period> indoorPeriods, String android_id) {
    // Graph Update
    // Make Graph
    Configuration conf = new BaseConfiguration();
    conf.setProperty("storage.backend", "cassandra");
    conf.setProperty("storage.hostname", "127.0.0.1");
    TitanGraph g = TitanFactory.open(conf);

    // Get Smartphone Vertex
    Vertex v = TitanHelper.getVertex(g, "android_id", android_id);
    if (v == null) {
      v = g.addVertex(null);
      v.setProperty("android_id", android_id);
      v.setProperty("ltype", "Object");
    }

    // Process Outdoor Cluster
    for (int i = 0; i < clusterRectangles.size(); i++) {
      ClusterRectangle clusterRectangle = clusterRectangles.get(i);
      double minLon = clusterRectangle.getMinLon();
      double minLat = clusterRectangle.getMinLat();
      double maxLon = clusterRectangle.getMaxLon();
      double maxLat = clusterRectangle.getMaxLat();

      for (int j = 0; j < clusterRectangle.getPeriods().size(); j++) {
        Vertex place = g.addVertex(null);
        place.setProperty("ltype", "Place.outdoor");
        place.setProperty("minLon", minLon);
        place.setProperty("minLat", minLat);
        place.setProperty("maxLon", maxLon);
        place.setProperty("maxLat", maxLat);

        Period period = clusterRectangle.getPeriods().get(j);
        long from = period.getFrom() * 1000;
        long to = period.getTo() * 1000;
        Edge isLocatedIn = g.addEdge(null, v, place, "isLocatedIn");
        Edge isContaining = g.addEdge(null, place, v, "isContaining");
        isLocatedIn.setProperty("from", from);
        isLocatedIn.setProperty("to", to);
        isContaining.setProperty("from", from);
        isContaining.setProperty("to", to);
      }
    }

    // Process Indoor Points
    for (int i = 0; i < indoorPeriods.size(); i++) {
      Period indoor = indoorPeriods.get(i);
      Vertex place = g.addVertex(null);
      place.setProperty("ltype", "Place.indoor");
      place.setProperty("longitude", indoor.getLongitude());
      place.setProperty("latitude", indoor.getLatitude());
      place.setProperty("from", indoor.getFrom());
      place.setProperty("to", indoor.getTo());
    }

    g.commit();
    g.shutdown();
  }
 @Override
 public boolean open() {
   BaseConfiguration conf = new BaseConfiguration();
   conf.setProperty("storage.backend", storageBackend);
   conf.setProperty("storage.tablename", storageTableName);
   titanGraph = TitanFactory.open(conf);
   titanGraph.makeKey(vertexUserId).dataType(String.class).indexed(Vertex.class).make();
   titanGraph.makeLabel(edgeMentions).make();
   titanGraph.makeLabel(edgeReTweets).make();
   titanGraph.commit();
   return true;
 }
 @Test
 public void testTitanFactoryBuilder() {
   String baseDir = Joiner.on(File.separator).join("target", "es", "titanfactory_jvmlocal_ext");
   TitanFactory.Builder builder = TitanFactory.build();
   builder.set("storage.backend", "inmemory");
   builder.set("index." + INDEX_NAME + ".elasticsearch.interface", "NODE");
   builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true");
   builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false");
   builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true");
   builder.set(
       "index." + INDEX_NAME + ".elasticsearch.ext.path.data", baseDir + File.separator + "data");
   builder.set(
       "index." + INDEX_NAME + ".elasticsearch.ext.path.work", baseDir + File.separator + "work");
   builder.set(
       "index." + INDEX_NAME + ".elasticsearch.ext.path.logs", baseDir + File.separator + "logs");
   TitanGraph graph = builder.open(); // Must not throw an exception
   assertTrue(graph.isOpen());
   graph.close();
 }
 public void open(WriteConfiguration config) {
   graph = (StandardTitanGraph) TitanFactory.open(config);
   features = graph.getConfiguration().getStoreFeatures();
   tx = graph.newTransaction();
   mgmt = graph.openManagement();
 }