Examples of DatasetImpl


Examples of org.openrdf.query.impl.DatasetImpl

  public void optimize(QueryModel query, BindingSet bindings)
    throws RdbmsException
  {
    if (!query.getDefaultGraphs().isEmpty() || !query.getNamedGraphs().isEmpty()) {
      this.dataset = new DatasetImpl(query.getDefaultGraphs(), query.getNamedGraphs());
    }
    this.bindings = bindings;
    query.visit(this);
  }
View Full Code Here

Examples of org.openrdf.query.impl.DatasetImpl

    BooleanQuery query = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString());
    query.setBinding("name", nameBob);

    assertTrue(query.ask());

    DatasetImpl dataset = new DatasetImpl();

    // default graph: {context1}
    dataset.addDefaultGraph(context1);
    query.setDataset(dataset);
    assertTrue(query.ask());

    // default graph: {context1, context2}
    dataset.addDefaultGraph(context2);
    query.setDataset(dataset);
    assertTrue(query.ask());

    // default graph: {context2}
    dataset.removeDefaultGraph(context1);
    query.setDataset(dataset);
    assertFalse(query.ask());

    queryBuilder.setLength(0);
    queryBuilder.append("PREFIX foaf: <" + FOAF_NS + "> ");
    queryBuilder.append("ASK ");
    queryBuilder.append("{ GRAPH ?g { ?p foaf:name ?name } }");

    query = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString());
    query.setBinding("name", nameBob);

    // default graph: {context2}; named graph: {}
    query.setDataset(dataset);
    assertFalse(query.ask());

    // default graph: {context1, context2}; named graph: {context2}
    dataset.addDefaultGraph(context1);
    dataset.addNamedGraph(context2);
    query.setDataset(dataset);
    assertFalse(query.ask());

    // default graph: {context1, context2}; named graph: {context1, context2}
    dataset.addNamedGraph(context1);
    query.setDataset(dataset);
    assertTrue(query.ask());
  }
View Full Code Here

