use of org.jkiss.dbeaver.model.data.DBDAttributeBinding in project dbeaver by dbeaver.
the class ContentPanelEditor method makeValueId.
private String makeValueId() {
String valueId;
DBSTypedObject valueType = valueController.getValueType();
if (valueType instanceof DBDAttributeBinding) {
valueType = ((DBDAttributeBinding) valueType).getAttribute();
}
if (valueType instanceof DBSObject) {
DBSObject object = (DBSObject) valueType;
valueId = DBUtils.getObjectFullName(object, DBPEvaluationContext.DDL);
if (object.getParentObject() != null) {
valueId = DBUtils.getObjectFullName(object.getParentObject(), DBPEvaluationContext.DDL) + ":" + valueId;
}
} else {
valueId = valueController.getValueName();
}
String dsId = "unknown";
if (valueController.getExecutionContext() != null) {
dsId = valueController.getExecutionContext().getDataSource().getContainer().getId();
}
return dsId + ":" + valueId;
}
use of org.jkiss.dbeaver.model.data.DBDAttributeBinding in project dbeaver by serge-rider.
the class ViewValuePanel method refreshValue.
private void refreshValue(boolean force) {
DBDAttributeBinding attr = presentation.getCurrentAttribute();
ResultSetRow row = presentation.getController().getCurrentRow();
if (attr == null || row == null) {
clearValue();
return;
}
boolean updateActions;
if (previewController == null) {
previewController = new ResultSetValueController(presentation.getController(), attr, row, IValueController.EditType.PANEL, viewPlaceholder) {
@Override
public void updateValue(@Nullable Object value, boolean updatePresentation) {
valueSaving = true;
try {
super.updateValue(value, updatePresentation);
} finally {
valueSaving = false;
}
presentation.updateValueView();
}
};
updateActions = true;
force = true;
} else {
updateActions = force = (force || previewController.getBinding() != attr);
previewController.setCurRow(row);
previewController.setBinding(attr);
}
viewValue(force);
if (updateActions) {
presentation.getController().updatePanelActions();
}
}
use of org.jkiss.dbeaver.model.data.DBDAttributeBinding in project dbeaver by serge-rider.
the class DataExporterJSON method exportRow.
@Override
public void exportRow(DBCSession session, Object[] row) throws DBException, IOException {
if (rowNum > 0) {
out.write(",\n");
}
rowNum++;
out.write("\t{\n");
for (int i = 0; i < row.length; i++) {
DBDAttributeBinding column = columns.get(i);
String columnName = column.getName();
out.write("\t\t\"" + escapeJsonString(columnName) + "\" : ");
Object cellValue = row[i];
if (DBUtils.isNullValue(cellValue)) {
writeTextCell(null);
} else if (cellValue instanceof DBDContent) {
// Content
// Inline textual content and handle binaries in some special way
DBDContent content = (DBDContent) cellValue;
try {
DBDContentStorage cs = content.getContents(session.getProgressMonitor());
if (cs != null) {
if (ContentUtils.isTextContent(content)) {
try (Reader in = cs.getContentReader()) {
out.write("\"");
writeCellValue(in);
out.write("\"");
}
} else {
getSite().writeBinaryData(cs);
}
}
} finally {
content.release();
}
} else {
if (cellValue instanceof Number || cellValue instanceof Boolean) {
out.write(cellValue.toString());
} else if (cellValue instanceof Date && formatDateISO) {
writeTextCell(dateFormat.format(cellValue));
} else {
writeTextCell(super.getValueDisplayString(column, cellValue));
}
}
if (i < row.length - 1) {
out.write(",");
}
out.write("\n");
}
out.write("\t}");
}
use of org.jkiss.dbeaver.model.data.DBDAttributeBinding 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;
}
use of org.jkiss.dbeaver.model.data.DBDAttributeBinding in project dbeaver by serge-rider.
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();
}
Aggregations