Example #1
0
 /**
  * Execute Drill to Query
  *
  * @param query query
  */
 private void executeDrill(MQuery query) {
   int AD_Table_ID = MTable.getTable_ID(query.getTableName());
   if (!MRole.getDefault().isCanReport(AD_Table_ID)) {
     FDialog.error(0, null, "AccessCannotReport", query.getTableName());
     return;
   }
   if (AD_Table_ID != 0) new WReport(AD_Table_ID, query);
 } //	executeDrill
  /** Print result generate for this report */
  void print() throws Exception {
    Language language = Language.getLoginLanguage(); // Base Language
    MPrintFormat pf = null;
    int pfid = 0;

    // get print format for client, else copy system to client
    RowSet pfrs =
        MPrintFormat.getAccessiblePrintFormats(
            MTable.getTable_ID(X_RV_PP_Product_BOMLine_Storage_TableName), -1, null);
    pfrs.next();
    pfid = pfrs.getInt("AD_PrintFormat_ID");

    if (pfrs.getInt("AD_Client_ID") != 0) pf = MPrintFormat.get(getCtx(), pfid, false);
    else pf = MPrintFormat.copyToClient(getCtx(), pfid, getAD_Client_ID());
    pfrs.close();

    if (pf == null) raiseError("Error: ", "No Print Format");

    pf.setLanguage(language);
    pf.setTranslationLanguage(language);
    // query
    MQuery query = new MQuery(X_RV_PP_Product_BOMLine_Storage_TableName);
    query.addRestriction(
        X_T_BOMLine.COLUMNNAME_AD_PInstance_ID,
        MQuery.EQUAL,
        AD_PInstance_ID,
        getParamenterName(X_T_BOMLine.COLUMNNAME_AD_PInstance_ID),
        getParamenterInfo(X_T_BOMLine.COLUMNNAME_AD_PInstance_ID));

    query.addRestriction(
        X_T_BOMLine.COLUMNNAME_M_Warehouse_ID,
        MQuery.EQUAL,
        p_M_Warehouse_ID,
        getParamenterName(X_T_BOMLine.COLUMNNAME_M_Warehouse_ID),
        getParamenterInfo(X_T_BOMLine.COLUMNNAME_M_Warehouse_ID));

    query.addRestriction(
        X_T_BOMLine.COLUMNNAME_M_Warehouse_ID,
        MQuery.EQUAL,
        p_M_Warehouse_ID,
        getParamenterName("DateTrx"),
        getParamenterInfo("DateTrx"));

    PrintInfo info =
        new PrintInfo(
            X_RV_PP_Product_BOMLine_Storage_TableName,
            MTable.getTable_ID(X_RV_PP_Product_BOMLine_Storage_TableName),
            getRecord_ID());
    ReportEngine re = new ReportEngine(getCtx(), pf, query, info);

    ReportCtl.preview(re);
    // wait for report window to be closed as t_bomline
    // records are deleted when process ends
    while (re.getView().isDisplayable()) {
      Env.sleep(1);
    }
  }
 /** Zoom */
 public void zoom() {
   log.info("");
   Integer C_Order_ID = getSelectedRowKey();
   if (C_Order_ID == null) return;
   MQuery query = new MQuery("C_Order");
   query.addRestriction("C_Order_ID", MQuery.EQUAL, C_Order_ID);
   query.setRecordCount(1);
   int AD_WindowNo = getAD_Window_ID("C_Order", isSoTrx.isSelected());
   AEnv.zoom(AD_WindowNo, query);
 } //	zoom
