code: private OntModel getGraphSparqlQuery(URI graphUri) {
  
          StringBuilder queryStr = new StringBuilder("CONSTRUCT { ?s ?p ?o } \n")
                  .append("WHERE {\n");
  
          // Add named graph if necessary
          if (graphUri != null) {
              queryStr.append("GRAPH <").append(graphUri.toASCIIString()).append("> ");
          }
          queryStr.append("{ ?s ?p ?o } } \n");
  
          log.debug("Querying graph store: {}", queryStr.toString());
  
          Query query = QueryFactory.create(queryStr.toString());
          QueryExecution qe = QueryExecutionFactory.sparqlService(this.getSparqlQueryEndpoint().toASCIIString(), query);
          MonitoredQueryExecution qexec = new MonitoredQueryExecution(qe);
          // Note that we are not using the store specification here to avoid retrieving remote models
  //        OntModel resultModel = ModelFactory.createOntologyModel();
          OntModel resultModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF);
          try {
              qexec.execConstruct(resultModel);
              return resultModel;
          } finally {
              qexec.close();
          }
      }
docs: Obtains the OntModel within a named graph or the default graph if no graphUri is provided
  
  @param graphUri
  @return