DATAMONGO-1710 - Adopt to changed AnnotationUtils.getValue(…) and OperatorNode.getRightOperand() behavior.
Related ticket: SPR-15540.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -52,6 +52,7 @@ import org.springframework.util.ObjectUtils;
|
|||||||
*
|
*
|
||||||
* @author Thomas Darimont
|
* @author Thomas Darimont
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
class SpelExpressionTransformer implements AggregationExpressionTransformer {
|
class SpelExpressionTransformer implements AggregationExpressionTransformer {
|
||||||
|
|
||||||
@@ -258,8 +259,10 @@ class SpelExpressionTransformer implements AggregationExpressionTransformer {
|
|||||||
return convertUnaryMinusOp(context, leftResult);
|
return convertUnaryMinusOp(context, leftResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!currentNode.isUnaryOperator()) {
|
||||||
// we deliberately ignore the RHS result
|
// we deliberately ignore the RHS result
|
||||||
transform(currentNode.getRight(), currentNode, operationObject, context);
|
transform(currentNode.getRight(), currentNode, operationObject, context);
|
||||||
|
}
|
||||||
|
|
||||||
return operationObject;
|
return operationObject;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -34,6 +34,7 @@ import org.springframework.expression.spel.ast.StringLiteral;
|
|||||||
*
|
*
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
public class LiteralNode extends ExpressionNode {
|
public class LiteralNode extends ExpressionNode {
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ public class LiteralNode extends ExpressionNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OperatorNode operator = (OperatorNode) parent;
|
OperatorNode operator = (OperatorNode) parent;
|
||||||
return operator.isUnaryMinus() && operator.getRight() == null;
|
return operator.isUnaryMinus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2016 the original author or authors.
|
* Copyright 2013-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,21 +22,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.springframework.expression.spel.ExpressionState;
|
import org.springframework.expression.spel.ExpressionState;
|
||||||
import org.springframework.expression.spel.ast.OpAnd;
|
import org.springframework.expression.spel.ast.*;
|
||||||
import org.springframework.expression.spel.ast.OpDivide;
|
|
||||||
import org.springframework.expression.spel.ast.OpEQ;
|
|
||||||
import org.springframework.expression.spel.ast.OpGE;
|
|
||||||
import org.springframework.expression.spel.ast.OpGT;
|
|
||||||
import org.springframework.expression.spel.ast.OpLE;
|
|
||||||
import org.springframework.expression.spel.ast.OpLT;
|
|
||||||
import org.springframework.expression.spel.ast.OpMinus;
|
|
||||||
import org.springframework.expression.spel.ast.OpModulus;
|
|
||||||
import org.springframework.expression.spel.ast.OpMultiply;
|
|
||||||
import org.springframework.expression.spel.ast.OpNE;
|
|
||||||
import org.springframework.expression.spel.ast.OpOr;
|
|
||||||
import org.springframework.expression.spel.ast.OpPlus;
|
|
||||||
import org.springframework.expression.spel.ast.Operator;
|
|
||||||
import org.springframework.expression.spel.ast.OperatorPower;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link ExpressionNode} representing an operator.
|
* An {@link ExpressionNode} representing an operator.
|
||||||
@@ -44,6 +30,7 @@ import org.springframework.expression.spel.ast.OperatorPower;
|
|||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @author Thomas Darimont
|
* @author Thomas Darimont
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
public class OperatorNode extends ExpressionNode {
|
public class OperatorNode extends ExpressionNode {
|
||||||
|
|
||||||
@@ -126,7 +113,7 @@ public class OperatorNode extends ExpressionNode {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isUnaryOperator() {
|
public boolean isUnaryOperator() {
|
||||||
return operator.getRightOperand() == null;
|
return operator.getChildCount() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class MongoQueryMethod extends QueryMethod {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean hasAnnotatedQuery() {
|
public boolean hasAnnotatedQuery() {
|
||||||
return getAnnotatedQuery() != null;
|
return findAnnotatedQuery().isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,9 +103,15 @@ public class MongoQueryMethod extends QueryMethod {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getAnnotatedQuery() {
|
String getAnnotatedQuery() {
|
||||||
|
return findAnnotatedQuery().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
String query = (String) AnnotationUtils.getValue(getQueryAnnotation());
|
private Optional<String> findAnnotatedQuery() {
|
||||||
return StringUtils.hasText(query) ? query : null;
|
|
||||||
|
return Optional.ofNullable(getQueryAnnotation()) //
|
||||||
|
.map(AnnotationUtils::getValue) //
|
||||||
|
.map(it -> (String) it) //
|
||||||
|
.filter(StringUtils::hasText);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,8 +121,10 @@ public class MongoQueryMethod extends QueryMethod {
|
|||||||
*/
|
*/
|
||||||
String getFieldSpecification() {
|
String getFieldSpecification() {
|
||||||
|
|
||||||
String value = (String) AnnotationUtils.getValue(getQueryAnnotation(), "fields");
|
return Optional.ofNullable(getQueryAnnotation()) //
|
||||||
return StringUtils.hasText(value) ? value : null;
|
.map(it -> (String) AnnotationUtils.getValue(it, "fields")) //
|
||||||
|
.filter(StringUtils::hasText) //
|
||||||
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user