Related with issue 27787: Adds comments and removes unused code
authorAugusto Mauch <augusto.mauch@openbravo.com>
Mon, 01 Dec 2014 15:13:04 +0100
changeset 25482 79198ab4f09b
parent 25481 d60c4bb642ea
child 25483 5a8a44dabdce
Related with issue 27787: Adds comments and removes unused code
modules/org.openbravo.client.application/src/org/openbravo/client/application/MenuManager.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/MenuManager.java	Thu Nov 27 09:46:03 2014 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/MenuManager.java	Mon Dec 01 15:13:04 2014 +0100
@@ -316,26 +316,33 @@
       return Boolean.toString(isSingleRecord());
     }
 
+    /**
+     * This method returns true if the menu entry is read only. The menu entry will be read only
+     * either if the uipattern of its tab is "RO" (Read Only) or if the current role only has read
+     * only access to the tab or to its window
+     */
     public boolean isReadOnly() {
       boolean tabIsReadOnlyForAll = getTab() != null && getTab().getUIPattern().equals("RO");
       boolean tabIsReadOnlyForRole = isTabReadOnlyforRole();
       return tabIsReadOnlyForAll || tabIsReadOnlyForRole;
     }
 
+    /**
+     * Returns true if the tab is not editable by the current role by checking the WindowAccess and
+     * TabAccess entities
+     */
     public boolean isTabReadOnlyforRole() {
-      // OBCriteria
       boolean isReadOnly = false;
-
+      // If there is no tab there is nothing to check
       if (getTab() == null) {
         return false;
       }
-
+      // Obtains the Window Access for the current role
       Role role = OBContext.getOBContext().getRole();
       OBCriteria<WindowAccess> windowAccessCriteria = OBDal.getInstance().createCriteria(
           WindowAccess.class);
       windowAccessCriteria.add(Restrictions.eq(WindowAccess.PROPERTY_ROLE, role));
       windowAccessCriteria.add(Restrictions.eq(WindowAccess.PROPERTY_WINDOW, getTab().getWindow()));
-
       WindowAccess windowAccess = (WindowAccess) windowAccessCriteria.uniqueResult();
       if (windowAccess != null) {
         // there is a window access defined for this window and this role
@@ -346,13 +353,12 @@
         TabAccess tabAccess = (TabAccess) tabAccessCriteria.uniqueResult();
         if (tabAccess != null) {
           // there is a window access defined and a tab access defined too
-          windowAccess.isEditableField();
-          tabAccess.isEditableField();
-
+          // The menu entry will be read only if the tab is not editable by this role
           isReadOnly = !tabAccess.isEditableField();
           //
         } else {
           // There is a window access defined but there is not a tab access defined
+          // The menu entry will be read only if the window is not editable by this role
           isReadOnly = !windowAccess.isEditableField();
         }
       } else {