use of com.developmentontheedge.sql.model.AstIdentifierConstant in project be5 by DevelopmentOnTheEdge.
the class ContextApplier method applyDictionary.
private void applyDictionary(AstBeDictionary child) {
String value = context.getDictionaryValue(child.getTagName(), child.getName(), child.getParameters());
child.replaceWith(new AstIdentifierConstant(value));
}
use of com.developmentontheedge.sql.model.AstIdentifierConstant in project be5 by DevelopmentOnTheEdge.
the class FilterApplier method addFilter.
public void addFilter(AstQuery query, Map<ColumnRef, Object> conditions) {
if (conditions.size() == 0)
return;
AstWhere where = new AstWhere();
if (query.jjtGetNumChildren() == 1) {
AstSelect select = (AstSelect) query.child(0);
if (select.getWhere() != null)
where = select.getWhere();
else
select.where(where);
} else {
AstTableRef tableRef = new AstTableRef(new AstParenthesis(query.clone()), new AstIdentifierConstant("tmp"));
AstSelect select = new AstSelect(new AstSelectList(), new AstFrom(tableRef));
select.where(where);
query.replaceWith(new AstQuery(select));
}
addWhere(where, conditions);
}
use of com.developmentontheedge.sql.model.AstIdentifierConstant in project be5 by DevelopmentOnTheEdge.
the class FilterApplier method setFilter.
public void setFilter(AstStart ast, Map<ColumnRef, Object> conditions) {
AstQuery query = ast.getQuery();
dropOldConditions(query);
if (conditions.size() == 0)
return;
AstWhere where = new AstWhere();
addWhere(where, conditions);
if (query.jjtGetNumChildren() == 1)
((AstSelect) query.child(0)).where(where);
else {
AstTableRef tableRef = new AstTableRef(new AstParenthesis(query.clone()), new AstIdentifierConstant("tmp"));
AstSelect select = new AstSelect(new AstSelectList(), new AstFrom(tableRef));
select.where(where);
query.replaceWith(new AstQuery(select));
}
}
use of com.developmentontheedge.sql.model.AstIdentifierConstant in project be5 by DevelopmentOnTheEdge.
the class SqlServerTransformer method transformDateAdd.
@Override
protected void transformDateAdd(AstFunNode node) {
SimpleNode date = node.child(0);
SimpleNode number = node.child(1);
String name = node.getFunction().getName();
String type = name.equalsIgnoreCase("add_months") ? "MONTH" : name.equalsIgnoreCase("add_days") ? "DAY" : "MILLISECOND";
node.replaceWith(DATEADD.node(new AstIdentifierConstant(type), number, date));
}
use of com.developmentontheedge.sql.model.AstIdentifierConstant in project be5 by DevelopmentOnTheEdge.
the class SqlServerTransformer method transformDateTrunc.
@Override
protected void transformDateTrunc(AstFunNode node) {
AstStringConstant child = (AstStringConstant) node.child(0);
String dateformat = child.getValueUnescaped();
AstIdentifierConstant datepart = new AstIdentifierConstant(dateformat);
AstNumericConstant date = AstNumericConstant.of(0);
node.replaceWith(DATEADD.node(datepart, DATEDIFF.node(datepart, date, node.child(1)), date));
}
Aggregations