use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.
the class JdbcUtils method appendOrderByFields.
public static StringBuilder appendOrderByFields(final StringBuilder sql, final Map<? extends CharSequence, Boolean> orderBy) {
boolean first = true;
for (final Entry<? extends CharSequence, Boolean> entry : orderBy.entrySet()) {
if (first) {
first = false;
} else {
sql.append(", ");
}
final CharSequence fieldName = entry.getKey();
if (fieldName instanceof FieldDefinition) {
final FieldDefinition fieldDefinition = (FieldDefinition) fieldName;
fieldDefinition.appendColumnName(sql);
} else {
sql.append(fieldName);
}
final Boolean ascending = entry.getValue();
if (!ascending) {
sql.append(" DESC");
}
}
return sql;
}
use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.
the class JdbcUtils method addColumnNames.
public static void addColumnNames(final StringBuilder sql, final RecordDefinition recordDefinition, final String tablePrefix) {
for (int i = 0; i < recordDefinition.getFieldCount(); i++) {
if (i > 0) {
sql.append(", ");
}
final FieldDefinition fieldDefinition = recordDefinition.getField(i);
addSelectColumnName(sql, tablePrefix, fieldDefinition);
}
}
use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.
the class JdbcQueryIterator method getNextRecord.
public static Record getNextRecord(final JdbcRecordStore recordStore, final RecordDefinition recordDefinition, final List<FieldDefinition> fields, final RecordFactory<Record> recordFactory, final ResultSet resultSet, final boolean internStrings) {
final Record record = recordFactory.newRecord(recordDefinition);
if (record != null) {
record.setState(RecordState.INITIALIZING);
int columnIndex = 1;
for (final FieldDefinition field : fields) {
final JdbcFieldDefinition jdbcField = (JdbcFieldDefinition) field;
try {
columnIndex = jdbcField.setFieldValueFromResultSet(resultSet, columnIndex, record, internStrings);
} catch (final SQLException e) {
throw new RuntimeException("Unable to get value " + (columnIndex + 1) + " from result set", e);
}
}
record.setState(RecordState.PERSISTED);
recordStore.addStatistic("query", record);
}
return record;
}
use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.
the class AbstractJdbcRecordStore method getField.
public JdbcFieldDefinition getField(final String schemaName, final String tableName, final String columnName) {
final String typePath = PathUtil.toPath(schemaName, tableName);
final RecordDefinition recordDefinition = getRecordDefinition(typePath);
if (recordDefinition == null) {
return null;
} else {
final FieldDefinition attribute = recordDefinition.getField(columnName);
return (JdbcFieldDefinition) attribute;
}
}
use of com.revolsys.record.schema.FieldDefinition in project com.revolsys.open by revolsys.
the class XlsxRecordWriter method addHeaderRow.
private void addHeaderRow(final Worksheet worksheet, final RecordDefinition recordDefinition) {
final List<Cols> columnGroups = worksheet.getCols();
final Cols columns = smlObjectFactory.createCols();
columnGroups.add(columns);
final Row headerRow = smlObjectFactory.createRow();
this.sheetRows.add(headerRow);
final List<Cell> cells = headerRow.getC();
for (final FieldDefinition field : recordDefinition.getFields()) {
final String fieldName = field.getName();
final Col column = smlObjectFactory.createCol();
columns.getCol().add(column);
column.setMin(field.getIndex() + 1);
column.setMax(field.getIndex() + 1);
column.setBestFit(true);
final int textLength = Math.min(40, Math.max(fieldName.length() + 2, field.getMaxStringLength()));
column.setWidth(textLength * 1.25);
addCellInlineString(cells, fieldName);
}
}
Aggregations