當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryExecution.execDescribe方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.query.QueryExecution.execDescribe方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryExecution.execDescribe方法的具體用法?Java QueryExecution.execDescribe怎麽用?Java QueryExecution.execDescribe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.query.QueryExecution的用法示例。


在下文中一共展示了QueryExecution.execDescribe方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sparqlDescribe

import com.hp.hpl.jena.query.QueryExecution; //導入方法依賴的package包/類
/**
 * @return opened result Model
 */
@Override
public ClosableIterable<Statement> sparqlDescribe(String queryString)
        throws ModelRuntimeException {
	assertModel();
	Query query = QueryFactory.create(queryString);
	QueryExecution qexec = QueryExecutionFactory.create(query, this.jenaModel);
	
	if(query.isDescribeType()) {
		com.hp.hpl.jena.rdf.model.Model m = qexec.execDescribe();
		Model resultModel = new ModelImplJena(null, m, Reasoning.none);
		resultModel.open();
		return resultModel;
	} else {
		throw new RuntimeException("Cannot handle this type of queries! Please use DESCRIBE.");
	}
	
}
 
開發者ID:semweb4j,項目名稱:semweb4j,代碼行數:21,代碼來源:ModelImplJena.java

示例2: sparqlDescribe

import com.hp.hpl.jena.query.QueryExecution; //導入方法依賴的package包/類
@Override
public ClosableIterable<Statement> sparqlDescribe(String query)
		throws ModelRuntimeException {
	Query jenaQuery = QueryFactory.create(query);
	QueryExecution qexec = QueryExecutionFactory.create(jenaQuery,
			this.dataset);

	if (jenaQuery.isDescribeType()) {
		com.hp.hpl.jena.rdf.model.Model m = qexec.execDescribe();
		Model resultModel = new ModelImplJena(null, m, Reasoning.none);
		resultModel.open();
		return resultModel;
	} else {
		throw new RuntimeException(
				"Cannot handle this type of query! Please use DESCRIBE.");
	}
}
 
開發者ID:semweb4j,項目名稱:semweb4j,代碼行數:18,代碼來源:ModelSetImplJena.java

示例3: getCBD

import com.hp.hpl.jena.query.QueryExecution; //導入方法依賴的package包/類
private Model getCBD(String uri, String endpoint, String graph) {

		String query = "DESCRIBE <" + uri + ">";
		System.out.println(query);
		Query sparqlQuery = QueryFactory.create(query, Syntax.syntaxARQ);
		QueryExecution qexec = QueryExecutionFactory.sparqlService(
				endpoint, sparqlQuery, graph);
		Model m2;
		try {
			m2 = qexec.execDescribe();
		} catch (Exception e) {
			// the result vector is too large: create empty model
			m2 = ModelFactory.createDefaultModel();
		}
		return m2;
		
	}
 
開發者ID:mommi84,項目名稱:Mandolin,代碼行數:18,代碼來源:DatasetBuildSemantifier.java

示例4: getCBD

import com.hp.hpl.jena.query.QueryExecution; //導入方法依賴的package包/類
public Model getCBD(Resource r) {
	String sparqlQueryString = "DESCRIBE <" + r + ">";
	QueryFactory.create(sparqlQueryString);
	QueryExecution qexec = QueryExecutionFactory.sparqlService(
			endpoint, sparqlQueryString, graph);
	Model cbd = qexec.execDescribe();
	qexec.close();
	return cbd;
}
 
開發者ID:AKSW,項目名稱:rocker,代碼行數:10,代碼來源:CBDBuilder.java

示例5: showQueryResults

import com.hp.hpl.jena.query.QueryExecution; //導入方法依賴的package包/類
private void showQueryResults(String queryString, HttpServletRequest request, HttpServletResponse response) 
		throws IOException {
	Query query = QueryFactory.create(queryString);
	if(query.isSelectType() || query.isDescribeType()) {
		Config config = new Config(request);
		ResultsFormat fmt = ResultsFormat.lookup(request.getParameter("format"));
		Dataset tdbstore = TDBFactory.createDataset(config.getTripleStoreDir());
		QueryExecution qexec = QueryExecutionFactory.create(query, tdbstore);
		qexec.getContext().set(TDB.symUnionDefaultGraph, true);
		if(query.isSelectType()) {
 			ResultSet results = qexec.execSelect();
 			if(fmt == null) {
 				out.print(queryString+"\n");
 				ResultSetFormatter.out(out, results, query);
 			}
 			else
 				ResultSetFormatter.output(out, results, fmt);
		}
		else {
		  Model model = qexec.execDescribe();
       RDFWriter rdfWriter = model.getWriter("RDF/XML-ABBREV");
       rdfWriter.setProperty("showXmlDeclaration", "true");
       rdfWriter.setProperty("tab", "6");
       rdfWriter.write(model, out, null);
		}
	}
	else {
		out.print("Only select or describe queries allowed");
	}
}
 
開發者ID:IKCAP,項目名稱:turbosoft,代碼行數:31,代碼來源:SparqlEndpoint.java

