use of org.teiid.language.Expression in project teiid by teiid.
the class IdentifierFunctionModifier method translate.
public List<?> translate(Function function) {
List<Object> objs = new ArrayList<Object>();
List<Expression> parms = function.getParameters();
objs.add(function.getName().substring(function.getName().indexOf('_') + 1));
objs.add(SQLConstants.Tokens.LPAREN);
for (Iterator<Expression> iter = parms.iterator(); iter.hasNext(); ) {
Expression expr = iter.next();
if (expr instanceof ColumnReference) {
boolean dotAll = false;
boolean useSelector = false;
ColumnReference cr = (ColumnReference) expr;
Column c = cr.getMetadataObject();
if (c != null) {
if ("\"mode:properties\"".equalsIgnoreCase(c.getSourceName())) {
// $NON-NLS-1$
dotAll = true;
useSelector = true;
} else if ("\"jcr:path\"".equalsIgnoreCase(c.getSourceName())) {
// $NON-NLS-1$
useSelector = true;
}
}
if (useSelector) {
NamedTable nt = ((ColumnReference) expr).getTable();
if (nt.getCorrelationName() != null) {
objs.add(nt.getCorrelationName());
} else {
objs.add(nt);
}
} else {
objs.add(expr);
}
if (dotAll) {
// $NON-NLS-1$
objs.add(".*");
}
} else {
objs.add(expr);
}
if (iter.hasNext()) {
// $NON-NLS-1$
objs.add(", ");
}
}
objs.add(SQLConstants.Tokens.RPAREN);
return objs;
}
Aggregations