Package org.openrdf.query.impl

Examples of org.openrdf.query.impl.DatasetImpl


    if (dataset != null) {
      return dataset;
    }

    // No external dataset specified, use query's own dataset (if any)
    return new DatasetImpl(parsedQuery.getDefaultGraphs(), parsedQuery.getNamedGraphs());
  }
View Full Code Here


  }

  public EvaluationStrategyImpl(TripleSource tripleSource, QueryModel query) {
    this(tripleSource);
    if (!query.getDefaultGraphs().isEmpty() || !query.getNamedGraphs().isEmpty()) {
      this.dataset = new DatasetImpl(query.getDefaultGraphs(), query.getNamedGraphs());
    }
  }
View Full Code Here

   *         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

    }
  }

  private <Q extends Query> Q initQuery(Q query) {
    if (readContexts.length > 0) {
      DatasetImpl ds = new DatasetImpl();
      for (URI graph : readContexts) {
        ds.addDefaultGraph(graph);
        ds.addNamedGraph(graph);
      }
      query.setDataset(ds);
    }

    query.setIncludeInferred(includeInferred);
View Full Code Here

      // Query named graphs
      namedGraphsQuery.setBinding("action", action);
      TupleResult 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);
        }
      }

      // Check for lax-cardinality conditions
      boolean laxCardinality = false;
View Full Code Here

  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

    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

  {
    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

  {
    // 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

        } 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

TOP

Related Classes of org.openrdf.query.impl.DatasetImpl

Copyright © 2018 www.massapicom. 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.