Examples of org.openrdf.query.impl.DatasetImpl

  {
    boolean includeInferred = ServerUtil.parseBooleanParam(params, INCLUDE_INFERRED_PARAM_NAME,
        query.getIncludeInferred());
    query.setIncludeInferred(includeInferred);

    DatasetImpl dataset = parseDataset(params, vf);
    if (dataset != null) {
      query.setDataset(dataset);
    }

    if (query instanceof TupleQuery) {
View Full Code Here

Examples of org.openrdf.query.impl.DatasetImpl

  {
    // build a dataset, if specified
    String[] defaultGraphURIs = params.getValuesArray(DEFAULT_GRAPH_PARAM_NAME);
    String[] namedGraphURIs = params.getValuesArray(NAMED_GRAPH_PARAM_NAME);

    DatasetImpl dataset = null;

    if (defaultGraphURIs != null || namedGraphURIs != null) {
      dataset = new DatasetImpl();

      if (defaultGraphURIs != null) {
        for (String defaultGraphURI : defaultGraphURIs) {
          try {
            URI uri = vf.createURI(defaultGraphURI);
            dataset.addDefaultGraph(uri);
          }
          catch (IllegalArgumentException e) {
            throw new ResourceException(CLIENT_ERROR_BAD_REQUEST, "Illegal URI for default graph: "
                + defaultGraphURI);
          }
        }
      }

      if (namedGraphURIs != null) {
        for (String namedGraphURI : namedGraphURIs) {
          try {
            URI uri = vf.createURI(namedGraphURI);
            dataset.addNamedGraph(uri);
          }
          catch (IllegalArgumentException e) {
            throw new ResourceException(CLIENT_ERROR_BAD_REQUEST, "Illegal URI for named graph: "
                + namedGraphURI);
          }
View Full Code Here

Examples of org.openrdf.query.impl.DatasetImpl

        } else {
            this.contexts = new URI[]{};
        }
        //also init the dataset required for SPARQL queries
        if(contexts.length > 0){
            DatasetImpl dataset = new DatasetImpl();
            for(URI context : this.contexts){
                dataset.addNamedGraph(context);
                dataset.addDefaultGraph(context);
            }
            this.dataset = dataset;
        } else {
            this.dataset = null;
        }
View Full Code Here

Examples of org.openrdf.query.impl.DatasetImpl

// build a dataset, if specified
        String[] defaultGraphURIs = form.getValuesArray( DEFAULT_GRAPH_PARAM_NAME );
        String[] namedGraphURIs = form.getValuesArray( NAMED_GRAPH_PARAM_NAME );

        DatasetImpl dataset = null;
        if( defaultGraphURIs.length > 0 || namedGraphURIs.length > 0 )
        {
            dataset = new DatasetImpl();

            if( defaultGraphURIs.length > 0 )
            {
                for( String defaultGraphURI : defaultGraphURIs )
                {
                    try
                    {
                        URI uri = repository.getValueFactory().createURI( defaultGraphURI );
                        dataset.addDefaultGraph( uri );
                    }
                    catch( IllegalArgumentException e )
                    {
                        throw new ResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "Illegal URI for default graph: "
                                                                                      + defaultGraphURI );
                    }
                }
            }

            if( namedGraphURIs.length > 0 )
            {
                for( String namedGraphURI : namedGraphURIs )
                {
                    try
                    {
                        URI uri = repository.getValueFactory().createURI( namedGraphURI );
                        dataset.addNamedGraph( uri );
                    }
                    catch( IllegalArgumentException e )
                    {
                        throw new ResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "Illegal URI for named graph: "
                                                                                      + namedGraphURI );
View Full Code Here

Examples of org.openrdf.query.impl.DatasetImpl

   *         If DatasetClause does not contain a valid URI.
   */
  public static Dataset process(ASTQueryContainer qc)
    throws MalformedQueryException
  {
    DatasetImpl dataset = null;

    List<ASTDatasetClause> datasetClauses = qc.getQuery().getDatasetClauseList();

    if (!datasetClauses.isEmpty()) {
      dataset = new DatasetImpl();

      for (ASTDatasetClause dc : datasetClauses) {
        ASTIRI astIri = dc.jjtGetChild(ASTIRI.class);

        try {
          URI uri = new URIImpl(astIri.getValue());
          if (dc.isNamed()) {
            dataset.addNamedGraph(uri);
          }
          else {
            dataset.addDefaultGraph(uri);
          }
        }
        catch (IllegalArgumentException e) {
          throw new MalformedQueryException(e.getMessage(), e);
        }
View Full Code Here

Examples of org.openrdf.query.impl.DatasetImpl

    // build a dataset, if specified
    String[] defaultGraphURIs = request.getParameterValues(DEFAULT_GRAPH_PARAM_NAME);
    String[] namedGraphURIs = request.getParameterValues(NAMED_GRAPH_PARAM_NAME);

    DatasetImpl dataset = null;
    if (defaultGraphURIs != null || namedGraphURIs != null) {
      dataset = new DatasetImpl();

      if (defaultGraphURIs != null) {
        for (String defaultGraphURI : defaultGraphURIs) {
          try {
            URI uri = repository.getValueFactory().createURI(defaultGraphURI);
            dataset.addDefaultGraph(uri);
          }
          catch (IllegalArgumentException e) {
            throw new ClientHTTPException(SC_BAD_REQUEST, "Illegal URI for default graph: "
                + defaultGraphURI);
          }
        }
      }

      if (namedGraphURIs != null) {
        for (String namedGraphURI : namedGraphURIs) {
          try {
            URI uri = repository.getValueFactory().createURI(namedGraphURI);
            dataset.addNamedGraph(uri);
          }
          catch (IllegalArgumentException e) {
            throw new ClientHTTPException(SC_BAD_REQUEST, "Illegal URI for named graph: "
                + namedGraphURI);
          }
View Full Code Here

Examples of org.openrdf.query.impl.DatasetImpl

    BooleanQuery query = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString());
    query.setBinding("name", nameBob);

    assertTrue(query.evaluate());

    DatasetImpl dataset = new DatasetImpl();

    // default graph: {context1}
    dataset.addDefaultGraph(context1);
    query.setDataset(dataset);
    assertTrue(query.evaluate());

    // default graph: {context1, context2}
    dataset.addDefaultGraph(context2);
    query.setDataset(dataset);
    assertTrue(query.evaluate());

    // default graph: {context2}
    dataset.removeDefaultGraph(context1);
    query.setDataset(dataset);
    assertFalse(query.evaluate());

    queryBuilder.setLength(0);
    queryBuilder.append("PREFIX foaf: <" + FOAF_NS + "> ");
    queryBuilder.append("ASK ");
    queryBuilder.append("{ GRAPH ?g { ?p foaf:name ?name } }");

    query = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString());
    query.setBinding("name", nameBob);

    // default graph: {context2}; named graph: {}
    query.setDataset(dataset);
    assertFalse(query.evaluate());

    // default graph: {context1, context2}; named graph: {context2}
    dataset.addDefaultGraph(context1);
    dataset.addNamedGraph(context2);
    query.setDataset(dataset);
    assertFalse(query.evaluate());

    // default graph: {context1, context2}; named graph: {context1, context2}
    dataset.addNamedGraph(context1);
    query.setDataset(dataset);
    assertTrue(query.evaluate());
  }
View Full Code Here

Examples of org.openrdf.query.impl.DatasetImpl

      // Query named graphs
      namedGraphsQuery.setBinding("action", action);
      TupleQueryResult namedGraphs = namedGraphsQuery.evaluate();

      DatasetImpl dataset = null;

      if (defaultGraphURI != null || namedGraphs.hasNext()) {
        dataset = new DatasetImpl();

        if (defaultGraphURI != null) {
          dataset.addDefaultGraph(defaultGraphURI);
        }

        while (namedGraphs.hasNext()) {
          BindingSet graphBindings = namedGraphs.next();
          URI namedGraphURI = (URI)graphBindings.getValue("graph");
          dataset.addNamedGraph(namedGraphURI);
        }
      }

      suite.addTest(factory.createSPARQLQueryTest(testURI, testName, queryFile, resultFile, dataset));
    }
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.