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);
}
}
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;
}
}
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;
}
}
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);
}
}
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());
}
}
Aggregations