Create custom class CVertex
public class CVertex extends OrientVertex{
public CVertex(OrientBaseGraph graph, OIdentifiable record) {
super(graph, record);
// TODO Auto-generated constructor stub
}
public OrientVertex get(){
return (OrientVertex)this;
}
}
public class CVertex extends OrientVertex{
public CVertex(OrientBaseGraph graph, OIdentifiable record) {
super(graph, record);
// TODO Auto-generated constructor stub
}
public OrientVertex get(){
return (OrientVertex)this;
}
}
OrientGraph graph = new OrientGraph(
"dburl", "admin", "admin");
"dburl", "admin", "admin");
OIndexManager idxManager = graph.getRawGraph().getMetadata().getIndexManager();
OIndex<?> idx = idxManager.getIndex(INDEX_CONSTANTS.FB_ID_INDEX);
OIdentifiable user = (OIdentifiable) idx.get(fbId);
if(null==user){
return null;
}
final ODocument value = ((OIdentifiable) user).getRecord();
CVertex v = null;
if (value.getSchemaClass().isSubClassOf(OrientVertex.CLASS_NAME)) {
// DIRECT VERTEX
v = new CVertex(graph, value);
}else{
return null;
}
return v.get();
OIndex<?> idx = idxManager.getIndex(INDEX_CONSTANTS.FB_ID_INDEX);
OIdentifiable user = (OIdentifiable) idx.get(fbId);
if(null==user){
return null;
}
final ODocument value = ((OIdentifiable) user).getRecord();
CVertex v = null;
if (value.getSchemaClass().isSubClassOf(OrientVertex.CLASS_NAME)) {
// DIRECT VERTEX
v = new CVertex(graph, value);
}else{
return null;
}
return v.get();
No comments:
Post a Comment