@Override
public void setUp() {
OGlobalConfiguration.USE_WAL.setValue(true);
super.setUp();
final OrientVertexType v1 = graph.createVertexType("V1");
final OrientVertexType v2 = graph.createVertexType("V2");
final OrientEdgeType edgeType = graph.createEdgeType("Friend");
edgeType.createProperty("in", OType.LINK, v2);
edgeType.createProperty("out", OType.LINK, v1);
// ASSURE NOT DUPLICATES
edgeType.createIndex("out_in", OClass.INDEX_TYPE.UNIQUE, "in", "out");
graph.addVertex("class:V2").setProperty("name", "Luca");
graph.commit();
}
protected void createSchema()
{
graph.executeOutsideTx(new OCallable<Object, OrientBaseGraph>() {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Object call(final OrientBaseGraph g)
{
OrientVertexType v = g.getVertexBaseType();
if(!v.existsProperty(NODE_ID)) { // TODO fix schema detection hack later
v.createProperty(NODE_ID, OType.INTEGER);
g.createKeyIndex(NODE_ID, Vertex.class, new Parameter("type", "UNIQUE_HASH_INDEX"), new Parameter(
"keytype", "INTEGER"));
v.createEdgeProperty(Direction.OUT, SIMILAR, OType.LINKBAG);
v.createEdgeProperty(Direction.IN, SIMILAR, OType.LINKBAG);
OrientEdgeType similar = g.createEdgeType(SIMILAR);
similar.createProperty("out", OType.LINK, v);
similar.createProperty("in", OType.LINK, v);
g.createKeyIndex(COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"),
new Parameter("keytype", "INTEGER"));
g.createKeyIndex(NODE_COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"),
new Parameter("keytype", "INTEGER"));
}
return null;
}
});
}