use of org.jkiss.dbeaver.model.struct.DBSEntity in project dbeaver by serge-rider.
the class ResultSetPersister method prepareInsertStatements.
private void prepareInsertStatements() throws DBException {
// Make insert statements
final DBSEntity table = viewer.getModel().getSingleSource();
if (table == null) {
throw new DBCException("Internal error: can't get single entity metadata, insert is not possible");
}
for (ResultSetRow row : addedRows) {
DataStatementInfo statement = new DataStatementInfo(DBSManipulationType.INSERT, row, table);
DBDAttributeBinding docAttr = model.getDocumentAttribute();
if (docAttr != null) {
statement.keyAttributes.add(new DBDAttributeValue(docAttr, model.getCellValue(docAttr, row)));
} else {
for (int i = 0; i < columns.length; i++) {
DBDAttributeBinding column = columns[i];
statement.keyAttributes.add(new DBDAttributeValue(column, model.getCellValue(column, row)));
}
}
insertStatements.add(statement);
}
}
use of org.jkiss.dbeaver.model.struct.DBSEntity in project dbeaver by serge-rider.
the class ArrayAttributeTransformer method transformAttribute.
@Override
public void transformAttribute(@NotNull DBCSession session, @NotNull DBDAttributeBinding attribute, @NotNull List<Object[]> rows, @NotNull Map<String, String> options) throws DBException {
DBSDataType collectionType;
if (attribute.getAttribute() instanceof DBSTypedObjectEx) {
collectionType = ((DBSTypedObjectEx) attribute.getAttribute()).getDataType();
} else {
collectionType = DBUtils.resolveDataType(session.getProgressMonitor(), session.getDataSource(), attribute.getTypeName());
}
if (collectionType != null) {
DBSDataType componentType = collectionType.getComponentType(session.getProgressMonitor());
if (componentType instanceof DBSEntity) {
ComplexTypeAttributeTransformer.createNestedTypeBindings(session, attribute, rows, (DBSEntity) componentType);
return;
}
}
// No component type found.
// Array items should be resolved in a lazy mode
MapAttributeTransformer.resolveMapsFromData(session, attribute, rows);
}
Aggregations