use of org.xwiki.notifications.filters.internal.status.InListOfReadEventsNode in project xwiki-platform by xwiki.
the class ExpressionNodeToHQLConverterTest method parseWithInListOfReadEventsNode.
@Test
public void parseWithInListOfReadEventsNode() {
DocumentReference user = new DocumentReference("xwiki", "XWiki", "userA");
when(serializer.serialize(user)).thenReturn("xwiki:XWiki.UserA");
AbstractNode testAST = new NotNode(new InListOfReadEventsNode(user));
ExpressionNodeToHQLConverter.HQLQuery result = parser.parse(testAST);
assertEquals(" NOT (" + "event IN (select status.activityEvent from ActivityEventStatusImpl status " + "where status.activityEvent = event and status.entityId = :userStatusRead " + "and status.read = true))", result.getQuery());
assertEquals("xwiki:XWiki.UserA", result.getQueryParameters().get("userStatusRead"));
}
use of org.xwiki.notifications.filters.internal.status.InListOfReadEventsNode 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