示例6: execute

import com.hp.hpl.jena.query.QueryExecution; //導入方法依賴的package包/類
@Override
public Object execute(Map<String, EdmLiteral> parameters) throws ODataException
{
   EdmLiteral query_lit = parameters.remove("query");
   // Olingo2 checks for presence of non-nullable parameters for us!
   String query_s = query_lit.getLiteral();
   Query query = QueryFactory.create(query_s);
   if (!(query.isSelectType() || query.isDescribeType()))
   {
      throw new InvalidOperationException(query.getQueryType());
   }

   DrbCortexModel cortexmodel;
   try
   {
      cortexmodel = DrbCortexModel.getDefaultModel();
   }
   catch (IOException ex)
   {
      throw new RuntimeException(ex);
   }

   Model model = cortexmodel.getCortexModel().getOntModel();

   QueryExecution qexec = null;
   // FIXME: QueryExecution in newer versions of Jena (post apache incubation) implement AutoClosable.
   try
   {
      qexec = QueryExecutionFactory.create(query, model);
      if (query.isSelectType())
      {
         ResultSet results = qexec.execSelect();
         return ResultSetFormatter.asXMLString(results);
      }
      else
      {
         Model description = qexec.execDescribe();
         // newer version of Jena have the RIOT package for I/O
         StringWriter strwrt = new StringWriter();
         Abbreviated abb = new Abbreviated();
         abb.write(description, strwrt, null);
         return strwrt.toString();
      }
   }
   finally
   {
      if (qexec != null)
      {
         qexec.close();
      }
   }
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:53,代碼來源:Sparql.java

示例7: doGet

import com.hp.hpl.jena.query.QueryExecution; //導入方法依賴的package包/類
protected void doGet(HttpServletRequest request,
		HttpServletResponse response) throws IOException, ServletException {
	D2RServer server = D2RServer.fromServletContext(getServletContext());
	server.checkMappingFileChanged();
	String relativeResourceURI = request.getRequestURI().substring(
			request.getContextPath().length()
					+ request.getServletPath().length());
	// Some servlet containers keep the leading slash, some don't
	if (!"".equals(relativeResourceURI)
			&& "/".equals(relativeResourceURI.substring(0, 1))) {
		relativeResourceURI = relativeResourceURI.substring(1);
	}
	if (request.getQueryString() != null) {
		relativeResourceURI = relativeResourceURI + "?"
				+ request.getQueryString();
	}

	/* Determine service stem, i.e. vocab/ in /[vocab/]data */
	int servicePos;
	if (-1 == (servicePos = request.getServletPath().indexOf(
			"/" + D2RServer.getDataServiceName())))
		throw new ServletException("Expected to find service path /"
				+ D2RServer.getDataServiceName());
	String serviceStem = request.getServletPath().substring(1,
			servicePos + 1);

	String resourceURI = RequestParamHandler
			.removeOutputRequestParam(server.resourceBaseURI(serviceStem)
					+ relativeResourceURI);
	String documentURL = server.dataURL(serviceStem, relativeResourceURI);

	String pageURL = server.pageURL(serviceStem, relativeResourceURI);

	String sparqlQuery = "DESCRIBE <" + resourceURI + ">";
	QueryExecution qe = QueryExecutionFactory.create(sparqlQuery,
			server.dataset());
	if (server.getConfig().getPageTimeout() > 0) {
		qe.setTimeout(Math.round(server.getConfig().getPageTimeout() * 1000));
	}
	Model description = qe.execDescribe();
	qe.close();
	
	if (description.size() == 0) {
		response.sendError(404);
	}
	if (description.qnameFor(FOAF.primaryTopic.getURI()) == null
			&& description.getNsPrefixURI("foaf") == null) {
		description.setNsPrefix("foaf", FOAF.NS);
	}
	Resource resource = description.getResource(resourceURI);

	Resource document = description.getResource(documentURL);
	document.addProperty(FOAF.primaryTopic, resource);

	Statement label = resource.getProperty(RDFS.label);
	if (label != null) {
		document.addProperty(RDFS.label,
				"RDF Description of " + label.getString());
	}
	server.addDocumentMetadata(description, document);
	if (server.getConfig().serveMetadata()) {
		// add document metadata from template
		Model resourceMetadataTemplate = server.getConfig().getResourceMetadataTemplate(
				server, getServletContext());
		MetadataCreator resourceMetadataCreator = new MetadataCreator(
				server, resourceMetadataTemplate);
		description.add(resourceMetadataCreator.addMetadataFromTemplate(
				resourceURI, documentURL, pageURL));
		
		Map<String, String> descPrefixes = description.getNsPrefixMap();
		descPrefixes.putAll(resourceMetadataTemplate.getNsPrefixMap());
		description.setNsPrefixes(descPrefixes);
	}
	// TODO: Add a Content-Location header
	new ModelResponse(description, request, response).serve();
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:77,代碼來源:ResourceDescriptionServlet.java


注:本文中的com.hp.hpl.jena.query.QueryExecution.execDescribe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。