Search in sources :

Example 6 with DBSDataManipulator

use of org.jkiss.dbeaver.model.struct.DBSDataManipulator in project dbeaver by serge-rider.

the class ResultSetModel method isAttributeReadOnly.

public boolean isAttributeReadOnly(@NotNull DBDAttributeBinding attribute) {
    if (!isSingleSource()) {
        return true;
    }
    if (attribute.getMetaAttribute().isReadOnly()) {
        return true;
    }
    DBDRowIdentifier rowIdentifier = attribute.getRowIdentifier();
    if (rowIdentifier == null || !(rowIdentifier.getEntity() instanceof DBSDataManipulator)) {
        return true;
    }
    DBSDataManipulator dataContainer = (DBSDataManipulator) rowIdentifier.getEntity();
    return (dataContainer.getSupportedFeatures() & DBSDataManipulator.DATA_UPDATE) == 0;
}
Also used : DBSDataManipulator(org.jkiss.dbeaver.model.struct.DBSDataManipulator)

Example 7 with DBSDataManipulator

use of org.jkiss.dbeaver.model.struct.DBSDataManipulator in project dbeaver by dbeaver.

the class MockDataGenerateTool method execute.

public void execute(IWorkbenchWindow window, IWorkbenchPart activePart, Collection<DBSObject> objects) throws DBException {
    ArrayList<DBSDataManipulator> dbObjects = new ArrayList<>();
    for (DBSObject obj : objects) {
        dbObjects.add((DBSDataManipulator) obj);
    }
    MockDataExecuteWizard wizard = new MockDataExecuteWizard(mockDataSettings, dbObjects, MockDataMessages.tools_mockdata_wizard_page_name);
    ToolWizardDialog dialog = new ToolWizardDialog(window, wizard) {

        @Override
        protected void finishPressed() {
            if (validateProperties(getCurrentPage())) {
                return;
            }
            if (mockDataSettings.isRemoveOldData()) {
                if (!UIUtils.confirmAction(getShell(), MockDataMessages.tools_mockdata_wizard_title, MockDataMessages.tools_mockdata_confirm_delete_old_data_message)) {
                    return;
                }
            }
            super.finishPressed();
        }

        @Override
        protected void nextPressed() {
            IWizardPage currentPage = getCurrentPage();
            if (currentPage instanceof MockDataWizardPageSettings) {
                if (validateProperties(currentPage)) {
                    return;
                }
            }
            super.nextPressed();
        }

        /**
         * Returns TRUE if invalid
         */
        private boolean validateProperties(IWizardPage currentPage) {
            if (currentPage instanceof MockDataWizardPageSettings) {
                if (!((MockDataWizardPageSettings) currentPage).validateProperties()) {
                    this.setErrorMessage("All numeric properties should be positive.");
                    return true;
                }
            }
            return false;
        }

        @Override
        protected Point getInitialSize() {
            return new Point(850, 550);
        }
    };
    dialog.open();
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ToolWizardDialog(org.jkiss.dbeaver.ui.dialogs.tools.ToolWizardDialog) DBSDataManipulator(org.jkiss.dbeaver.model.struct.DBSDataManipulator) ArrayList(java.util.ArrayList) IWizardPage(org.eclipse.jface.wizard.IWizardPage) Point(org.eclipse.swt.graphics.Point)

Example 8 with DBSDataManipulator

use of org.jkiss.dbeaver.model.struct.DBSDataManipulator in project dbeaver by dbeaver.

the class ResultSetModel method isAttributeReadOnly.

public boolean isAttributeReadOnly(@NotNull DBDAttributeBinding attribute) {
    if (!isSingleSource()) {
        return true;
    }
    if (attribute.getMetaAttribute().isReadOnly()) {
        return true;
    }
    DBDRowIdentifier rowIdentifier = attribute.getRowIdentifier();
    if (rowIdentifier == null || !(rowIdentifier.getEntity() instanceof DBSDataManipulator)) {
        return true;
    }
    DBSDataManipulator dataContainer = (DBSDataManipulator) rowIdentifier.getEntity();
    return (dataContainer.getSupportedFeatures() & DBSDataManipulator.DATA_UPDATE) == 0;
}
Also used : DBSDataManipulator(org.jkiss.dbeaver.model.struct.DBSDataManipulator)

Example 9 with DBSDataManipulator

use of org.jkiss.dbeaver.model.struct.DBSDataManipulator in project dbeaver by dbeaver.

the class DatabaseProducerPageInputObjects method chooseEntity.

protected boolean chooseEntity(DataTransferPipe pipe) {
    DataTransferSettings settings = getWizard().getSettings();
    final DBNModel navigatorModel = DBWorkbench.getPlatform().getNavigatorModel();
    final DBNNode rootNode = DBWorkbench.getPlatform().getWorkspace().getProjects().size() == 1 ? navigatorModel.getRoot().getProjectNode(DBWorkbench.getPlatform().getWorkspace().getActiveProject()) : navigatorModel.getRoot();
    boolean chooseConsumer = settings.isConsumerOptional();
    DBNNode node = DBWorkbench.getPlatformUI().selectObject(UIUtils.getActiveWorkbenchShell(), chooseConsumer ? NLS.bind(DTUIMessages.database_producer_page_input_objects_node_select_target, pipe.getProducer().getDatabaseObject().getName()) : NLS.bind(DTUIMessages.database_producer_page_input_objects_node_select_source, pipe.getConsumer().getObjectName()), rootNode, lastSelection, new Class[] { DBSObjectContainer.class, DBSDataContainer.class }, new Class[] { chooseConsumer ? DBSDataManipulator.class : DBSDataContainer.class }, null);
    if (node instanceof DBNDatabaseNode) {
        lastSelection = (DBNDatabaseNode) node;
        DBSObject object = ((DBNDatabaseNode) node).getObject();
        if (chooseConsumer) {
            if (object instanceof DBSDataManipulator) {
                pipe.setConsumer(new DatabaseTransferConsumer((DBSDataManipulator) object));
            }
        } else {
            if (object instanceof DBSDataContainer) {
                pipe.setProducer(new DatabaseTransferProducer((DBSDataContainer) object));
            }
        }
        return true;
    }
    return false;
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DatabaseTransferConsumer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferConsumer) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) DBSDataManipulator(org.jkiss.dbeaver.model.struct.DBSDataManipulator) DatabaseTransferProducer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer) DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Example 10 with DBSDataManipulator

