Beispiel #1
0
 /**
  * Get Tree ID for role
  *
  * @return AD_Tree_ID as int
  */
 private int getTreeID() {
   int AD_Role_ID = m_context.getAD_Role_ID();
   // Load Menu Structure ----------------------
   int AD_Tree_ID =
       QueryUtil.getSQLValue(
           null,
           "SELECT COALESCE(r.AD_Tree_Menu_ID, ci.AD_Tree_Menu_ID)"
               + "FROM AD_ClientInfo ci"
               + " INNER JOIN AD_Role r ON (ci.AD_Client_ID=r.AD_Client_ID) "
               + "WHERE AD_Role_ID=?",
           AD_Role_ID);
   if (AD_Tree_ID <= 0) AD_Tree_ID = 10; // Menu
   return AD_Tree_ID;
 } // getTreeID
Beispiel #2
0
  /**
   * ************************************************************************* Get Window in default
   * context based on Role
   *
   * @param windowNO relative window
   * @param AD_Window_ID window
   * @param AD_Menu_ID menu
   * @return WindowVO or null
   */
  public UIWindow getWindow(int windowNO, int AD_Window_ID, int AD_Menu_ID) {
    UIWindow win = null;
    // win = m_windows.get(AD_Window_ID);
    // if (win != null)
    // {
    // win.clearLookupCache();
    // return win;
    // }
    UIWindowVOFactory winFactory = new UIWindowVOFactory();
    UIWindowVO winVO = null;
    int AD_UserDef_Win_ID = -1;
    WindowVOCacheKey vokey =
        new WindowVOCacheKey(
            AD_Window_ID, m_context.getAD_Role_ID(), AD_Menu_ID, Env.getAD_Language(m_context));

    // note, the usage of m_context below in constructing window is only for
    // language, menu, role,
    // and those are already included in the cache key, so we can safely
    // assume the win is correctly cached
    if (Userdef_Winids.get(null, vokey) == null) {
      winVO = winFactory.get(m_context, AD_Window_ID, AD_Menu_ID);
      if (winVO == null) {
        log.config("No Window - AD_Window_ID=" + AD_Window_ID + ",AD_Menu_ID=" + AD_Menu_ID);
        return null;
      }
      int theAD_UserDef_Win_ID = winVO.getAD_UserDef_Win_ID();

      if (Userdef_Winids.putIfAbsent(vokey, theAD_UserDef_Win_ID) == null)
        AD_UserDef_Win_ID = theAD_UserDef_Win_ID;
    } else AD_UserDef_Win_ID = Userdef_Winids.get(m_context, vokey);

    WindowCacheKey key =
        new WindowCacheKey(
            AD_Window_ID,
            AD_UserDef_Win_ID,
            m_context.getAD_Role_ID(),
            AD_Menu_ID,
            Env.getAD_Language(m_context));
    win = UIWindows.get(null, key);
    if (win == null) {
      // log.warning("key:" + key + " not found, create");
      if (winVO == null) winVO = winFactory.get(m_context, AD_Window_ID, AD_Menu_ID);
      if (winVO == null) {
        log.config("No Window - AD_Window_ID=" + AD_Window_ID + ",AD_Menu_ID=" + AD_Menu_ID);
        return null;
      }
      UIWindow newWin = new UIWindow(winVO);
      AD_Window_ID = newWin.getAD_Window_ID();
      //
      UIFieldVOFactory fieldFactory = new UIFieldVOFactory();
      newWin.setFields(fieldFactory.getAll(m_context, AD_Window_ID, AD_UserDef_Win_ID));
      //
      UITabVOFactory tabFactory = new UITabVOFactory();
      // setTabVOs initrlize tabs but not fields, 'cuz fields needs to be
      // copied over and initialized later
      newWin.setTabVOsWithFieldsUninitialized(
          m_context, tabFactory.getAll(m_context, AD_Window_ID, AD_UserDef_Win_ID), windowNO);
      win = UIWindows.putIfAbsent(key, newWin);
      if (win == null) win = newWin;
    }
    // deep copy the window object so we hold a separate window object for
    // each user session
    UIWindow duplicatedWin = (UIWindow) DeepCopy.copy(win);
    log.fine(duplicatedWin.toString());
    fillTabsFieldsAndInitFieldsAndCreateDependencyRelations(duplicatedWin, windowNO);

    MSession session = MSession.get(m_context);
    if (session != null)
      session.windowLog(
          m_context.getAD_Client_ID(),
          m_context.getAD_Org_ID(),
          duplicatedWin.getAD_Window_ID(),
          0);

    return duplicatedWin;
  } // getWindowVO