提交 e2b0c4dc 编写于 作者: A Alexandru-Cristian Balmus 提交者: Joram Barrez
上级 e2406768
......@@ -180,6 +180,16 @@ public interface HistoricProcessInstanceQuery extends Query<HistoricProcessInsta
* cannot be null. The string can include the wildcard character '%' to express like-strategy: starts with (string%), ends with (%string) or contains (%string%).
*/
HistoricProcessInstanceQuery variableValueLike(String name, String value);
/** Only select process instances which had global variable value like (case insensitive)
* the given value when they ended. Only applies to already ended process instances,
* otherwise use a {@link ProcessInstanceQuery} instead! This can be used on string
* variables only.
* @param name cannot be null.
* @param value cannot be null. The string can include the
* wildcard character '%' to express like-strategy: starts with
* (string%), ends with (%string) or contains (%string%). */
HistoricProcessInstanceQuery variableValueLikeIgnoreCase(String name, String value);
/**
* Only select historic process instances that were started before the given date.
......
......@@ -156,7 +156,13 @@ public abstract class AbstractVariableQueryImpl<T extends Query<?, ?>, U> extend
addVariable(name, value, QueryOperator.LIKE, localScope);
return (T) this;
}
@SuppressWarnings("unchecked")
public T variableValueLikeIgnoreCase(String name, String value, boolean localScope) {
addVariable(name, value, QueryOperator.LIKE_IGNORE_CASE, localScope);
return (T)this;
}
private void addVariable(String name, Object value, QueryOperator operator, boolean localScope) {
if (name == null) {
throw new ActivitiIllegalArgumentException("name is null");
......@@ -182,8 +188,9 @@ public abstract class AbstractVariableQueryImpl<T extends Query<?, ?>, U> extend
if (operator == QueryOperator.NOT_EQUALS_IGNORE_CASE && !(value instanceof String)) {
throw new ActivitiIllegalArgumentException("Only string values can be used with 'not equals ignore case' condition");
}
if (operator == QueryOperator.LIKE && !(value instanceof String)) {
if((operator == QueryOperator.LIKE || operator == QueryOperator.LIKE_IGNORE_CASE) && !(value instanceof String))
{
throw new ActivitiIllegalArgumentException("Only string values can be used with 'like' condition");
}
}
......
......@@ -454,7 +454,7 @@ public class HistoricProcessInstanceQueryImpl extends AbstractVariableQueryImpl<
return variableValueLike(name, value, true);
}
}
public HistoricProcessInstanceQuery locale(String locale) {
this.locale = locale;
return this;
......@@ -464,7 +464,17 @@ public class HistoricProcessInstanceQueryImpl extends AbstractVariableQueryImpl<
withLocalizationFallback = true;
return this;
}
@Override
public HistoricProcessInstanceQuery variableValueLikeIgnoreCase(String name, String value) {
if (inOrStatement) {
currentOrQueryObject.variableValueLikeIgnoreCase(name, value, true);
return this;
} else {
return variableValueLikeIgnoreCase(name, value, true);
}
}
public HistoricProcessInstanceQuery or() {
if (inOrStatement) {
throw new ActivitiException("the query is already in an or statement");
......
......@@ -19,5 +19,14 @@ package org.activiti.engine.impl;
* @author Frederik Heremans
*/
public enum QueryOperator {
EQUALS, NOT_EQUALS, GREATER_THAN, GREATER_THAN_OR_EQUAL, LESS_THAN, LESS_THAN_OR_EQUAL, LIKE, EQUALS_IGNORE_CASE, NOT_EQUALS_IGNORE_CASE,
EQUALS,
NOT_EQUALS,
GREATER_THAN,
GREATER_THAN_OR_EQUAL,
LESS_THAN,
LESS_THAN_OR_EQUAL,
LIKE,
EQUALS_IGNORE_CASE,
NOT_EQUALS_IGNORE_CASE,
LIKE_IGNORE_CASE,
}
......@@ -461,7 +461,7 @@
</if>
<if test="queryVariableValue.textValue != null &amp;&amp; queryVariableValue.longValue == null &amp;&amp; queryVariableValue.doubleValue == null">
<choose>
<when test="queryVariableValue.operator.equals('EQUALS_IGNORE_CASE') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
<when test="queryVariableValue.operator.equals('EQUALS_IGNORE_CASE') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE') || queryVariableValue.operator.equals('LIKE_IGNORE_CASE')">
and lower(A${index}.TEXT_)
</when>
<otherwise>
......@@ -469,7 +469,7 @@
</otherwise>
</choose>
<choose>
<when test="queryVariableValue.operator.equals('LIKE')">LIKE</when>
<when test="queryVariableValue.operator.equals('LIKE') || queryVariableValue.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
<otherwise><include refid="executionVariableOperator" /></otherwise>
</choose>
#{queryVariableValue.textValue}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册