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


Java ParsedTupleQuery类代码示例

本文整理汇总了Java中org.eclipse.rdf4j.query.parser.ParsedTupleQuery的典型用法代码示例。如果您正苦于以下问题:Java ParsedTupleQuery类的具体用法?Java ParsedTupleQuery怎么用?Java ParsedTupleQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParsedTupleQuery类属于org.eclipse.rdf4j.query.parser包,在下文中一共展示了ParsedTupleQuery类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createRelation

import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; //导入依赖的package包/类
@Override
public SparkRDF4JSparqlRelation createRelation(SQLContext sqlContext,
		scala.collection.immutable.Map<String, String> scalaParameters, StructType schema) {
	Map<String, String> parameters = JavaConversions.asJavaMap(scalaParameters);
	String service = Optional.ofNullable(parameters.get("service")).orElseThrow(() -> new RuntimeException(
			"Spark RDF4J Sparql requires a SPARQL 'service' to be specified in the parameters"));
	String query = Optional.ofNullable(parameters.get("query")).orElseThrow(() -> new RuntimeException(
			"Spark RDF4J Sparql requires a 'query' to be specified in the parameters"));

	try {
		ParsedQuery parsedQuery = QueryParserUtil.parseQuery(QueryLanguage.SPARQL, query, null);
		if(!(parsedQuery instanceof ParsedTupleQuery)) {
			throw new RuntimeException("Spark RDF4J can only be used with Tuple (Select) queries right now.");
		}
		return new SparkRDF4JSparqlRelation(service, parsedQuery, schema, sqlContext);
	} catch (MalformedQueryException e) {
		throw new RuntimeException("Query was not valid SPARQL", e);
	}

}
 
开发者ID:ansell,项目名称:spark-rdf4j,代码行数:21,代码来源:SparkRDF4JDefaultSource.java

示例2: buildSelectSPARQLQuery

import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; //导入依赖的package包/类
private static String buildSelectSPARQLQuery(TupleExpr expr, Collection<String> projection)
        throws Exception
{
    TupleExpr body = expr.clone();

    if (projection != null) {
        Projection proj = new Projection();
        ProjectionElemList elemList = new ProjectionElemList();

        for (String var : projection)
            elemList.addElement(new ProjectionElem(var));

        proj.setProjectionElemList(elemList);

        proj.setArg(body);
        body = proj;
    }

    ParsedTupleQuery query = new ParsedTupleQuery(body);

    String queryString = new SPARQLQueryRenderer().render(new ParsedTupleQuery(expr));
    queryString = updateFunctionCallsSELECT(expr, queryString, computeVars(expr));

    return queryString;
}
 
开发者ID:semagrow,项目名称:semagrow,代码行数:26,代码来源:SPARQLQueryStringUtil.java

示例3: createSparqlQueryValidator

import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; //导入依赖的package包/类
private Validator createSparqlQueryValidator() {
    Validator validator = new Validator() {
        private static final long serialVersionUID = 1L;

        @Override
        public void validate(Object value) throws InvalidValueException {
            final String valueStr = (String) value;
            if (value == null || valueStr.isEmpty()) {
                throw new InvalidValueException(ctx.tr("sparqlvalidator.emptyQuery"));
            }

            try {
                ParsedQuery parsedQuery = QueryParserUtil.parseQuery(QueryLanguage.SPARQL, valueStr, null);
                if (!(parsedQuery instanceof ParsedBooleanQuery)&&!(parsedQuery instanceof ParsedTupleQuery)) {
                    throw new InvalidValueException(ctx.tr("error.unsupported.query.type"));
                }
            } catch (MalformedQueryException ex) {
                throw new InvalidValueException(ctx.tr("sparqlvalidator.invalidQuery") + " " + ex.getMessage());
            }
        }
    };
    return validator;
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:24,代码来源:RdfValidatorVaadinDialog.java

示例4: tupleExpr2Str

import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; //导入依赖的package包/类
public static String tupleExpr2Str(TupleExpr expr) {
    try {
        return new SPARQLQueryRenderer().render(new ParsedTupleQuery(expr)).substring(15).replace('\n',' ');
    } catch (Exception e) {
        e.printStackTrace();
        return "";
    }
}
 
开发者ID:semagrow,项目名称:semagrow,代码行数:9,代码来源:SPARQLQueryStringUtil.java

示例5: SemagrowSailTupleQuery

import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; //导入依赖的package包/类
public SemagrowSailTupleQuery( ParsedTupleQuery query, String queryString, SailRepositoryConnection connection )
{
    super(query, connection );
    this.queryString = queryString;
}
 
开发者ID:semagrow,项目名称:semagrow,代码行数:6,代码来源:SemagrowSailTupleQuery.java


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