use of org.jkiss.dbeaver.model.data.DBDAttributeBinding in project dbeaver by dbeaver.
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;
}
use of org.jkiss.dbeaver.model.data.DBDAttributeBinding in project dbeaver by dbeaver.
the class DataExporterCSV method printHeader.
private void printHeader() {
for (int i = 0, columnsSize = columns.size(); i < columnsSize; i++) {
DBDAttributeBinding column = columns.get(i);
String colName = column.getLabel();
if (CommonUtils.isEmpty(colName)) {
colName = column.getName();
}
writeCellValue(colName, true);
if (i < columnsSize - 1) {
writeDelimiter();
}
}
writeRowLimit();
}
use of org.jkiss.dbeaver.model.data.DBDAttributeBinding in project dbeaver by dbeaver.
the class DataExporterHTML method exportRow.
@Override
public void exportRow(DBCSession session, Object[] row) throws DBException, IOException {
out.write("<tr" + (rowCount++ % 2 == 0 ? " class=\"odd\"" : "") + ">");
for (int i = 0; i < row.length; i++) {
DBDAttributeBinding column = columns.get(i);
if (DBUtils.isNullValue(row[i])) {
writeTextCell(null, false);
} else if (row[i] instanceof DBDContent) {
// Content
// Inline textual content and handle binaries in some special way
DBDContent content = (DBDContent) row[i];
try {
DBDContentStorage cs = content.getContents(session.getProgressMonitor());
out.write("<td>");
if (cs != null) {
if (ContentUtils.isTextContent(content)) {
writeCellValue(cs.getContentReader());
} else {
getSite().writeBinaryData(cs);
}
}
out.write("</td>");
} finally {
content.release();
}
} else {
String stringValue = super.getValueDisplayString(column, row[i]);
boolean isImage = row[i] instanceof File && stringValue != null && stringValue.endsWith(".jpg");
if (isImage) {
writeImageCell((File) row[i]);
} else {
writeTextCell(stringValue, false);
}
}
}
out.write("</tr>\n");
}
use of org.jkiss.dbeaver.model.data.DBDAttributeBinding in project dbeaver by serge-rider.
the class GISLeafletViewer method saveAttributeSettings.
private void saveAttributeSettings() {
if (valueController instanceof IAttributeController) {
DBDAttributeBinding binding = ((IAttributeController) valueController).getBinding();
if (binding.getEntityAttribute() != null) {
DBVEntity vEntity = DBVUtils.getVirtualEntity(binding, true);
DBVEntityAttribute vAttr = vEntity.getVirtualAttribute(binding, true);
if (vAttr != null) {
vAttr.setProperty(PROP_FLIP_COORDINATES, String.valueOf(flipCoordinates));
vAttr.setProperty(PROP_SRID, String.valueOf(getValueSRID()));
}
valueController.getExecutionContext().getDataSource().getContainer().getRegistry().flushConfig();
}
}
}
use of org.jkiss.dbeaver.model.data.DBDAttributeBinding in project dbeaver by serge-rider.
the class GeometryDataUtils method setGeometryProperties.
public static void setGeometryProperties(IResultSetController controller, GeomAttrs geomAttrs, DBGeometry geometry, ResultSetRow row) {
// Now extract all geom values from data
ResultSetModel model = controller.getModel();
if (row != null) {
// Now get description
if (!geomAttrs.descAttrs.isEmpty()) {
Map<String, Object> properties = new LinkedHashMap<>();
for (DBDAttributeBinding da : geomAttrs.descAttrs) {
Object descValue = model.getCellValue(da, row);
if (!DBUtils.isNullValue(descValue)) {
properties.put(da.getName(), descValue);
}
}
geometry.setProperties(properties);
}
}
}
Aggregations