示例#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 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;
         }
       }
     }
   }
 }