use of org.jkiss.code.NotNull in project dbeaver by serge-rider.
the class TableToolDialog method getScriptListener.
@Override
protected SQLScriptProgressListener<MySQLTable> getScriptListener() {
return new SQLScriptStatusDialog<MySQLTable>(getShell(), getTitle() + " progress", null) {
@Override
protected void createStatusColumns(Tree objectTree) {
TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
msgColumn.setText("Message");
}
@Override
public void processObjectResults(@NotNull MySQLTable object, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
if (resultSet == null) {
return;
}
Map<String, String> statusMap = new LinkedHashMap<>();
while (resultSet.nextRow()) {
statusMap.put(CommonUtils.toString(resultSet.getAttributeValue("Msg_type")), CommonUtils.toString(resultSet.getAttributeValue("Msg_text")));
}
TreeItem treeItem = getTreeItem(object);
if (treeItem != null && !statusMap.isEmpty()) {
if (statusMap.size() == 1) {
treeItem.setText(1, statusMap.values().iterator().next());
} else {
String statusText = statusMap.get("status");
if (!CommonUtils.isEmpty(statusText)) {
treeItem.setText(1, statusText);
}
for (Map.Entry<String, String> status : statusMap.entrySet()) {
if (!status.getKey().equals("status")) {
TreeItem subItem = new TreeItem(treeItem, SWT.NONE);
subItem.setText(0, status.getKey());
subItem.setText(1, status.getValue());
}
}
treeItem.setExpanded(true);
}
}
}
};
}
use of org.jkiss.code.NotNull in project dbeaver by serge-rider.
the class OracleStructureAssistant method findObjectsByMask.
@NotNull
@Override
public List<DBSObjectReference> findObjectsByMask(DBRProgressMonitor monitor, DBSObject parentObject, DBSObjectType[] objectTypes, String objectNameMask, boolean caseSensitive, boolean globalSearch, int maxResults) throws DBException {
OracleSchema schema = parentObject instanceof OracleSchema ? (OracleSchema) parentObject : null;
try (JDBCSession session = DBUtils.openMetaSession(monitor, dataSource, "Find objects by name")) {
List<DBSObjectReference> objects = new ArrayList<>();
// Search all objects
searchAllObjects(session, schema, objectNameMask, objectTypes, caseSensitive, maxResults, objects);
if (ArrayUtils.contains(objectTypes, OracleObjectType.CONSTRAINT, OracleObjectType.FOREIGN_KEY) && objects.size() < maxResults) {
// Search constraints
findConstraintsByMask(session, schema, objectNameMask, objectTypes, maxResults, objects);
}
// Sort objects. Put ones in the current schema first
final OracleSchema activeSchema = dataSource.getDefaultObject();
Collections.sort(objects, new Comparator<DBSObjectReference>() {
@Override
public int compare(DBSObjectReference o1, DBSObjectReference o2) {
if (CommonUtils.equalObjects(o1.getContainer(), o2.getContainer())) {
return o1.getName().compareTo(o2.getName());
}
if (o1.getContainer() == null || o1.getContainer() == activeSchema) {
return -1;
}
if (o2.getContainer() == null || o2.getContainer() == activeSchema) {
return 1;
}
return o1.getContainer().getName().compareTo(o2.getContainer().getName());
}
});
return objects;
} catch (SQLException ex) {
throw new DBException(ex, dataSource);
}
}
use of org.jkiss.code.NotNull in project dbeaver by serge-rider.
the class DefaultResourceHandlerImpl method makeNavigatorNode.
@NotNull
@Override
public DBNResource makeNavigatorNode(@NotNull DBNNode parentNode, @NotNull IResource resource) throws CoreException, DBException {
DBNResource node = super.makeNavigatorNode(parentNode, resource);
ProgramInfo program = ProgramInfo.getProgram(resource);
if (program != null && program.getImage() != null) {
node.setResourceImage(program.getImage());
}
return node;
}
use of org.jkiss.code.NotNull in project dbeaver by serge-rider.
the class TableToolDialog method getScriptListener.
@Override
protected SQLScriptProgressListener<PostgreObject> getScriptListener() {
return new SQLScriptStatusDialog<PostgreObject>(getShell(), getTitle() + " progress", null) {
@Override
protected void createStatusColumns(Tree objectTree) {
TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
msgColumn.setText("Message");
}
@Override
public void processObjectResults(@NotNull PostgreObject object, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
if (statement == null) {
return;
}
TreeItem treeItem = getTreeItem(object);
if (treeItem != null) {
try {
int warnNum = 0;
SQLWarning warning = ((JDBCStatement) statement).getWarnings();
while (warning != null) {
if (warnNum == 0) {
treeItem.setText(1, warning.getMessage());
} else {
TreeItem warnItem = new TreeItem(treeItem, SWT.NONE);
warnItem.setText(0, "");
warnItem.setText(1, warning.getMessage());
}
warnNum++;
warning = warning.getNextWarning();
}
if (warnNum == 0) {
treeItem.setText(1, "Done");
}
} catch (SQLException e) {
// ignore
}
treeItem.setExpanded(true);
}
}
@Override
public void endObjectProcessing(@NotNull PostgreObject object, Exception error) {
super.endObjectProcessing(object, error);
if (error != null) {
TreeItem treeItem = getTreeItem(object);
if (treeItem != null) {
treeItem.setText(1, error.getMessage());
}
}
}
};
}
use of org.jkiss.code.NotNull in project dbeaver by serge-rider.
the class WMIClass method readData.
@NotNull
@Override
public DBCStatistics readData(@NotNull DBCExecutionSource source, @NotNull DBCSession session, @NotNull DBDDataReceiver dataReceiver, DBDDataFilter dataFilter, long firstRow, long maxRows, long flags) throws DBCException {
DBCStatistics statistics = new DBCStatistics();
try {
long startTime = System.currentTimeMillis();
WMIObjectCollectorSink sink = new WMIObjectCollectorSink(session.getProgressMonitor(), getNamespace().getService(), firstRow, maxRows);
getNamespace().getService().enumInstances(getName(), sink, WMIConstants.WBEM_FLAG_SHALLOW);
statistics.setExecuteTime(System.currentTimeMillis() - startTime);
startTime = System.currentTimeMillis();
sink.waitForFinish();
WMIResultSet resultSet = new WMIResultSet(session, this, sink.getObjectList());
long resultCount = 0;
try {
dataReceiver.fetchStart(session, resultSet, firstRow, maxRows);
while (resultSet.nextRow()) {
resultCount++;
dataReceiver.fetchRow(session, resultSet);
}
} finally {
try {
dataReceiver.fetchEnd(session, resultSet);
} catch (DBCException e) {
//$NON-NLS-1$
log.error("Error while finishing result set fetch", e);
}
resultSet.close();
dataReceiver.close();
}
statistics.setFetchTime(System.currentTimeMillis() - startTime);
statistics.setRowsFetched(resultCount);
return statistics;
} catch (WMIException e) {
throw new DBCException(e, getDataSource());
}
}
Aggregations