Example #4
0
  /** Zoom */
  protected void zoom() {
    log.info("");
    Integer M_Product_ID = getSelectedRowKey();
    if (M_Product_ID == null) return;
    //	AEnv.zoom(MProduct.Table_ID, M_Product_ID.intValue(), true);	//	SO

    MQuery query = new MQuery("M_Product");
    query.addRestriction("M_Product_ID", MQuery.EQUAL, M_Product_ID);
    query.setRecordCount(1);
    int AD_WindowNo = getAD_Window_ID("M_Product", true); // 	SO
    zoom(AD_WindowNo, query);
  } //	zoom
  public void actionZoom() {
    int AD_Window_ID = MTable.get(Env.getCtx(), MLocator.Table_ID).getAD_Window_ID();
    if (AD_Window_ID <= 0) AD_Window_ID = 139; // 	hardcoded window Warehouse & Locators
    log.info("");
    //

    MQuery zoomQuery = new MQuery();
    zoomQuery.addRestriction(MLocator.COLUMNNAME_M_Locator_ID, MQuery.EQUAL, getValue());
    zoomQuery.setRecordCount(1); // 	guess

    AEnv.zoom(AD_Window_ID, zoomQuery);
  }
  /** Zoom action To be overwritten by concrete classes */
  public void zoom() {
    if (getSelectedRowKey() != null && getSelectedRowKey() > 0) {
      MQuery zoomQuery = new MQuery(); //  ColumnName might be changed in MTab.validateQuery
      String column = getKeyColumn();
      // strip off table name, fully qualify name doesn't work when zoom into detail tab
      if (column.indexOf(".") > 0) column = column.substring(column.indexOf(".") + 1);
      zoomQuery.addRestriction(column, MQuery.EQUAL, getSelectedRowKey());
      zoomQuery.setRecordCount(1);
      zoomQuery.setTableName(column.substring(0, column.length() - 3));

      AEnv.zoom(236, zoomQuery);
    }
  }
 /** Zoom */
 @Override
 protected void zoom() {
   log.info("");
   final Integer ID = getSelectedRowKey();
   if (ID == null) {
     return;
   }
   final String p_tableName = getTableName();
   final MQuery query = new MQuery(p_tableName);
   query.addRestriction(p_tableName + "_ID", MQuery.EQUAL, ID);
   query.setRecordCount(1);
   final int AD_WindowNo = getAD_Window_ID(p_tableName, true);
   zoom(AD_WindowNo, query);
 } // zoom
Example #8
0
  /** Answer Button */
  private void cmd_button() {
    log.config("Activity=" + m_activity);
    if (m_activity == null) return;
    //
    MWFNode node = m_activity.getNode();
    if (MWFNode.ACTION_UserWindow.equals(node.getAction())) {
      int AD_Window_ID = node.getAD_Window_ID(); // Explicit Window
      String ColumnName = m_activity.getPO().get_TableName() + "_ID";
      int Record_ID = m_activity.getRecord_ID();
      MQuery query = MQuery.getEqualQuery(ColumnName, Record_ID);
      boolean IsSOTrx = m_activity.isSOTrx();
      //
      log.info(
          "Zoom to AD_Window_ID=" + AD_Window_ID + " - " + query + " (IsSOTrx=" + IsSOTrx + ")");

      AEnv.zoom(AD_Window_ID, query);
    } else if (MWFNode.ACTION_UserForm.equals(node.getAction())) {
      int AD_Form_ID = node.getAD_Form_ID();

      Window form = ADForm.openForm(AD_Form_ID);
      AEnv.showWindow(form);
    } else if (MWFNode.ACTION_SmartBrowse.equals(node.getAction())) {
      int AD_Browse_ID = node.getAD_Browse_ID();

      Window browse = WBrowser.openBrowse(AD_Browse_ID);
      AEnv.showWindow(browse);
    } else log.log(Level.SEVERE, "No User Action:" + node.getAction());
  } //	cmd_button
Example #9
0
  /** Action - Zoom */
  @Override
  public void actionZoom() {
    int AD_Window_ID = MTable.get(Env.getCtx(), MLocator.Table_ID).getAD_Window_ID();
    if (AD_Window_ID <= 0) AD_Window_ID = 139; // 	hardcoded window Warehouse & Locators
    log.info("");
    //
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    AWindow frame = new AWindow();

    MQuery zoomQuery = new MQuery();
    zoomQuery.addRestriction(MLocator.COLUMNNAME_M_Locator_ID, Operator.EQUAL, getValue());
    zoomQuery.setRecordCount(1); // 	guess

    if (!frame.initWindow(AD_Window_ID, zoomQuery)) return;
    AEnv.addToWindowManager(frame);
    AEnv.showCenterScreen(frame);
    frame = null;
    setCursor(Cursor.getDefaultCursor());
  } //	actionZoom
 /** Zoom M_Lot */
 private void cmd_zoom() {
   int M_Lot_ID = 0;
   KeyNamePair pp = fieldLot.getSelectedItem();
   if (pp != null) M_Lot_ID = pp.getKey();
   MQuery zoomQuery = new MQuery("M_Lot");
   zoomQuery.addRestriction("M_Lot_ID", MQuery.EQUAL, M_Lot_ID);
   log.info(zoomQuery.toString());
   //
   setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   //
   int AD_Window_ID = 257; // Lot
   AWindow frame = new AWindow();
   if (frame.initWindow(AD_Window_ID, zoomQuery)) {
     this.setVisible(false);
     this.setModal(false); // otherwise blocked
     this.setVisible(true);
     AEnv.addToWindowManager(frame);
     AEnv.showScreen(frame, SwingConstants.EAST);
   }
   // async window - not able to get feedback
   frame = null;
   //
   setCursor(Cursor.getDefaultCursor());
 } // cmd_zoom
Example #11
0
  /**
   * Action Find. - create where clause - query database
   *
   * @param includeAliasCombination include alias combination
   */
  private void action_Find(boolean includeAliasCombination) {
    log.info("");
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    //	Create where Clause
    MQuery query = null;
    if (m_query != null) query = m_query.deepCopy();
    else query = new MQuery();
    //	Alias
    if (includeAliasCombination && f_Alias != null && f_Alias.getValue().toString().length() > 0) {
      String value = f_Alias.getValue().toString().toUpperCase();
      if (!value.endsWith("%")) value += "%";
      query.addRestriction("UPPER(Alias)", MQuery.LIKE, value);
    }
    //	Combination (mandatory)
    if (includeAliasCombination && f_Combination.getValue().toString().length() > 0) {
      String value = f_Combination.getValue().toString().toUpperCase();
      if (!value.endsWith("%")) value += "%";
      query.addRestriction("UPPER(Combination)", MQuery.LIKE, value);
    }
    //	Org (mandatory)
    if (f_AD_Org_ID != null && f_AD_Org_ID.getValue() != null)
      query.addRestriction("AD_Org_ID", MQuery.EQUAL, f_AD_Org_ID.getValue());
    //	Account (mandatory)
    if (f_Account_ID != null && f_Account_ID.getValue() != null)
      query.addRestriction("Account_ID", MQuery.EQUAL, f_Account_ID.getValue());
    if (f_SubAcct_ID != null && f_SubAcct_ID.getValue() != null)
      query.addRestriction("C_SubAcct_ID", MQuery.EQUAL, f_SubAcct_ID.getValue());

    //	Product
    if (f_M_Product_ID != null && f_M_Product_ID.getValue() != null)
      query.addRestriction("M_Product_ID", MQuery.EQUAL, f_M_Product_ID.getValue());
    //	BPartner
    if (f_C_BPartner_ID != null && f_C_BPartner_ID.getValue() != null)
      query.addRestriction("C_BPartner_ID", MQuery.EQUAL, f_C_BPartner_ID.getValue());
    //	Campaign
    if (f_C_Campaign_ID != null && f_C_Campaign_ID.getValue() != null)
      query.addRestriction("C_Campaign_ID", MQuery.EQUAL, f_C_Campaign_ID.getValue());
    //	Loc From
    if (f_C_LocFrom_ID != null && f_C_LocFrom_ID.getValue() != null)
      query.addRestriction("C_LocFrom_ID", MQuery.EQUAL, f_C_LocFrom_ID.getValue());
    //	Loc To
    if (f_C_LocTo_ID != null && f_C_LocTo_ID.getValue() != null)
      query.addRestriction("C_LocTo_ID", MQuery.EQUAL, f_C_LocTo_ID.getValue());
    //	Project
    if (f_C_Project_ID != null && f_C_Project_ID.getValue() != null)
      query.addRestriction("C_Project_ID", MQuery.EQUAL, f_C_Project_ID.getValue());
    //	SRegion
    if (f_C_SalesRegion_ID != null && f_C_SalesRegion_ID.getValue() != null)
      query.addRestriction("C_SalesRegion_ID", MQuery.EQUAL, f_C_SalesRegion_ID.getValue());
    //	Org Trx
    if (f_AD_OrgTrx_ID != null && f_AD_OrgTrx_ID.getValue() != null)
      query.addRestriction("AD_OrgTrx_ID", MQuery.EQUAL, f_AD_OrgTrx_ID.getValue());
    //	Activity
    if (f_C_Activity_ID != null && f_C_Activity_ID.getValue() != null)
      query.addRestriction("C_Activity_ID", MQuery.EQUAL, f_C_Activity_ID.getValue());
    //	User 1
    if (f_User1_ID != null && f_User1_ID.getValue() != null)
      query.addRestriction("User1_ID", MQuery.EQUAL, f_User1_ID.getValue());
    //	User 2
    if (f_User2_ID != null && f_User2_ID.getValue() != null)
      query.addRestriction("User2_ID", MQuery.EQUAL, f_User2_ID.getValue());

    //	Query
    m_mTab.setQuery(query);
    m_mTab.query(false);
    statusBar.setStatusDB(String.valueOf(m_mTab.getRowCount()));
    setCursor(Cursor.getDefaultCursor());
  } //	action_Find
