/**
   * Process
   *
   * @return info
   * @throws Exception
   */
  protected String doIt() throws Exception {
    if (p_target_AD_Table_ID == 0)
      throw new AdempiereSystemError("@NotFound@ @AD_Table_ID@ " + p_target_AD_Table_ID);
    if (p_source_AD_Table_ID == 0)
      throw new AdempiereSystemError("@NotFound@ @AD_Table_ID@ " + p_source_AD_Table_ID);
    if (log.isLoggable(Level.INFO))
      log.info(
          "Source AD_Table_ID="
              + p_source_AD_Table_ID
              + ", Target AD_Table_ID="
              + p_target_AD_Table_ID);

    MTable targetTable = new MTable(getCtx(), p_target_AD_Table_ID, get_TrxName());
    MColumn[] targetColumns = targetTable.getColumns(true);
    if (targetColumns.length > 0)
      // TODO: dictionary message
      throw new AdempiereSystemError("Target table must not have columns");

    MTable sourceTable = new MTable(getCtx(), p_source_AD_Table_ID, get_TrxName());
    MColumn[] sourceColumns = sourceTable.getColumns(true);

    for (int i = 0; i < sourceColumns.length; i++) {
      MColumn colTarget = new MColumn(targetTable);
      PO.copyValues(sourceColumns[i], colTarget);
      colTarget.setAD_Table_ID(targetTable.getAD_Table_ID());
      colTarget.setEntityType(targetTable.getEntityType());
      // special case the key -> sourceTable_ID
      if (sourceColumns[i].getColumnName().equals(sourceTable.getTableName() + "_ID")) {
        String targetColumnName = new String(targetTable.getTableName() + "_ID");
        colTarget.setColumnName(targetColumnName);
        // if the element doesn't exist, create it
        M_Element element = M_Element.get(getCtx(), targetColumnName);
        if (element == null) {
          element =
              new M_Element(getCtx(), targetColumnName, targetTable.getEntityType(), get_TrxName());
          if (targetColumnName.equalsIgnoreCase(targetTable.getTableName() + "_ID")) {
            element.setColumnName(targetTable.getTableName() + "_ID");
            element.setName(targetTable.getName());
            element.setPrintName(targetTable.getName());
          }
          element.saveEx(get_TrxName());
        }
        colTarget.setAD_Element_ID(element.getAD_Element_ID());
        colTarget.setName(targetTable.getName());
        colTarget.setDescription(targetTable.getDescription());
        colTarget.setHelp(targetTable.getHelp());
      }
      // special case the UUID column -> sourceTable_UU
      if (sourceColumns[i].getColumnName().equals(sourceTable.getTableName() + "_UU")) {
        String targetColumnName = new String(targetTable.getTableName() + "_UU");
        colTarget.setColumnName(targetColumnName);
        // if the element doesn't exist, create it
        M_Element element = M_Element.get(getCtx(), targetColumnName);
        if (element == null) {
          element =
              new M_Element(getCtx(), targetColumnName, targetTable.getEntityType(), get_TrxName());
          if (targetColumnName.equalsIgnoreCase(targetTable.getTableName() + "_UU")) {
            element.setColumnName(targetTable.getTableName() + "_UU");
            element.setName(targetTable.getTableName() + "_UU");
            element.setPrintName(targetTable.getTableName() + "_UU");
          }
          element.saveEx(get_TrxName());
        }
        colTarget.setAD_Element_ID(element.getAD_Element_ID());
        colTarget.setName(targetTable.getName());
        colTarget.setDescription(targetTable.getDescription());
        colTarget.setHelp(targetTable.getHelp());
      }
      colTarget.setIsActive(sourceColumns[i].isActive());
      colTarget.saveEx(get_TrxName());
      // TODO: Copy translations
      m_count++;
    }

    //
    return "#" + m_count;
  } //	doIt
  public static String getReferenceClassName(
      int AD_Table_ID, String columnName, int displayType, int AD_Reference_ID) {
    String referenceClassName = null;
    //
    if (displayType == DisplayType.TableDir
        || (displayType == DisplayType.Search && AD_Reference_ID == 0)) {
      String refTableName =
          MQuery.getZoomTableName(
              columnName); // teo_sarca: BF [ 1817768 ] Isolate hardcoded table direct columns
      referenceClassName = "I_" + refTableName;

      MTable table = MTable.get(Env.getCtx(), refTableName);
      if (table != null) {
        String entityType = table.getEntityType();
        String modelpackage = getModelPackage(entityType);
        if (modelpackage != null) {
          referenceClassName = modelpackage + "." + referenceClassName;
        }
        if (!isGenerateModelGetterForEntity(AD_Table_ID, entityType)) {
          referenceClassName = null;
        }
      } else {
        throw new RuntimeException("No table found for " + refTableName);
      }
    } else if (displayType == DisplayType.Table
        || (displayType == DisplayType.Search && AD_Reference_ID > 0)) {
      // TODO: HARDCODED: do not generate model getter for Fact_Acct.Account_ID
      if (AD_Table_ID == 270 && columnName.equals("Account_ID")) return null;
      // TODO: HARDCODED: do not generate model getter for GL_DistributionLine.Account_ID
      if (AD_Table_ID == 707 && columnName.equals("Account_ID")) return null;
      //
      final String sql =
          "SELECT t.TableName, t.EntityType, ck.AD_Reference_ID"
              + " FROM AD_Ref_Table rt"
              + " INNER JOIN AD_Table t ON (t.AD_Table_ID=rt.AD_Table_ID)"
              + " INNER JOIN AD_Column ck ON (ck.AD_Table_ID=rt.AD_Table_ID AND ck.AD_Column_ID=rt.AD_Key)"
              + " WHERE rt.AD_Reference_ID=?";
      PreparedStatement pstmt = null;
      ResultSet rs = null;
      try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, AD_Reference_ID);
        rs = pstmt.executeQuery();
        if (rs.next()) {
          final String refTableName = rs.getString(1);
          final String entityType = rs.getString(2);
          final int refDisplayType = rs.getInt(3);
          if (refDisplayType == DisplayType.ID) {
            referenceClassName = "I_" + refTableName;
            String modelpackage = getModelPackage(entityType);
            if (modelpackage != null) {
              referenceClassName = modelpackage + "." + referenceClassName;
            }
            if (!isGenerateModelGetterForEntity(AD_Table_ID, entityType)) {
              referenceClassName = null;
            }
          }
        }
      } catch (SQLException e) {
        throw new DBException(e, sql);
      } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
      }
    } else if (displayType == DisplayType.Location) {
      referenceClassName = "I_C_Location";
    } else if (displayType == DisplayType.Locator) {
      referenceClassName = "I_M_Locator";
    } else if (displayType == DisplayType.Account) {
      referenceClassName = "I_C_ValidCombination";
    } else if (displayType == DisplayType.PAttribute) {
      referenceClassName = "I_M_AttributeSetInstance";
    } else {
      // TODO - Handle other types
      // sb.append("\tpublic I_"+columnName+" getI_").append(columnName).append("(){return null;
      // };");
    }
    //
    return referenceClassName;
  }