Class MRole

    • Field Detail

      • SQL_FULLYQUALIFIED

        public static final boolean SQL_FULLYQUALIFIED
        Access SQL Fully Qualified
        See Also:
        Constant Field Values
      • SQL_NOTQUALIFIED

        public static final boolean SQL_NOTQUALIFIED
        Access SQL Not Fully Qualified
        See Also:
        Constant Field Values
      • SUPERUSER_USER_ID

        public static final int SUPERUSER_USER_ID
        The AD_User_ID of the SuperUser
        See Also:
        Constant Field Values
      • SYSTEM_USER_ID

        public static final int SYSTEM_USER_ID
        The AD_User_ID of the System Administrator
        See Also:
        Constant Field Values
    • Constructor Detail

      • MRole

        public MRole​(Properties ctx,
                     int AD_Role_ID,
                     String trxName)
        Standard Constructor NOTE - This method must not be used when the role is being requested to manage permissions, in such case is necessary to use one of the get methods setting the userID
        Parameters:
        ctx - context
        AD_Role_ID - id
        trxName - transaction
      • MRole

        public MRole​(Properties ctx,
                     ResultSet rs,
                     String trxName)
        Load Constructor NOTE - This method must not be used when the role is being requested to manage permissions, in such case is necessary to use one of the get methods setting the userID
        Parameters:
        ctx - context
        rs - result set
        trxName - transaction
      • MRole

        public MRole​(MRole copy)
        Parameters:
        copy -
      • MRole

        public MRole​(Properties ctx,
                     MRole copy)
        Parameters:
        ctx -
        copy -
      • MRole

        public MRole​(Properties ctx,
                     MRole copy,
                     String trxName)
        Parameters:
        ctx -
        copy -
        trxName -
    • Method Detail

      • getDefault

        public static MRole getDefault()
        Get Default (Client) Role
        Returns:
        role
      • get

        public static MRole get​(Properties ctx,
                                int AD_Role_ID,
                                int AD_User_ID,
                                boolean reload)
        Get Role for User from cache
        Parameters:
        ctx - context
        AD_Role_ID - role
        AD_User_ID - user
        reload - if true forces load
        Returns:
        role
      • get

        public static MRole get​(Properties ctx,
                                int AD_Role_ID)
        Get Role (cached). Did not set user - so no access loaded
        Parameters:
        ctx - context
        AD_Role_ID - role
        Returns:
        role
      • getOfClient

        public static MRole[] getOfClient​(Properties ctx)
        Get Roles Of Client
        Parameters:
        ctx - context
        Returns:
        roles of client
      • getOfClient

        public static MRole[] getOfClient​(Properties ctx,
                                          String trxName)
        Get Roles Of Client
        Parameters:
        ctx - context
        trxName -
        Returns:
        roles of client
      • getOf

        public static MRole[] getOf​(Properties ctx,
                                    String whereClause)
        Get Roles With where clause
        Parameters:
        ctx - context
        whereClause - where clause
        Returns:
        roles of client
      • isQueryRequire

        public boolean isQueryRequire​(int noRecords)
        Require Query
        Parameters:
        noRecords - records
        Returns:
        true if query required
      • isQueryMax

        public boolean isQueryMax​(int noRecords)
        Over max Query
        Parameters:
        noRecords - records
        Returns:
        true if over max query
      • beforeSave

        protected boolean beforeSave​(boolean newRecord)
        Before Save
        Overrides:
        beforeSave in class PO
        Parameters:
        newRecord - new
        Returns:
        true if it can be saved
      • afterSave

        protected boolean afterSave​(boolean newRecord,
                                    boolean success)
        After Save
        Overrides:
        afterSave in class PO
        Parameters:
        newRecord - new
        success - success
        Returns:
        success
      • afterDelete

        protected boolean afterDelete​(boolean success)
        Executed after Delete operation.
        Overrides:
        afterDelete in class PO
        Parameters:
        success - true if record deleted
        Returns:
        true if delete is a success
      • updateAccessRecords

        public String updateAccessRecords()
        Create Access Records
        Returns:
        info
      • updateAccessRecords

        public String updateAccessRecords​(boolean reset)
        Create Access Records
        Parameters:
        reset - true will reset existing access
        Returns:
        info
      • toStringX

        public String toStringX​(Properties ctx)
        Extended String Representation
        Parameters:
        ctx - Properties
        Returns:
        extended info
      • setAD_User_ID

        public void setAD_User_ID​(int AD_User_ID)
        Set Logged in user
        Parameters:
        AD_User_ID - user requesting info
      • getAD_User_ID

        public int getAD_User_ID()
        Get Logged in user
        Returns:
        AD_User_ID user requesting info
      • loadAccess

        public void loadAccess​(boolean reload)
        Load Access Info
        Parameters:
        reload - re-load from disk
      • getClientWhere

        public String getClientWhere​(boolean rw)
        Get Client Where Clause Value
        Parameters:
        rw - read write
        Returns:
        "AD_Client_ID=0" or "AD_Client_ID IN(0,1)"
      • isClientAccess

        public boolean isClientAccess​(int AD_Client_ID,
                                      boolean rw)
        Access to Client
        Parameters:
        AD_Client_ID - client
        rw - read write access
        Returns:
        true if access
      • getOrgWhere

        public String getOrgWhere​(boolean rw)
        Get Org Where Clause Value
        Parameters:
        rw - read write
        Returns:
        "AD_Org_ID=0" or "AD_Org_ID IN(0,1)" or null (if access all org)
      • isOrgAccess

        public boolean isOrgAccess​(int AD_Org_ID,
                                   boolean rw)
        Access to Org
        Parameters:
        AD_Org_ID - org
        rw - read write access
        Returns:
        true if access
      • isCanReport

        public boolean isCanReport​(int AD_Table_ID)
        Can Report on table
        Parameters:
        AD_Table_ID - table
        Returns:
        true if access
      • isCanExport

        public boolean isCanExport​(int AD_Table_ID)
        Can Export Table
        Parameters:
        AD_Table_ID -
        Returns:
        true if access
      • isTableAccess

        public boolean isTableAccess​(int AD_Table_ID,
                                     boolean ro)
        Access to Table
        Parameters:
        AD_Table_ID - table
        ro - check read only access otherwise read write access level
        Returns:
        has RO/RW access to table
      • isTableAccessLevel

        public boolean isTableAccessLevel​(int AD_Table_ID,
                                          boolean ro)
        Access to Table based on Role User Level Table Access Level
        Parameters:
        AD_Table_ID - table
        ro - check read only access otherwise read write access level
        Returns:
        has RO/RW access to table
      • isColumnAccess

        public boolean isColumnAccess​(int AD_Table_ID,
                                      int AD_Column_ID,
                                      boolean ro)
        Access to Column
        Parameters:
        AD_Table_ID - table
        AD_Column_ID - column
        ro - read only
        Returns:
        true if access
      • isRecordAccess

        public boolean isRecordAccess​(int AD_Table_ID,
                                      int Record_ID,
                                      boolean ro)
        Access to Record (no check of table)
        Parameters:
        AD_Table_ID - table
        Record_ID - record
        ro - read only
        Returns:
        boolean
      • getWindowAccess

        public Boolean getWindowAccess​(int AD_Window_ID)
        Get Window Access
        Parameters:
        AD_Window_ID - window
        Returns:
        null in no access, TRUE if r/w and FALSE if r/o
      • getProcessAccess

        public Boolean getProcessAccess​(int AD_Process_ID)
        Get Process Access
        Parameters:
        AD_Process_ID - process
        Returns:
        null in no access, TRUE if r/w and FALSE if r/o
      • getTaskAccess

        public Boolean getTaskAccess​(int AD_Task_ID)
        Get Task Access
        Parameters:
        AD_Task_ID - task
        Returns:
        null in no access, TRUE if r/w and FALSE if r/o
      • getFormAccess

        public Boolean getFormAccess​(int AD_Form_ID)
        Get Form Access
        Parameters:
        AD_Form_ID - form
        Returns:
        null in no access, TRUE if r/w and FALSE if r/o
      • getWorkflowAccess

        public Boolean getWorkflowAccess​(int AD_Workflow_ID)
        Get Workflow Access
        Parameters:
        AD_Workflow_ID - workflow
        Returns:
        null in no access, TRUE if r/w and FALSE if r/o
      • addAccessSQL

        public String addAccessSQL​(String SQL,
                                   String TableNameIn,
                                   boolean fullyQualified,
                                   boolean rw)
        Appends where clause to SQL statement for Table
        Parameters:
        SQL - existing SQL statement
        TableNameIn - Table Name or list of table names AAA, BBB or AAA a, BBB b
        fullyQualified - fullyQualified names
        rw - if false, includes System Data
        Returns:
        updated SQL statement
      • canUpdate

        public boolean canUpdate​(int AD_Client_ID,
                                 int AD_Org_ID,
                                 int AD_Table_ID,
                                 int Record_ID,
                                 boolean createError)
        UPDATE - Can I Update the record. Access error info (AccessTableNoUpdate) is saved in the log
        Parameters:
        AD_Client_ID - context to derive client/org/user level
        AD_Org_ID - number of the current window to retrieve context
        AD_Table_ID - table
        Record_ID - record id
        createError - boolean
        Returns:
        true if you can update see org.compiere.model.MTable#dataSave(boolean)
      • canView

        public boolean canView​(Properties ctx,
                               String TableLevel)
        VIEW - Can I view record in Table with given TableLevel. TableLevel S__ 100 4 System info SCO 111 7 System shared info SC_ 110 6 System/Client info _CO 011 3 Client shared info _C_ 011 2 Client shared info __O 001 1 Organization info
        Parameters:
        ctx - context
        TableLevel - AccessLevel
        Returns:
        true/false Access error info (AccessTableNoUpdate, AccessTableNoView) is saved in the log see org.compiere.model.MTabVO#loadTabDetails(MTabVO, ResultSet)
      • isShowPreference

        public boolean isShowPreference()
        Show (Value) Preference Menu
        Returns:
        true if preference type is not None
      • checkActionAccess

        public int checkActionAccess​(int clientId,
                                     int docTypeId,
                                     String[] options,
                                     int maxIndex)
        Checks the access rights of the given role/client for the given document actions.
        Parameters:
        clientId -
        docTypeId -
        options -
        maxIndex -
        Returns:
        number of valid actions in the String[] options
      • getIncludedRoles

        public List<MRole> getIncludedRoles​(boolean recursive)
        Returns:
        unmodifiable list of included roles
      • getIncludedRolesWhereClause

        public String getIncludedRolesWhereClause​(String roleColumnSQL,
                                                  List<Object> params)
        Get Role Where Clause. It will look something like myalias.AD_Role_ID IN (?, ?, ?).
        Parameters:
        roleColumnSQL - role columnname or role column SQL (e.g. myalias.AD_Role_ID)
        params - a list where the method will put SQL parameters. If null, this method will generate a not parametrized query
        Returns:
        role SQL where clause
      • getInfoAccess

        public Boolean getInfoAccess​(int AD_InfoWindow_ID)
      • canAccess_Info_Product

        public boolean canAccess_Info_Product()
      • getWhereRoleType

        public static String getWhereRoleType​(String roleType,
                                              String tableName)
        Get where clause for a role types list
        Parameters:
        roleType - - comma separated list of role types, NULL can be used
        tableName - - if table needs to be qualified
        Returns:
        whereClause - return null if roleType is null or empty
      • isTableAccessExcluded

        public boolean isTableAccessExcluded​(int tableID)
        Does the table is excluded for current role (this method doesn't check the level of the table, use isTableAccess for this purpose)
        Parameters:
        tableID - ID of the table
        Returns: