Search in sources :

Example 1 with AbstractValueNode

use of org.xwiki.notifications.filters.expression.generics.AbstractValueNode 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;
}
Also used : InNode(org.xwiki.notifications.filters.expression.InNode) AbstractValueNode(org.xwiki.notifications.filters.expression.generics.AbstractValueNode) InListOfReadEventsNode(org.xwiki.notifications.filters.internal.status.InListOfReadEventsNode)

Example 2 with AbstractValueNode

use of org.xwiki.notifications.filters.expression.generics.AbstractValueNode in project xwiki-platform by xwiki.

the class InNode method toString.

@Override
public String toString() {
    StringBuilder s = new StringBuilder(leftOperand.toString());
    s.append(" IN (");
    String separator = "";
    for (AbstractValueNode value : values) {
        s.append(separator);
        s.append(value.toString());
        separator = ", ";
    }
    s.append(")");
    return s.toString();
}
Also used : AbstractValueNode(org.xwiki.notifications.filters.expression.generics.AbstractValueNode)

Aggregations

AbstractValueNode (org.xwiki.notifications.filters.expression.generics.AbstractValueNode)2 InNode (org.xwiki.notifications.filters.expression.InNode)1 InListOfReadEventsNode (org.xwiki.notifications.filters.internal.status.InListOfReadEventsNode)1