コード例 #1
0
  private Properties getModelConnectionProperties(ModelResource mr) {

    try {
      if (ModelIdentifier.isRelationalSourceModel(mr)) {
        IConnectionInfoProvider provider = null;

        try {
          provider = getProvider(mr);
        } catch (Exception e) {
          // If provider throws exception its OK because some models may not have connection info.
        }

        if (provider != null) {
          Properties properties = provider.getProfileProperties(mr); // ConnectionProperties(mr);
          Properties p2 = provider.getConnectionProperties(mr);
          String translatorName = provider.getTranslatorName(mr);
          for (Object key : p2.keySet()) {
            properties.put(key, p2.get(key));
          }
          if (translatorName != null) {
            properties.put(getString("translatorKey"), translatorName); // $NON-NLS-1$
          }
          if (properties != null && !properties.isEmpty()) {
            return properties;
          }
        }
      }
    } catch (CoreException e) {
      DatatoolsUiConstants.UTIL.log(e);
    }

    return null;
  }
コード例 #2
0
  private Collection<ModelResource> getRelationalModelsWithConnections() {
    Collection<ModelResource> result = new ArrayList<ModelResource>();

    try {
      ModelResource[] mrs =
          ModelWorkspaceManager.getModelWorkspaceManager().getModelWorkspace().getModelResources();
      for (ModelResource mr : mrs) {
        if (ModelIdentifier.isRelationalSourceModel(mr)) {
          IConnectionInfoProvider provider = null;

          try {
            provider = getProvider(mr);
          } catch (Exception e) {
            // If provider throws exception its OK because some models may not have connection info.
          }

          if (provider != null) {
            Properties properties = provider.getConnectionProperties(mr);
            if (properties != null && !properties.isEmpty()) {
              result.add(mr);
            }
          }
        }
      }

    } catch (CoreException e) {
      DqpUiConstants.UTIL.log(e);
    }

    return result;
  }