use of org.jkiss.dbeaver.model.struct.DBSDataManipulator in project dbeaver by dbeaver.

the class DatabaseProducerPageInputObjects method autoAssignMappings.

private void autoAssignMappings(List<DBSObject> containerObjects) {
    boolean chooseConsumer = getWizard().getSettings().isConsumerOptional();
    for (TableItem item : mappingTable.getItems()) {
        DataTransferPipe pipe = (DataTransferPipe) item.getData();
        if ((chooseConsumer && (pipe.getConsumer() == null || pipe.getConsumer().getDatabaseObject() == null)) || (!chooseConsumer && (pipe.getProducer() == null || pipe.getProducer().getDatabaseObject() == null))) {
            DBSObject objectToMap = chooseConsumer ? pipe.getProducer().getDatabaseObject() : pipe.getConsumer().getDatabaseObject();
            if (objectToMap == null) {
                continue;
            }
            DBSObject object = DBUtils.findObject(containerObjects, objectToMap.getName());
            if (object != null) {
                if (chooseConsumer) {
                    if (object instanceof DBSDataManipulator) {
                        pipe.setConsumer(new DatabaseTransferConsumer((DBSDataManipulator) object));
                    }
                } else {
                    if (object instanceof DBSDataContainer) {
                        pipe.setProducer(new DatabaseTransferProducer((DBSDataContainer) object));
                    }
                }
                updateItemData(item, pipe);
            }
        }
    }
    updatePageCompletion();
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DatabaseTransferConsumer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferConsumer) DBSDataManipulator(org.jkiss.dbeaver.model.struct.DBSDataManipulator) DatabaseTransferProducer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer) DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe)

Aggregations

DBSDataManipulator (org.jkiss.dbeaver.model.struct.DBSDataManipulator)13 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)8 DBSDataContainer (org.jkiss.dbeaver.model.struct.DBSDataContainer)7 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)4 DatabaseTransferConsumer (org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferConsumer)4 DatabaseTransferProducer (org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer)4 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 DBException (org.jkiss.dbeaver.DBException)2 DBNModel (org.jkiss.dbeaver.model.navigator.DBNModel)2 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)2 DataTransferPipe (org.jkiss.dbeaver.tools.transfer.DataTransferPipe)2 DataTransferSettings (org.jkiss.dbeaver.tools.transfer.DataTransferSettings)2 DatabaseConsumerSettings (org.jkiss.dbeaver.tools.transfer.database.DatabaseConsumerSettings)2 DatabaseMappingContainer (org.jkiss.dbeaver.tools.transfer.database.DatabaseMappingContainer)2 StreamEntityMapping (org.jkiss.dbeaver.tools.transfer.stream.StreamEntityMapping)2 StreamProducerSettings (org.jkiss.dbeaver.tools.transfer.stream.StreamProducerSettings)2 StreamTransferProducer (org.jkiss.dbeaver.tools.transfer.stream.StreamTransferProducer)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1