Skip to content

Commit

Permalink
reformatted neo4j support source code; made neo4j support compliant w…
Browse files Browse the repository at this point in the history
…ith latest interfaces
  • Loading branch information
ccjason committed Nov 11, 2014
1 parent 1010581 commit 53a1bcb
Showing 1 changed file with 40 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,54 @@
import org.propelgraph.LocatableGraphFactoryFactoryImpl;
import org.propelgraph.LocatableGraphFactory;
import org.propelgraph.DeleteableGraphFactory;
import org.propelgraph.UnsupportedFActionException;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph;


public class Neo4jLocatableGraphFactory implements LocatableGraphFactory, DeleteableGraphFactory {
static final String PREFIX = LocatableGraphFactory.SCHEME_PGGRAPH+":"+Neo4jLocatableGraphFactory.class.getName()+"/?";
static final String PREFIX = LocatableGraphFactory.SCHEME_PGGRAPH+":"+Neo4jLocatableGraphFactory.class.getName()+"/?";

@Override
public void delete(String urlPath) {
if (!urlPath.startsWith(PREFIX)) throw new RuntimeException("unsupported urlPath: "+urlPath);
int idx0 = PREFIX.length();
String graphname = LocatableGraphFactoryFactoryImpl.parseForURLParameter("&graphname=", urlPath);
String hostname = null; // hostname = byLocatableGraphFactoryFactoryImpl.parseForURLParameter("&hostname=", urlPath);
try {
Runtime.getRuntime().exec("rm -Rf neo4jstores/"+graphname+"/");
} catch (Exception exc) {
throw new RuntimeException(exc);
}
}

@Override
public void delete(String urlPath) {
if (!urlPath.startsWith(PREFIX)) throw new RuntimeException("unsupported urlPath: "+urlPath);
int idx0 = PREFIX.length();
String graphname = LocatableGraphFactoryFactoryImpl.parseForURLParameter("&graphname=", urlPath);
String hostname = null; // hostname = byLocatableGraphFactoryFactoryImpl.parseForURLParameter("&hostname=", urlPath);
try {
Runtime.getRuntime().exec("rm -Rf neo4jstores/"+graphname+"/");
} catch (Exception exc) {
throw new RuntimeException(exc);
}
}

@Override
public Graph create(String urlPath) {
if (!urlPath.startsWith(PREFIX)) throw new RuntimeException("unsupported urlPath: "+urlPath);
int idx0 = PREFIX.length();
String graphname = LocatableGraphFactoryFactoryImpl.parseForURLParameter("&graphname=", urlPath);
String hostname = null; // hostname = byLocatableGraphFactoryFactoryImpl.parseForURLParameter("&hostname=", urlPath);
try {
File fiDirGraph = new File("neo4jstores/"+graphname);
boolean boolAlreadyExists = fiDirGraph.exists();
Neo4jGraph g = new Neo4jGraph(fiDirGraph.getAbsolutePath());
if (!boolAlreadyExists) {
g.createKeyIndex("_id", Vertex.class);
//g.createKeyIndex(idPropForPeople, Vertex.class);
@Override
public Graph open(String urlPath, String faction, String fmode) throws UnsupportedFActionException {
if (!urlPath.startsWith(PREFIX)) throw new RuntimeException("unsupported urlPath: "+urlPath);
int idx0 = PREFIX.length();
String graphname = LocatableGraphFactoryFactoryImpl.parseForURLParameter("&graphname=", urlPath);
String hostname = null; // hostname = byLocatableGraphFactoryFactoryImpl.parseForURLParameter("&hostname=", urlPath);
if (!faction.equals(org.propelgraph.LocatableGraphFactory.FACTION_CREATE_OPEN)) throw new UnsupportedFActionException();
try {
File fiDirGraph = new File("neo4jstores/"+graphname);
boolean boolAlreadyExists = fiDirGraph.exists();
Neo4jGraph g = new Neo4jGraph(fiDirGraph.getAbsolutePath());
if (!boolAlreadyExists) {
g.createKeyIndex("_id", Vertex.class);
//g.createKeyIndex(idPropForPeople, Vertex.class);
}
return g;
} catch (Exception exc) {
throw new RuntimeException(exc);
}
return g;
} catch (Exception exc) {
throw new RuntimeException(exc);
}
}
}

@Override
public String getGraphURL(Graph graph) {
// we don't know how to determine the graph file being used if all we have is the Graph object
throw new RuntimeException("don't currently support this method");
}
@Override
public String getGraphURL(Graph graph) {
// we don't know how to determine the graph file being used if all we have is the Graph object
throw new RuntimeException("don't currently support this method");
}

}

0 comments on commit 53a1bcb

Please sign in to comment.