use of org.xwiki.notifications.filters.expression.InNode in project xwiki-platform by xwiki.
the class ExpressionNodeToHQLConverterTest method parseWithInNode.
@Test
public void parseWithInNode() {
AbstractNode testAST = new InNode(new PropertyValueNode(EventProperty.PAGE), Arrays.asList(new StringValueNode(TEST_VALUE_1), new StringValueNode(TEST_VALUE_2)));
ExpressionNodeToHQLConverter.HQLQuery result = parser.parse(testAST);
assertEquals(String.format("event.page IN (:%s, :%s)", TEST_VALUE_1_IDENTIFIER, TEST_VALUE_2_IDENTIFIER), result.getQuery());
assertEquals(TEST_VALUE_1, result.getQueryParameters().get(TEST_VALUE_1_IDENTIFIER));
assertEquals(TEST_VALUE_2, result.getQueryParameters().get(TEST_VALUE_2_IDENTIFIER));
}
use of org.xwiki.notifications.filters.expression.InNode in project xwiki-platform by xwiki.
the class ExpressionNodeToHQLConverter method parseOtherOperation.
private String parseOtherOperation(AbstractOperatorNode operator, HQLQuery result) {
String returnValue;
if (operator instanceof InNode) {
InNode inOperator = (InNode) operator;
StringBuilder builder = new StringBuilder(parseBlock(inOperator.getLeftOperand(), result));
builder.append(" IN (");
String separator = "";
for (AbstractValueNode value : inOperator.getValues()) {
builder.append(separator);
builder.append(parseBlock(value, result));
separator = ", ";
}
builder.append(")");
returnValue = builder.toString();
} else if (operator instanceof OrderByNode) {
OrderByNode orderByNode = (OrderByNode) operator;
returnValue = String.format("%s ORDER BY %s %s", parseBlock(orderByNode.getQuery(), result), parseBlock(orderByNode.getProperty(), result), orderByNode.getOrder().name());
} else if (operator instanceof InListOfReadEventsNode) {
InListOfReadEventsNode inList = (InListOfReadEventsNode) operator;
returnValue = String.format("event IN (select status.activityEvent from ActivityEventStatusImpl status " + "where status.activityEvent = event and status.entityId = :userStatusRead and status.read = true)");
result.getQueryParameters().put("userStatusRead", serializer.serialize(inList.getUser()));
} else {
returnValue = StringUtils.EMPTY;
}
return returnValue;
}
Aggregations