#1 2017-05-23 19:25:25

Guilherme
Member
Registered: 2017-01-09

Get the dashboards (and its dadgets) owned by an user

Hi guys,

This way I can list all the dashboards and all report from reportserver.

GLOBALS.getEntitiesByType(Dashboard.class).each{
    Dashboard dashboard = it;

    def dashbordName=dashboard.getName();

    GLOBALS.getEntitiesByType(Report.class).each{

        Report report = it

        def reportName = report.getName();
    }
}

Is there any way to get the dashboards (and its dadgets) owned by an user?

Offline

#2 2017-05-24 12:27:12

Rodion
Member
Registered: 2017-05-17

Re: Get the dashboards (and its dadgets) owned by an user

Hello Guilherme,
here is the code you need for your issue.
If you have still problems or an another question please feel free and ask.

Best regards,
Rodion

	import net.datenwerke.security.service.usermanager.entities.User;
	import net.datenwerke.security.service.authenticator.AuthenticatorService;
	import net.datenwerke.rs.dashboard.service.dashboard.entities.DashboardContainer;
	import net.datenwerke.rs.dashboard.service.dashboard.entities.Dashboard;
	import net.datenwerke.rs.dashboard.service.dashboard.entities.Dadget;
	import net.datenwerke.rs.dashboard.service.dashboard.DashboardService;


	import java.util.List;

	AuthenticatorService authenticatorService = GLOBALS.getInstance(AuthenticatorService.class); 
	def dashboardService = GLOBALS.getInstance(DashboardService.class);


		User user = authenticatorService.getCurrentUser();
		
		DashboardContainer dc = dashboardService.getDashboardFor(user);
		List<Dashboard> dashes = dc.getDashboards();
		
		for(Dashboard dash : dashes) {
			tout.println(dash.getName() + " : " + dash.getId());
			for(Dadget dadget : dash.getDadgets() ) {
				tout.println(dadget.getId() + " : " + dadget.toString());
			}

		}

Offline

#3 2017-05-24 18:54:56

Guilherme
Member
Registered: 2017-01-09

Re: Get the dashboards (and its dadgets) owned by an user

Rodion wrote:

Hello Guilherme,
here is the code you need for your issue.
If you have still problems or an another question please feel free and ask.

Best regards,
Rodion

	import net.datenwerke.security.service.usermanager.entities.User;
	import net.datenwerke.security.service.authenticator.AuthenticatorService;
	import net.datenwerke.rs.dashboard.service.dashboard.entities.DashboardContainer;
	import net.datenwerke.rs.dashboard.service.dashboard.entities.Dashboard;
	import net.datenwerke.rs.dashboard.service.dashboard.entities.Dadget;
	import net.datenwerke.rs.dashboard.service.dashboard.DashboardService;


	import java.util.List;

	AuthenticatorService authenticatorService = GLOBALS.getInstance(AuthenticatorService.class); 
	def dashboardService = GLOBALS.getInstance(DashboardService.class);


		User user = authenticatorService.getCurrentUser();
		
		DashboardContainer dc = dashboardService.getDashboardFor(user);
		List<Dashboard> dashes = dc.getDashboards();
		
		for(Dashboard dash : dashes) {
			tout.println(dash.getName() + " : " + dash.getId());
			for(Dadget dadget : dash.getDadgets() ) {
				tout.println(dadget.getId() + " : " + dadget.toString());
			}

		}

Thank you very much. Worked perfectly

Offline

Board footer

Powered by FluxBB