Hi there, I'm been playing with orient a couple weeks and I have to say 
that I'm really impressed, the things you can do with this technology are 
really cool!, but working with some initials graphs, I stumble in a problem 
related to traverse API that I just cannot manage to solve.

I have a simple graph database defined like this:

[ProcesoGenerico#23:0{lanzable:false,nombre:clinica,sqlId:1,out_incluye:[#17:96,
 
#17:97, #17:98, #17:99, #17:100]} v6, incluye#17:96{in:#23:1,out:#23:0} v1, 
ProcesoGenerico#23:1{lanzable:false,nombre:enfermeria,sqlId:2,in_incluye:[size=1]}
 
v2, incluye#17:97{in:#23:2,out:#23:0} v1, 
ProcesoGenerico#23:2{lanzable:false,nombre:recepcionhxh,sqlId:3,in_incluye:[size=1]}
 
v2, incluye#17:98{in:#23:3,out:#23:0} v1, 
ProcesoGenerico#23:3{lanzable:false,nombre:urgencias,sqlId:4,in_incluye:[size=1]}
 
v2, incluye#17:99{in:#21:0,out:#23:0} v1, 
ElementoGenerico#21:0{nombre:ambulancia,lanzable:false,sqlId:1,in_incluye:[#17:99]}
 
v2, incluye#17:100{in:#23:4,out:#23:0} v1, 
ProcesoGenerico#23:4{lanzable:false,nombre:hospitalizacion,sqlId:5,in_incluye:[size=1]}
 
v2]

Which could be pretty much expressed like this:
#23:0 clinica 0
    #23:1 enfermeria 1
    #23:2 recepcionhxh 1
    #23:3 urgencias 1
    #21:0 ambulancia 1
    #23:4 hospitalizacion 1

then I have this method inside a spring bean:

public List<TreeElementDTO> getOperationalTree(String clusterId){
OrientGraph orientGraph  = graphFactory.getTx();
OTraverse traverse = orientGraph.traverse();
traverse.setStrategy(STRATEGY.DEPTH_FIRST);
List<TreeElementDTO> returnValue = new ArrayList<TreeElementDTO>();
 Vertex rootVertex = getOperationalModelRootNode();
if(rootVertex != null){
List<OIdentifiable> traverseList = 
traverse.field("out_incluye").field("in").target(orientGraph.getVertex(rootVertex.getId())).limit(200)
              .execute();  
System.out.println(traverseList);
orientGraph.shutdown();
retrieveOperationalTreeWithLeves(0, 0, 
traverseList.iterator(), 
returnValue);
}
return returnValue;
}

..a method to retrieve the root element..(I'm pretty sure this can be done 
inside the query itself, but still kind of lost on how to achieve it)
/**
 * This methods retrieves the root for the operational tree, this is used 
to order the way this is presented on the external app
 * @return the vertex
 */
private Vertex getOperationalModelRootNode(){
Vertex returnValue = null;
OrientGraph orientGraph  = graphFactory.getTx();
for(Vertex item : orientGraph.getVertices("@class", "ModeloOperativo")){
if(!item.getEdges(Direction.IN, "incluye").iterator().hasNext()){
return item;
}
}
return returnValue;
}


the connection is provided by a factory defined like this:

