示例#1
0
  @Override
  public ResultSet apply(ResultSet pResultSet) {
    TableMetadata tableMetadata = pResultSet.getTableMetadata();

    LinkedList<String> tmp = new LinkedList<String>();

    for (int x = 0; x < tableMetadata.getTableColumns().size(); x++) {
      tmp.add("null");
    }

    LinkedList<Integer> colIndex = new LinkedList<>();
    LinkedList<Integer> colNull = new LinkedList<>();

    Iterator<String> i = this._Columns.iterator();

    String col;

    while (i.hasNext()) {
      col = i.next();
      int indexOfColumn = tableMetadata.indexByName(col);
      System.out.println(indexOfColumn);
      colIndex.add(indexOfColumn);
    }

    for (int c = 0; c < tableMetadata.getTableColumns().size(); c++) {
      System.out.println("concha");
      if (!colIndex.contains(c)) {
        System.out.println("culo");
        colNull.add(c);
      }
    }

    for (int j = 0; j < this._Values.size(); j++) {
      System.out.println("pene");
      tmp.set(colIndex.get(j), this._Values.get(j));
    }

    for (int k = 0; k < colNull.size(); k++) {
      System.out.println("astro");
      tmp.set(colNull.get(k), "null");
    }
    TableRegister tr = new TableRegister(tmp);
    LinkedList<TableRegister> list = new LinkedList<TableRegister>();
    list.add(tr);
    TableData t = new TableData(list);

    return (new ResultSet(t, tableMetadata));
  }
示例#2
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);
  }