Search in sources :

Example 1 with ExasolObjectType

use of org.jkiss.dbeaver.ext.exasol.editors.ExasolObjectType in project dbeaver by dbeaver.

the class ExasolStructureAssistant method searchTables.

// --------------
// Helper Classes
// --------------
private void searchTables(JDBCSession session, ExasolSchema schema, String searchObjectNameMask, List<ExasolObjectType> exasolObjectTypes, int maxResults, List<DBSObjectReference> objects, int nbResults) throws SQLException, DBException {
    String sql;
    if (schema != null) {
        sql = String.format(SQL_TABLES_SCHEMA, ExasolUtils.quoteString(schema.getName()), ExasolUtils.quoteString(searchObjectNameMask), buildTableTypes(exasolObjectTypes));
    } else {
        sql = String.format(SQL_TABLES_ALL, ExasolUtils.quoteString(searchObjectNameMask), buildTableTypes(exasolObjectTypes));
    }
    try (JDBCStatement dbStat = session.createStatement()) {
        dbStat.setFetchSize(DBConstants.METADATA_FETCH_SIZE);
        String schemaName;
        String objectName;
        ExasolSchema exasolSchema;
        ExasolObjectType objectType;
        try (JDBCResultSet dbResult = dbStat.executeQuery(sql)) {
            while (dbResult.next()) {
                if (session.getProgressMonitor().isCanceled()) {
                    break;
                }
                if (nbResults++ >= maxResults) {
                    break;
                }
                schemaName = JDBCUtils.safeGetStringTrimmed(dbResult, "TABLE_SCHEM");
                objectName = JDBCUtils.safeGetString(dbResult, "TABLE_NAME");
                exasolSchema = dataSource.getSchema(session.getProgressMonitor(), schemaName);
                if (exasolSchema == null) {
                    LOG.debug("Schema '" + schemaName + "' not found. Probably was filtered");
                    continue;
                }
                objectType = ExasolObjectType.TABLE;
                objects.add(new ExasolObjectReference(objectName, exasolSchema, objectType));
            }
        }
    }
}
Also used : ExasolObjectType(org.jkiss.dbeaver.ext.exasol.editors.ExasolObjectType) JDBCStatement(org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement) JDBCResultSet(org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet)

Example 2 with ExasolObjectType

use of org.jkiss.dbeaver.ext.exasol.editors.ExasolObjectType in project dbeaver by serge-rider.

the class ExasolStructureAssistant method searchTables.

// --------------
// Helper Classes
// --------------
private void searchTables(JDBCSession session, ExasolSchema schema, String searchObjectNameMask, List<ExasolObjectType> exasolObjectTypes, int maxResults, List<DBSObjectReference> objects, int nbResults) throws SQLException, DBException {
    String sql;
    if (schema != null) {
        sql = String.format(SQL_TABLES_SCHEMA, ExasolUtils.quoteString(schema.getName()), ExasolUtils.quoteString(searchObjectNameMask), buildTableTypes(exasolObjectTypes));
    } else {
        sql = String.format(SQL_TABLES_ALL, ExasolUtils.quoteString(searchObjectNameMask), buildTableTypes(exasolObjectTypes));
    }
    try (JDBCStatement dbStat = session.createStatement()) {
        dbStat.setFetchSize(DBConstants.METADATA_FETCH_SIZE);
        String schemaName;
        String objectName;
        ExasolSchema exasolSchema;
        ExasolObjectType objectType;
        try (JDBCResultSet dbResult = dbStat.executeQuery(sql)) {
            while (dbResult.next()) {
                if (session.getProgressMonitor().isCanceled()) {
                    break;
                }
                if (nbResults++ >= maxResults) {
                    break;
                }
                schemaName = JDBCUtils.safeGetStringTrimmed(dbResult, "TABLE_SCHEM");
                objectName = JDBCUtils.safeGetString(dbResult, "TABLE_NAME");
                exasolSchema = dataSource.getSchema(session.getProgressMonitor(), schemaName);
                if (exasolSchema == null) {
                    LOG.debug("Schema '" + schemaName + "' not found. Probably was filtered");
                    continue;
                }
                objectType = ExasolObjectType.TABLE;
                objects.add(new ExasolObjectReference(objectName, exasolSchema, objectType));
            }
        }
    }
}
Also used : ExasolObjectType(org.jkiss.dbeaver.ext.exasol.editors.ExasolObjectType) JDBCStatement(org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement) JDBCResultSet(org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet)

