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
This is Issue 155 moved from a Google Code project.
Added by 2010-11-24T11:09:26.000Z by trackstu...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).
Original labels: Type-Defect, Priority-Medium, v0.9.24
Original description
Hi All.
I'm created database the Graph capabilities of OrientDB.
I have got following code, which make this:
package test;
import com.orientechnologies.orient.core.db.graph.ODatabaseGraphTx;
import com.orientechnologies.orient.core.db.graph.OGraphVertex;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import org.apache.log4j.Logger;
import java.util.List;
import static com.tools.Constrains.URL_GRAPH;
public class GraphExample {
private static Logger log = Logger.getLogger(SearchTaskTest.class);
public static void main(String[] args) {
createDB();
createDate();
searchNode();
}
public static void createDB() {
ODatabaseGraphTx graph = new ODatabaseGraphTx(URL_GRAPH);
graph.create();
graph.close();
log.debug("==== Create orient DB graph ====");
}
private static void searchNode() {
ODatabaseGraphTx database = new ODatabaseGraphTx(URL_GRAPH);
database.open("admin", "admin");
database.getMetadata().getSchema().createClass("GraphVehicle").setSuperClass(database.getMetadata().getSchema().getClass("OGraphVertex"));
List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>("select from GraphVehicle"));
for (ODocument node : result) {
OGraphVertex vertex = new OGraphVertex(database, node);
System.out.print("id : " + vertex.get("id") + " " + vertex.getId() + " ");
System.out.print(vertex.browseInEdgesVertexes().size() + " ");
System.out.print(vertex.browseOutEdgesVertexes().size() + " ");
if (!vertex.browseOutEdgesVertexes().isEmpty()) {
OGraphVertex temp = vertex.browseOutEdgesVertexes().get(0);
System.out.print("\tout child : " + temp.getId() + " ");
}
System.out.println();
}
}
private static void createDate() {
ODatabaseGraphTx database = new ODatabaseGraphTx(URL_GRAPH);
database.open("admin", "admin");
database.getMetadata().getSchema().createClass("GraphVehicle").setSuperClass(database.getMetadata().getSchema().getClass("OGraphVertex"));
OGraphVertex rootNode = database.createVertex("GraphVehicle").set("id", 0);
OGraphVertex currentNode = rootNode;
for (int i = 1; i < 10; ++i) {
OGraphVertex newNode = database.createVertex("GraphVehicle").set("id", i);
currentNode.link(newNode);
currentNode = newNode;
}
database.setRoot("graph", rootNode);
database.close();
}
}
Out print:
13:59:35,781 DEBUG SearchTaskTest:26 - ==== Create orient DB graph ====
id : 9 7:0 1 0
id : 8 7:1 1 1 out child : 7:1
id : 7 7:2 1 1 out child : 7:2
id : 6 7:3 1 1 out child : 7:3
id : 5 7:4 1 1 out child : 7:4
id : 4 7:5 1 1 out child : 7:5
id : 3 7:6 1 1 out child : 7:6
id : 2 7:7 1 1 out child : 7:7
id : 1 7:8 1 1 out child : 7:8
id : 0 7:9 0 1 out child : 7:9
It is very strange, because vertex.getId() equals vertex.browseInEdgesVertexes().get(0).getId().
How I can get list node from root note to current note?
I see Java API http://www.orientechnologies.com/releases/latest/javadoc/index.html?com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.html
Class OGraphVertex have got two method this browseInEdgesVertexes() , browseOutEdgesVertexes(), but they not work?
Thanks.
The text was updated successfully, but these errors were encountered:
This is Issue 155 moved from a Google Code project.
Added by 2010-11-24T11:09:26.000Z by trackstu...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).
Original labels: Type-Defect, Priority-Medium, v0.9.24
Original description
The text was updated successfully, but these errors were encountered: