예제 #1
0
  @Override
  public void process(final Exchange exchange) throws Exception {
    // If a query is set in the header or uri, use it
    Collection<String> queries = new ArrayList<String>();
    Collection tmp = exchange.getIn().getHeader(SPARQL_QUERY_PROP, Collection.class);
    if (tmp != null) {
      queries = tmp;
    } else {
      String query = exchange.getIn().getHeader(SPARQL_QUERY_PROP, String.class);
      if (query != null) {
        queries.add(query);
      }
    }

    if (queries.size() > 0) sparqlQuery(exchange, queries);
    else inputTriples(exchange);
  }
예제 #2
0
  protected void sparqlQuery(Exchange exchange, Collection<String> queries)
      throws RepositoryException, MalformedQueryException, QueryEvaluationException,
          TupleQueryResultHandlerException, RDFHandlerException {

    List list = new ArrayList();
    for (String query : queries) {

      //            Long startTime = exchange.getIn().getHeader(START_TIME_QUERY_PROP, Long.class);
      //            Long ttl = exchange.getIn().getHeader(TTL_QUERY_PROP, Long.class);
      String auth = exchange.getIn().getHeader(CONF_QUERY_AUTH, String.class);
      Boolean infer = exchange.getIn().getHeader(CONF_INFER, Boolean.class);

      Object output = performSelect(query, auth, infer);
      if (queries.size() == 1) {
        exchange.getOut().setBody(output);
        return;
      } else list.add(output);
    }
    exchange.getOut().setBody(list);
  }