Users, who using the SQLReport engine to retrieve data from data sources and view the results, are necessary in the report system. The users information which class name is “ReportUserWrapper”, can be used in:

  • Some reports are private report, only the users registered in the system can be retrieve.
  • Some reports are limited to be viewed by specified users.
  • Some reports can not be customized, except some users have the right privileges.

For simplify integrating and developing, SQLReport using a simple model for the users, the user model only contains the following attributes:

  • User ID (String): The identity of a user, the value of this attribute is defined by the SQLReport customers.
  • User Name (String): The name of the user.
  • Is Administrator (Boolean): Is this user a report administrator? From SQLReport view, there is only two types of users, the normal report viewer and report administrators. Only administrators can re-define reports and deploy them in the client-interface.

Further more, for some reason, maybe SQLReport user model should contains more information which can be used in the report definitions and expression. So the users model add a hash-table to hold more variables of users.

As autonomy system, SQLReport does not save users information, but in some case, for example checking the user’s privileges, SQLReport needs to know current user logon into the system and ask whether the current report could be accessible by the user.

SQLReport provides another interface to interoperate with the customer system which storing the user information and managing users privileges. The interface is: com.jeasonzhao.report.engine.irp.IUserInterop

public interface IUserInterop
{
    /**
     * Get the current user information
     * @param renderParameter Object
     * @return UserInfo
     */
    public ReportUserWrapper getCurrentUser(Object renderParameter);

    /**
     * Send notice: Add a new report
     * @param user UserInfo
     * @param report Report
     */
    public void addUserReport(ReportUserWrapper user,Report report);

    /**
     * Check the permission about some specification report.
     * @param user UserInfo
     * @param report Report
     */
    public boolean isUserCanAccessReport(ReportUserWrapper user,Report report);
}

Maybe most of all confusion is about the parameter of the function “getCurrentUser”. The value and type of this parameter depends on the customer system, here is a short brief:

  • If the customer system is a JSP/J2EE/Servlet, the “renderParameter” will be the instance of current session.
  • If the customer system is a Java Application, the “renderParameter” is always be a null pointer.
  • If the customer system is a DotNet Application, the “renderParameter” is always be a null pointer.

When a report retrieving request received, the  getCurrentUser will be invoked to get the current user, and then the isUserCanAccessReport will be invoke followed to determine the user can access this report or not.

When users customized an existing report, the addUserReport will be invoked to tell the customer system to store the report for the user.


Jeason Zhao (沈胜衣,斛律光) ------雪饮再现,一个人的江湖
我知道我是谁,我是沈胜衣,默默的活着,就像空气。