use of org.teiid.language.ColumnReference 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;
}
use of org.teiid.language.ColumnReference in project teiid by teiid.
the class TestMetadataObject method getElementID.
// ################ TEST ELEMENT METADATAID ######################
public Column getElementID(String groupName, String elementName, TranslationUtility transUtil) {
// $NON-NLS-1$ //$NON-NLS-2$
Select query = (Select) transUtil.parseCommand("SELECT " + elementName + " FROM " + groupName);
DerivedColumn symbol = query.getDerivedColumns().get(0);
ColumnReference element = (ColumnReference) symbol.getExpression();
return element.getMetadataObject();
}
use of org.teiid.language.ColumnReference in project teiid by teiid.
the class TestCollectorVisitor method test1.
@Test
public void test1() {
// $NON-NLS-1$
NamedTable g1 = new NamedTable("g1", null, null);
// $NON-NLS-1$
ColumnReference e1 = new ColumnReference(g1, "e1", null, String.class);
// $NON-NLS-1$ //$NON-NLS-2$
helpTestElementsUsedByGroups(e1, new String[] { "g1.e1" }, new String[] { "g1" });
}
use of org.teiid.language.ColumnReference in project teiid by teiid.
the class TestCollectorVisitor method example1.
public LanguageObject example1() {
// $NON-NLS-1$
NamedTable g = new NamedTable("g1", null, null);
List symbols = new ArrayList();
// $NON-NLS-1$
symbols.add(new ColumnReference(g, "e1", null, String.class));
// $NON-NLS-1$ //$NON-NLS-2$
Function function = new Function("length", Arrays.asList(new ColumnReference(g, "e2", null, String.class)), Integer.class);
symbols.add(function);
List groups = new ArrayList();
groups.add(g);
Select q = new Select(symbols, false, groups, null, null, null, null);
return q;
}
use of org.teiid.language.ColumnReference in project teiid by teiid.
the class TestCollectorVisitor method test2.
@Test
public void test2() {
// $NON-NLS-1$
NamedTable g1 = new NamedTable("g1", null, null);
// $NON-NLS-1$
ColumnReference e1 = new ColumnReference(g1, "e1", null, String.class);
// $NON-NLS-1$
ColumnReference e2 = new ColumnReference(g1, "e2", null, String.class);
Comparison cc = new Comparison(e1, e2, Operator.EQ);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
helpTestElementsUsedByGroups(cc, new String[] { "g1.e1", "g1.e2" }, new String[] { "g1" });
}
Aggregations