Package com.franz.agbase

Examples of com.franz.agbase.TriplesIterator


    // use Jena to determine what kind of query this is (AG doesn't seem to provide an operation for this)
    // so we call the appropriate execution method:
    Query query = QueryFactory.create(sparqlQuery);

    // only one of these results is captured
    TriplesIterator tripleIter = null;
    ValueSetIterator valSetIter = null;
    Boolean askResult = null;

   
    queryResult.setContentType("text/plain");

    // SELECT
    if ( query.isSelectType() ) {
      valSetIter = sq.select();
    }
    // DESCRIBE
    else if ( query.isDescribeType() ) {
      tripleIter = sq.describe();
    }
    // CONSTRUCT
    else if ( query.isConstructType() ) {
      tripleIter = sq.construct();
    }
    // ASK
    else if ( query.isAskType() ) {
      askResult = Boolean.valueOf(sq.ask());
    }

    if ( valSetIter != null ) {
      queryResult.setIsEmpty(! valSetIter.hasNext());
      String res;
     
      if ( form.equalsIgnoreCase("html") ) {
        queryResult.setContentType("text/html");
        res = AgUtils.getResultInHtml(log, valSetIter);
      }
      else if ( form.equalsIgnoreCase("n3") ) {
        queryResult.setContentType("text/plain");
        res = AgUtils.getResultInN3(log, valSetIter);
      }
      else if ( form.equalsIgnoreCase("nt") ) {
        queryResult.setContentType("text/plain");
        res = AgUtils.getResultInNTriples(log, valSetIter);
      }
      else if ( form.equalsIgnoreCase("csv") ) {
        queryResult.setContentType("text/plain");
        res = AgUtils.getResultInCsv(log, valSetIter);
      }
      else if ( form.equalsIgnoreCase("json") ) {
        queryResult.setContentType("application/json");
        res = AgUtils.getResultInJson(log, valSetIter);
      }
      else {
        queryResult.setContentType("text/html");
        res = AgUtils.getResultInHtml(log, valSetIter);
      }
     
      queryResult.setResult(res);
    }
    else if ( tripleIter != null ) {
      queryResult.setIsEmpty(! tripleIter.hasNext());
     
      // TODO: NOTE: the AG serializers are not working (not even in the examples provided by them)
     
      String res = null;
     
View Full Code Here


    System.out.println("Added " + ts.numberOfTriples() + " triples to the store.");
  }
 
  private static void getStatements(AllegroGraph ts) throws AllegroGraphException {
    System.out.println("getStatements...");
    TriplesIterator cc = ts.getStatements(false,null,null,null);
    showTriples(cc);

  }
View Full Code Here

TOP

Related Classes of com.franz.agbase.TriplesIterator

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.