Search in sources :

Example 61 with FieldDefinition

use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.

the class RecordLayerTableModel method setSortOrder.

@Override
public SortOrder setSortOrder(final int columnIndex) {
    final SortOrder sortOrder = super.setSortOrder(columnIndex);
    final FieldDefinition fieldName = getColumnFieldDefinition(columnIndex);
    if (Property.hasValue(fieldName)) {
        Map<FieldDefinition, Boolean> orderBy;
        if (sortOrder == SortOrder.ASCENDING) {
            orderBy = Collections.singletonMap(fieldName, true);
        } else if (sortOrder == SortOrder.DESCENDING) {
            orderBy = Collections.singletonMap(fieldName, false);
        } else {
            orderBy = Collections.singletonMap(fieldName, true);
        }
        if (this.sync == null) {
            setOrderByInternal(orderBy);
        } else {
            setOrderByInternal(orderBy);
            refresh();
        }
    }
    return sortOrder;
}
Also used : FieldDefinition(com.revolsys.record.schema.FieldDefinition) SortOrder(javax.swing.SortOrder)

Example 62 with FieldDefinition

use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.

the class RecordLayerTableModel method setSortOrder.

@Override
public SortOrder setSortOrder(final int columnIndex, final SortOrder sortOrder) {
    super.setSortOrder(columnIndex, sortOrder);
    final FieldDefinition fieldDefinition = getColumnFieldDefinition(columnIndex);
    if (fieldDefinition != null) {
        Map<FieldDefinition, Boolean> orderBy;
        if (sortOrder == SortOrder.ASCENDING) {
            orderBy = Collections.singletonMap(fieldDefinition, true);
        } else if (sortOrder == SortOrder.DESCENDING) {
            orderBy = Collections.singletonMap(fieldDefinition, false);
        } else {
            orderBy = Collections.singletonMap(fieldDefinition, true);
        }
        if (this.sync == null) {
            setOrderByInternal(orderBy);
        } else {
            setOrderByInternal(orderBy);
            refresh();
        }
    }
    return sortOrder;
}
Also used : FieldDefinition(com.revolsys.record.schema.FieldDefinition)

Example 63 with FieldDefinition

use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.

the class MergedValuePredicate method isHighlighted.

@Override
public boolean isHighlighted(final Component renderer, final ComponentAdapter adapter) {
    try {
        final int rowIndex = adapter.convertRowIndexToView(adapter.row);
        final int columnIndex = adapter.convertColumnIndexToView(adapter.column);
        final Record record = this.model.getRecord(rowIndex);
        final Record mergedRecord = this.model.getMergedRecord();
        if (record == mergedRecord) {
            return false;
        } else {
            final String fieldName = this.model.getColumnFieldName(columnIndex);
            final FieldDefinition field = this.model.getColumnFieldDefinition(columnIndex);
            if (field != null) {
                final Object value = record.getValue(fieldName);
                final Object mergedValue = mergedRecord.getValue(fieldName);
                if (value instanceof Geometry) {
                    return false;
                } else if (mergedValue instanceof Geometry) {
                    return false;
                } else {
                    return !field.equals(value, mergedValue);
                }
            }
        }
    } catch (final IndexOutOfBoundsException e) {
    }
    return false;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) FieldDefinition(com.revolsys.record.schema.FieldDefinition) Record(com.revolsys.record.Record)

Example 64 with FieldDefinition

use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.

the class RecordStoreLayer method newBoundingBoxQuery.

protected Query newBoundingBoxQuery(BoundingBox boundingBox) {
    final RecordDefinition recordDefinition = getInternalRecordDefinition();
    final FieldDefinition geometryField = recordDefinition.getGeometryField();
    boundingBox = convertBoundingBox(boundingBox);
    if (geometryField == null || Property.isEmpty(boundingBox)) {
        return null;
    } else {
        Query query = getQuery();
        query = query.newQuery(recordDefinition);
        query.and(F.envelopeIntersects(geometryField, boundingBox));
        return query;
    }
}
Also used : Query(com.revolsys.record.query.Query) FieldDefinition(com.revolsys.record.schema.FieldDefinition) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 65 with FieldDefinition

use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.

the class RecordStoreLayer method getRecords.

@Override
public <R extends LayerRecord> List<R> getRecords(final Geometry geometry, final double distance) {
    if (Property.isEmpty(geometry) || !hasGeometryField()) {
        return Collections.emptyList();
    } else {
        final RecordDefinition recordDefinition = getRecordDefinition();
        final FieldDefinition geometryField = getGeometryField();
        final WithinDistance where = F.dWithin(geometryField, geometry, distance);
        final Query query = new Query(recordDefinition, where);
        return getRecords(query);
    }
}
Also used : Query(com.revolsys.record.query.Query) FieldDefinition(com.revolsys.record.schema.FieldDefinition) WithinDistance(com.revolsys.record.query.functions.WithinDistance) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

FieldDefinition (com.revolsys.record.schema.FieldDefinition)133 RecordDefinition (com.revolsys.record.schema.RecordDefinition)38 DataType (com.revolsys.datatype.DataType)32 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)23 JdbcFieldDefinition (com.revolsys.jdbc.field.JdbcFieldDefinition)19 PathName (com.revolsys.io.PathName)15 Record (com.revolsys.record.Record)15 ArrayList (java.util.ArrayList)15 Geometry (com.revolsys.geometry.model.Geometry)13 CodeTable (com.revolsys.record.code.CodeTable)9 Query (com.revolsys.record.query.Query)8 LineString (com.revolsys.geometry.model.LineString)7 ArrayRecord (com.revolsys.record.ArrayRecord)7 RecordDefinitionImpl (com.revolsys.record.schema.RecordDefinitionImpl)7 SQLException (java.sql.SQLException)7 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)4 IOException (java.io.IOException)4 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 BadLocationException (javax.swing.text.BadLocationException)4