use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class QueryValueTest method testOr.
private void testOr() {
final Condition trueCondition1 = Q.or(Q.equal(this.idField, 10));
assertConditionTrue(trueCondition1, this.record);
final Condition trueCondition2 = Q.or(Q.equal(this.idField, 11), Q.equal(this.nameAttribute, "foobar"));
assertConditionTrue(trueCondition2, this.record);
final Condition falseCondition1 = Q.or(Q.equal(this.idField, 11), Q.equal(this.nameAttribute, "foobar1"));
assertConditionFalse(falseCondition1, this.record);
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class FileGdbRecordStore method getWhereClause.
protected StringBuilder getWhereClause(final Query query) {
final StringBuilder whereClause = new StringBuilder();
final Condition whereCondition = query.getWhereCondition();
if (!whereCondition.isEmpty()) {
appendQueryValue(query, whereClause, whereCondition);
}
return whereClause;
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class RecordLayerTableModel method getFilterQuery.
protected Query getFilterQuery() {
final Query query = this.layer.getQuery();
final Condition filter = getFilter();
query.and(filter);
query.setOrderBy(this.orderBy);
if (this.filterByBoundingBox) {
final Project project = this.layer.getProject();
final BoundingBox viewBoundingBox = project.getViewBoundingBox();
final RecordDefinition recordDefinition = this.layer.getRecordDefinition();
final FieldDefinition geometryField = recordDefinition.getGeometryField();
if (geometryField != null) {
query.and(F.envelopeIntersects(geometryField, viewBoundingBox));
}
}
return query;
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class FeatureLayer method newQueryParameters.
public Map<String, Object> newQueryParameters(final Query query) {
final Map<String, Object> parameters = new LinkedHashMap<>();
parameters.put("f", "json");
parameters.put("returnGeometry", "true");
parameters.put("where", this.recordDefinition.getIdFieldName() + " > 0");
if (query != null) {
// WHERE
final Condition whereCondition = query.getWhereCondition();
if (whereCondition != Condition.ALL) {
final String where = whereCondition.toString();
parameters.put("where", where);
}
// ORDER BY
final Map<? extends CharSequence, Boolean> orderBy = query.getOrderBy();
if (Property.hasValue(orderBy)) {
final String orderByFields = JdbcUtils.appendOrderByFields(new StringBuilder(), orderBy).toString();
parameters.put("orderByFields", orderByFields);
}
}
return parameters;
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class RecordStoreLayer method getCachedRecord.
@SuppressWarnings("unchecked")
@Override
protected <R extends LayerRecord> R getCachedRecord(final Identifier identifier) {
final RecordDefinition recordDefinition = getInternalRecordDefinition();
synchronized (getSync()) {
LayerRecord record = this.recordsByIdentifier.get(identifier);
if (record == null) {
final List<String> idFieldNames = recordDefinition.getIdFieldNames();
if (idFieldNames.isEmpty()) {
return null;
} else {
final Condition where = getCachedRecordQuery(idFieldNames, identifier);
final Query query = new Query(recordDefinition, where);
final RecordStore recordStore = this.recordStore;
if (recordStore != null) {
try (Transaction transaction = recordStore.newTransaction(Propagation.REQUIRED);
RecordReader reader = newRecordStoreRecordReader(query)) {
record = reader.getFirst();
if (record != null) {
addCachedRecord(identifier, record);
}
}
}
}
}
return (R) record;
}
}
Aggregations