use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class BlockCanceler method cancelBlock.
public static void cancelBlock(DBRProgressMonitor monitor, Thread blockActiveThread) throws DBException {
BlockCanceler canceler = null;
if (blockActiveThread != null) {
// Schedule thread interrupt job
canceler = new BlockCanceler(blockActiveThread);
canceler.schedule(INTERRUPT_TIMEOUT);
}
DBRBlockingObject block = monitor.getActiveBlock();
if (block != null) {
final Thread thread = Thread.currentThread();
final String threadOldName = thread.getName();
thread.setName("Operation cancel [" + block + "]");
try {
block.cancelBlock();
if (canceler != null) {
canceler.blockCanceled = true;
}
} catch (Throwable e) {
throw new DBException("Cancel error", e);
} finally {
thread.setName(threadOldName);
}
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class SQLConstraintManager method appendConstraintDefinition.
protected void appendConstraintDefinition(StringBuilder decl, DBECommandAbstract<OBJECT_TYPE> command) {
//$NON-NLS-1$
decl.append(" (");
// Get columns using void monitor
try {
List<? extends DBSEntityAttributeRef> attrs = command.getObject().getAttributeReferences(VoidProgressMonitor.INSTANCE);
if (attrs != null) {
boolean firstColumn = true;
for (DBSEntityAttributeRef constraintColumn : attrs) {
final DBSEntityAttribute attribute = constraintColumn.getAttribute();
if (attribute == null) {
continue;
}
//$NON-NLS-1$
if (!firstColumn)
decl.append(",");
firstColumn = false;
decl.append(DBUtils.getQuotedIdentifier(attribute));
}
}
} catch (DBException e) {
log.warn("Can't obtain attribute references", e);
}
//$NON-NLS-1$
decl.append(")");
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class SQLIndexManager method addObjectCreateActions.
@Override
protected void addObjectCreateActions(List<DBEPersistAction> actions, ObjectCreateCommand command) {
final TABLE_TYPE table = command.getObject().getTable();
final OBJECT_TYPE index = command.getObject();
// Create index
final String indexName = DBUtils.getQuotedIdentifier(index.getDataSource(), index.getName());
index.setName(indexName);
StringBuilder decl = new StringBuilder(40);
decl.append("CREATE ");
if (index.isUnique()) {
decl.append("UNIQUE ");
}
//$NON-NLS-1$
decl.append("INDEX ").append(indexName).append(" ON ").append(//$NON-NLS-1$
table.getFullyQualifiedName(DBPEvaluationContext.DDL)).append(//$NON-NLS-1$
" (");
try {
// Get columns using void monitor
boolean firstColumn = true;
for (DBSTableIndexColumn indexColumn : CommonUtils.safeCollection(command.getObject().getAttributeReferences(VoidProgressMonitor.INSTANCE))) {
//$NON-NLS-1$
if (!firstColumn)
decl.append(",");
firstColumn = false;
decl.append(indexColumn.getName());
appendIndexColumnModifiers(decl, indexColumn);
}
} catch (DBException e) {
log.error(e);
}
//$NON-NLS-1$
decl.append(")");
actions.add(new SQLDatabasePersistAction(ModelMessages.model_jdbc_create_new_index, decl.toString()));
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class DBNProject method rename.
@Override
public void rename(DBRProgressMonitor monitor, String newName) throws DBException {
try {
final IProjectDescription description = getProject().getDescription();
description.setName(newName);
getProject().move(description, true, monitor.getNestedMonitor());
} catch (CoreException e) {
throw new DBException("Can't rename project", e);
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class DBNProject method readChildNodes.
@Override
protected DBNNode[] readChildNodes(DBRProgressMonitor monitor) throws DBException {
IProject project = getProject();
if (!project.isOpen()) {
try {
project.open(monitor.getNestedMonitor());
project.refreshLocal(IFile.DEPTH_ONE, monitor.getNestedMonitor());
} catch (CoreException e) {
throw new DBException("Can't open project '" + project.getName() + "'", e);
}
}
DBPDataSourceRegistry dataSourceRegistry = getModel().getPlatform().getProjectManager().getDataSourceRegistry(project);
DBNNode[] children = super.readChildNodes(monitor);
if (dataSourceRegistry != null) {
children = ArrayUtils.insertArea(DBNNode.class, children, 0, new Object[] { new DBNProjectDatabases(this, dataSourceRegistry) });
}
return children;
}
Aggregations