@Bean(name="graphFactory")
    public OrientGraphFactory factoryProducer() {
        log.debug("Configuring Orient Datasource");
        
//OGlobalConfiguration.INDEX_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(-1);
        if (propertyResolver.getProperty("url") == null || 
propertyResolver.getProperty("username") == null 
        || propertyResolver.getProperty("password") == null) {
            log.error("Your Orient database connection pool configuration 
is incorrect! The application" +
                    "cannot start. Please check your Spring profile, 
current profiles are: {}",
                    Arrays.toString(env.getActiveProfiles()));

            throw new ApplicationContextException("OrientDatabase 
connection pool is not configured correctly");
        }
        
        OrientGraphFactory orientDbFactory = new 
OrientGraphFactory(propertyResolver.getProperty("url"), 
        propertyResolver.getProperty("username"), 
propertyResolver.getProperty("password"));
        orientDbFactory.setupPool(10, 100);
        
        return orientDbFactory;
    }

My problem is that the call to the function returns different stuff from 
time to time as you can see on my app logs

[
ProcesoGenerico#23:0{lanzable:false,nombre:clinica,sqlId:1,out_incluye:[#17:96, 
#17:97]} v3, incluye#17:96{in:#23:1,out:#23:0} v1, 
ProcesoGenerico#23:1{lanzable:false,nombre:enfermeria,sqlId:2,in_incluye:[size=1]}
 
v2, incluye#17:97{in:#23:2,out:#23:0} v1, 
ProcesoGenerico#23:2{lanzable:false,nombre:recepcionhxh,sqlId:3,in_incluye:[size=1]}
 
v2]
#23:0 clinica 0
#23:1 enfermeria 1
#23:2 recepcionhxh 1
Hibernate: s...........
[
ProcesoGenerico#23:0{lanzable:false,nombre:clinica,sqlId:1,out_incluye:[#17:96, 
#17:97, #17:98, #17:99]} v5, incluye#17:96{in:#23:1,out:#23:0} v1, 
ProcesoGenerico#23:1{lanzable:false,nombre:enfermeria,sqlId:2,in_incluye:[size=1]}
 
v2, incluye#17:97{in:#23:2,out:#23:0} v1, 
ProcesoGenerico#23:2{lanzable:false,nombre:recepcionhxh,sqlId:3,in_incluye:[size=1]}
 
v2, incluye#17:98{in:#23:3,out:#23:0} v1, 
ProcesoGenerico#23:3{lanzable:false,nombre:urgencias,sqlId:4,in_incluye:[size=1]}
 
v2, incluye#17:99{in:#21:0,out:#23:0} v1, 
ElementoGenerico#21:0{nombre:ambulancia,lanzable:false,sqlId:1,in_incluye:[#17:99]}
 
v2]
#23:0 clinica 0
#23:1 enfermeria 1
#23:2 recepcionhxh 1
#23:3 urgencias 1
#21:0 ambulancia 1
Hibernate: select compa...............
[
ProcesoGenerico#23:0{lanzable:false,nombre:clinica,sqlId:1,out_incluye:[#17:96, 
#17:97, #17:98]} v4, incluye#17:96{in:#23:1,out:#23:0} v1, 
ProcesoGenerico#23:1{lanzable:false,nombre:enfermeria,sqlId:2,in_incluye:[size=1]}
 
v2, incluye#17:97{in:#23:2,out:#23:0} v1, 
ProcesoGenerico#23:2{lanzable:false,nombre:recepcionhxh,sqlId:3,in_incluye:[size=1]}
 
v2, incluye#17:98{in:#23:3,out:#23:0} v1, 
ProcesoGenerico#23:3{lanzable:false,nombre:urgencias,sqlId:4,in_incluye:[size=1]}
 
v2]
#23:0 clinica 0
#23:1 enfermeria 1
#23:2 recepcionhxh 1
#23:3 urgencias 1
Hibernate: select ................
[
ProcesoGenerico#23:0{lanzable:false,nombre:clinica,sqlId:1,out_incluye:[#17:96]}
 
v2, incluye#17:96{in:#23:1,out:#23:0} v1, 
ProcesoGenerico#23:1{lanzable:false,nombre:enfermeria,sqlId:2,in_incluye:[size=1]}
 
v2]
#23:0 clinica 0
#23:1 enfermeria 1
Hibernate: select com............
[
ProcesoGenerico#23:0{lanzable:false,nombre:clinica,sqlId:1,out_incluye:[#17:96, 
#17:97, #17:98, #17:99, #17:100]} v6, incluye#17:96{in:#23:1,out:#23:0} v1, 
ProcesoGenerico#23:1{lanzable:false,nombre:enfermeria,sqlId:2,in_incluye:[size=1]}
 
v2, incluye#17:97{in:#23:2,out:#23:0} v1, 
ProcesoGenerico#23:2{lanzable:false,nombre:recepcionhxh,sqlId:3,in_incluye:[size=1]}
 
v2, incluye#17:98{in:#23:3,out:#23:0} v1, 
ProcesoGenerico#23:3{lanzable:false,nombre:urgencias,sqlId:4,in_incluye:[size=1]}
 
v2, incluye#17:99{in:#21:0,out:#23:0} v1, 
ElementoGenerico#21:0{nombre:ambulancia,lanzable:false,sqlId:1,in_incluye:[#17:99]}
 
v2, incluye#17:100{in:#23:4,out:#23:0} v1, 
ProcesoGenerico#23:4{lanzable:false,nombre:hospitalizacion,sqlId:5,in_incluye:[size=1]}
 
v2]
#23:0 clinica 0
#23:1 enfermeria 1
#23:2 recepcionhxh 1
#23:3 urgencias 1
#21:0 ambulancia 1
#23:4 hospitalizacion 1

Rigth now I don't have concurrency problems, I'm the only person testing 
the application, and I just don't understand why, from call to call, the 
function just returns a different value. (the printed values correspond to 
System.out after traverse call).

I think it could be related to a miss use of traverse API, but after 
checking different questions on this forum, on stack, and also the oficial 
docs I'm still lost, so any help whould be apreciated

-- 

--- 
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 orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to