Exemple #1
0
  public TableMetadata crossMetadata(TableMetadata pMetadata, TableMetadata pAnotherMetadata) {
    // New Primary Key Is The Primary Key Of The First Metadata
    TableAttribute newPK =
        new TableAttribute(
            pMetadata.getTableName() + "." + pMetadata.getPrimaryKey().getName(),
            pMetadata.getPrimaryKey().getType());

    // Create Simple Info About The New METADATA Created
    TableMetadata newMetadata =
        new TableMetadata(pMetadata.getTableName() + "." + pAnotherMetadata.getTableName(), newPK);

    // Iterators for TableMetadata's
    Iterator<TableAttribute> iteratorMeta = pMetadata.getTableColumns().iterator();

    // Temporal for adding from the used METADATA's
    TableAttribute tmpViewAttribute = null;

    // Get The METADATA complete information of each attribute
    // TableName.AttributeName
    while (iteratorMeta.hasNext()) {
      tmpViewAttribute = iteratorMeta.next();
      newMetadata
          .getTableColumns()
          .add(
              new TableAttribute(
                  pMetadata.getTableName() + "." + tmpViewAttribute.getName(),
                  tmpViewAttribute.getType()));
    }
    Iterator<TableAttribute> iteratorAnotherMeta = pAnotherMetadata.getTableColumns().iterator();

    while (iteratorAnotherMeta.hasNext()) {
      tmpViewAttribute = iteratorAnotherMeta.next();
      newMetadata
          .getTableColumns()
          .add(
              new TableAttribute(
                  pAnotherMetadata.getTableName() + "." + tmpViewAttribute.getName(),
                  tmpViewAttribute.getType()));
    }
    System.out.print("La puta madre... llegue aquí");
    return (newMetadata);
  }