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;
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class DBNResource method refreshNode.
@Override
public DBNNode refreshNode(DBRProgressMonitor monitor, Object source) throws DBException {
try {
resource.refreshLocal(IResource.DEPTH_INFINITE, monitor.getNestedMonitor());
// FIXME: The only workaround is to check real file and drop resource by force
if (!resource.getLocation().toFile().exists()) {
log.warn("Resource '" + resource.getName() + "' doesn't exists on file system: deleted in workspace");
resource.delete(true, monitor.getNestedMonitor());
}
} catch (CoreException e) {
throw new DBException("Can't refresh resource", e);
}
return this;
}
Aggregations