Ejemplo n.º 1
0
 @Override
 public IExtendedIterator<IStatement> match(
     IReference subject,
     IReference predicate,
     IValue object,
     boolean includeInferred,
     IReference... contexts) {
   String query;
   if (contexts.length > 0 && !includeInferred) {
     query = "SELECT DISTINCT ?s ?p ?o ?g WHERE { GRAPH ?g { ?s ?p ?o } }";
   } else {
     query = "SELECT DISTINCT ?s ?p ?o WHERE { ?s ?p ?o }";
   }
   IDataManagerQuery<?> dmQuery = createQuery(query, null, includeInferred, contexts);
   setParameters(dmQuery, subject, predicate, object);
   return dmQuery
       .evaluate()
       .mapWith(
           new IMap<Object, IStatement>() {
             @Override
             public IStatement map(Object value) {
               IBindings<?> bindings = (IBindings<?>) value;
               return new Statement(
                   (IReference) bindings.get("s"),
                   (IReference) bindings.get("p"),
                   bindings.get("o"),
                   (IReference) bindings.get("g"));
             }
           });
 }
Ejemplo n.º 2
0
 @Override
 public boolean hasMatch(
     IReference subject,
     IReference predicate,
     IValue object,
     boolean includeInferred,
     IReference... contexts) {
   String query;
   if (contexts.length > 0 && !includeInferred) {
     query = "ASK { GRAPH ?g { ?s ?p ?o } }";
   } else {
     query = "ASK { ?s ?p ?o }";
   }
   IDataManagerQuery<?> dmQuery = createQuery(query, null, includeInferred, contexts);
   setParameters(dmQuery, subject, predicate, object);
   Object result = dmQuery.evaluate().next();
   return Boolean.TRUE.equals(result);
 }