Search in sources :

Example 6 with DBSDataContainer

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

the class SearchDataQuery method run.

@Override
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
    try {
        String searchString = params.getSearchString();
        //monitor.subTask("Collect tables");
        Set<DBPDataSource> dataSources = new HashSet<>();
        for (DBSDataContainer searcher : params.sources) {
            dataSources.add(searcher.getDataSource());
        }
        // Search
        DBNModel dbnModel = DBeaverCore.getInstance().getNavigatorModel();
        monitor.beginTask("Search \"" + searchString + "\" in " + params.sources.size() + " table(s) / " + dataSources.size() + " database(s)", params.sources.size());
        try {
            for (DBSDataContainer dataContainer : params.sources) {
                if (monitor.isCanceled()) {
                    break;
                }
                String objectName = DBUtils.getObjectFullName(dataContainer, DBPEvaluationContext.DML);
                DBNDatabaseNode node = dbnModel.findNode(dataContainer);
                if (node == null) {
                    log.warn("Can't find tree node for object \"" + objectName + "\"");
                    continue;
                }
                monitor.subTask(objectName);
                DBPDataSource dataSource = dataContainer.getDataSource();
                if (dataSource == null) {
                    log.warn("Object \"" + objectName + "\" not connected");
                    continue;
                }
                SearchTableMonitor searchMonitor = new SearchTableMonitor();
                try (DBCSession session = DBUtils.openUtilSession(searchMonitor, dataSource, "Search rows in " + objectName)) {
                    TestDataReceiver dataReceiver = new TestDataReceiver(searchMonitor);
                    findRows(session, dataContainer, dataReceiver);
                    if (dataReceiver.rowCount > 0) {
                        SearchDataObject object = new SearchDataObject(node, dataReceiver.rowCount, dataReceiver.filter);
                        searchResult.addObjects(Collections.singletonList(object));
                    }
                }
                monitor.worked(1);
            }
        } finally {
            monitor.done();
        }
        return Status.OK_STATUS;
    } catch (DBException e) {
        return GeneralUtils.makeExceptionStatus(e);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

Example 7 with DBSDataContainer

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

the class SQLResultsView method setContainer.

public void setContainer(IResultSetContainer container) {
    detachedContainer.currentContainer = container;
    final DBSDataContainer dataContainer = container.getDataContainer();
    String partName = dataContainer == null ? "Data" : dataContainer.getName();
    setPartName(partName);
}
Also used : DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer)

Aggregations

DBSDataContainer (org.jkiss.dbeaver.model.struct.DBSDataContainer)7 NotNull (org.jkiss.code.NotNull)2 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)2 DBNModel (org.jkiss.dbeaver.model.navigator.DBNModel)2 DBException (org.jkiss.dbeaver.DBException)1 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)1 DBCStatistics (org.jkiss.dbeaver.model.exec.DBCStatistics)1 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)1 DBSEntity (org.jkiss.dbeaver.model.struct.DBSEntity)1 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)1 DatabaseTransferProducer (org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer)1 DataTransferPipe (org.jkiss.dbeaver.tools.transfer.wizard.DataTransferPipe)1