Search in sources :

Example 11 with DBSEntity

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);
    }
}
Also used : DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity)

Example 12 with DBSEntity

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);
}
Also used : DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType) DBSTypedObjectEx(org.jkiss.dbeaver.model.struct.DBSTypedObjectEx) DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity)

Aggregations

DBSEntity (org.jkiss.dbeaver.model.struct.DBSEntity)12 DBException (org.jkiss.dbeaver.DBException)4 ArrayList (java.util.ArrayList)3 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)3 DBSDataType (org.jkiss.dbeaver.model.struct.DBSDataType)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 BigDecimal (java.math.BigDecimal)1 LinkedHashSet (java.util.LinkedHashSet)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 PaletteDrawer (org.eclipse.gef.palette.PaletteDrawer)1 TemplateVariable (org.eclipse.jface.text.templates.TemplateVariable)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 TableItem (org.eclipse.swt.widgets.TableItem)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 DiagramPart (org.jkiss.dbeaver.ext.erd.part.DiagramPart)1