Examples of GraphQuery


Examples of com.complexible.stardog.api.GraphQuery

 
  public <T> List<T> construct(String sparql,  Map<String, Object> args, GraphMapper<T> mapper) {
    Connection connection = dataSource.getConnection();
    GraphQueryResult result = null;
    try {
      GraphQuery query = connection.graph(sparql);
     
      if (args != null) {
        for (Entry<String, Object> arg : args.entrySet()) {          
          query.parameter(arg.getKey(), arg.getValue());
        }
      }
     
      ArrayList<T> list = new ArrayList<T>();
     
      result = query.execute();
     
      // return empty lists for empty queries
      if (result == null) {
        return list;
      }
View Full Code Here

Examples of com.hp.hpl.jena.graph.query.GraphQuery

        { return graphAdd( getGraph(), triples ); }
   
    public void testS()
        { 
        Graph g = geGraphSPO();
        GraphQuery q = new GraphQuery().addMatch( GraphQuery.X, RDF.Nodes.subject, GraphQuery.S );
        ExtendedIterator<Node> it = q.executeBindings( g, new Node[] {GraphQuery.X, GraphQuery.S} ).mapWith( select(1) );
        assertEquals( nodeSet( "S" ), it.toSet() );
        }
View Full Code Here

Examples of com.hp.hpl.jena.graph.query.GraphQuery

        assertEquals( nodeSet( "S" ), it.toSet() );
        }
    public void testP()
        { 
        Graph g = geGraphSPO();
        GraphQuery q = new GraphQuery().addMatch( GraphQuery.X, RDF.Nodes.predicate, GraphQuery.P );
        ExtendedIterator<Node> it = q.executeBindings( g, new Node[] {GraphQuery.X, GraphQuery.P} ).mapWith( select(1) );
        assertEquals( nodeSet( "P" ), it.toSet() );
        }
View Full Code Here

Examples of com.hp.hpl.jena.graph.query.GraphQuery

        }
   
    public void testO()
        { 
        Graph g = geGraphSPO();
        GraphQuery q = new GraphQuery().addMatch( GraphQuery.X, RDF.Nodes.object, GraphQuery.O );
        ExtendedIterator<Node> it = q.executeBindings( g, new Node[] {GraphQuery.X, GraphQuery.O} ).mapWith( select(1) );
        assertEquals( nodeSet( "O" ), it.toSet() );
        }
View Full Code Here

Examples of com.hp.hpl.jena.graph.query.GraphQuery

        a.addProperty(p, l1);
        assertTrue(model.getGraph().find(null, p.asNode(), l1.asNode()).hasNext());
        assertTrue(model.getGraph().find(null, p.asNode(), l2.asNode()).hasNext());
        assertTrue(model.getGraph().find(a.asNode(), p.asNode(), l2.asNode()).hasNext());
        assertTrue( model.getGraph().contains( a.asNode(), p.asNode(), l2.asNode() ) );
        GraphQuery q = new GraphQuery();
        q.addMatch(a.asNode(), p.asNode(), l2.asNode());
        Iterator<Domain> qi = model.getGraph().queryHandler().prepareBindings(q, new Node[] {}).executeBindings();
        assertTrue(qi.hasNext());
        // Similar tests at Model API level
        // Selector s1 = new SimpleSelector(a, p, l2);
        assertTrue(model.listStatements( a, p, l2 ).hasNext());
View Full Code Here

Examples of com.hp.hpl.jena.graph.query.GraphQuery

    public TestQuery( String name )
        { super( name ); }

    public void testEmptyQueryPattern()
        {
        assertEquals( new ArrayList<Triple>(), new GraphQuery().getPattern() );
        }
View Full Code Here

Examples of com.hp.hpl.jena.graph.query.GraphQuery

        assertEquals( new ArrayList<Triple>(), new GraphQuery().getPattern() );
        }
   
    public void testIOneTriple()
        {
        GraphQuery q = new GraphQuery();
        Triple spo = triple( "S P O" );
        q.addMatch( spo );
        assertEquals( listOfOne( spo ), q.getPattern() );
        }
View Full Code Here

Examples of com.hp.hpl.jena.graph.query.GraphQuery

   
    public void testSeveralTriples()
        {
        Triple [] triples = tripleArray( "a P b; c Q ?d; ?e R '17'" );
        List<Triple> expected = new ArrayList<Triple>();
        GraphQuery q = new GraphQuery();
        for (int i = 0; i < triples.length; i += 1)
            {
            expected.add( triples[i] );
            q.addMatch( triples[i] );
            assertEquals( expected, q.getPattern() );           
            }
        }
View Full Code Here

Examples of com.tinkerpop.blueprints.GraphQuery

    protected Vertex findVertex(String name, RelationshipType type) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Finding vertex for: name=" + name + ", type=" + type);
        }

        GraphQuery query = graph.query()
                .has(RelationshipProperty.NAME.getName(), name)
                .has(RelationshipProperty.TYPE.getName(), type.getName());
        Iterator<Vertex> results = query.vertices().iterator();
        return results.hasNext() ? results.next() : null// returning one since name is unique
    }
View Full Code Here

Examples of com.tinkerpop.blueprints.GraphQuery

        Assert.assertTrue(actual.containsAll(Arrays.asList("imp-click-join1", "imp-click-join2")),
                "Actual does not contain expected: " + actual);
    }

    private Vertex getEntityVertex(String entityName, RelationshipType entityType) {
        GraphQuery entityQuery = getQuery()
                .has(RelationshipProperty.NAME.getName(), entityName)
                .has(RelationshipProperty.TYPE.getName(), entityType.getName());
        Iterator<Vertex> iterator = entityQuery.vertices().iterator();
        Assert.assertTrue(iterator.hasNext());

        Vertex entityVertex = iterator.next();
        Assert.assertNotNull(entityVertex);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.