コード例 #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();
 }