use of org.jkiss.dbeaver.model.exec.DBCAttributeMetaData in project dbeaver by serge-rider.
the class DBVUtils method readDictionaryRows.
@NotNull
public static List<DBDLabelValuePair> readDictionaryRows(DBCSession session, DBSEntityAttribute valueAttribute, DBDValueHandler valueHandler, DBCResultSet dbResult) throws DBCException {
List<DBDLabelValuePair> values = new ArrayList<>();
List<DBCAttributeMetaData> metaColumns = dbResult.getMeta().getAttributes();
List<DBDValueHandler> colHandlers = new ArrayList<>(metaColumns.size());
for (DBCAttributeMetaData col : metaColumns) {
colHandlers.add(DBUtils.findValueHandler(session, col));
}
// Extract enumeration values and (optionally) their descriptions
while (dbResult.nextRow()) {
// Check monitor
if (session.getProgressMonitor().isCanceled()) {
break;
}
// Get value and description
Object keyValue = valueHandler.fetchValueObject(session, dbResult, valueAttribute, 0);
if (keyValue == null) {
continue;
}
String keyLabel = valueHandler.getValueDisplayString(valueAttribute, keyValue, DBDDisplayFormat.NATIVE);
if (metaColumns.size() > 1) {
keyLabel = "";
for (int i = 1; i < colHandlers.size(); i++) {
Object descValue = colHandlers.get(i).fetchValueObject(session, dbResult, metaColumns.get(i), i);
if (!keyLabel.isEmpty()) {
keyLabel += " ";
}
keyLabel += colHandlers.get(i).getValueDisplayString(metaColumns.get(i), descValue, DBDDisplayFormat.NATIVE);
}
}
values.add(new DBDLabelValuePair(keyLabel, keyValue));
}
return values;
}
use of org.jkiss.dbeaver.model.exec.DBCAttributeMetaData in project dbeaver by serge-rider.
the class ResultSetValueController method getColumnId.
@NotNull
@Override
public String getColumnId() {
DBCExecutionContext context = getExecutionContext();
DBCAttributeMetaData metaAttribute = binding.getMetaAttribute();
return DBUtils.getSimpleQualifiedName(context == null ? null : context.getDataSource().getContainer().getName(), metaAttribute.getEntityName(), metaAttribute.getName());
}
use of org.jkiss.dbeaver.model.exec.DBCAttributeMetaData in project dbeaver by serge-rider.
the class StreamTransferConsumer method fetchStart.
@Override
public void fetchStart(DBCSession session, DBCResultSet resultSet, long offset, long maxRows) throws DBCException {
if (!initialized) {
// Can be invoked multiple times in case of per-segment transfer
initExporter(session);
}
// Prepare columns
metaColumns = new ArrayList<>();
List<DBCAttributeMetaData> attributes = resultSet.getMeta().getAttributes();
for (DBCAttributeMetaData attribute : attributes) {
DBDAttributeBinding columnBinding = DBUtils.getAttributeBinding(session, attribute);
metaColumns.add(columnBinding);
}
row = new Object[metaColumns.size()];
if (!initialized) {
try {
processor.exportHeader(session);
} catch (DBException e) {
log.warn("Error while exporting table header", e);
} catch (IOException e) {
throw new DBCException("IO error", e);
}
}
initialized = true;
}
Aggregations