예제 #1
0
 @Override
 public DBSObjectState getObjectState() {
   if (this == dataSource.getDefaultInstance()) {
     return DBSObjectState.NORMAL;
   } else {
     return PostgreConstants.STATE_UNAVAILABLE;
   }
 }
예제 #2
0
 @Association
 public Collection<PostgreSchema> getSchemas(DBRProgressMonitor monitor) throws DBException {
   if (this != dataSource.getDefaultInstance()) {
     throw new DBException("Can't access non-default database");
   }
   // Get all schemas
   return schemaCache.getAllObjects(monitor, this);
 }
예제 #3
0
 public PostgreSchema getSchema(DBRProgressMonitor monitor, long oid) throws DBException {
   if (this != dataSource.getDefaultInstance()) {
     throw new DBException("Can't access non-default database");
   }
   for (PostgreSchema schema : schemaCache.getAllObjects(monitor, this)) {
     if (schema.getObjectId() == oid) {
       return schema;
     }
   }
   return null;
 }
예제 #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);
    }
  }
예제 #5
0
  public PostgreDataType getDataType(String typeName) {
    if (typeName.endsWith("[]")) {
      // In some cases ResultSetMetadata returns it as []
      typeName = "_" + typeName.substring(0, typeName.length() - 2);
    }
    String alias = PostgreConstants.DATA_TYPE_ALIASES.get(typeName);
    if (alias != null) {
      typeName = alias;
    }
    {
      // First check system catalog
      final PostgreSchema schema = getCatalogSchema();
      if (schema != null) {
        final PostgreDataType dataType = schema.dataTypeCache.getCachedObject(typeName);
        if (dataType != null) {
          return dataType;
        }
      }
    }

    // Check schemas in search path
    final List<String> searchPath = dataSource.getSearchPath();
    for (String schemaName : searchPath) {
      final PostgreSchema schema = schemaCache.getCachedObject(schemaName);
      if (schema != null) {
        final PostgreDataType dataType = schema.dataTypeCache.getCachedObject(typeName);
        if (dataType != null) {
          return dataType;
        }
      }
    }
    // Check the rest
    for (PostgreSchema schema : schemaCache.getCachedObjects()) {
      if (searchPath.contains(schema.getName())) {
        continue;
      }
      final PostgreDataType dataType = schema.dataTypeCache.getCachedObject(typeName);
      if (dataType != null) {
        return dataType;
      }
    }
    log.debug("Data type '" + typeName + "' not found in database '" + getName() + "'");
    return null;
  }
예제 #6
0
 @Override
 public boolean refreshDefaultObject(@NotNull DBCSession session) throws DBException {
   return dataSource.refreshDefaultObject(session);
 }
예제 #7
0
 @Nullable
 @Override
 public PostgreSchema getDefaultObject() {
   return schemaCache.getCachedObject(dataSource.getActiveSchemaName());
 }
예제 #8
0
 public PostgreSchema getSchema(DBRProgressMonitor monitor, String name) throws DBException {
   if (this != dataSource.getDefaultInstance()) {
     throw new DBException("Can't access non-default database");
   }
   return schemaCache.getObject(monitor, this, name);
 }
예제 #9
0
 @NotNull
 @Override
 public DBCExecutionContext openIsolatedContext(
     @NotNull DBRProgressMonitor monitor, @NotNull String purpose) throws DBException {
   return dataSource.openIsolatedContext(monitor, purpose);
 }
예제 #10
0
 @NotNull
 @Override
 public DBCExecutionContext[] getAllContexts() {
   return dataSource.getAllContexts();
 }
예제 #11
0
 @NotNull
 @Override
 public DBCExecutionContext getDefaultContext(boolean meta) {
   return dataSource.getDefaultContext(meta);
 }
예제 #12
0
 @Override
 public DBSObject getParentObject() {
   return dataSource.getContainer();
 }