Jump to content
  • Add resource name in Audit Domain


    jzhou_1

    Question:

    The current Audit domain does not include the resource name/name, only uri which is recorded in the jiauditevent table. However, the customer need to show the resource name/label instead of the uri in their custom auditng report. They are trying to modifying the Audit domain to link the resource name/label.

     

    Solution:

    You can join the jiresource and jiresourcefolder with the foreign key parent_folder, then join with jiauditevent to link the resource name/label in Audit domain.

    For example, you can create a derived table, e.g. new_table in the aduit domain as the following query: 
    select distinct rf.uri || '/' || r.name as resource_uri, r.label as resource_name 
    from jiresource r, jiresourcefolder rf 
    where r.parent_folder=rf.id; 

    Then you can add the join this derived table, e.g. new_table with the existing jiauditevent by key: new_table.resource_uri=jiauditevent.uri. After the join, you should be able to use the resource_name for your audit report.


    User Feedback

    Recommended Comments

    Thanks for the wiki ! 

    I managed to get the resource_name using a subquery inside a join clause, sample here to get report executions (date of exec, report name, report_uri, user exec) :

    SELECT jia.event_date, jir.resource_name, jia.resource_uri, jia.username FROM 
    jiauditevent jia
    INNER JOIN (
        SELECT DISTINCT rf.uri || '/' || r.name AS resource_uri, r.label AS resource_name, resourcetype 
        FROM jiresource r, jiresourcefolder rf 
        WHERE r.parent_folder=rf.id
    ) jir ON jia.resource_uri = jir.resource_uri 
    WHERE jir.resourcetype LIKE '%com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit%'
    ORDER BY jia.event_date DESC

    Sample result : 

    Event_date Resource_name Resource_uri Username
    "2022-02-02 17:11:48.745" my report

    /public/test/my_report

    jasperadmin

     

    Link to comment
    Share on other sites



    Guest
    This is now closed for further comments

×
×
  • Create New...