Ejemplo n.º 1
0
 @Override
 public DBSObjectState getObjectState() {
   if (this == dataSource.getDefaultInstance()) {
     return DBSObjectState.NORMAL;
   } else {
     return PostgreConstants.STATE_UNAVAILABLE;
   }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 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;
  }
Ejemplo n.º 6
0
 @Override
 public boolean refreshDefaultObject(@NotNull DBCSession session) throws DBException {
   return dataSource.refreshDefaultObject(session);
 }
Ejemplo n.º 7
0
 @Nullable
 @Override
 public PostgreSchema getDefaultObject() {
   return schemaCache.getCachedObject(dataSource.getActiveSchemaName());
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 9
0
 @NotNull
 @Override
 public DBCExecutionContext openIsolatedContext(
     @NotNull DBRProgressMonitor monitor, @NotNull String purpose) throws DBException {
   return dataSource.openIsolatedContext(monitor, purpose);
 }
Ejemplo n.º 10
0
 @NotNull
 @Override
 public DBCExecutionContext[] getAllContexts() {
   return dataSource.getAllContexts();
 }
Ejemplo n.º 11
0
 @NotNull
 @Override
 public DBCExecutionContext getDefaultContext(boolean meta) {
   return dataSource.getDefaultContext(meta);
 }
Ejemplo n.º 12
0
 @Override
 public DBSObject getParentObject() {
   return dataSource.getContainer();
 }