use of com.developmentontheedge.sql.model.AstBeSqlVar in project be5 by DevelopmentOnTheEdge.
the class ContextApplier method applyVars.
/**
* todo rename getSubQuery
*/
public AstBeSqlSubQuery applyVars(String key, Function<String, String> varResolver) {
AstBeSqlSubQuery subQuery = context.getSubQueries().get(key);
if (subQuery == null)
return null;
AstBeSqlSubQuery result = (AstBeSqlSubQuery) subQuery.clone();
if (result.getLimit() != null)
new LimitsApplier(0, result.getLimit()).transformQuery(result.getQuery());
applyFirstLevelVars(1, result, (AstBeSqlVar node) -> applyVar(key, node, varResolver));
// result.tree().select( AstBeSqlVar.class ).forEach( varNode -> {
// String value = varResolver.apply( subQuery.translateVar( varNode.getName() ) );
// if( value == null )
// value = varNode.getDefault();
// SimpleNode constant;
//
// if(varNode.jjtGetParent() instanceof AstBeSqlSubQuery && value != null && !"".equals(value.trim()))
// {
// constant = SqlQuery.parse(value).getQuery();
// }
// else
// {
// if(value == null)
// {
// value = "null";
// }
// constant = varNode.jjtGetParent() instanceof AstStringConstant ? new AstStringPart(value)
// : new AstIdentifierConstant(value);
// }
//
// varNode.replaceWith( constant );
// } );
checkExpression(result, key, varResolver);
return result;
}
use of com.developmentontheedge.sql.model.AstBeSqlVar in project be5 by DevelopmentOnTheEdge.
the class FilterApplier method toNode.
private SimpleNode toNode(Object value) {
if (SqlTypeUtils.isNumber(value.getClass()))
return AstNumericConstant.of((Number) value);
String strValue = value.toString();
Matcher matcher = BeSqlVar_PATTERN.matcher(strValue);
if (matcher.find()) {
return new AstBeSqlVar(matcher.group(1));
}
return new AstStringConstant(strValue);
}
Aggregations