Search in sources :

Example 11 with QueryValue

use of com.revolsys.record.query.QueryValue in project com.revolsys.open by revolsys.

the class EnvelopeIntersects method test.

@Override
public boolean test(final Record record) {
    final QueryValue left = getLeft();
    final BoundingBox boundingBox1 = getBoundingBox(left, record);
    final QueryValue right = getRight();
    final BoundingBox boundingBox2 = getBoundingBox(right, record);
    if (boundingBox1 == null || boundingBox2 == null) {
        return false;
    } else {
        return boundingBox1.intersects(boundingBox2);
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) QueryValue(com.revolsys.record.query.QueryValue) AbstractBinaryQueryValue(com.revolsys.record.query.AbstractBinaryQueryValue)

Example 12 with QueryValue

use of com.revolsys.record.query.QueryValue in project com.revolsys.open by revolsys.

the class Upper method getValue.

@SuppressWarnings("unchecked")
@Override
public <V> V getValue(final Record record) {
    final QueryValue parameter = getParameter();
    final String stringValue = parameter.getStringValue(record);
    if (Property.hasValue(stringValue)) {
        return (V) stringValue.toUpperCase();
    } else {
        return (V) stringValue;
    }
}
Also used : QueryValue(com.revolsys.record.query.QueryValue)

Example 13 with QueryValue

use of com.revolsys.record.query.QueryValue in project com.revolsys.open by revolsys.

the class Lower method getValue.

@SuppressWarnings("unchecked")
@Override
public <V> V getValue(final Record record) {
    final QueryValue parameter = getParameter();
    final String stringValue = parameter.getStringValue(record);
    if (Property.hasValue(stringValue)) {
        return (V) stringValue.toLowerCase();
    } else {
        return (V) stringValue;
    }
}
Also used : QueryValue(com.revolsys.record.query.QueryValue)

Example 14 with QueryValue

use of com.revolsys.record.query.QueryValue in project com.revolsys.open by revolsys.

the class PostgreSQLRecordStore method appendQueryValue.

@Override
public void appendQueryValue(final Query query, final StringBuilder sql, final QueryValue queryValue) {
    if (queryValue instanceof EnvelopeIntersects) {
        final EnvelopeIntersects envelopeIntersects = (EnvelopeIntersects) queryValue;
        final QueryValue boundingBox1Value = envelopeIntersects.getBoundingBox1Value();
        if (boundingBox1Value == null) {
            sql.append("NULL");
        } else {
            boundingBox1Value.appendSql(query, this, sql);
        }
        sql.append(" && ");
        final QueryValue boundingBox2Value = envelopeIntersects.getBoundingBox2Value();
        if (boundingBox2Value == null) {
            sql.append("NULL");
        } else {
            boundingBox2Value.appendSql(query, this, sql);
        }
    } else {
        super.appendQueryValue(query, sql, queryValue);
    }
}
Also used : EnvelopeIntersects(com.revolsys.record.query.functions.EnvelopeIntersects) QueryValue(com.revolsys.record.query.QueryValue)

Example 15 with QueryValue

use of com.revolsys.record.query.QueryValue in project com.revolsys.open by revolsys.

the class OracleRecordStore method appendWithinDistance.

private void appendWithinDistance(final Query query, final StringBuilder sql, final WithinDistance withinDistance) {
    final FieldDefinition geometryField = query.getGeometryField();
    if (geometryField instanceof OracleSdoGeometryJdbcFieldDefinition) {
        sql.append("MDSYS.SDO_WITHIN_DISTANCE(");
        final QueryValue geometry1Value = withinDistance.getGeometry1Value();
        if (geometry1Value == null) {
            sql.append("NULL");
        } else {
            geometry1Value.appendSql(query, this, sql);
        }
        sql.append(", ");
        final QueryValue geometry2Value = withinDistance.getGeometry2Value();
        if (geometry2Value == null) {
            sql.append("NULL");
        } else {
            geometry2Value.appendSql(query, this, sql);
        }
        sql.append(",'distance = ' || ");
        final QueryValue distanceValue = withinDistance.getDistanceValue();
        if (distanceValue == null) {
            sql.append("0");
        } else {
            distanceValue.appendSql(query, this, sql);
        }
        sql.append(") = 'TRUE'");
    } else if (geometryField instanceof ArcSdeStGeometryFieldDefinition) {
        final Column column = (Column) withinDistance.getGeometry1Value();
        final GeometryFactory geometryFactory = column.getFieldDefinition().getRecordDefinition().getGeometryFactory();
        final Value geometry2Value = (Value) withinDistance.getGeometry2Value();
        final Value distanceValue = (Value) withinDistance.getDistanceValue();
        final Number distance = (Number) distanceValue.getValue();
        final Object geometryObject = geometry2Value.getValue();
        BoundingBox boundingBox;
        if (geometryObject instanceof BoundingBox) {
            boundingBox = (BoundingBox) geometryObject;
        } else if (geometryObject instanceof Geometry) {
            final Geometry geometry = (Geometry) geometryObject;
            boundingBox = geometry.getBoundingBox();
        } else {
            boundingBox = geometryFactory.newBoundingBoxEmpty();
        }
        boundingBox = boundingBox.expand(distance.doubleValue());
        boundingBox = boundingBox.convert(geometryFactory);
        sql.append("(SDE.ST_ENVINTERSECTS(");
        column.appendSql(query, this, sql);
        sql.append(",");
        sql.append(boundingBox.getMinX());
        sql.append(",");
        sql.append(boundingBox.getMinY());
        sql.append(",");
        sql.append(boundingBox.getMaxX());
        sql.append(",");
        sql.append(boundingBox.getMaxY());
        sql.append(") = 1 AND SDE.ST_DISTANCE(");
        column.appendSql(query, this, sql);
        sql.append(", ");
        geometry2Value.appendSql(query, this, sql);
        sql.append(") <= ");
        distanceValue.appendSql(query, this, sql);
        sql.append(")");
    } else {
        throw new IllegalArgumentException("Unknown geometry attribute type " + geometryField.getClass());
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) OracleSdoGeometryJdbcFieldDefinition(com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition) Column(com.revolsys.record.query.Column) FieldDefinition(com.revolsys.record.schema.FieldDefinition) OracleJdbcRowIdFieldDefinition(com.revolsys.oracle.recordstore.field.OracleJdbcRowIdFieldDefinition) ArcSdeStGeometryFieldDefinition(com.revolsys.oracle.recordstore.esri.ArcSdeStGeometryFieldDefinition) JdbcFieldDefinition(com.revolsys.jdbc.field.JdbcFieldDefinition) OracleSdoGeometryJdbcFieldDefinition(com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition) BoundingBox(com.revolsys.geometry.model.BoundingBox) QueryValue(com.revolsys.record.query.QueryValue) Value(com.revolsys.record.query.Value) ArcSdeStGeometryFieldDefinition(com.revolsys.oracle.recordstore.esri.ArcSdeStGeometryFieldDefinition) QueryValue(com.revolsys.record.query.QueryValue)

Aggregations

QueryValue (com.revolsys.record.query.QueryValue)16 Column (com.revolsys.record.query.Column)5 Value (com.revolsys.record.query.Value)5 ILike (com.revolsys.record.query.ILike)4 FieldDefinition (com.revolsys.record.schema.FieldDefinition)4 JdbcFieldDefinition (com.revolsys.jdbc.field.JdbcFieldDefinition)3 ArcSdeStGeometryFieldDefinition (com.revolsys.oracle.recordstore.esri.ArcSdeStGeometryFieldDefinition)3 OracleJdbcRowIdFieldDefinition (com.revolsys.oracle.recordstore.field.OracleJdbcRowIdFieldDefinition)3 OracleSdoGeometryJdbcFieldDefinition (com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition)3 BinaryCondition (com.revolsys.record.query.BinaryCondition)3 CollectionValue (com.revolsys.record.query.CollectionValue)3 EnvelopeIntersects (com.revolsys.record.query.functions.EnvelopeIntersects)3 ValueNode (com.akiban.sql.parser.ValueNode)2 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 AbstractBinaryQueryValue (com.revolsys.record.query.AbstractBinaryQueryValue)2 AbstractMultiCondition (com.revolsys.record.query.AbstractMultiCondition)2 AbstractMultiQueryValue (com.revolsys.record.query.AbstractMultiQueryValue)2 Condition (com.revolsys.record.query.Condition)2 In (com.revolsys.record.query.In)2 IsNotNull (com.revolsys.record.query.IsNotNull)2