Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods getInEdges and getOutEdges of class OGraphDatabase return zero results #1702

Closed
stefomak opened this issue Sep 23, 2013 · 1 comment
Assignees
Labels

Comments

@stefomak
Copy link

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.

  1. Schema setup:

// 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"));

  1. Create initial vertices:

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();

  1. Java client create edge: "user1 canAccess folder1"

oGraph.setUseLightweightEdges(false);
Edge user1CanAccessFile1 = oGraph.addEdge("class:CanAccess", user1, file1, "canAccess");

  1. 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

@lvca
Copy link
Member

lvca commented Jan 30, 2014

We're removing OGraphDatabase API. Please use Blueprints API.

@lvca lvca closed this as completed Jan 30, 2014
@ghost ghost assigned lvca Jan 30, 2014
@lvca lvca modified the milestones: 1.7rc1, 1.7 Feb 5, 2014
@lvca lvca modified the milestone: 1.7rc1 Aug 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants