Package org.atomojo.sparql

Examples of org.atomojo.sparql.Triple


      List<Triple> triples = select.getWhereClause().getClauses();
      pivot = null;
      entryPivot = false;
      feedPivot = false;
      unsatisfiable = false;
      Triple lastBind = null;
      for (Triple t : triples) {
         Ref subject = t.getSubject();
         Ref predicate = t.getPredicate();
         Ref object = t.getObject();
         if (subject instanceof VariableRef && predicate instanceof TermRef && object instanceof NilRef) {
            String name = ((VariableRef)subject).getName();
            if (name.equals(var)) {
               URI term = ((TermRef)predicate).getTerm();
               if (term.equals(ENTRY_TERM)) {
                  entryPivot = true;
               } else if (term.equals(FEED_TERM)) {
                  feedPivot = true;
               } else if (pivot==null) {
                  pivot = t;
                  pivotTerm = term;
                  log.info("Pivoting on "+pivot);
                  pivotValue = pivot.getObject() instanceof LiteralRef ? ((LiteralRef)pivot.getObject()).getValue() : Nil.getInstance();
               }
            } else {
               unsatisfiable = true;
            }
         } else if (subject instanceof TermRef) {
            // should be ok (e.g. find a specific entry/feed)
            log.info("Unsatisfiable triple "+t);
            unsatisfiable = true;
         } else if (subject instanceof VariableRef && predicate instanceof TermRef && object instanceof LiteralRef) {
            // ok
            // limit to var now
            String name = ((VariableRef)subject).getName();
            if (!name.equals(var)) {
               log.info("Unsatisfiable triple "+t);
               unsatisfiable = true;
            } else if (pivot==null) {
               pivot = t;
               pivotTerm = ((TermRef)predicate).getTerm();
               log.info("Pivoting on "+pivot);
               pivotValue = pivot.getObject() instanceof LiteralRef ? ((LiteralRef)pivot.getObject()).getValue() : Nil.getInstance();
            }
         } else if (subject instanceof VariableRef && predicate instanceof TermRef && object instanceof VariableRef) {
            // ok
            // limit to var now
            String name = ((VariableRef)subject).getName();
            if (!name.equals(var)) {
               log.info("Unsatisfiable triple "+t);
               unsatisfiable = true;
            } else {
               lastBind = t;
            }
         } else {
            // unsatisfiable
            log.info("Unsatisfiable triple "+t);
            unsatisfiable = true;
         }
      }
      if (entryPivot && feedPivot) {
         log.info("Entry and feed predicates on same variable is unsatisfiable.");
         unsatisfiable = true;
      }
      if (!unsatisfiable && pivot==null) {
         pivot = lastBind;
         pivotTerm = ((TermRef)lastBind.getPredicate()).getTerm();
         log.info("Pivoting on "+pivot);
         pivotValue = pivot.getObject() instanceof LiteralRef ? ((LiteralRef)pivot.getObject()).getValue() : Nil.getInstance();
      }
   }
View Full Code Here

TOP

Related Classes of org.atomojo.sparql.Triple

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.