Java Code Examples for org.jooq.impl.DSL#function()

The following examples show how to use org.jooq.impl.DSL#function() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PgExpressionHandler.java    From FROST-Server with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public FieldWrapper visit(Date node) {
    Expression param = node.getParameters().get(0);
    FieldWrapper input = param.accept(this);
    if (input instanceof TimeFieldWrapper) {
        TimeFieldWrapper timeExpression = (TimeFieldWrapper) input;
        return new SimpleFieldWrapper(DSL.function("date", Date.class, timeExpression.getDateTime()));
    }
    throw new IllegalArgumentException("Date can only be used on times, not on " + input.getClass().getName());
}
 
Example 2
Source File: PgExpressionHandler.java    From FROST-Server with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public FieldWrapper visit(GeoDistance node) {
    Expression p1 = node.getParameters().get(0);
    Expression p2 = node.getParameters().get(1);
    FieldWrapper e1 = p1.accept(this);
    FieldWrapper e2 = p2.accept(this);
    Field<Geometry> g1 = e1.getFieldAsType(Geometry.class, true);
    Field<Geometry> g2 = e2.getFieldAsType(Geometry.class, true);
    if (g1 == null || g2 == null) {
        throw new IllegalArgumentException("GeoDistance requires two geometries, got " + e1 + " & " + e2);
    }
    return new SimpleFieldWrapper(DSL.function("ST_Distance", SQLDataType.NUMERIC, g1, g2));
}
 
Example 3
Source File: PgExpressionHandler.java    From FROST-Server with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public FieldWrapper visit(GeoLength node) {
    Expression p1 = node.getParameters().get(0);
    FieldWrapper e1 = p1.accept(this);
    Field<Geometry> g1 = e1.getFieldAsType(Geometry.class, true);
    if (g1 == null) {
        throw new IllegalArgumentException("GeoLength requires a geometry, got " + e1);
    }
    return new SimpleFieldWrapper(DSL.function("ST_Length", SQLDataType.NUMERIC, g1));
}