예제 #1
0
  static void resolveTables(
      DBRProgressMonitor monitor,
      DBCExecutionContext executionContext,
      TemplateContext context,
      List<DBSEntity> entities)
      throws DBException {
    TemplateVariable schemaVariable =
        ((SQLContext) context).getTemplateVariable(SQLContainerResolver.VAR_NAME_SCHEMA);
    TemplateVariable catalogVariable =
        ((SQLContext) context).getTemplateVariable(SQLContainerResolver.VAR_NAME_CATALOG);

    String catalogName = catalogVariable == null ? null : catalogVariable.getDefaultValue();
    String schemaName = schemaVariable == null ? null : schemaVariable.getDefaultValue();
    DBSObjectContainer objectContainer =
        DBUtils.getAdapter(DBSObjectContainer.class, executionContext.getDataSource());
    if (objectContainer == null) {
      return;
    }
    if (!CommonUtils.isEmpty(catalogName) || !CommonUtils.isEmpty(schemaName)) {
      // Find container for specified schema/catalog
      objectContainer =
          (DBSObjectContainer)
              DBUtils.getObjectByPath(monitor, objectContainer, catalogName, schemaName, null);
    } else {
      DBSObjectSelector objectSelector =
          DBUtils.getAdapter(DBSObjectSelector.class, executionContext.getDataSource());
      if (objectSelector != null) {
        objectContainer =
            DBUtils.getAdapter(DBSObjectContainer.class, objectSelector.getSelectedObject());
      }
    }
    if (objectContainer != null) {
      makeProposalsFromChildren(monitor, objectContainer, entities);
    }
  }
예제 #2
0
 @Nullable
 private static DBSObject getSelectedObject(DBPDataSource dataSource) {
   DBSObjectSelector objectSelector = DBUtils.getAdapter(DBSObjectSelector.class, dataSource);
   if (objectSelector != null) {
     return objectSelector.getSelectedObject();
   }
   return null;
 }