本文整理了Java中org.apache.jena.query.Query.getOrderBy
方法的一些代码示例,展示了Query.getOrderBy
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getOrderBy
方法的具体详情如下:
包路径:org.apache.jena.query.Query
类名称:Query
方法名:getOrderBy
暂无
代码示例来源:origin: apache/tinkerpop
/**
* Extracts any {@code SortCondition} instances from the SPARQL query and holds them in an index of their keys
* where the value is that keys sorting direction.
*/
private static Map<String, Order> createOrderIndexFromQuery(final Query query) {
final Map<String, Order> orderingIndex = new HashMap<>();
if (query.hasOrderBy()) {
final List<SortCondition> sortingConditions = query.getOrderBy();
for (SortCondition sortCondition : sortingConditions) {
final Expr expr = sortCondition.getExpression();
// by default, the sort will be ascending. getDirection() returns -2 if the DESC/ASC isn't
// supplied - weird
orderingIndex.put(expr.getVarName(), sortCondition.getDirection() == -1 ? Order.decr : Order.incr);
}
}
return orderingIndex;
}
代码示例来源:origin: apache/jena
@Override
public void visitOrderBy(Query query)
{
if ( query.getOrderBy() != null )
x ^= query.getOrderBy().hashCode() ;
}
代码示例来源:origin: apache/jena
@Override
public void visitOrderBy(Query query1)
{
check("ORDER BY", query1.getOrderBy(), query2.getOrderBy() ) ;
}
代码示例来源:origin: apache/jena
@Override
public void visitOrderBy(Query query) {
if (query.hasOrderBy()) {
for (SortCondition sc : query.getOrderBy())
newQuery.addOrderBy(sc);
}
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public void visitOrderBy(Query query) {
if ( query.hasOrderBy() ) {
for (SortCondition sc : query.getOrderBy())
newQuery.addOrderBy(sc) ;
}
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
/**
* <sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd">
* <head>
* <variable name="s"/>
* <variable name="p"/>
* <variable name="o"/>
* </head>
* <results distinct="false" ordered="true">
* @see org.springframework.batch.item.file.FlatFileHeaderCallback#writeHeader(java.io.Writer)
*/
@Override
public void writeHeader(Writer writer) throws IOException {
PrintWriter pw = new PrintWriter(writer);
pw.println("<?xml version=\"1.0\"?>") ;
pw.println("<sparql xmlns=\"http://www.w3.org/2005/sparql-results#\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd\">");
pw.println(" <head>") ;
List<String> varNames = query.getResultVars();
for(String varName : varNames) {
pw.println(" <variable name=\"" + varName + "\" />") ;
}
pw.println(" </head>") ;
pw.print(" <results distinct=\"" + query.isDistinct() + "\" " + "ordered=\"" + !CollectionUtils.isEmpty(query.getOrderBy()) + "\">");
pw.flush();
}
});
代码示例来源:origin: apache/jena
@Override
public void setVars(Map<Var, Node> values) {
if (values.isEmpty()) {
return;
}
ExprRewriter exprRewriter = new ExprRewriter(values);
ExprList having = exprRewriter.rewrite(new ExprList(query
.getHavingExprs()));
List<SortCondition> orderBy = exprRewriter
.rewriteSortConditionList(query.getOrderBy());
VarExprList groupBy = exprRewriter.rewrite(query.getGroupBy());
query.getHavingExprs().clear();
query.getHavingExprs().addAll(having.getList());
if (orderBy != null) {
if (query.getOrderBy() == null) {
for (SortCondition sc : orderBy) {
query.addOrderBy(sc);
}
} else {
query.getOrderBy().clear();
query.getOrderBy().addAll(orderBy);
}
}
query.getGroupBy().clear();
query.getGroupBy().addAll(groupBy);
}
代码示例来源:origin: apache/jena
/** Find the variables needed out of this query.
* If we don't do sorting in-DB, then we need the ORDER BY variables as well.
* @param query
*/
public static List<Var> queryOutVars(Query query)
{
// If part query, need all variables.
// Project variables
List<Var> vars = toList(map(query.getResultVars().iterator(), Var::alloc)) ;
// Add the ORDER BY variables
List<SortCondition> orderConditions = query.getOrderBy() ;
if ( orderConditions != null )
{
for ( SortCondition sc : orderConditions )
{
Set<Var> x = sc.getExpression().getVarsMentioned() ;
for ( Var v : x )
{
if ( ! vars.contains(v) )
vars.add(v) ;
}
}
}
return vars ;
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
@Override
public void setVars(Map<Var, Node> values) {
if (values.isEmpty()) {
return;
}
ExprRewriter exprRewriter = new ExprRewriter(values);
ExprList having = exprRewriter.rewrite(new ExprList(query
.getHavingExprs()));
List<SortCondition> orderBy = exprRewriter
.rewriteSortConditionList(query.getOrderBy());
VarExprList groupBy = exprRewriter.rewrite(query.getGroupBy());
query.getHavingExprs().clear();
query.getHavingExprs().addAll(having.getList());
if (orderBy != null) {
if (query.getOrderBy() == null) {
for (SortCondition sc : orderBy) {
query.addOrderBy(sc);
}
} else {
query.getOrderBy().clear();
query.getOrderBy().addAll(orderBy);
}
}
query.getGroupBy().clear();
query.getGroupBy().addAll(groupBy);
}
代码示例来源:origin: apache/jena
@Override
public void visitOrderBy(Query query)
{
if ( query.hasOrderBy() )
{
out.print("ORDER BY ") ;
boolean first = true ;
for (SortCondition sc : query.getOrderBy())
{
if ( ! first )
out.print(" ") ;
sc.format(fmtExpr, out) ;
first = false ;
}
out.println() ;
}
}
代码示例来源:origin: apache/jena
/**
* Copy all the modifications from the Solution Modifier argument
* @param solutionModifier The solution modifier to copy from.
*/
public void addAll(SolutionModifierHandler solutionModifier) {
List<SortCondition> lst = solutionModifier.query.getOrderBy();
if (lst != null) {
for (SortCondition sc : lst) {
query.addOrderBy(sc);
}
}
query.getGroupBy().addAll(solutionModifier.query.getGroupBy());
query.getHavingExprs().addAll(solutionModifier.query.getHavingExprs());
query.setLimit(solutionModifier.query.getLimit());
query.setOffset(solutionModifier.query.getOffset());
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
/**
* Copy all the modifications from the Solution Modifier argument
* @param solutionModifier The solution modifier to copy from.
*/
public void addAll(SolutionModifierHandler solutionModifier) {
List<SortCondition> lst = solutionModifier.query.getOrderBy();
if (lst != null) {
for (SortCondition sc : lst) {
query.addOrderBy(sc);
}
}
query.getGroupBy().addAll(solutionModifier.query.getGroupBy());
query.getHavingExprs().addAll(solutionModifier.query.getHavingExprs());
query.setLimit(solutionModifier.query.getLimit());
query.setOffset(solutionModifier.query.getOffset());
}
代码示例来源:origin: apache/jena
/** Transform a query using {@link ElementTransform} and {@link ExprTransform}.
* It is the responsibility of these transforms to transform to a legal SPARQL query.
*/
public static Query transform(Query query, ElementTransform transform, ExprTransform exprTransform) {
Query q2 = QueryTransformOps.shallowCopy(query);
// "Shallow copy with transform."
transformVarExprList(q2.getProject(), exprTransform);
transformVarExprList(q2.getGroupBy(), exprTransform);
transformExprList(q2.getHavingExprs(), exprTransform);
if (q2.getOrderBy() != null) {
transformSortConditions(q2.getOrderBy(), exprTransform);
}
// ?? DOES NOT WORK: transformExprListAgg(q2.getAggregators(), exprTransform) ; ??
// if ( q2.hasHaving() ) {}
// if ( q2.hasAggregators() ) {}
Element el = q2.getQueryPattern();
Element el2 = ElementTransformer.transform(el, transform, exprTransform);
// Top level is always a group.
if (!(el2 instanceof ElementGroup)) {
ElementGroup eg = new ElementGroup();
eg.addElement(el2);
el2 = eg;
}
q2.setQueryPattern(el2);
return q2;
}
代码示例来源:origin: com.github.galigator.openllet/openllet-jena
final List<SortCondition> sortConditions = _query.getOrderBy();
if (sortConditions != null && !sortConditions.isEmpty())
results = new SortedResultSet(results, sortConditions);
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
if(query.getOrderBy() == null) {
query.addOrderBy(sc);
} else {
query.getOrderBy().add(0, sc);
代码示例来源:origin: Galigator/openllet
final List<SortCondition> sortConditions = _query.getOrderBy();
if (sortConditions != null && !sortConditions.isEmpty())
results = new SortedResultSet(results, sortConditions);
代码示例来源:origin: Galigator/openllet
final List<SortCondition> sortConditions = _query.getOrderBy();
if (sortConditions != null && !sortConditions.isEmpty())
results = new SortedResultSet(results, sortConditions);
代码示例来源:origin: apache/jena
if ( query.getOrderBy() != null )
for ( SortCondition sc : query.getOrderBy() )
内容来源于网络,如有侵权,请联系作者删除!