Hi Enrico,

Although an OrientVertex uses an ODocument internally, you cannot cast a 
Vertex to an ODocument.

Are all of your edge classes derived from E and all of your vertex classes 
derived from V?

You might double-check that, just in case.

Best regards,

-Colin

Orient Technologies

The Company behind OrientDB


On Thursday, May 7, 2015 at 7:53:28 AM UTC-5, Enrico Di Marco wrote:
>
> Hi, 
> i'm trying to implement a time series function in Orient Graph 2.0.8
> i would like to build a simple series like the following
>
> Time --next--> Time --next--> Time --last-->Time
>
> where Time is a Vertex with timestamp and next and last are edges defined 
> both as classes at shema level
> target in the function is attached to the newly created timestamp Vertex
>
> my function is as folllow
>
> var now = new Date().getTime();
>     var gdb = orient.getGraph();
>     var last;
>     try {
>         //create time vtx
>         last = gdb.addVertex('class:Time');
>         last.setProperty('last_update', now);
>         //create edge  target->now
>         var targetV=gdb.getVertex(target);
>         if (targetV!=null){
>             
>           //return newLastE;
>             //se c'era un last aggiorno gli archi
>             var lastsE = gdb.getEdgesOfClass('last');
>             if (lastsE.iterator().hasNext()) {
>                 var oldLastE =lastsE.iterator().next();
>                  //return oldLastE;
>
>                 var inV=oldLastE.getInVertex();
>                 //return inV;
>                 var outV=oldLastE.getOutVertex();
>                 //return outV;
>
>                 var next=gdb.addEdge(null, outV, inV, "next");
>               //return next;
>                 oldLastE.remove();
>                 //return oldLastE;
>                 gdb.addEdge(null, inV, last, "last");
>             }else{
>                 //first time run
>                 var root = gdb.addVertex('class:Time');
>                 root.setProperty('last_update', 0);
>                 gdb.addEdge(null, root, last, "last");
>             }
>           var newLastE=gdb.addEdge(null, targetV, last, "updated"); //(id, 
> in, out, class)
>         }
>         gdb.commit();
>     } catch (err) {
>         gdb.rollback();
>         response.send(500, 'error creating time vertex', 'text/plain', 
> err.toString());
>     }
>     return last;
>
>
>
> the problem arise when i try to build the edge 'next' with an error
>
> java.lang.ClassCastException: 
> Cannotcastcom.orientechnologies.orient.core.record.impl.ODocumenttocom.tinkerpop.blueprints.Vertex
>
> i can i avoid this Cast and go ahead ?
>
> thanks for your time
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to