本文整理汇总了Java中com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP类的典型用法代码示例。如果您正苦于以下问题:Java QueryEngineHTTP类的具体用法?Java QueryEngineHTTP怎么用?Java QueryEngineHTTP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryEngineHTTP类属于com.hp.hpl.jena.sparql.engine.http包,在下文中一共展示了QueryEngineHTTP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResources
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
private Collection<String> getResources(String query, String varName)
{
Collection<String> ret = new HashSet<String>();
QueryEngineHTTP endpoint = new QueryEngineHTTP(SPARQL_ENDPOINT, query);
try {
ResultSet rs = endpoint.execSelect();
while (rs.hasNext()) {
QuerySolution qs = rs.next();
ret.add(qs.getResource(varName).getURI());
}
}
catch (Throwable t) {
t.printStackTrace();
}
finally {
endpoint.close();
}
return ret;
}
示例2: execQuery
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
private String[] execQuery(String query, Processor processor)
{
QueryEngineHTTP endpoint = new QueryEngineHTTP(_sparql, query);
try {
ResultSet rs = endpoint.execSelect();
if ( !rs.hasNext() ) { return EMPTY; }
List<String> l = new ArrayList<String>();
while (rs.hasNext())
{
String uri = processor.process(rs.next().get("x"));
if ( uri != null ) { l.add(uri); }
}
return ( l.size() == 0 ? EMPTY : l.toArray(EMPTY) );
}
catch (Throwable t) {
t.printStackTrace();
}
finally {
endpoint.close();
}
return EMPTY;
}
示例3: loadModelFromSPARQL
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
public static void loadModelFromSPARQL(Model m, String uri, boolean filter)
{
String sDescribe = buildDESCRIBE(uri);
System.out.println(sDescribe);
QueryEngineHTTP endpoint
= new QueryEngineHTTP(SPARQL_ENDPOINT, sDescribe);
try {
Model mTemp = ModelFactory.createDefaultModel();
endpoint.execDescribe(mTemp);
if ( filter ) { filterSubject(mTemp, uri); }
m.add(mTemp);
}
catch (RiotException e) {
System.out.println("Error: " + e.getMessage());
}
finally {
endpoint.close();
}
}
示例4: execQuery
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
private String[] execQuery(String query)
{
QueryEngineHTTP endpoint = new QueryEngineHTTP(_sparql, query);
try {
System.err.println(query);
//endpoint.setSelectContentType(WebContent.contentTypeResultsXML);
ResultSet rs = endpoint.execSelect();
if ( !rs.hasNext() ) { return EMPTY; }
List<String> l = new ArrayList<String>();
while (rs.hasNext())
{
String sameAs = rs.next().getResource("x").getURI();
if ( !_accept.matcher(sameAs).matches() ) { continue; }
l.add(sameAs);
}
return ( l.size() == 0 ? EMPTY : l.toArray(EMPTY) );
}
catch (Throwable t) {
t.printStackTrace();
}
finally {
endpoint.close();
}
return EMPTY;
}
示例5: harvest
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
private void harvest(String query, CSVWriter p)
{
QueryEngineHTTP endpoint = new QueryEngineHTTP(_sparql, query);
try {
System.err.println(query);
ResultSet rs = endpoint.execSelect();
if ( !rs.hasNext() ) { return; }
int cursor = 0;
while (rs.hasNext())
{
QuerySolution sol = rs.next();
String src = sol.getResource("src").getURI();
String trg = sol.getResource("trg").getURI();
p.println(src, trg);
if (++cursor % 1000 == 0) { System.out.println("fetched: " + cursor); }
}
}
catch (Throwable t) {
t.printStackTrace();
}
finally {
endpoint.close();
}
}
示例6: execGraphQuery
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
@Override
public Object execGraphQuery(String query) {
com.hp.hpl.jena.query.Query queryVar = QueryFactory.create(query) ;
QueryEngineHTTP qexec = QueryExecutionFactory.createServiceRequest(this.serviceURI, queryVar);
String params = prop.getProperty(Constants.URL_PARAM);
StringTokenizer paramTokens = new StringTokenizer(params, ";");
while(paramTokens.hasMoreTokens())
{
String token = paramTokens.nextToken();
qexec.addParam(token, prop.getProperty(token));
}
Model resultModel = qexec.execConstruct() ;
logger.info("Executing the RDF File Graph Query " + query);
return resultModel;
//qexec.close() ;
}
示例7: execSelectQuery
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
@Override
public Object execSelectQuery(String query) {
com.hp.hpl.jena.query.Query q2 = QueryFactory.create(query);
com.hp.hpl.jena.query.Query queryVar = QueryFactory.create(query) ;
QueryEngineHTTP qexec = QueryExecutionFactory.createServiceRequest(this.serviceURI, queryVar);
String params = prop.getProperty(Constants.URL_PARAM);
StringTokenizer paramTokens = new StringTokenizer(params, ";");
while(paramTokens.hasMoreTokens())
{
String token = paramTokens.nextToken();
qexec.addParam(token, prop.getProperty(token));
}
com.hp.hpl.jena.query.ResultSet rs = qexec.execSelect();
return rs;
}
示例8: addBasicInfo
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
private Cube addBasicInfo(String graph, String userId) {
ParameterizedSparqlString prepareQuery = new ParameterizedSparqlString(QUERY_CUBE_INFO);
prepareQuery.setIri("g", graph);
prepareQuery.setLiteral("auth", userId, XSDDatatype.XSDstring);
QueryEngineHTTP qeHTTP = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(TRIPLE_STORE, prepareQuery.toString());
ResultSet rs = qeHTTP.execSelect();
Cube cube = new Cube();
if (rs.hasNext()) {
QuerySolution result = rs.next();
cube.setGraph(graph);
cube.setAuth(userId);
cube.setLabel(result.get("label").toString());
cube.setId(result.get("id").toString());
cube.setDescription(result.get("description").toString());
}
qeHTTP.close();
return cube;
}
示例9: getDimensionsInfo
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
private List<Dimension> getDimensionsInfo(String graph) {
ParameterizedSparqlString prepareQuery = new ParameterizedSparqlString(QUERY_DIMENSION_INFO);
prepareQuery.setIri("g", graph);
QueryEngineHTTP qeHTTP = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(TRIPLE_STORE, prepareQuery.toString());
ResultSet rs = qeHTTP.execSelect();
List<Dimension> dims = new LinkedList<Dimension>();
while (rs.hasNext()) {
QuerySolution result = rs.next();
Dimension dim = new Dimension();
dim.setLabel(result.get("label").toString());
dim.setSubpropertyOf(result.get("subproperty").toString());
dim.setUrl(result.get("id").toString());
dims.add(dim);
}
qeHTTP.close();
return dims;
}
示例10: getMeasuresInfo
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
private List<Measure> getMeasuresInfo(String graph) {
ParameterizedSparqlString prepareQuery = new ParameterizedSparqlString(QUERY_MEASURE_INFO);
prepareQuery.setIri("g", graph);
QueryEngineHTTP qeHTTP = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(TRIPLE_STORE, prepareQuery.toString());
ResultSet rs = qeHTTP.execSelect();
List<Measure> measures = new LinkedList<Measure>();
while (rs.hasNext()) {
QuerySolution result = rs.next();
Measure measure = new Measure();
measure.setLabel(result.get("label").toString());
measure.setSubpropertyOf(result.get("subproperty").toString());
measure.setUrl(result.get("id").toString());
measures.add(measure);
}
qeHTTP.close();
return measures;
}
示例11: getLabelForResource
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
public String getLabelForResource(String graph, String resource) {
ParameterizedSparqlString prepareQuery = new ParameterizedSparqlString(COMPONENT_LABEL);
prepareQuery.setIri("g", graph);
prepareQuery.setIri("s", resource);
QueryEngineHTTP qeHTTP = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(TRIPLE_STORE, prepareQuery.toString());
ResultSet rs = qeHTTP.execSelect();
String label = "";
if (rs.hasNext()) {
QuerySolution result = rs.next();
label = result.get("label").toString();
}
qeHTTP.close();
return label;
}
示例12: getRangeForResource
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
public String getRangeForResource(String graph, String resource) {
ParameterizedSparqlString prepareQuery = new ParameterizedSparqlString(COMPONENT_RANGE);
prepareQuery.setIri("g", graph);
prepareQuery.setIri("s", resource);
QueryEngineHTTP qeHTTP = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(TRIPLE_STORE, prepareQuery.toString());
ResultSet rs = qeHTTP.execSelect();
String label = "";
if (rs.hasNext()) {
QuerySolution result = rs.next();
label = result.get("range").toString();
}
qeHTTP.close();
return label;
}
示例13: getDatasetFromUser
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
public DatasetDescription getDatasetFromUser(String graph, String userId) {
ParameterizedSparqlString prepareQuery = new ParameterizedSparqlString(QUERY_DATASET_DESCRIPTION);
prepareQuery.setIri("g", graph);
prepareQuery.setLiteral("auth", userId, XSDDatatype.XSDstring);
QueryEngineHTTP qeHTTP = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(TRIPLE_STORE, prepareQuery.toString());
ResultSet rs = qeHTTP.execSelect();
DatasetDescription dd = new DatasetDescription();
if (rs.hasNext()) {
QuerySolution result = rs.next();
dd.setNamedGraph(graph);
dd.setDatasetId(result.get("id").toString());
dd.setLabel(result.get("label").toString());
dd.setDescription(result.get("description").toString());
}
qeHTTP.close();
return dd;
}
示例14: getDatasetsFromUser
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
public List<DatasetDescription> getDatasetsFromUser(String userId) {
ParameterizedSparqlString prepareQuery = new ParameterizedSparqlString(QUERY_DATASET_DESCRIPTIONS);
prepareQuery.setLiteral("auth", userId, XSDDatatype.XSDstring);
QueryEngineHTTP qeHTTP = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(TRIPLE_STORE, prepareQuery.toString());
ResultSet rs = qeHTTP.execSelect();
List<DatasetDescription> descriptions = new LinkedList<DatasetDescription>();
while (rs.hasNext()) {
QuerySolution result = rs.next();
DatasetDescription dd = new DatasetDescription();
dd.setNamedGraph(result.get("g").toString());
dd.setDatasetId(result.get("id").toString());
dd.setLabel(result.get("label").toString());
dd.setDescription(result.get("description").toString());
descriptions.add(dd);
}
qeHTTP.close();
return descriptions;
}
示例15: getLabel
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入依赖的package包/类
public String getLabel(String graph) {
logger.debug("getLabel: " + graph);
ParameterizedSparqlString prepareQuery = new ParameterizedSparqlString(GRAPH_LABEL);
prepareQuery.setIri("g", graph);
QueryEngineHTTP qeHTTP = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(TRIPLE_STORE, prepareQuery.toString());
ResultSet rs = qeHTTP.execSelect();
List<String> labels = new LinkedList<String>();
while (rs.hasNext()) {
QuerySolution result = rs.next();
labels.add(result.get("label").toString());
}
qeHTTP.close();
if (labels == null || labels.size() != 1) {
logger.warn("label size != 1");
}
return labels.get(0);
}