Is it possible to retrieve a list of reports which a user has access on it from the RS application to our project.
We are trying to show a list of reports available to a user in our project , so that when he get in to our project he must be able to see the list of reports which he has access to the same.
I use a script datasource + Dynamic List for a report that shows datasources a given user has access to, so I guess it should be possible to create a similar report showing reports a given user has access to.
How your application will access this list of reports? Would JSON retrieved via url work in your case?
Using dynamic list we are able to retrieve all reportlists as json by url.
Now, we want to retrieve those lists specific to a user.
Is there way to display all tables and data of internal database.
Do you have a user id as one of your dynamic list columns?
If so, you could probably use filters in url, as described here
Anyway, it would be helpful if you posted your DL query and URL.
Karolina
P.S. For displaying all tables (there are approx. 380 tables in the RS database) you may use any database management software or any IDE with good database suport
We have installed reportserver with the help of bitnami , by the connection url we come to know that (jdbc:mysql://127.0.0.1:3307/bitnami_reportserver ) ,the database is bitnami_reportserver , but we are not able to list any such database in our mysql server.
We were able to get into the internal database , we are trying to get a relationship between rs_user and rs_report , by which we could get the list of report a user has access to.
We are not getting such tables in which we could relate rs_users and rs_report.
Here is the script for script datasource with reports that users have access to.
You may then create a dynamic list based on this datasource and:
either add a parameter (userId) and use it in the report query
or
return all reports and users and then use filter in the url.
import net.datenwerke.rs.base.service.datasources.definitions.DatabaseDatasource;
import net.datenwerke.rs.base.service.reportengines.table.output.object.RSTableModel
import net.datenwerke.rs.base.service.reportengines.table.output.object.RSTableRow
import net.datenwerke.rs.base.service.reportengines.table.output.object.TableDefinition
import net.datenwerke.security.service.security.SecurityService;
import net.datenwerke.security.service.security.SecurityServiceSecuree;
import net.datenwerke.security.service.security.rights.Execute;
import net.datenwerke.security.service.security.rights.Read;
import net.datenwerke.security.service.security.rights.Right;
import net.datenwerke.security.service.usermanager.entities.User;
import net.datenwerke.rs.core.service.reportmanager.entities.reports.Report;
/**
* ScriptDatasource that returns all the reports users have access to
*/
/* get services */
SecurityService securityService = GLOBALS.getRsService(SecurityService.class);
/* prepare datasource definition: column names and data types */
TableDefinition tableDefinition = new TableDefinition(
['USER_ID', 'USER_NAME', 'REPORT_ID', 'REPORT_NAME', 'REPORT_DESC'],
[Long.class, String.class, Long.class, String.class, String.class]
);
def result = new RSTableModel(tableDefinition);
/* load all report entities and add them to the result object */
/* get users */
GLOBALS.getEntitiesByType(User.class).each{
User user = it
/* get user data */
def userId = user.getId()
def userName = user.getName()
/* get all reports */
GLOBALS.getEntitiesByType(Report.class).each{
Report report = it
/* report data: id, name, description */
def reportId = report.getId();
def reportName = report.getName();
def desc = report.getDescription();
/* check read and execute rights to reports */
def hasExecuteAccess = securityService.checkRights(user, report, SecurityServiceSecuree.class, Execute.class);
def hasReadAccess = securityService.checkRights(user, report, SecurityServiceSecuree.class, Read.class);
/* result row in the script datasource */
def resultLine = [userId, userName, reportId, reportName, desc];
/* adding only the reports users have rights to see and to execute */
if(hasExecuteAccess && hasReadAccess){
result.addDataRow(new RSTableRow(tableDefinition, resultLine.toArray()));
}
}
}
return result;
If you have a lot of users and reports, consider creating additional table in a database and periodically load users and reports to the table instead of using the script datasource.
We also want to retrieve the report list with Teamspace names, so that we can categorize the list (actually, some type of category field would be best) -
This query does what we are looking to do:
SELECT rs_user.username, rs_teamspace_member.*, rs_teamspace_2_member.teamspace_id, rs_teamspace.NAME_FIELD, rs_report.NAME_FIELD, rs_report.description, rs_report.uuid
FROM ((((rs_user INNER JOIN rs_teamspace_member ON rs_user.id = rs_teamspace_member.user_id) INNER JOIN rs_teamspace_2_member ON rs_teamspace_member.ENTITY_ID = rs_teamspace_2_member.members_id) INNER JOIN rs_teamspace ON rs_teamspace_2_member.teamspace_id = rs_teamspace.ENTITY_ID) INNER JOIN rs_report_mngr_node ON rs_user.id = rs_report_mngr_node.owner_id) INNER JOIN rs_report ON rs_report_mngr_node.ENTITY_ID = rs_report.id
WHERE (((rs_user.username)=“YOURUSERNAME”));
I’d appreciate any thoughts on how to construct a URL to bring back the teamspace and/or report category information.
We were able to execute reports using the script datasource , while running the report each time a new temporary table has been getting created for example “rs_tmptbl_1_1_0” , we are executing the reports using this table. Since they are temporary ,and gets deleted after certain period we are getting errors while executing the reports.
import net.datenwerke.rs.base.service.datasources.definitions.DatabaseDatasource;
import net.datenwerke.rs.base.service.reportengines.table.output.object.RSTableModel
import net.datenwerke.rs.base.service.reportengines.table.output.object.RSTableRow
import net.datenwerke.rs.base.service.reportengines.table.output.object.TableDefinition
import net.datenwerke.security.service.security.SecurityService;
import net.datenwerke.security.service.security.SecurityServiceSecuree;
import net.datenwerke.security.service.security.rights.Execute;
import net.datenwerke.security.service.security.rights.Read;
import net.datenwerke.security.service.security.rights.Right;
import net.datenwerke.security.service.usermanager.entities.User;
import net.datenwerke.rs.core.service.reportmanager.entities.reports.Report;
/**
* ScriptDatasource that returns all the reports users have access to
*/
/* get services */
SecurityService securityService = GLOBALS.getRsService(SecurityService.class);
/* prepare datasource definition: column names and data types */
TableDefinition tableDefinition = new TableDefinition(
['USER_ID', 'USER_NAME', 'REPORT_ID', 'REPORT_NAME', 'REPORT_DESC'],
[Long.class, String.class, Long.class, String.class, String.class]
);
def result = new RSTableModel(tableDefinition);
/* load all report entities and add them to the result object */
/* get users */
GLOBALS.getEntitiesByType(User.class).each{
User user = it
/* get user data */
def userId = user.getId()
def userName = user.getName()
/* get all reports */
GLOBALS.getEntitiesByType(Report.class).each{
Report report = it
/* report data: id, name, description */
def reportId = report.getId();
def reportName = report.getName();
def desc = report.getDescription();
/* check read and execute rights to reports */
def hasExecuteAccess = securityService.checkRights(user, report, SecurityServiceSecuree.class, Execute.class);
def hasReadAccess = securityService.checkRights(user, report, SecurityServiceSecuree.class, Read.class);
/* result row in the script datasource */
def resultLine = [userId, userName, reportId, reportName, desc];
/* adding only the reports users have rights to see and to execute */
if(hasExecuteAccess && hasReadAccess){
result.addDataRow(new RSTableRow(tableDefinition, resultLine.toArray()));
}
}
}
return result;
tmp tables will be deleted after a while (if their cache setting != -1), so you should not execute a query addressing the tmp table name.
There are two possibilities for this:
You can address the table name directly:
select * from $!{TMP_TABLENAME}
WHERE $X{IN, USER_ID, userid}
and REPORT_ID >= 100000
The resulting query:
select * from rs_tmptbl_1_1_0
WHERE ...
Address the basic query of this tmp-table:
select * from ($!{query}) myTmpTable
WHERE $X{IN, USER_ID, userid}
and REPORT_ID >= 100000
The resulting query:
select * from (SELECT * FROM rs_tmptbl_1_1_0) myTmpTable
WHERE ...