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