コード例 #1
0
  public static Map<String, Integer> getForeignKeysInformation(TdTable table) {
    Map<String, Integer> info = new HashMap<String, Integer>();

    for (ForeignKey foreign : getForeignKeys(table)) {
      info.put(foreign.getName(), foreign.getFeature().size());
    }
    return info;
  }
コード例 #2
0
 /**
  * Method "addForeignKey".
  *
  * @param table
  * @param foreignKey the foreign key of the given table
  */
 public static ForeignKey addForeignKey(TdTable table, ForeignKey foreignKey) {
   assert table != null;
   assert foreignKey != null;
   List<ForeignKey> foreignKeyList = getForeignKeys(table);
   String newForeignKeyName = foreignKey.getName();
   for (ForeignKey theForeignKey : foreignKeyList) {
     if (theForeignKey.getName().equals(newForeignKeyName)) {
       theForeignKey.getFeature().addAll(foreignKey.getFeature());
       StructuralFeature[] structuralFeaturethe =
           theForeignKey
               .getFeature()
               .toArray(new StructuralFeature[theForeignKey.getFeature().size()]);
       for (StructuralFeature foreignKeyColumn : structuralFeaturethe) {
         TdColumn theColumn = (TdColumn) (foreignKeyColumn);
         theColumn.getKeyRelationship().remove(foreignKey);
         theColumn.getKeyRelationship().add(theForeignKey);
       }
       return theForeignKey;
     }
   }
   table.getOwnedElement().add(foreignKey);
   return foreignKey;
 }