Example 3 with ExasolObjectType

use of org.jkiss.dbeaver.ext.exasol.editors.ExasolObjectType in project dbeaver by serge-rider.

the class ExasolStructureAssistant method findObjectsByMask.

@NotNull
@Override
public List<DBSObjectReference> findObjectsByMask(DBRProgressMonitor monitor, DBSObject parentObject, DBSObjectType[] objectTypes, String objectNameMask, boolean caseSensitive, boolean globalSearch, int maxResults) throws DBException {
    LOG.debug(objectNameMask);
    List<ExasolObjectType> exasolObjectTypes = new ArrayList<>(objectTypes.length);
    for (DBSObjectType dbsObjectType : objectTypes) {
        exasolObjectTypes.add((ExasolObjectType) dbsObjectType);
    }
    ExasolSchema schema = parentObject instanceof ExasolSchema ? (ExasolSchema) parentObject : null;
    try (JDBCSession session = DBUtils.openMetaSession(monitor, dataSource, "Find objects by name")) {
        return searchAllObjects(session, schema, objectNameMask, exasolObjectTypes, caseSensitive, maxResults);
    } catch (SQLException ex) {
        throw new DBException(ex, dataSource);
    }
}
Also used : ExasolObjectType(org.jkiss.dbeaver.ext.exasol.editors.ExasolObjectType) JDBCSession(org.jkiss.dbeaver.model.exec.jdbc.JDBCSession) DBException(org.jkiss.dbeaver.DBException) SQLException(java.sql.SQLException) DBSObjectType(org.jkiss.dbeaver.model.struct.DBSObjectType) ArrayList(java.util.ArrayList) NotNull(org.jkiss.code.NotNull)

Example 4 with ExasolObjectType

use of org.jkiss.dbeaver.ext.exasol.editors.ExasolObjectType in project dbeaver by dbeaver.

the class ExasolStructureAssistant method findObjectsByMask.

@NotNull
@Override
public List<DBSObjectReference> findObjectsByMask(DBRProgressMonitor monitor, DBSObject parentObject, DBSObjectType[] objectTypes, String objectNameMask, boolean caseSensitive, boolean globalSearch, int maxResults) throws DBException {
    LOG.debug(objectNameMask);
    List<ExasolObjectType> exasolObjectTypes = new ArrayList<>(objectTypes.length);
    for (DBSObjectType dbsObjectType : objectTypes) {
        exasolObjectTypes.add((ExasolObjectType) dbsObjectType);
    }
    ExasolSchema schema = parentObject instanceof ExasolSchema ? (ExasolSchema) parentObject : null;
    try (JDBCSession session = DBUtils.openMetaSession(monitor, dataSource, "Find objects by name")) {
        return searchAllObjects(session, schema, objectNameMask, exasolObjectTypes, caseSensitive, maxResults);
    } catch (SQLException ex) {
        throw new DBException(ex, dataSource);
    }
}
Also used : ExasolObjectType(org.jkiss.dbeaver.ext.exasol.editors.ExasolObjectType) JDBCSession(org.jkiss.dbeaver.model.exec.jdbc.JDBCSession) DBException(org.jkiss.dbeaver.DBException) SQLException(java.sql.SQLException) DBSObjectType(org.jkiss.dbeaver.model.struct.DBSObjectType) ArrayList(java.util.ArrayList) NotNull(org.jkiss.code.NotNull)

Aggregations

ExasolObjectType (org.jkiss.dbeaver.ext.exasol.editors.ExasolObjectType)4 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 NotNull (org.jkiss.code.NotNull)2 DBException (org.jkiss.dbeaver.DBException)2 JDBCResultSet (org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet)2 JDBCSession (org.jkiss.dbeaver.model.exec.jdbc.JDBCSession)2 JDBCStatement (org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement)2 DBSObjectType (org.jkiss.dbeaver.model.struct.DBSObjectType)2