Search in sources :

Example 81 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystemsLoader method loadArea.

private void loadArea() {
    try (final RecordReader reader = newReader("/public/epsg_area", "area_code");
        ChannelWriter writer = newWriter("area")) {
        for (final Record record : reader) {
            writeInt(writer, record, "area_code");
            writeString(writer, record, "area_name");
            writeDouble(writer, record, "area_west_bound_lon");
            writeDouble(writer, record, "area_south_bound_lat");
            writeDouble(writer, record, "area_east_bound_lon");
            writeDouble(writer, record, "area_north_bound_lat");
            writeDeprecated(writer, record);
        }
    }
}
Also used : RecordReader(com.revolsys.record.io.RecordReader) Record(com.revolsys.record.Record) ChannelWriter(com.revolsys.io.channels.ChannelWriter)

Example 82 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystemsLoader method loadPrimeMeridian.

private void loadPrimeMeridian() throws IOException {
    try (final RecordReader reader = newReader("/public/epsg_primemeridian", "prime_meridian_code");
        ChannelWriter writer = newWriter("primeMeridian")) {
        for (final Record record : reader) {
            writeInt(writer, record, "prime_meridian_code");
            writeString(writer, record, "prime_meridian_name");
            writeInt(writer, record, "uom_code");
            writeDouble(writer, record, "greenwich_longitude");
            if (isDeprecated(record)) {
                System.err.println("Add deprecated support to prime meridian");
            }
        }
    }
}
Also used : RecordReader(com.revolsys.record.io.RecordReader) Record(com.revolsys.record.Record) ChannelWriter(com.revolsys.io.channels.ChannelWriter)

Example 83 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class PostgreSQLJdbcQueryResultPager method getList.

@Override
public List<Record> getList() {
    synchronized (this) {
        if (this.results == null) {
            final ArrayList<Record> results = new ArrayList<>();
            final int pageSize = getPageSize();
            final int pageNumber = getPageNumber();
            if (pageNumber != -1) {
                String sql = getSql();
                final int startRowNum = (pageNumber - 1) * pageSize;
                sql = getSql() + " OFFSET " + startRowNum + " LIMIT " + pageSize;
                final RecordDefinition recordDefinition = getRecordDefinition();
                if (recordDefinition != null) {
                    final RecordFactory recordFactory = getRecordFactory();
                    final JdbcRecordStore recordStore = getRecordStore();
                    try (JdbcConnection connection = recordStore.getJdbcConnection()) {
                        final List<FieldDefinition> attributes = recordDefinition.getFields();
                        try (final PreparedStatement statement = connection.prepareStatement(sql);
                            final ResultSet resultSet = JdbcQueryIterator.getResultSet(statement, getQuery())) {
                            if (resultSet.next()) {
                                int i = 0;
                                do {
                                    final Record object = JdbcQueryIterator.getNextRecord(recordStore, recordDefinition, attributes, recordFactory, resultSet, this.internStrings);
                                    results.add(object);
                                    i++;
                                } while (resultSet.next() && i < pageSize);
                            }
                        } catch (final SQLException e) {
                            throw connection.getException("updateResults", sql, e);
                        }
                    }
                }
            }
            this.results = results;
        }
        return this.results;
    }
}
Also used : SQLException(java.sql.SQLException) JdbcRecordStore(com.revolsys.jdbc.io.JdbcRecordStore) FieldDefinition(com.revolsys.record.schema.FieldDefinition) ArrayList(java.util.ArrayList) JdbcConnection(com.revolsys.jdbc.JdbcConnection) PreparedStatement(java.sql.PreparedStatement) RecordDefinition(com.revolsys.record.schema.RecordDefinition) RecordFactory(com.revolsys.record.RecordFactory) ResultSet(java.sql.ResultSet) Record(com.revolsys.record.Record)

Example 84 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class RecordStoreQueryListModel method getRecords.

