use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by serge-rider.
the class DBNModel method getNodeByObject.
@Nullable
public DBNDatabaseNode getNodeByObject(DBRProgressMonitor monitor, DBSObject object, boolean addFiltered) {
DBNDatabaseNode node = getNodeByObject(object);
if (node != null) {
return node;
}
DBSObject[] path = DBUtils.getObjectPath(object, true);
for (int i = 0; i < path.length - 1; i++) {
DBSObject item = path[i];
DBSObject nextItem = path[i + 1];
node = getNodeByObject(item);
if (node == null) {
return null;
}
try {
cacheNodeChildren(monitor, node, nextItem, addFiltered);
} catch (DBException e) {
log.error(e.getMessage());
return null;
}
}
return getNodeByObject(object);
}
use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by serge-rider.
the class DBVModel method findEntity.
/**
* Search for virtual entity descriptor
*
* @param entity entity
* @param createNew create new entity if missing
* @return entity virtual entity
*/
public DBVEntity findEntity(DBSEntity entity, boolean createNew) {
DBSObject[] path = DBUtils.getObjectPath(entity, false);
if (path.length == 0) {
log.warn("Empty entity path");
return null;
}
if (path[0] != dataSourceContainer) {
log.warn("Entity's root must be datasource container '" + dataSourceContainer.getName() + "'");
return null;
}
DBVContainer container = this;
for (int i = 1; i < path.length; i++) {
DBSObject item = path[i];
container = container.getContainer(item.getName(), createNew);
if (container == null) {
return null;
}
}
return container.getEntity(entity.getName(), createNew);
}
use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by serge-rider.
the class SQLStructEditor method createObjectReferences.
protected void createObjectReferences(DBRProgressMonitor monitor, DBECommandContext commandContext, ObjectCreateCommand createCommand) throws DBException {
OBJECT_TYPE object = createCommand.getObject();
final DBERegistry editorsRegistry = object.getDataSource().getContainer().getPlatform().getEditorsRegistry();
for (Class childType : getChildTypes()) {
Collection<? extends DBSObject> children = getChildObjects(monitor, object, childType);
if (!CommonUtils.isEmpty(children)) {
SQLObjectEditor<DBSObject, CONTAINER_TYPE> nestedEditor = getObjectEditor(editorsRegistry, childType);
if (nestedEditor != null) {
for (DBSObject child : children) {
ObjectCreateCommand childCreateCommand = (ObjectCreateCommand) nestedEditor.makeCreateCommand(child);
//((StructCreateCommand)createCommand).aggregateCommand(childCreateCommand);
commandContext.addCommand(childCreateCommand, null, false);
}
}
}
}
}
Aggregations