countEdges in embeded javasript function

已查看 24 次
跳至第一个未读帖子

Gerard Vergoni

未读,
2016年4月19日 08:54:332016/4/19
收件人 OrientDB
Hello,

I have a function that embeds JavaScript and blueprints here

var gdb = orient.getGraph();
var retour = {};
try{
 
var login = gdb.getVertex(id);
 
if(login){
// insert controle here
   
var pays = login.getLabel().slice(-2);
   
var Ccompte = gdb.getVertexType("Compte_".concat(pays))|| gdb.createVertexType("Compte_".concat(pays),"Compte");
   
var Cconfig = gdb.getVertexType("Config_".concat(pays))|| gdb.createVertexType("Config_".concat(pays),"Config");  
   
var compte = gdb.addVertex("class:"+Ccompte);
      compte
.setProperty("Pays",pays);
   
var config = gdb.addVertex("class:"+Cconfig);
      config
.setProperty("Nom","message");
      config
.setProperty("Desc","Service Messagerie");
    login
.addEdge("Membre",compte)
    login
.addEdge("MP", config );
    gdb
.commit();
   
    retour
.ID =  compte.getId();
    retour
.pays = pays;
 
}  
 
else{
    retour
.err = 'Compte Introuvable';
    retour
.errcode = 152;
 
}
} catch(err) {
  gdb
.rollback();
  retour
.err = err.toString();
  retour
.errcode = 201
} finally {
  gdb
.shutdown();
}
return retour;

and I am a control insert the number of Edges with
 if ( login.countEdges (Direction.OUT, "Membre")== 0 ) {.....

Here is the description of countEdges

public long countEdges(Direction iDirection,String... iLabels)   (Blueprints Extension) Returns the number of edges connected to the current Vertex.

Parameters:
    iDirection
- The direction between OUT, IN or BOTH
    iLabels
- Optional labels as Strings to consider
Returns:
    A
long with the total edges found



I have an error on the type Direction

if someone has an idea I'm interested

Thank you

alessand...@gmail.com

未读,
2016年4月19日 09:28:162016/4/19
收件人 orient-...@googlegroups.com
Hi Gerard,
are you getting this error "ReferenceError: \"Direction\" is not defined" ? 

Kind regards,
Alessandro

Gerard Vergoni

未读,
2016年4月19日 09:37:592016/4/19
收件人 OrientDB
Hi Alessandro
Yes .... unfortunately I do not know or find the declaration of the "Direction" structure

alessand...@gmail.com

未读,
2016年4月19日 09:45:432016/4/19
收件人 orient-...@googlegroups.com
Hi Gerard,
I think you're mixing javascript code with java code.
The method countEdges belongs to java code.

Best regards,
Alessandro


Gerard Vergoni

未读,
2016年4月19日 09:59:272016/4/19
收件人 OrientDB
library has the blueprints exactly as
getVertex
, getVertex type, AddVertex, addEdge
that work
very well ...
so there must be a gateway that the relationship between JavaScript and Java

Le mardi 19 avril 2016 15:45:43 UTC+2, alessand...@gmail.com a écrit :
Hi Vegard,

alessand...@gmail.com

未读,
2016年4月19日 10:46:072016/4/19
收件人 OrientDB
Hi Gerard,
you can try substituting

if ( login.countEdges (Direction.OUT, "Membre")== 0 ) {.....

with

var edge=login.getRecord().field("out_Membre");
if(edge==null || edge.size()==0){ ...


Best regards,
Alessandro

Gerard Vergoni

未读,
2016年4月19日 11:19:162016/4/19
收件人 OrientDB
it works with this code I'll do like that
Thank you very much for your help ...

it is amazing that the whole method of blueprints bookstore not use the "Direction" works fine in JavaScript! ... there probably has a solution, it would be interesting to find
回复全部
回复作者
转发
0 个新帖子