private static void collectTables(
     DBRProgressMonitor monitor, DBSObjectContainer container, Set<DBSEntity> tables)
     throws DBException {
   if (monitor.isCanceled()) {
     return;
   }
   container.cacheStructure(monitor, DBSObjectContainer.STRUCT_ALL);
   final Collection<? extends DBSObject> children = container.getChildren(monitor);
   if (!CommonUtils.isEmpty(children)) {
     Class<? extends DBSObject> childType = container.getChildType(monitor);
     DBSObjectFilter objectFilter =
         container.getDataSource().getContainer().getObjectFilter(childType, container, true);
     for (DBSObject entity : children) {
       if (monitor.isCanceled()) {
         break;
       }
       if (objectFilter != null && !objectFilter.matches(entity.getName())) {
         continue;
       }
       if (entity instanceof DBSEntity) {
         tables.add((DBSEntity) entity);
       } else if (entity instanceof DBSObjectContainer) {
         collectTables(monitor, (DBSObjectContainer) entity, tables);
       }
     }
   }
 }
Example #2
0
 @Override
 public String getNodeName() {
   DBSObject object = getObject();
   if (object == null) {
     return DBConstants.NULL_VALUE_LABEL;
   }
   String objectName;
   if (object instanceof DBPOverloadedObject) {
     objectName = ((DBPOverloadedObject) object).getOverloadedName();
   } else {
     objectName = object.getName();
   }
   if (CommonUtils.isEmpty(objectName)) {
     objectName = object.toString();
     if (CommonUtils.isEmpty(objectName)) {
       objectName = object.getClass().getName() + "@" + object.hashCode(); // $NON-NLS-1$
     }
   }
   /*
           if (object instanceof DBSObjectUnique) {
               String uniqueName = ((DBSObjectUnique) object).getUniqueName();
               if (!uniqueName.equals(objectName)) {
                   if (uniqueName.startsWith(objectName)) {
                       uniqueName = uniqueName.substring(objectName.length());
                   }
                   objectName += " (" + uniqueName + ")";
               }
           }
   */
   return objectName;
 }
Example #3
0
 private static boolean equalObjects(DBSObject object1, DBSObject object2) {
   if (object1 == object2) {
     return true;
   }
   if (object1 == null || object2 == null) {
     return false;
   }
   while (object1 != null && object2 != null) {
     if (object1.getClass() != object2.getClass()
         || !CommonUtils.equalObjects(
             DBUtils.getObjectUniqueName(object1), DBUtils.getObjectUniqueName(object2))) {
       return false;
     }
     object1 = object1.getParentObject();
     object2 = object2.getParentObject();
   }
   return true;
 }
Example #4
0
  @Override
  public void setDefaultObject(@NotNull DBRProgressMonitor monitor, @NotNull DBSObject object)
      throws DBException {
    if (object instanceof PostgreSchema) {
      PostgreSchema oldActive = getDefaultObject();
      if (oldActive == object) {
        return;
      }

      for (JDBCExecutionContext context : dataSource.getAllContexts()) {
        setSearchPath(monitor, (PostgreSchema) object, context);
      }
      dataSource.setActiveSchemaName(object.getName());
      dataSource.setSearchPath(object.getName());

      if (oldActive != null) {
        DBUtils.fireObjectSelect(oldActive, false);
      }
      DBUtils.fireObjectSelect(object, true);
    }
  }
Example #5
0
 public DBPDataSource getDataSource() {
   DBSObject object = getObject();
   return object == null ? null : object.getDataSource();
 }