use of org.teiid.language.AggregateFunction in project teiid by teiid.
the class CoherenceVisitor method getExpressionString.
// GHH 20080326 - found that code to fall back on Name if NameInSource
// was null wasn't working properly, so replaced with tried and true
// code from another custom connector.
private String getExpressionString(Expression e) throws TranslatorException {
String expressionName = null;
// - the rest of this method is unchanged
if (e instanceof ColumnReference) {
Column mdIDElement = ((ColumnReference) e).getMetadataObject();
expressionName = mdIDElement.getNameInSource();
if (expressionName == null || expressionName.equals("")) {
// $NON-NLS-1$
expressionName = mdIDElement.getName();
}
} else if (e instanceof Literal) {
// try {
// if(((Literal)e).getType().equals(Class.forName(Timestamp.class.getName()))) {
// LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Found an expression that uses timestamp; converting to LDAP string format."); //$NON-NLS-1$
// Timestamp ts = (Timestamp)((Literal)e).getValue();
// Date dt = new Date(ts.getTime());
// //TODO: Fetch format if provided.
// SimpleDateFormat sdf = new SimpleDateFormat(LDAPConnectorConstants.ldapTimestampFormat);
// expressionName = sdf.format(dt);
// LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Timestamp to stsring is: " + expressionName); //$NON-NLS-1$
// }
// else {
// expressionName = ((Literal)e).getValue().toString();
// }
expressionName = ((Literal) e).getValue().toString();
// } catch (ClassNotFoundException cce) {
// final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.timestampClassNotFoundError"); //$NON-NLS-1$
// throw new TranslatorException(cce, msg);
// }
//
} else {
if (e instanceof AggregateFunction) {
// $NON-NLS-1$
LogManager.logError(LogConstants.CTX_CONNECTOR, "Received IAggregate, but it is not supported. Check capabilities.");
} else if (e instanceof Function) {
// $NON-NLS-1$
LogManager.logError(LogConstants.CTX_CONNECTOR, "Received IFunction, but it is not supported. Check capabilties.");
} else if (e instanceof ScalarSubquery) {
// $NON-NLS-1$
LogManager.logError(LogConstants.CTX_CONNECTOR, "Received IScalarSubquery, but it is not supported. Check capabilties.");
} else if (e instanceof SearchedCase) {
// $NON-NLS-1$
LogManager.logError(LogConstants.CTX_CONNECTOR, "Received ISearchedCaseExpression, but it is not supported. Check capabilties.");
}
// $NON-NLS-1$
final String msg = CoherencePlugin.Util.getString("CoherenceVisitory.unsupportedElementError", e.toString());
throw new TranslatorException(msg);
}
expressionName = escapeReservedChars(expressionName);
return expressionName;
}
use of org.teiid.language.AggregateFunction in project teiid by teiid.
the class TestAggregateImpl method testGetExpression.
public void testGetExpression() throws Exception {
// $NON-NLS-1$
AggregateFunction agg = example("testName", NonReserved.COUNT, true, 42);
assertNotNull(agg.getExpression());
assertTrue(agg.getExpression() instanceof Literal);
assertEquals(new Integer(42), ((Literal) agg.getExpression()).getValue());
}
Aggregations