Example #12
0
  /**
   * Dyanmic Init. When a row is selected, the editor values are set (editors do not change grid)
   *
   * @return true if initialized
   */
  private boolean initAccount() {
    m_AD_Client_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_Client_ID");
    //	Get AcctSchema Info
    if (s_AcctSchema == null || s_AcctSchema.getC_AcctSchema_ID() != m_C_AcctSchema_ID)
      s_AcctSchema = new MAcctSchema(Env.getCtx(), m_C_AcctSchema_ID, null);
    log.config(s_AcctSchema.toString() + ", #" + s_AcctSchema.getAcctSchemaElements().length);
    Env.setContext(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", m_C_AcctSchema_ID);

    //  Model
    int AD_Window_ID = 153; // 	Maintain Account Combinations
    GridWindowVO wVO = AEnv.getMWindowVO(m_WindowNo, AD_Window_ID, 0);
    if (wVO == null) return false;
    m_mWindow = new GridWindow(wVO);
    m_mTab = m_mWindow.getTab(0);
    // Make sure is the tab is loaded - teo_sarca [ 1659124 ]
    if (!m_mTab.isLoadComplete()) m_mWindow.initTab(0);

    //  ParameterPanel restrictions
    m_mTab.getField("Alias").setDisplayLength(15);
    m_mTab.getField("Combination").setDisplayLength(15);
    //  Grid restrictions
    m_mTab.getField("AD_Client_ID").setDisplayed(false);
    m_mTab.getField("C_AcctSchema_ID").setDisplayed(false);
    m_mTab.getField("IsActive").setDisplayed(false);
    m_mTab.getField("IsFullyQualified").setDisplayed(false);
    //  don't show fields not being displayed in this environment
    for (int i = 0; i < m_mTab.getFieldCount(); i++) {
      GridField field = m_mTab.getField(i);
      if (!field.isDisplayed(true)) //  check context
      field.setDisplayed(false);
    }

    //  GridController
    m_gridController = new GridController();
    m_gridController.initGrid(m_mTab, true, m_WindowNo, null, null);
    m_gridController.setPreferredSize(new Dimension(300, 100));
    panel.add(m_gridController, BorderLayout.CENTER);

    //  Prepare Parameter
    m_gbc.anchor = GridBagConstraints.NORTHWEST;
    m_gbc.gridy = 0; // 	line
    m_gbc.gridx = 0;
    m_gbc.gridwidth = 1;
    m_gbc.insets = m_fieldInsets;
    m_gbc.fill = GridBagConstraints.HORIZONTAL;
    m_gbc.weightx = 0;
    m_gbc.weighty = 0;

    int TabNo = 0;

    //	Alias
    if (s_AcctSchema.isHasAlias()) {
      GridField alias = m_mTab.getField("Alias");
      f_Alias = VEditorFactory.getEditor(m_mTab, alias, false);
      addLine(alias, f_Alias, false);
    } //	Alias

    //	Combination
    GridField combination = m_mTab.getField("Combination");
    f_Combination = VEditorFactory.getEditor(m_mTab, combination, false);
    addLine(combination, f_Combination, false);
    m_newRow = true;

    /** Create Fields in Element Order */
    MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements();
    for (int i = 0; i < elements.length; i++) {
      MAcctSchemaElement ase = elements[i];
      String type = ase.getElementType();
      boolean isMandatory = ase.isMandatory();
      //
      if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) {
        GridField field = m_mTab.getField("AD_Org_ID");
        f_AD_Org_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_AD_Org_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account)) {
        GridField field = m_mTab.getField("Account_ID");
        f_Account_ID = VEditorFactory.getEditor(m_mTab, field, false);
        //	((VLookup)f_Account_ID).setWidth(400);
        addLine(field, f_Account_ID, isMandatory);
        f_Account_ID.addVetoableChangeListener(this);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) {
        GridField field = m_mTab.getField("C_SubAcct_ID");
        f_SubAcct_ID = VEditorFactory.getEditor(m_mTab, field, false);
        //	((VLookup)f_SubAcct_ID).setWidth(400);
        addLine(field, f_SubAcct_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product)) {
        GridField field = m_mTab.getField("M_Product_ID");
        f_M_Product_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_M_Product_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner)) {
        GridField field = m_mTab.getField("C_BPartner_ID");
        f_C_BPartner_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_C_BPartner_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign)) {
        GridField field = m_mTab.getField("C_Campaign_ID");
        f_C_Campaign_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_C_Campaign_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom)) {
        GridField field = m_mTab.getField("C_LocFrom_ID");
        f_C_LocFrom_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_C_LocFrom_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo)) {
        GridField field = m_mTab.getField("C_LocTo_ID");
        f_C_LocTo_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_C_LocTo_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project)) {
        GridField field = m_mTab.getField("C_Project_ID");
        f_C_Project_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_C_Project_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion)) {
        GridField field = m_mTab.getField("C_SalesRegion_ID");
        f_C_SalesRegion_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_C_SalesRegion_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx)) {
        GridField field = m_mTab.getField("AD_OrgTrx_ID");
        f_AD_OrgTrx_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_AD_OrgTrx_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity)) {
        GridField field = m_mTab.getField("C_Activity_ID");
        f_C_Activity_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_C_Activity_ID, isMandatory);
      }
      //	User1
      else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList1)) {
        GridField field = m_mTab.getField("User1_ID");
        f_User1_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_User1_ID, isMandatory);
      } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList2)) {
        GridField field = m_mTab.getField("User2_ID");
        f_User2_ID = VEditorFactory.getEditor(m_mTab, field, false);
        addLine(field, f_User2_ID, isMandatory);
      }
    } //	Create Fields in Element Order

    //	Add description
    m_newRow = true;
    m_gbc.gridy = m_line++;
    m_gbc.gridx = 0;
    m_gbc.gridwidth = 4;
    m_gbc.insets = new Insets(5, 15, 2, 0); // 	top,left,bottom,right
    m_gbc.fill = GridBagConstraints.HORIZONTAL;
    f_Description.setFont(f_Description.getFont().deriveFont(Font.ITALIC));
    parameterPanel.add(f_Description, m_gbc);

    //	Finish
    m_query = new MQuery();
    m_query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID);
    m_query.addRestriction("IsFullyQualified", MQuery.EQUAL, "Y");
    if (m_mAccount.C_ValidCombination_ID == 0) m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
    else {
      MQuery query = new MQuery();
      query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID);
      query.addRestriction("C_ValidCombination_ID", MQuery.EQUAL, m_mAccount.C_ValidCombination_ID);
      m_mTab.setQuery(query);
    }
    m_mTab.query(false);
    m_gridController.getTable().addMouseListener(new VAccountDialog_mouseAdapter(this));
    m_gridController.addDataStatusListener(this);

    statusBar.setStatusLine(s_AcctSchema.toString());
    statusBar.setStatusDB("?");

    //	Initial value
    if (m_mAccount.C_ValidCombination_ID != 0) m_mTab.navigate(0);

    log.config("fini");
    return true;
  } //	initAccount
  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;
  }