use of org.jkiss.dbeaver.model.sql.SQLHelpTopic in project dbeaver by serge-rider.
the class SQLContextInformer method readDataSourceHelp.
private static String readDataSourceHelp(DBRProgressMonitor monitor, DBPDataSource dataSource, DBPKeywordType keywordType, String keyword) {
final SQLHelpProvider helpProvider = DBUtils.getAdapter(SQLHelpProvider.class, dataSource);
if (helpProvider == null) {
return null;
}
final SQLHelpTopic helpTopic = helpProvider.findHelpTopic(monitor, keyword, keywordType);
if (helpTopic == null) {
return null;
}
if (!CommonUtils.isEmpty(helpTopic.getContents())) {
return helpTopic.getContents();
} else if (!CommonUtils.isEmpty(helpTopic.getUrl())) {
return "<a href=\"" + helpTopic.getUrl() + "\">" + keyword + "</a>";
} else {
return null;
}
}
use of org.jkiss.dbeaver.model.sql.SQLHelpTopic in project dbeaver by serge-rider.
the class MySQLHelpProvider method loadTopics.
private void loadTopics(DBRProgressMonitor monitor) {
try (final JDBCSession session = DBUtils.openMetaSession(monitor, dataSource, "Read MySQL help topicc")) {
try (JDBCPreparedStatement dbStat = session.prepareStatement("SELECT name, description, example, url FROM mysql.help_topic")) {
try (JDBCResultSet dbResult = dbStat.executeQuery()) {
while (dbResult.next()) {
String topicName = dbResult.getString(1);
SQLHelpTopic helpTopic = new SQLHelpTopic();
helpTopic.setContents("<pre>" + dbResult.getString(2) + "</pre>");
helpTopic.setExample(dbResult.getString(3));
helpTopic.setUrl(dbResult.getString(4));
if (topicName != null) {
synchronized (topicCache) {
topicCache.put(topicName.toUpperCase(Locale.ENGLISH), helpTopic);
}
}
}
}
} catch (SQLException e) {
log.error("Error reading help topics", e);
}
} finally {
isLoaded = true;
}
}
Aggregations