示例#1
0
  private Set<ModelElement> query_AllModelElements(Package pkg) {

    Set<ModelElement> modelElements = new HashSet<ModelElement>();
    modelElements.addAll(pkg.getOwnedElement());
    for (Package subPackage : pkg.getImporter()) {
      modelElements.addAll(query_AllModelElements(subPackage));
    }
    return modelElements;
  }
 /**
  * Method "getSchemaNames".
  *
  * @return the schema names concatenated or the empty string (never null)
  */
 public String getSchemaNames() {
   String str = PluginConstant.EMPTY_STRING;
   for (ColumnSet columnSet : getColumnSets()) {
     Package schema = ColumnSetHelper.getParentCatalogOrSchema(columnSet);
     if (schema != null && RelationalPackage.eINSTANCE.getSchema().equals(schema.eClass())) {
       str = str + schema.getName() + " "; // $NON-NLS-1$
     }
   }
   return str;
 }
 /**
  * Method "getCatalogNames".
  *
  * @return the catalog names concatenated or the empty string (never null)
  */
 public String getCatalogNames() {
   String str = PluginConstant.EMPTY_STRING;
   for (ColumnSet columnSet : getColumnSets()) {
     Package schema = ColumnSetHelper.getParentCatalogOrSchema(columnSet);
     if (schema == null) {
       continue;
     }
     if (RelationalPackage.eINSTANCE.getCatalog().equals(schema.eClass())) {
       str = str + schema.getName() + " "; // $NON-NLS-1$
     } else {
       Package catalog = ColumnSetHelper.getParentCatalogOrSchema(schema);
       if (catalog != null) {
         str = str + catalog.getName() + " "; // $NON-NLS-1$
       }
     }
   }
   return str;
 }
示例#4
0
  /**
   * DOC sgandon Comment method "getPackageDataProvider".
   *
   * @param result
   * @param thePackage
   * @return
   */
  private static Connection getFirstPackageConnection(Package thePackage) {
    assert thePackage != null;
    Connection connection = null;
    // check that package does not belong to another package
    Namespace parentNS = thePackage.getNamespace();
    if (parentNS != null) {
      Package parentPackage = SwitchHelpers.PACKAGE_SWITCH.doSwitch(thePackage.getNamespace());
      if (parentPackage != null) {
        connection = getFirstPackageConnection(parentPackage);
      } // else class is not linked to any package so get it's Connection
    }
    if (connection == null) {
      for (DataManager dm : thePackage.getDataManager()) {
        Connection conn = SwitchHelpers.CONNECTION_SWITCH.doSwitch(dm);
        if (conn != null) {
          connection = conn;
          break;
        } // else keep going
      }
    } // else connection as been found in recurstive call

    return connection;
  }
 /* method is used to remove table from database */
 public static void removeTables(
     String tableLabel,
     orgomg.cwm.objectmodel.core.Package subpack,
     DatabaseConnection connection) {
   if (subpack == null) {
     for (orgomg.cwm.objectmodel.core.Package pk : connection.getDataPackage()) {
       Iterator<ModelElement> iterator = pk.getOwnedElement().iterator();
       while (iterator.hasNext()) {
         Object o = iterator.next();
         if (o instanceof MetadataTable) {
           MetadataTable table = (MetadataTable) o;
           if (table.getLabel() != null && table.getLabel().equals(tableLabel)) {
             iterator.remove();
             break;
           }
         }
         if (o instanceof orgomg.cwm.objectmodel.core.Package) {
           subpack = (orgomg.cwm.objectmodel.core.Package) o;
           removeTables(tableLabel, subpack, connection);
         }
       }
     }
   } else {
     Iterator<ModelElement> iterator = subpack.getOwnedElement().iterator();
     while (iterator.hasNext()) {
       Object o = iterator.next();
       if (o instanceof MetadataTable) {
         MetadataTable table = (MetadataTable) o;
         if (table.getLabel() != null && table.getLabel().equals(tableLabel)) {
           iterator.remove();
           break;
         }
       }
     }
   }
 }