use of com.developmentontheedge.sql.model.AstBeListPlaceHolder in project be5 by DevelopmentOnTheEdge.
the class ContextApplier method applyPlaceHolder.
private void applyPlaceHolder(AstBePlaceHolder placeholderNode) {
String ph = placeholderNode.getPlaceHolder();
SimpleNode replacement;
if (placeholderNode instanceof AstBeListPlaceHolder) {
AstInValueList list = new AstInValueList(SqlParserTreeConstants.JJTINVALUELIST);
context.roles().map(AstStringConstant::new).forEach(list::addChild);
replacement = list;
} else {
String rawResult;
switch(ph) {
case "username":
rawResult = context.getUserName();
break;
case "timestamp":
rawResult = String.valueOf(System.currentTimeMillis());
break;
default:
throw new UnsupportedOperationException("Unsupported placeholder: " + ph);
}
replacement = new AstStringConstant(rawResult);
}
replacement.inheritFrom(placeholderNode);
placeholderNode.replaceWith(replacement);
}
Aggregations