protected List<Record> getRecords(final String searchParam) {
    if (Property.hasValue(searchParam) && searchParam.length() >= 2) {
        final Map<String, Record> allObjects = new TreeMap<>();
        for (Query query : this.queries) {
            if (allObjects.size() < this.maxResults) {
                query = query.clone();
                query.setOrderBy(this.displayFieldName);
                final Condition whereCondition = query.getWhereCondition();
                if (whereCondition instanceof BinaryCondition) {
                    final BinaryCondition binaryCondition = (BinaryCondition) whereCondition;
                    if (binaryCondition.getOperator().equalsIgnoreCase("like")) {
                        final String likeString = "%" + searchParam.toUpperCase().replaceAll("[^A-Z0-9 ]", "%") + "%";
                        Q.setValue(0, binaryCondition, likeString);
                    } else {
                        Q.setValue(0, binaryCondition, searchParam);
                    }
                }
                query.setLimit(this.maxResults);
                final Reader<Record> reader = this.recordStore.getRecords(query);
                try {
                    final List<Record> objects = reader.toList();
                    for (final Record object : objects) {
                        if (allObjects.size() < this.maxResults) {
                            final String key = object.getString(this.displayFieldName);
                            if (!allObjects.containsKey(key)) {
                                if (searchParam.equals(key)) {
                                    this.selectedItem = object;
                                }
                                allObjects.put(key, object);
                            }
                        }
                    }
                } finally {
                    reader.close();
                }
            }
        }
        return new ArrayList<>(allObjects.values());
    } else {
        return Collections.emptyList();
    }
}
Also used : Condition(com.revolsys.record.query.Condition) BinaryCondition(com.revolsys.record.query.BinaryCondition) Query(com.revolsys.record.query.Query) BinaryCondition(com.revolsys.record.query.BinaryCondition) ArrayList(java.util.ArrayList) Record(com.revolsys.record.Record) TreeMap(java.util.TreeMap)

Example 85 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class AbstractRecordQueryField method showMenu.

private void showMenu() {
    final List<Record> records = this.listModel;
    if (records.isEmpty()) {
        this.menu.setVisible(false);
    } else {
        this.menu.setVisible(true);
        int x;
        int y;
        x = 0;
        final Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration());
        final Rectangle bounds = getGraphicsConfiguration().getBounds();
        final int menuHeight = this.menu.getBounds().height;
        final int screenY = getLocationOnScreen().y;
        final int componentHeight = getHeight();
        final int bottomOfMenu = screenY + menuHeight + componentHeight;
        if (bottomOfMenu > bounds.height - screenInsets.bottom) {
            y = -menuHeight;
        } else {
            y = componentHeight;
        }
        // } else {
        // x = this.getWidth();
        // y = 0;
        // }
        this.menu.show(this, x, y);
        this.menu.pack();
    }
}
Also used : Insets(java.awt.Insets) Rectangle(java.awt.Rectangle) Record(com.revolsys.record.Record)

Aggregations

Record (com.revolsys.record.Record)198 ArrayRecord (com.revolsys.record.ArrayRecord)43 RecordReader (com.revolsys.record.io.RecordReader)34 RecordDefinition (com.revolsys.record.schema.RecordDefinition)34 Geometry (com.revolsys.geometry.model.Geometry)29 LineString (com.revolsys.geometry.model.LineString)21 Point (com.revolsys.geometry.model.Point)20 ChannelWriter (com.revolsys.io.channels.ChannelWriter)19 Identifier (com.revolsys.identifier.Identifier)17 ArrayList (java.util.ArrayList)16 FieldDefinition (com.revolsys.record.schema.FieldDefinition)15 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)14 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)13 NoSuchElementException (java.util.NoSuchElementException)13 DataType (com.revolsys.datatype.DataType)10 Query (com.revolsys.record.query.Query)9 HashMap (java.util.HashMap)9 List (java.util.List)8 LinkedHashMap (java.util.LinkedHashMap)7 Edge (com.revolsys.geometry.graph.Edge)6