Ejemplo n.º 1
0
  private com.relteq.sirius.jaxb.Table restoreTable(Tables db_table) throws TorqueException {
    com.relteq.sirius.jaxb.Table table = factory.createTable();
    table.setName(db_table.getName());

    Criteria crit = new Criteria();
    crit.addAscendingOrderByColumn(TabularDataKeysPeer.COLUMN_NUMBER);
    @SuppressWarnings("unchecked")
    List<TabularDataKeys> db_tdk_l = db_table.getTabularDataKeyss(crit);
    com.relteq.sirius.jaxb.ColumnNames colnames = factory.createColumnNames();
    for (TabularDataKeys db_tdk : db_tdk_l) colnames.getColumnName().add(restoreColumnName(db_tdk));
    table.setColumnNames(colnames);

    crit.clear();
    crit.addJoin(TabularDataPeer.TABLE_ID, TabularDataKeysPeer.TABLE_ID);
    crit.addJoin(TabularDataPeer.COLUMN_NAME, TabularDataKeysPeer.COLUMN_NAME);
    crit.addAscendingOrderByColumn(TabularDataPeer.ROW_NUMBER);
    crit.addAscendingOrderByColumn(TabularDataKeysPeer.COLUMN_NUMBER);
    @SuppressWarnings("unchecked")
    List<TabularData> db_td_l = db_table.getTabularDatas(crit);
    com.relteq.sirius.jaxb.Row row = null;
    Integer rownum = null;
    java.util.Iterator<com.relteq.sirius.jaxb.ColumnName> citer = null;
    for (TabularData db_td : db_td_l) {
      if (null != rownum && !rownum.equals(db_td.getRowNumber())) {
        table.getRow().add(row);
        row = null;
      }
      if (null == row) {
        row = factory.createRow();
        citer = colnames.getColumnName().iterator();
      }
      while (citer.hasNext()) {
        com.relteq.sirius.jaxb.ColumnName colname = citer.next();
        if (colname.getValue().equals(db_td.getColumnName())) {
          row.getColumn().add(db_td.getValue());
          break;
        } else {
          row.getColumn().add(null);
          logger.warn(
              "Column "
                  + colname.getValue()
                  + " skipped (table="
                  + db_td.getId()
                  + ", row="
                  + db_td.getRowNumber()
                  + ")");
        }
      }
    }
    if (null != row) table.getRow().add(row);

    return table;
  }