view plaincopy to clipboardprint?
1.
2.
package smartbi.sdk.service.demo;
3.
4.
import smartbi.sdk.ClientConnector;
5.
import smartbi.sdk.service.catalog.CatalogService;
6.
import smartbi.sdk.service.simplereport.Report;
7.
8.
import smartbi.sdk.service.simplereport.SimpleReportService;
9.
import smartbi.sdk.service.user.UserManagerService;
10.
import smartbi.user.IDepartment;
11.
import smartbi.sdk.RemoteException;
12.
13.
public class SDKDemo {
14.
public void conn() {
15.
String connectorURL = "http://localhost:8080/smartbi";
16.
ClientConnector conn = new ClientConnector(connectorURL);
17.
try {
18.
//第一次调用必须建立一个连接,后续调用则不必再建连接
19.
boolean ret = conn.open("admin", "manager");
20.
if (ret) {
21.
//资源目录树
22.
CatalogService catalogService = new CatalogService(conn);
23.
String elementId = "I
24.
String elementType = "SIMPLE_REPORT";
25.
boolean result = catalogService.isCatalogElementAccessible(elementId, elementType);
26.
System.out.println(result);
27.
28.
//灵活报表
29.
SimpleReportService simpleReportService = new SimpleReportService(conn);
30.
String reportId = "I
31.
Report report = simpleReportService.openReport(reportId);
32.
System.out.println(report.getCurrentReportName());
33.
34.
35.
36.
37.
//用户管理
38.
UserManagerService userManagerService = new UserManagerService(conn);
39.
String departmentId = "DEPARTMENT";
40.
IDepartment department = userManagerService.getDepartmentById(departmentId);
41.
System.out.println(department.getName());
42.
}
43.
} catch (RemoteException e) {
44.
e.printStackTrace();
45.
} finally {
46.
// 关闭应用连接器
47.
conn.close();
48.
}
49.
}
50.
public static void main(String[] args) {
51.
SDKDemo sdk = new SDKDemo();
52.
sdk.conn();
53.
}
54.
}