当前位置: 首页>>代码示例>>Java>>正文


Java QueryEngineHTTP.execSelect方法代码示例

本文整理汇总了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;
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:20,代码来源:WikidataFetch.java

示例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;
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:24,代码来源:WikidataCoReferenceResolver.java

示例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;
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:27,代码来源:CoReferenceResolverImpl.java

示例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();
    }
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:26,代码来源:CoRefCacheHarvester.java

示例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;
}
 
开发者ID:SEMOSS,项目名称:semoss,代码行数:18,代码来源:RemoteJenaEngine.java

示例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;
}
 
开发者ID:bayerls,项目名称:bacon,代码行数:23,代码来源:MergeDao.java

示例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;
}
 
开发者ID:bayerls,项目名称:bacon,代码行数:25,代码来源:MergeDao.java

示例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;
}
 
开发者ID:bayerls,项目名称:bacon,代码行数:25,代码来源:MergeDao.java

示例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;
    }
 
开发者ID:bayerls,项目名称:bacon,代码行数:21,代码来源:MergeDao.java

示例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;
    }
 
开发者ID:bayerls,项目名称:bacon,代码行数:21,代码来源:MergeDao.java

示例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;
}
 
开发者ID:bayerls,项目名称:bacon,代码行数:24,代码来源:MergeDao.java

示例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;
}
 
开发者ID:bayerls,项目名称:bacon,代码行数:24,代码来源:MergeDao.java

示例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);
}
 
开发者ID:bayerls,项目名称:bacon,代码行数:25,代码来源:MergeDao.java

示例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;
}
 
开发者ID:bayerls,项目名称:bacon,代码行数:26,代码来源:MergeDao.java

示例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;
}
 
开发者ID:bayerls,项目名称:bacon,代码行数:20,代码来源:MergeDao.java


注:本文中的com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP.execSelect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。