You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I cannot get results from methods getInEdges and getOutEdges of class OGraphDatabase (they always return zero results) in server side Java Hook (onRecordAfterCreate).
I'm working with OrientDB Graph Edition version 1.5.1.
// User
OClass user = oSchema.createClass("User", oSchema.getClass("V"));
user.createProperty("username", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE);
etc...
// User canAccess Folder
OClass canAccess = oSchema.createClass("CanAccess", oSchema.getClass("E"));
Server side Java Hook reacts at afterCreate event:
@OverRide
public void onRecordAfterCreate(ORecord<?> iRecord){
...
ODocument edgeDoc = (ODocument) iRecord;
// if iRecord is edge of class CanAccess I get the Folder vertex
OGraphDatabase oGraph = new OGraphDatabase((ODatabaseRecordTx)iRecord.getDatabase());
ODocument folder1Doc = oGraph.getInVertex(edgeDoc);
// Now I need to find edges of class "Contains"
// BUT WHEN I TRY TO GET IN-EDGES I GET ONLY AN EMPTY SET
Set inEdges = oGraph.getInEdges(folder1Doc);
...
}
At this point inEdges.size() = 0 !!!
But if I print folder1Doc.toJSON() I can see the links to edges:
{...,"out_contains":"#15:0","in_canAccess":"#16:1",...}
And if I execute query in SQL I find the edge:
oGraph.query(new OSQLSynchQuery("select from (traverse out_contains from #13:0 )")
Wath is wrong in my use of API oGraph.getInEdges(folder1Doc); ?
I really appreciate any help...
Thankyou
Stefano
The text was updated successfully, but these errors were encountered:
Hi, I cannot get results from methods getInEdges and getOutEdges of class OGraphDatabase (they always return zero results) in server side Java Hook (onRecordAfterCreate).
I'm working with OrientDB Graph Edition version 1.5.1.
// Folder
OClass folder = oSchema.createClass("Folder", oSchema.getClass("V"));
folder.createProperty("name", OType.STRING);
folder.createProperty("keyId", Type.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE_HASH_INDEX);
etc....
// File
OClass file = oSchema.createClass("File", resource);
file.createProperty("type", OType.STRING);
etc...
// Folder contains File
OClass contains = oSchema.createClass("Contains", oSchema.getClass("E"));
// User
OClass user = oSchema.createClass("User", oSchema.getClass("V"));
user.createProperty("username", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE);
etc...
// User canAccess Folder
OClass canAccess = oSchema.createClass("CanAccess", oSchema.getClass("E"));
OrientGraph oGraph = new OrientGraph("remote:localhost/mycompany", "admin", "admin");
oGraph.setUseLightweightEdges(false);
Vertex folder1 = oGraph.addVertex("class:Folder",
"name", "Progetti",
"keyId", "01234567890",
etc....);
Vertex file1 = oGraph.addVertex("class:File",
"type", "Acrobat PDF file",
etc....);
Edge folder1ContainsFile1 = oGraph.addEdge("class:Contains", folder1, file1, "contains");
Vertex user1 = oGraph.addVertex("class:User",
"username", "stefomak",
etc...);
oGraph.commit();
oGraph.setUseLightweightEdges(false);
Edge user1CanAccessFile1 = oGraph.addEdge("class:CanAccess", user1, file1, "canAccess");
@OverRide
public void onRecordAfterCreate(ORecord<?> iRecord){
...
ODocument edgeDoc = (ODocument) iRecord;
// if iRecord is edge of class CanAccess I get the Folder vertex
OGraphDatabase oGraph = new OGraphDatabase((ODatabaseRecordTx)iRecord.getDatabase());
ODocument folder1Doc = oGraph.getInVertex(edgeDoc);
// Now I need to find edges of class "Contains"
// BUT WHEN I TRY TO GET IN-EDGES I GET ONLY AN EMPTY SET
Set inEdges = oGraph.getInEdges(folder1Doc);
...
}
At this point inEdges.size() = 0 !!!
But if I print folder1Doc.toJSON() I can see the links to edges:
{...,"out_contains":"#15:0","in_canAccess":"#16:1",...}
And if I execute query in SQL I find the edge:
oGraph.query(new OSQLSynchQuery("select from (traverse out_contains from #13:0 )")
Wath is wrong in my use of API oGraph.getInEdges(folder1Doc); ?
I really appreciate any help...
Thankyou
Stefano
The text was updated successfully, but these errors were encountered: