本文整理汇总了Java中com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP.execSelect方法的典型用法代码示例。如果您正苦于以下问题:Java QueryEngineHTTP.execSelect方法的具体用法?Java QueryEngineHTTP.execSelect怎么用?Java QueryEngineHTTP.execSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP
的用法示例。
在下文中一共展示了QueryEngineHTTP.execSelect方法的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: 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;
}
示例4: 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();
}
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: 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);
}
示例14: getEntityDefs
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入方法依赖的package包/类
public List<EntityDefinition> getEntityDefs(String graph) {
logger.debug("getEntityDefs: " + graph);
ParameterizedSparqlString prepareQuery = new ParameterizedSparqlString(ENTITY_LABEL_QUERY);
prepareQuery.setIri("g", graph);
QueryEngineHTTP qeHTTP = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(TRIPLE_STORE, prepareQuery.toString());
ResultSet rs = qeHTTP.execSelect();
List<EntityDefinition> entities = new LinkedList<EntityDefinition>();
while (rs.hasNext()) {
QuerySolution result = rs.next();
EntityDefinition ed = new EntityDefinition();
ed.setResource(result.get("s").toString());
ed.setLabel(result.getLiteral("l").getString());
ed.setDefinedBy(result.get("d").toString());
entities.add(ed);
}
qeHTTP.close();
return entities;
}
示例15: getEntityDefinitions
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP; //导入方法依赖的package包/类
public List<String> getEntityDefinitions(String graph) {
logger.debug("getEntityDefinitions: " + graph);
ParameterizedSparqlString prepareQuery = new ParameterizedSparqlString(ENTITY_QUERY);
prepareQuery.setIri("g", graph);
QueryEngineHTTP qeHTTP = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(TRIPLE_STORE, prepareQuery.toString());
ResultSet rs = qeHTTP.execSelect();
List<String> entities = new LinkedList<String>();
while(rs.hasNext()) {
QuerySolution result = rs.next();
entities.add(result.get("s").toString());
}
qeHTTP.close();
return entities;
}