use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class SystemSource method addAtan2Function.
private void addAtan2Function(String name, String description) {
functions.add(new FunctionMethod(name, description, NUMERIC, FUNCTION_CLASS, name, new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("number1", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Atan_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("number2", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Atan_arg2")) }, // $NON-NLS-1$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description)));
functions.add(new FunctionMethod(name, description, NUMERIC, FUNCTION_CLASS, name, new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("number1", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Atan_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("number2", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Atan_arg2")) }, // $NON-NLS-1$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description)));
}
use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class SystemSource method addBitFunction.
private void addBitFunction(String functionName, String description, String methodName, int parameters, String resultDescription) {
FunctionParameter[] paramArray = null;
if (parameters == 1) {
paramArray = new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("integer", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Bitfunc_arg1")) };
} else if (parameters == 2) {
paramArray = new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Bitfunc2_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("integer2", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Bitfunc2_arg2")) };
}
functions.add(new FunctionMethod(functionName, description, NUMERIC, FUNCTION_CLASS, methodName, paramArray, // $NON-NLS-1$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, resultDescription)));
}
use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class SystemSource method addQuarterFunction.
private void addQuarterFunction(String name, String methodName, String dateDesc, String timestampDesc, String returnType) {
functions.add(new FunctionMethod(name, dateDesc, DATETIME, FUNCTION_CLASS, methodName, new FunctionParameter[] { // $NON-NLS-1$
new FunctionParameter("date", DataTypeManager.DefaultDataTypes.DATE, dateDesc) }, // $NON-NLS-1$
new FunctionParameter("result", returnType, dateDesc)));
functions.add(new FunctionMethod(name, timestampDesc, DATETIME, FUNCTION_CLASS, methodName, new FunctionParameter[] { // $NON-NLS-1$
new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP, timestampDesc) }, // $NON-NLS-1$
new FunctionParameter("result", returnType, timestampDesc)));
}
use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class SystemSource method addDateFunction.
private void addDateFunction(String name, String methodName, String dateDesc, String timestampDesc, String returnType) {
functions.add(new FunctionMethod(name, dateDesc, DATETIME, FUNCTION_CLASS, methodName, new FunctionParameter[] { // $NON-NLS-1$
new FunctionParameter("date", DataTypeManager.DefaultDataTypes.DATE, dateDesc) }, // $NON-NLS-1$
new FunctionParameter("result", returnType, dateDesc)));
functions.add(new FunctionMethod(name, timestampDesc, DATETIME, FUNCTION_CLASS, methodName, new FunctionParameter[] { // $NON-NLS-1$
new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP, timestampDesc) }, // $NON-NLS-1$
new FunctionParameter("result", returnType, timestampDesc)));
}
use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class ODataSQLVisitor method visit.
@Override
public void visit(Function obj) {
if (this.executionFactory.getFunctionModifiers().containsKey(obj.getName())) {
List<?> parts = this.executionFactory.getFunctionModifiers().get(obj.getName()).translate(obj);
if (parts != null) {
// $NON-NLS-1$
throw new AssertionError("not supported");
}
}
String name = obj.getName();
List<Expression> args = obj.getParameters();
if (isInfixFunction(name)) {
this.filter.append(Tokens.LPAREN);
if (args != null) {
for (int i = 0; i < args.size(); i++) {
append(args.get(i));
if (i < (args.size() - 1)) {
this.filter.append(Tokens.SPACE);
this.filter.append(infixFunctions.get(name));
this.filter.append(Tokens.SPACE);
}
}
}
this.filter.append(Tokens.RPAREN);
} else {
FunctionMethod method = obj.getMetadataObject();
if (name.startsWith(method.getCategory())) {
name = name.substring(method.getCategory().length() + 1);
}
this.filter.append(name).append(Tokens.LPAREN);
if (args != null && args.size() != 0) {
if (SourceSystemFunctions.ENDSWITH.equalsIgnoreCase(name)) {
append(args.get(1));
this.filter.append(Tokens.COMMA);
append(args.get(0));
} else {
for (int i = 0; i < args.size(); i++) {
append(args.get(i));
if (i < args.size() - 1) {
this.filter.append(Tokens.COMMA);
}
}
}
}
this.filter.append(Tokens.RPAREN);
}
}
Aggregations