Report Engine Java Developer Guide                    BusinessObjects Enterprise XI R2                                 Win...
Copyright      If you find any problems with this documentation, please report them to Business Objects               S.A....
ContentsChapter 1   Introduction                                                                                          ...
Chapter 6   Drilling in Web Intelligence Reports                                                                      77  ...
ExamplesReferencing BusinessObjects Enterprise SDK 17Instantiating the ISessionMgr class 18HTML form for gathering a user’...
ExamplesDynamically creating input names 66Handling many, simple prompts 66Displaying a simple list of values 68Handling m...
ReportEngine Developer GuideIntroduction                               chapter
1   Introduction    About this guide    About this guide                       This guide describes the processes and proc...
ReportEngine Developer GuideIntroduction toReportEngine SDK                               chapter
1   Introduction to ReportEngine SDK    Overview    Overview                    ReportEngine SDK consists of a number of J...
Introduction to ReportEngine SDK                                                           Migrating to BusinessObjects XI...
1   Introduction to ReportEngine SDK    A typical ReportEngine SDK application    Viewing reports                     An a...
Introduction to ReportEngine SDK                                                       A typical ReportEngine SDK applicat...
1   Introduction to ReportEngine SDK    Installing ReportEngine SDK    Installing ReportEngine SDK    Installing Business ...
ReportEngine Developer GuideApplication Essentials                               chapter
2   Application Essentials    Overview    Overview                     Before providing viewing, reporting, and editing fu...
Application Essentials                                                                           “Hello World”   2        ...
2   Application Essentials    BusinessObjects Enterprise sessions                    You need to include this line in ever...
Application Essentials                                                       BusinessObjects Enterprise sessions    2Getti...
2   Application Essentials    BusinessObjects Enterprise sessions                    •    Enterprise Mode                 ...
Application Essentials                                                                  Implementing “Hello World”    2Ret...
2   Application Essentials    Implementing “Hello World”                             index.jsp                          lo...
Application Essentials                                                           Implementing “Hello World”    2          ...
2   Application Essentials    User preferences                             }                             catch( SDKExcepti...
Application Essentials                                                                      User preferences      2Accessi...
2   Application Essentials    User preferences                      Variable Name                                Possible ...
Application Essentials                                                                           User preferences     2   ...
2   Application Essentials    User preferences                                     IUser user = (IUser)users.iterator().ne...
Application Essentials                                                                   Exception handling     2       4....
2   Application Essentials    Reporting essentials    Reporting essentials                     All applications that view,...
Application Essentials                                                           Reporting essentials    2Once instantiate...
2   Application Essentials    Reporting essentials                                 ReportEngineType.FC_ReportEngine);     ...
ReportEngine Developer GuideDocument Management                               chapter
3   Document Management    Overview    Overview                    Two key parts of a typical ReportEngine SDK application...
Document Management                                                              Document state: storage tokens   3Documen...
3   Document Management    Document state: storage tokens                    You can retrieve the maximum storage stack si...
Document Management                                            Document state: storage tokens   3  e.Temporary files      ...
3   Document Management    Organizing documents in categories and folders                     Table 3-1 Storage token life...
Document Management                                                Organizing documents in categories and folders   3     ...
3   Document Management    Organizing documents in categories and folders                     InfoView Advanced Right     ...
Document Management                                              Organizing documents in categories and folders     3     ...
3   Document Management    Organizing documents in categories and folders                                        + “ CI_IN...
Document Management                               Organizing documents in categories and folders   3Example: Retrieve a us...
3   Document Management    Organizing documents in categories and folders                     Note: See “Displaying a docu...
Document Management                                               Organizing documents in categories and folders     3Movi...
3   Document Management    Working with documents                         String query;                         IInfoObjec...
Document Management                                                                    Working with documents     3       ...
3   Document Management    Working with documents                    This function is placed either at the head of the lis...
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Resdk java custo_webi_dg
Upcoming SlideShare
Loading in …5
×

Resdk java custo_webi_dg

1,004
-1

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,004
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Resdk java custo_webi_dg

  1. 1. Report Engine Java Developer Guide BusinessObjects Enterprise XI R2 Windows and UNIX
  2. 2. Copyright If you find any problems with this documentation, please report them to Business Objects S.A. in writing at documentation@businessobjects.com. Copyright © Business Objects S.A. 2004. All rights reserved.Trademarks Business Objects, the Business Objects logo, Crystal Reports, and Crystal Enterprise are trademarks or registered trademarks of Business Objects SA or its affiliated companies in the United States and other countries. All other names mentioned herein may be trademarks of their respective owners.Patents Business Objects owns the following U.S. patents, which may cover products that are offered and sold by Business Objects: 5,555,403, 6,247,008 B1, 6,578,027 B2, 6,490,593 and 6,289,352.Third-party Business Objects products in this release may contain redistributions of software licensedcontributors from third-party contributors. Some of these individual components may also be available under alternative licenses. A partial listing of third-party contributors that have requested or permitted acknowledgments, as well as required notices, can be found at: http://www.businessobjects.com/thirdparty
  3. 3. ContentsChapter 1 Introduction 7Chapter 2 Introduction to ReportEngine SDK 9 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Packages for customizing BusinessObjects Enterprise XI R2 . . . . . . . . . . 10 Migrating to BusinessObjects XI R2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 A typical ReportEngine SDK application . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Installing ReportEngine SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Chapter 3 Application Essentials 15 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 “Hello World” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 BusinessObjects Enterprise sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Implementing “Hello World” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 User preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Exception handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Reporting essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Chapter 4 Document Management 33 Document types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Document state: storage tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Organizing documents in categories and folders . . . . . . . . . . . . . . . . . . . . 38 Working with documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Document properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Chapter 5 Viewing Reports 59 Viewing reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Handling prompts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Displaying a report map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Developing with Web Intelligence Report Engine SDK 3
  4. 4. Chapter 6 Drilling in Web Intelligence Reports 77 Introduction to drilling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Drilling in reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Chapter 7 Building and Editing Data Providers 89 Data providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Building a data provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Executing queries and retrieving the data . . . . . . . . . . . . . . . . . . . . . . . . 100 Chapter 8 Formatting Reports 101 Creating and editing the document structure . . . . . . . . . . . . . . . . . . . . . . 102 Creating and editing cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Page layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115Appendix A Working with Recordsets 117 Anatomy of a recordset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118Appendix B Business Objects Information Resources 121 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Customer support, consulting and training . . . . . . . . . . . . . . . . . . . . . . . . 123 Useful addresses at a glance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124Appendix C Logging with ReportEngine SDK Overview 127 Logging Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Activating logging by editing the configuration files . . . . . . . . . . . . . . . . . 129Appendix D Configuring ReportEngine using webi.properties 135 Developing with Web Intelligence Report Engine SDK 4
  5. 5. ExamplesReferencing BusinessObjects Enterprise SDK 17Instantiating the ISessionMgr class 18HTML form for gathering a user’s login information 19Establishing a session 20Printing a user’s preferences 26Setting a user’s report panel preference to Java 27Adding a new preference to a user’s profile 29Referencing the ReportEngine SDK 30Instantiating a ReportEngine an IReportEngine object 31Instantiating a ReportEngine objects depending on file type 31Storage token life cycle 36how to check that a user has the right to create categories 40Traversing the category tree recursively 41Retrieve a user’s Inbox and Favorites folder IDs 43Creating a new folder or category 44Moving and renaming categories or folders 45Retrieve the properties for a category 45Displaying a document list 47Save a document 48Scheduling a document 49Retrieve the list of groups to which a user belongs 51Sending a document to folders and categories 52Send a document to the inbox of groups of users 54Getting the name of a document 56Adding a property to a document 57Viewing all the reports in a Web Intelligence document 61Viewing a report in a Web Intelligence document 62Viewing a report in Microsoft Excel format 63Handling a single, simple prompt 64 Developing with Web Intelligence Report Engine SDK 5
  6. 6. ExamplesDynamically creating input names 66Handling many, simple prompts 66Displaying a simple list of values 68Handling multivalued prompts 70Handling multicolumn lists of values 70Order of filling a hierarchy of nested prompts 72Handling nested prompts 72Refreshing a list of values containing nested prompts 73Traversing the report map for a Web Intelligence document 74Defining the query string parameters 82Setting the drill path 84Displaying the drilled report 86Launching the Java Report Panel 94Building a data provider 96Creating a simple condition 98Structure of a complex condition 99Including a prompt in a condition 99Creating a blank document 102Creating a document structure 105Creating an attachment 107Editing the sections of a report 107Building a report: adding expressions to axes 110Accessing the values in a recordset 1196 Developing with Web Intelligence Report Engine SDK
  7. 7. ReportEngine Developer GuideIntroduction chapter
  8. 8. 1 Introduction About this guide About this guide This guide describes the processes and procedures for creating web applications using BusinessObjects Enterprise SDK and the ReportEngine SDK package. Who should read this guide To use the BusinessObjects Enterprise SDK and ReportEngine SDKs you need a working knowledge of the concepts of distributed computing systems, HTTP server technology, and JSP development. You also need a basic knowledge of the products in the BusinessObjects product line. Familiarity with BusinessObjects Enterprise is assumed. Business Objects information resources For more information and assistance, see “Business Objects Information Resources” on page 121. This appendix describes the Business Objects documentation, customer support, training, and consulting services, with links to online resources. 8 ReportEngine Developer Guide
  9. 9. ReportEngine Developer GuideIntroduction toReportEngine SDK chapter
  10. 10. 1 Introduction to ReportEngine SDK Overview Overview ReportEngine SDK consists of a number of Java packages. Typically, every application that uses these packages must implement the same kinds of workflows. This chapter briefly introduces ReportEngine SDK and the workflows a typical application needs to implement. Packages for customizing BusinessObjects Enterprise XI R2 There are two packages for customizing BusinessObjects Enterprise: • BusinessObjects Enterprise SDK The "platform package," provides platform functions of the Business Objects servers, and document scheduling. • ReportEngine SDK This package plugs into Business Objects Enterprise SDK. It provides the functions of the Web Intelligence and Desktop Intelligence Report Engines. BusinessObjects Enterprise SDK ReportEngine SDK Crystal Enterprise Documents Web Intelligence documents View View Refresh Refresh Analyze Analyze Create† Format† Platform functions Manage sessions and users Desktop Intelligence documents View Manage documents and categories Refresh List universes and folders Schedule documents Analyze† Metadata (universe) Explore† †Web Intelligence Documents for REBean Only BusinessObjects Enterprise SDK is called the platform package because it exposes the platform functions of the Business Objects servers. ReportEngine SDK exposes the functions of the Desktop Intelligence and Web Intelligence Report Engines. 10 ReportEngine Developer Guide
  11. 11. Introduction to ReportEngine SDK Migrating to BusinessObjects XI R2 1Migrating to BusinessObjects XI R2 If you already have a business intelligence solution based on previous versions of ReportEngine SDK you might need to migrate your solution. Migration affects the following areas: • referencing components of the BusinessObjects Enterprise platform • controlling user sessions • listing and navigating through folders and categories • managing and viewing documents • handling security commands • using the various dictionaries • deploying your application For more information on migration issues see the Migrating Business Objects Customized Applications to BusinessObjects XI R2 guide.A typical ReportEngine SDK application Not all applications that use ReportEngine SDK have the same features, but all typically provide features for listing and viewing documents contained in the BusinessObjects Enterprise Central Management System (CMS). A more sophisticated application could also include features such as document creation and report formatting.Application essentials Every application that uses ReportEngine SDK needs to perform common tasks such as importing the appropriate packages, and creating and managing the user’s BusinessObjects Enterprise session (login). Every application should also take user profiles into account and ensure that errors are handled properly. See “User rights for categories and folders” on page 39 and “User preferences” on page 24.Document management Document management features include the ability to list the documents that the current user can view, and, depending on the user’s rights, allowing the user to browse and manage categories and folders used to organize the documents. Document management can also include features such as saving, and scheduling documents. ReportEngine Developer Guide 11
  12. 12. 1 Introduction to ReportEngine SDK A typical ReportEngine SDK application Viewing reports An application that provides for viewing documents can display them using the default DHTML format. It is easy to extend this to handle documents that contain prompts, and to provide drilling functions. These extended functions have to be handled when a document is refreshed. How you provide viewing features depends on the type of document opened. The report-viewing part of the application should include routines for viewing reports in the following document types: • Web Intelligence (*.wid) • Crystal Reports documents • Desktop Intelligence (*.rep) • other document types, for example Adobe® Acrobat®, Microsoft® Excel or XML format. See “Viewing reports” on page 60 for a full listing of available formats. Creating documents: building and editing data providers To give users the ability to create documents and generate their own reports, you need to provide them with tools to build and edit data providers. A data provider encapsulates information about an information source and the query that defines the information retrieved. Creating a document essentially means creating a data provider. You can use the same classes to provide different features for editing a query, such as adding conditions and changing the scope of analysis. Formatting documents Formatting documents involves creating and positioning the elements of a report (blocks, sections, and cells) in the appropriate report structure. Using ReportEngine SDK you can build reports from scratch. ReportEngine SDK includes classes for controlling report page decoration (fonts, colors, headers, and footers) and layout. 12 ReportEngine Developer Guide
  13. 13. Introduction to ReportEngine SDK A typical ReportEngine SDK application 1Open document workflow The following diagram shows the workflow for opening a document. Client Report Engine pages SDK open a document check for prompts fill prompts until there are none left unfilled fill document toolbar get the report map fill report map get the report in the requested format fill rendering areaRefresh document workflow The following diagram shows the workflow for refreshing a document. Client Report Engine pages SDK <open document workflow> update document toolbar refresh the report refresh check for prompts fill prompts until there are none left unfilled set the position fill document toolbar get the report map fill report map fill rendering get the report in the requested format area ReportEngine Developer Guide 13
  14. 14. 1 Introduction to ReportEngine SDK Installing ReportEngine SDK Installing ReportEngine SDK Installing Business Objects components ReportEngine SDK components are added to the development machine when BusinessObjects Enterprise XI R2 is installed on the system. To develop a custom ReportEngine SDK application it is necessary to connect to a running BusinessObjects Enterprise server, however, the development environment does not have to be on the same machine as the BusinessObjects Enterprise Server. Install ReportEngine SDK components on a development machine by: 1. Run BusinessObjects Enterprise XI R2 installer. 2. Click Next on the BusinessObjects Enterprise XI R2 Installation Wizard panel. 3. Select the I accept the License Agreement button in the License Agreement panel. 4. Click Next. 5. Select the Perform Server Installation 6. Click Next. 7. Enter your corporate information and keycode. 8. Click Next. 9. Specify the destination folder in the Destination folder text box. 10. Click Next. 11. Select the Custom button 12. Click Next. 13. Deselect all BusinessObjects Enterprise Features. 14. Enable the SDK products feature. To install J2EE components only, deselect the SDK products feature and install the Java features sub-component. 15. Click Next. 16. Click Next. This installs all components necessary to develop custom Business Objects applications; Java libraries are installed and registered correctly. 14 ReportEngine Developer Guide
  15. 15. ReportEngine Developer GuideApplication Essentials chapter
  16. 16. 2 Application Essentials Overview Overview Before providing viewing, reporting, and editing functions ReportEngine SDK applications need to perform basic tasks, such as referencing the appropriate package and creating a BusinessObjects Enterprise session for the user. This chapter covers the essential concepts and tasks that all applications that customize BusinessObjects Enterprise must use. “Hello World” The simplest application you can write with BusinessObjects Enterprise SDK is one that creates a BusinessObjects Enterprise session, that is, provides log in and log out functions. This is the basis for building much more sophisticated applications that provide, for example, functions to list, view and create documents, and attach them to hierarchical categories. get name and open a password Name = “janderson” session from user Pass = “*******” close session display “Hello World” and a logout link Table 2-1 Application for logging in and out of BusinessObjects Enterprise This application gathers login details from the user, and sends the details to another page which uses BusinessObjects Enterprise SDK to try to open a BusinessObjects Enterprise session. If the session is successfully created, the application displays a “Hello World” message and the option to log out. When 16 ReportEngine Developer Guide
  17. 17. Application Essentials “Hello World” 2 the user clicks the logout link, the application closes the user’s BusinessObjects Enterprise session with BusinessObjects Enterprise SDK and displays the first page again. Each page that uses BusinessObjects Enterprise SDK must: • reference BusinessObjects Enterprise SDK • create or reference an IEnterpriseSession object • create or reference an IInfoStore object See “Implementing “Hello World”” on page 21 for code that implements this application.Referencing BusinessObjects Enterprise SDK Referencing BusinessObjects Enterprise SDK gives your web application access to the BusinessObjects Enterprise platform functions exposed by the SDK. Note: You must use BusinessObjects Enterprise SDK prior to using ReportEngine SDK. To develop a Java application Business Objects recomments that you add all libraries found in the <BusinessObjectsHome>common3.5javalib into the WEB-INFlib directory of your JSP project. Referencing BusinessObjects Enterprise SDK To reference BusinessObjects Enterprise SDK, import the BusinessObjects Enterprise packages. Example: Referencing BusinessObjects Enterprise SDK To import BusinessObjects Enterprise SDK packages, add the following line to pages that use the packages. <% page import="com.crystaldecisions.sdk.framework.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.occa.pluginmgr.*, com.crystaldecisions.sdk.plugin.*, com.crystaldecisions.sdk.plugin.desktop.server.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.plugin.destination.smtp.*, com.crystaldecisions.sdk.plugin.destination.managed.*, com.crystaldecisions.sdk.exception.SDKException, com.crystaldecisions.sdk.occa.security.*, com.crystaldecisions.sdk.plugin.desktop.user.*, com.crystaldecisions.sdk.properties.*, com.businessobjects.sdk.plugin.desktop.webintelligence.CeWeb IntelligenceRightID"%> ReportEngine Developer Guide 17
  18. 18. 2 Application Essentials BusinessObjects Enterprise sessions You need to include this line in every page that uses BusinessObjects Enterprise SDK. Creating an new user session In BusinessObjects Enterprise SDK the ISessionMgr lets a user to log in to the BusinessObjects Enterprise server and create a session. Session information is stored in the IEnterpriseSession object returned by this method. Every session has a corresponding IEnterpriseSession object which is used to access ReportEngine SDK. Creating an ISessionMgr object To create a user session for an application that uses BusinessObjects Enterprise SDK, you must first instantiate a new ISessionMgr object. Example: Instantiating the ISessionMgr class ISessionMgr mySessionMgr = CrystalEnterprise.getSessionMgr(); BusinessObjects Enterprise sessions Every user of InfoView requires a BusinessObjects Enterprise session before entering and using the system. The BusinessObjects Enterprise session represents the user’s current interaction with BusinessObjects Enterprise. A user’s BusinessObjects Enterprise session provides access to the user’s details, and objects that are subject to the rights of the user, for example, the list of universes that the current user can use to create documents. You must create a BusinessObjects Enterprise session for the user: it is the key part of the log in and authentication process. To create a session for a user: 1. Get the user’s login information: • name • password • the Central Management System (CMS) the user wishes to log into • authentication type (Enterprise, LDAP, winAD) 2. Establish a valid BusinessObjects Enterprise session for the user. 18 ReportEngine Developer Guide
  19. 19. Application Essentials BusinessObjects Enterprise sessions 2Getting login information The simplest way to get a user’s login information is to use an HTML form into which the user enters a name and a password. When the user submits the form, the values for the fields are passed via the query string to a page that processes the values. Example: HTML form for gathering a user’s login information <FORM name="LoginForm" action="Login.jsp" method="POST"> <TABLE><TR> <TD>Name:</TD> <TD><input name="Name"></TD> </TR> <TR> <TD>Password:</TD> <TD><input type="password" name="pass"></TD> </TR> <TR> <TD>Central Management System:</TD> <TD><input name="CMS"></TD> </TR> <TR> <TD>Authentication:</TD> <TD> <select name=auth> <option value=secEnterprise>Enterprise</option> <option value=secLDAP>LDAP</option> <option value=secLDAP>WinAD</option> </select> </TD> </TR> <TR> <TD><input id=submit1 name=submit1 type=submit value="Login"></TD> </TR></TABLE> </FORM> When the user enters login information and clicks the Login button, the values for the fields are passed to Login.jsp in the query string parameters Name and Pass. Since the method attribute of the form is set to POST, these values will not be visible in the URL. Authentication The way you monitor passwords depends on how BusinessObjects Enterprise passwords have been set up by the BusinessObjects Enterprise system administrator. There are two settings available to the system administrator which you can use as the basis for the login procedure in your own application: ReportEngine Developer Guide 19
  20. 20. 2 Application Essentials BusinessObjects Enterprise sessions • Enterprise Mode This mode requires from the user to submit a user name and password which are unique to BusinessObjects Enterprise (and may be different from their network name/password combination). • LDAP Mode This mode requires the user to submit a user name and password which are stored on a corporate LDAP server. • WinAD Mode This mode requires the user to submit a user name and password which are stored on a Windows Authentication Server. For more information on authentication in Windows, see the BusinessObjects Enterprise XI R2 Administrator’s Guide. Establishing a valid BusinessObjects Enterprise user’s session To establish a valid BusinessObjects Enterprise user’s session: 1. Try to create an IEnterpriseSession object for the user. 2. If the IEnterpriseSession object is valid, store this object in the user’s session attributes. 3. Create an IInfoStore object and store in the user’s session attributes. These steps are usually done together and are normally followed by redirecting the user to an appropriate page: a welcome page or back to the login page, depending on the validity of the session. Example: Establishing a session The following code fragment illustrates how to establish a BusinessObjects Enterprise session. ISessionMgr mySessionMgr = CrystalEnterprise.getSessionMgr(); IEnterpriseSession eSession; try { eSession = mySessionMgr.logon(name, password, CMS, auth); if (eSession != null){ session.setAttribute("EnterpriseSession", enterpriseSession); IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore"); session.setAttribute("InfoStore", iStore); } catch (SDKException sdkEx){ ; } 20 ReportEngine Developer Guide
  21. 21. Application Essentials Implementing “Hello World” 2Retrieving a BusinessObjects Enterprise session Once you have established a valid BusinessObjects Enterprise session for the user, you can retrieve it from the user’s session attributes.Closing a BusinessObjects Enterprise session To close a session, that is, log a user out of BusinessObjects Enterprise, use IEnterpriseSession.logoff. Closing a session is important: • It frees the resources held by the user’s BusinessObjects Enterprise session. • It forces other users to start their own sessions rather than just taking over an existing session. Note: See “logout.jsp” on page 24 for an example of how to close a BusinessObjects Enterprise session.BusinessObjects Enterprise session time-out The time-out of a Business Objects Enterprise SDK Session is the life time of the IEnterpriseSession object; the session is destroyed when the object is destroyed. Business Objects recommends that you store the users IEnterpriseSession object in the application server session objects, in this way the user session have the exact same time out as the Application server session.Implementing “Hello World” Following is an implementation of the Hello World application discussed on page 16. To run this application you need to have installed BusinessObjects Enterprise and established a Business Objects Central Management System. For more information, see the Installation and Configuration Guide for Windows or UNIX. ReportEngine Developer Guide 21
  22. 22. 2 Application Essentials Implementing “Hello World” index.jsp login.jsp Name = “janderson” Pass = “********” logout.jsp home.html In this implementation index.jsp displays a form which collects the user’s login information which is passed to login.jsp. Login.jsp attempts to create a session and IInfoObject for the user. If the operation is successful, login.jsp redirects to home.html which displays the “Hello World” message and a link to logout.jsp. When the user clicks the logout link, logout.jsp closes the session and displays index.jsp again. index.jsp <html> <body> <h1>Create a BusinessObjects Enterprise Session</h1> <form name="LoginForm" action="login.jsp" method="POST"> <table><tr> <td>Name: </td> <td><input name="Name"></td> </tr> <tr> <td>Password: </td> <td><input type="password" name="Pass"></td> </tr> <TR> <TD>Crystal Management System:</TD> <TD><input name="CMS"></TD> </TR> <TR> <TD>Authentication:</TD> <TD> <select name=auth> <option value=secEnterprise>Enterprise</ option> <option value=secLDAP>LDAP</option> </select> </TD> 22 ReportEngine Developer Guide
  23. 23. Application Essentials Implementing “Hello World” 2 </TR> <tr> <td><input id=s1 name=s1 type=submit value="Login"></ td> </tr></table> </form> </body> </html>login.jsp This page is opened when the user clicks Login in the form LoginForm described on page 19. The user name and password used for the login are passed from the HTML form in the query string parameters Name and Pass. <%@ page import="com.crystaldecisions.sdk.framework.CrystalEnterp rise" %> <%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSe ssion" %> <%@ page import="com.crystaldecisions.sdk.framework.ISessionMgr" %> <%@ page import="com.crystaldecisions.sdk.exception.SDKException" %> <% String CMS = request.getParameter("cms"); String userID = request.getParameter("user"); String password = request.getParameter("password"); String auth = request.getParameter("auth"); if ( CMS == null) CMS = ""; if ( userID == null) userID = ""; if ( password == null) password = ""; if ( auth == null) auth = ""; IEnterpriseSession enterpriseSession; try { ISessionMgr mySessionMgr = CrystalEnterprise.getSessionMgr(); enterpriseSession = mySessionMgr.logon(userID, password, CMS,auth); if (enterpriseSession != null) {//Create and store useful objects for the session. session.setAttribute("EnterpriseSession", enterpriseSession); IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore"); session.setAttribute("InfoStore", iStore); response.sendRedirect("home.html"); } else response.sendRedirect("index.jsp"); ReportEngine Developer Guide 23
  24. 24. 2 Application Essentials User preferences } catch( SDKException mySDKExept) { response.sendRedirect("index.jsp"); } %> home.html <html> <body> <h1>Create a Web Intelligence Session: Home Page</h1> <p>Hello World!</p> <a href="logout.jsp">Log out</a> </body> </html> logout.jsp <%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSe ssion" %> <% IEnterpriseSession enterpriseSession; enterpriseSession =(IEnterpriseSession) session.getAttribute("EnterpriseSession"); session.removeAttribute("EnterpriseSession"); if(enterpriseSession != null) { enterpriseSession.logoff(); enterpriseSession = null; } %> User preferences Users can set their InfoView and ReportEngine viewing options using the Preferences page in InfoView or BusinessObjects Enterprise SDK. When designing a ReportEngine SDK application you should take this into account. For example, if the user wants to use the Java version of the Report Panel for creating and editing documents, then you need to design your application so that it can display the Java Report Panel rather than the DHTML Report Panel. 24 ReportEngine Developer Guide
  25. 25. Application Essentials User preferences 2Accessing InfoView user preferences With BusinessObjects Enterprise SDK you can get, set and add new preferences in a user’s profile. Standard preferences and possible settings are: BusinessObjects Enterprise user preference variables, values and meaning. Variable Name Possible Meaning Values webi_view P View documents in PDF format. I View Documents in Interactive format. H View Documents in DHTML format. (default) webi_panel java Create documents using the Java Report Panel. (default) html Create documents using the HTML Report Panel. DOCUMENT_WIStartNewDrill duplicate Start the drill action in a duplicate report. existing Start the Drill action in the current report. (default) DOCUMENT_WIPromptDrillOutScope N Prompt if drill requires additional data. (default) Y Do not prompt if Drill requires additional data. DOCUMENT_WISyncDrillBlocks N Synchronize Drill on report blocks. (default) Y Do not Synchronize Drill on report blocks. ReportEngine Developer Guide 25
  26. 26. 2 Application Essentials User preferences Variable Name Possible Meaning Values DOCUMENT_WIDrillBar N Show the Drill bar. Y Hide the Drill bar. (default) Note: other applications may have their own user settings which are stored in the user profile. For more information see “Adding custom options to a user’s profile” on page 28. Getting a user’s InfoView preferences To read the value of a user’s option: 1. Get the current user’s IUser object using an IInfoStore query. 2. Get the "desktopsettings" profile string. 3. Convert the profile string to a Map for easy manipulation and printing. Example: Printing a user’s preferences The following code functions show how to retrieve a user’s BusinessObjects Enterprise preferences and print them to an HTML response stream. <%! //Return a string containing a user’s Web Intelligence Preferences String getWebiPrefs(IInfoStore iStore, int uId){ String prefs = ""; String sQuery = "SELECT SI_ID, SI_NAME, SI_DATA FROM” + “ CI_SYSTEMOBJECTS WHERE SI_ID = " + uId + ""; IInfoObjects users = null; try{ users = iStore.query(sQuery); if (users.size() > 0){ IUser user = (IUser)users.iterator().next(); prefs = user.getProfileString("desktopsettings"); } }catch(SDKException sEx){ return ““; } return prefs; } //Convert a String of preferences to a Map Map webiPrefsToMap(String prefs){ StringTokenizer st = new StringTokenizer (prefs, "&"); Map webiPrefs = null; while (st.hasMoreTokens()) { String s2 = st.nextToken(); StringTokenizer st2 = new StringTokenizer (s2, "="); if (st2.countTokens() == 2) 26 ReportEngine Developer Guide
  27. 27. Application Essentials User preferences 2 webiPrefs.put(st2.nextToken(), st2.nextToken()); } return webiPrefs; } %> The following code fragment shows how to use the functions declared above to print a user’s BusinessObjects Enterprise preferences to an HTML stream. <% int userID = myIEnterpriseSession.getUserInfo().getUserID(); PrintWriter myWriter = response.getWriter(); String prefs = getWebiPrefs(myIInfoStore, userID); Map prefsMap = webiPrefsToMap(prefs); if (prefsMap != null){ Iterator itr = prefsMap.entrySet().iterator(); while(itr.hasNext()) { Map.Entry current = (Map.Entry)itr.next(); myWriter.print ( current.getKey() + "=" + current.getValue() + "<br>"); } } %>Setting an option in a user profile To set an option: 1. Get a user’s preferences. 2. Update a standard option in the Map continuing the user preferences. 3. Convert the Map to a String. 4. Update the user profile with IInfoStore.commit. Example: Setting a user’s report panel preference to Java The following code functions enables a user’s profile to be updated to use the Java Report Panel. <%! //Update the user’s Web Intelligence preferences. void setWebiPrefs(IInfoStore iStore, String prefs, int uId) { String sQuery = "SELECT SI_ID, SI_NAME, SI_DATA FROM CI_SYSTEMOBJECTS WHERE SI_ID = " + uId + ""; IInfoObjects users = null; try{ users = iStore.query(sQuery); if (users.size() > 0){ ReportEngine Developer Guide 27
  28. 28. 2 Application Essentials User preferences IUser user = (IUser)users.iterator().next(); user.setProfileString("desktopsettings", prefs); iStore.commit(users); } }catch(SDKException sEx){ ; } } //Convert a preferences Map to a string String webiPrefsToSting(Map wPrefs){ StringBuffer sbWebiPrefs = new StringBuffer(); Iterator itr = wPrefs.entrySet().iterator(); while(itr.hasNext()) { Map.Entry current = (Map.Entry)itr.next(); if(sbWebiPrefs.length() != 0) sbWebiPrefs.append("&"); sbWebiPrefs.append(current.getKey()); sbWebiPrefs.append("="); sbWebiPrefs.append(current.getValue()); } return sbWebiPrefs.toString(); } %> The following code fragment shows how to use the functions declared above to update a user’s Web Intelligence preferences. <% //Update a user’s Web Intelligence preferences int userID = myIEnterpriseSession.getUserInfo().getUserID(); String prefs = getWebiPrefs(myIInfoStore, userID); Map prefsMap = webiPrefsToMap(prefs); prefsMap.put( "webi_panel", "java"); setWebiPrefs(iStore, webiPrefsToSting(prefsMap), userID); %> Note: The functions getWebiPrefs and webiPrefsToMap are declared in the example “Printing a user’s preferences” on page 26 Adding custom options to a user’s profile To add custom options to a user’s profile: 1. Get a user’s preferences. 2. Set the custom option with Map.put. When you set an option that does not exist in the user profile, Map.put creates a new option and sets it to the value you specify. 3. Convert the Map to a String. 28 ReportEngine Developer Guide
  29. 29. Application Essentials Exception handling 2 4. Update the user profile with IInfoStore.commit. Example: Adding a new preference to a user’s profile The following code fragment sets a custom preference. <% //Add a custom Web Intelligence preference using functions defined in the previous examples int userID = myIEnterpriseSession.getUserInfo().getUserID(); String prefs = getWebiPrefs(myIInfoStore, userID); Map prefsMap = webiPrefsToMap(prefs); prefsMap.put( "MyPreference", "tea"); setWebiPrefs(iStore, webiPrefsToSting(prefsMap), userID); %> Note: The functions getWebiPrefs and webiPrefsToMap are declared in the example “Printing a user’s preferences” on page 26.Exception handling BusinessObjects Enterprise SDK generates exceptions of the type REException. Depending on the cause of the exception, ReportEngine SDK generates exceptions of the following type: • CommunicationException • ConfigurationException • CustomSortException • DSObjectSynchroException • FilterConditionException • NotImplementedException Exceptions and their descriptions are listed in the online reference documentation. Note: All exception classes (above) are subclasses of the REException class, Business Objects recommends using the REException.getCode when testing code. Note: You can return localized error messages message by calling REException.getLocalizedMessage. ReportEngine Developer Guide 29
  30. 30. 2 Application Essentials Reporting essentials Reporting essentials All applications that view, edit or format Web Intelligence and Desktop Intelligence documents need to: • reference ReportEngine SDK • retrieve the ReportEngines service • retrieve the ReportEngine instance This links the ReportEngine and platform packages. • close the ReportEngines object Note: You use Report Engine SDK to: • View, refresh, fill prompt, drill, edit query and format Web Intelligence documents. • View refresh, fill prompt Desktop Intelligence documents. Referencing ReportEngine SDK Referencing the ReportEngine packages gives your web application access to the ReportEngine SDK functions. ReportEngine SDK allows users to work with both Web Intelligence and Desktop Intelligence documents. Use the ReportEngines factory object to retrieve the ReportEngine instance necessary to open the document type required. If the web application uses J2EE it must reference REBean. Example: Referencing the ReportEngine SDK To import the REBean package, add the following line to JSP pages that use REBean. <%@ page import= "com.businessobjects.rebean.wi.*" %> You need to include this line in every JSP page that uses REBean classes. Creating a ReportEngine object To create a ReportEngine object for an application that uses ReportEngine SDK, retrieve the ReportEngines object from the user’s IEnterpriseSession. Using the ReportEngines object you can retrieve a ReportEngine instance to open either Web Intelligence or Desktop Intelligence documents. 30 ReportEngine Developer Guide
  31. 31. Application Essentials Reporting essentials 2Once instantiated, manipulation of a ReportEngine instance is essentially thesame, regardless of whether the current user has opened a Web Intelligenceor Desktop Intelligence document. This eliminates the need for repeatedconditional statements to check the document type and allows simpler, morestreamlined code to be written.Example: Instantiating a ReportEngine an IReportEngine objectTo instantiate the ReportEngine object, add the following lines to one pageof the web application that uses the reporting features of the ReportEngineSDK.ISessionMgr mySessionMgr = CrystalEnterprise.getSessionMgr();enterpriseSession = mySessionMgr.logon(userID, password, CMS,auth);if (enterpriseSession != null){ ILogonTokenMgr iLManager = enterpriseSession.getLogonTokenMgr() ; ReportEngines repEngines = (ReportEngines) enterpriseSession.getService("ReportEngines"); ReportEngine widocRepEngine = (ReportEngine)repEngines.getService( ReportEngines.ReportEngineType.WI_REPORT_ENGINE); session.setAttribute("widReportEngine", widocRepEngine);}Use the “kind” attribute of a document IInfoObject to see if a Web Intelligenceor Desktop Intelligence ReportEngine needs to be opened.Example: Instantiating a ReportEngine objects depending on file typeString strQuery = "Select SI_KIND from CI_INFOOBJECTS” + “where SI_ID=" + strDocId;IInfoObjects iDocObjects = iStore.Query(strQuery);IInfoObject iDocObject = null;try{ iDocObject = (InfoObject) iDocObjects[0];}catch{ ...}String strKind = iDocObject.Kind;ReportEngine reportEngine = null;if(strKind.Equals("Webi")){ reportEngine = reportEngines.getService( ReportEngineType.WI_ReportEngine);}else{ reportEngine = reportEngines.getService( ReportEngine Developer Guide 31
  32. 32. 2 Application Essentials Reporting essentials ReportEngineType.FC_ReportEngine); } Closing a ReportEngines object Just as you need to close a BusinessObjects Enterprise session, you should also close a ReportEngines when you have finished with it. To close a report engine object use ReportEngines.close(). This method deallocates the memory assigned to the object and should be called before you call IEnterpriseSession.logoff(). 32 ReportEngine Developer Guide
  33. 33. ReportEngine Developer GuideDocument Management chapter
  34. 34. 3 Document Management Overview Overview Two key parts of a typical ReportEngine SDK application are listing the documents that the user can view, and depending on the user’s rights, allowing the user to browse and manage categories and folders used to organize the documents. This chapter explains how to open, list, and work with documents. Document types With BusinessObjects Enterprise SDK you can work with: • Web Intelligence documents • Desktop Intelligence documents • Crystal Reports documents • third-party documents, for example Microsoft Excel (.xls), and Adobe Acrobat (.pdf) files Using ReportEngine SDK you can do everything Web Intelligence users can do with Web Intelligence documents: • view as DHTML • view as PDF • view as Excel • view as XML • refresh • create • categorize • delete • drill • save • schedule • send 34 ReportEngine Developer Guide
  35. 35. Document Management Document state: storage tokens 3Document state: storage tokens Storage tokens represent a state of a document at a particular stage, each time a document is edited, for example refreshed, the document state changes. Storage tokens are used to: • Retrieve the document state from page to page. • Simulate an undo action in a customized application.Storage token life cycle ReportEngine SDK generates a storage token: • when you open a document • when the microcube contents are modified or formatted When you open a document, ReportEngine SDK creates a DocumentInstance object that has a storage token. ReportEngine SDK also creates a temporary state that contain information about the document’s current state. Temporary files Executing file doc object open doc StorageToken = r0 r0 view1 A storage token is self descriptive with regards to the type of ReportEngine required to open the associated document. This means that you do not need to check the document type before opening. For information on how to control storage token, see “Configuring ReportEngine using webi.properties” on page 135. As the document changes state through the execution of JSP files, the storage token changes too, and more temporary states, representing the document’s states, are created. ReportEngine Developer Guide 35
  36. 36. 3 Document Management Document state: storage tokens You can retrieve the maximum storage stack size, that is to say, the maximum number of storage tokens that can be created as a document changes state programmatically and validate that a storage token is valid by calling ReportEngine.getStorageTokenStackSize() or ReportEngine.IsStorageTokenValid. ReportEngine SDK generates a new storage token and corresponding set of temporary files at the following triggers: User interface Triggers SDK Triggers refreshing the document calling DocumentInstance.getView drilling modifying the DrillPath object creating and editing a document calling DataProvider.getResult applying new formats calling DataProvider.runQuery IDataProvider.RunQuery running a query opening a document Note: Setting a password and filling in a prompt does not cause a new token to be generated directly. However, a new storage token is generated when you commit the change using DocumentInstance.getView. Example: Storage token life cycle The following diagram shows how storage tokens change according to triggers in the user interface and the object model. It also shows how the storage tokens are passed between web pages and refer file states stored in memory that can be used to reconstruct the DocumentInstance object using the call ReportEngine.getDocumentFromStoratagetoken. In the diagram below, this call name is shortened to “get doc”. Using the storage token as an identifier for a document state, you can restore the document to any of its saved states. 36 ReportEngine Developer Guide
  37. 37. Document Management Document state: storage tokens 3 e.Temporary files Executing files docInstance object 1 open docInstance StorageToken = r0 r0 GIF run query StorageToken = r0-s0 r0-s0 view1 r0-s0 2 get doc(r0-s0) GIF GIF drill StorageToken = r0-s1 r0-s1 view2 r0-s1 3 get doc(r0-s1) GIF drill StorageToken = r0-s2 r0-s2 GIF commit change StorageToken = r0-s3 view3 r0-s3 ReportEngine Developer Guide 37
  38. 38. 3 Document Management Organizing documents in categories and folders Table 3-1 Storage token life cycle Advantages of storage tokens Performance Using a storage token is to refer to document states is fast and optimized for memory usage. Lifetime A storage token in the file system lasts as long as the ReportEngines object used to create ReportEngine instances. Business Objects recommended that you store a ReportEngines object in the session object once it is created and retrieve it again as required for document storage tokens to be valid throughout an application. Browser navigation back and forward After progressing through several document states, users can go back and forwards in their browser to a previous document state and continue working from that state. Undo mechanism You can build an undo mechanism by passing the storage token from the previous action perform on the document to the next web page. Organizing documents in categories and folders In InfoView, categories and folders are used to classify documents in the central management system. Documents organized in the hierarchical category and folder structures are easier for users to find; A user can save a document to selected categories and folders. A document can be assigned to one or more public or personal categories. 38 ReportEngine Developer Guide
  39. 39. Document Management Organizing documents in categories and folders 3 Table 3-2 Categorized documents. Using the BusinessObjects Enterprise query mechanism you can navigate a category or folder hierarchy and retrieve IInfoObjects containing the individual categories and folders. These in turn enable you to: • create, rename and delete categories and folders • get the details of a categories and foldersUser rights for categories and folders A System administrator, using BusinessObjects Enterprise Central Management Console, can set how much control a user or group has over categories and folders. User rights settings are updated in the Advanced Rights page of the InfoView section for BusinessObjects Enterprise Applications of the Central Management Console. The following table lists an InfoView user’s possible rights. Folder and category-related settings in a Web Intelligence user’s rights InfoView Advanced Right Variable Name User can change preferences CeInfoViewRightID.PREFERENCE User can move and copy CeInfoViewRightID.ORGANIZE objects, create shortcuts and add object to the favorites folder. Can use InfoView simple CeInfoViewRightID.SIMPLESEARCH search Can use InfoView advanced CeInfoViewRightID.ADVANCEDSEARCH search ReportEngine Developer Guide 39
  40. 40. 3 Document Management Organizing documents in categories and folders InfoView Advanced Right Variable Name Can use InfoView filter feature CeInfoViewRightID.FILTER User has a favorites folder CeInfoViewRightID.FAVORITES User can view inbox contents CeInfoViewRightID.VIEWINBOX User can create categories CeInfoViewRightID.CREATECATEGORIES User can assign categories to CeInfoViewRightID.ASSIGNCATEGORIES users or groups User can send documents to CeInfoViewRightID.SENDDOCUMENTS users and groups User can create dashboards CeInfoViewRightID.CREATEDASHBOARDS User can create folders CeInfoViewRightID.CREATEFOLDERS A list of a user’s rights over an object in the IInfoStore can be recovered by retrieving the user’s ISecurityInfo object for a certain BusinessObjects Enterprise application. Example: how to check that a user has the right to create categories This code fragment shows how to validate a user has the right to create categories. <% IInfoStore iStore = (IInfoStore)session.getAttribute("InfoStore"); IInfoObject infoView = null; String query = "SELECT STATIC FROM CI_APPOBJECTS,” + “ CI_SYSTEMOBJECTS WHERE” + “ (SI_PARENTID = 99 AND SI_KIND=" + CeKind.INFOVIEW + ")"; try{ IInfoObjects appObjects = iStore.query( query); if (appObjects.size() > 0) infoView = (IInfoObject )appObjects.get(0); if (infoView != null){ ISecurityInfo secInfo = infoView.getSecurityInfo(); if (secInfo.checkCustomRight( CeInfoViewRightID.CREATECATEGORIES, infoView.getKind())) { ... } } 40 ReportEngine Developer Guide
  41. 41. Document Management Organizing documents in categories and folders 3 }catch (Exception exc){ ... } %> Note: Before trying to manage categories, check that the user who started the session has the appropriate rights. Note: A list of a rights for other BusinessObjects Enterprise applications can be found by changing the CeKind being searched for. For example, to search for a user’s Web Intelligence rights the query string would include CeKind.WEBINTELLIGENCE in the place of CeKind.INFOVIEW.Navigating categories and folders Categories and folders in a Central Management System are represented as a tree. Personal and Public are root nodes for categories. Home is the root node for folders. To access the category or folder trees, query the repository to retrieve the ID of the parent node for categories or folders. Use this ID to navigate the child nodes. Example: Traversing the category tree recursively The following example shows functions that use BusinessObjects Enterprise SDK to recover the ID of the parent folder for a user’s personal categories. Using this ID a bulleted list containing the hierarchical structure of the user’s personal categories is generated. <%! //Return the ID of a specific folder public int getFolderParentId(IInfoStore iStore, int userID, String kind){ int FolderID = 0; IInfoObjects folders = null; String query = "SELECT SI_PARENTID FROM CI_INFOOBJECTS” + “ WHERE SI_KIND=" + kind + "" + “ AND SI_OWNERID=" + userID; try{ folders = iStore.query(query); if(folders.size() > 0) FolderID= ((IInfoObject)folders.get(0)).getParentID(); }catch (SDKException sdke){ return FolderID;} return FolderID; } //Return a selectable list of categories or folders String getCategoryList(IInfoStore iStore, int id, String kind ){ String results = ""; IInfoObject category; if (id == -1) id = 0; String sQuery = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM” ReportEngine Developer Guide 41
  42. 42. 3 Document Management Organizing documents in categories and folders + “ CI_INFOOBJECTS WHERE SI_PARENTID=" + id + " AND SI_KIND= "+ kind + "" ; try{ IInfoObjects categories = iStore.query(sQuery); if (!categories.isEmpty()){ results += "<ul>"; for(int i = 0; i < categories.size(); i++){ category = (IInfoObject)categories.get(i); String name = category.getTitle(); int catID = category.getID() ; results += "<li><input type="radio" name="" + kind + "" value="" + catID + "" >" + name + "</li>n"; results += getCategoryList(iStore, category.getID(), kind); } results += "</ul>"; } }catch (SDKException sdke){ results = null; } return results; } %> The following code fragment shows how to use the functions declared above to print personal categories for a user. <% IEnterpriseSession enterpriseSession =(IEnterpriseSession) session.getAttribute("EnterpriseSession"); IInfoStore iStore= (IInfoStore)session.getAttribute("InfoStore"); int userID = enterpriseSession.getUserInfo().getUserID(); int persoCatsfolderID = getFolderParentId( iStore,userID,(String)CeKind.PERSONALCAT); String catButtons = getCategoryList( iStore, (String)CeKind.PERSONALCAT)); %> Note: For an example of how to list documents in a folder, see “Displaying a document list” on page 47. Retrieving Inbox and favorites folder IDs Each BusinessObjects Enterprise user has unique personal directories. The Inbox and Favorites directories contain documents sent to a specific user or saved for personal rather than corporate use. To list the contents of these folders you need to retrieve the ID for each user’s personal directories. Once the root directory ID is retrieved, you can list and navigate the contents in the same way corporate folders are navigated. 42 ReportEngine Developer Guide
  43. 43. Document Management Organizing documents in categories and folders 3Example: Retrieve a user’s Inbox and Favorites folder IDsThe following example shows functions that use BusinessObjects EnterpriseSDK to recover the ID of the parent folder for a user’s Inbox and Favoritesfolders.<%!//Retrieve the ID for any type of personal folderpublic int getFolderId(IInfoStore iStore, int userID, String kind){ int FolderID = 0; IInfoObjects folders = null; String query = "SELECT SI_ID" + " FROM CI_INFOOBJECTS" + " WHERE SI_KIND=" + kind + "" + " AND SI_OWNERID=" + userID; try{ folders = iStore.query(query); if(folders.size() > 0) FolderID = ((IInfoObject)folders.get(0)).getID(); }catch(SDKException sdke){ FolderID = -1; } return FolderID;}//Retrieve the ID of a user’s Inboxint getInboxFolderId(IInfoStore iStore, int userID){ return getFolderId(iStore,userID,(String)CeKind.INBOX);}//Retrieve the ID of a user’s favorites folderint getFavoritesPFolderID(IInfoStore iStore, int userID){ return getFolderId(iStore,userID,(String)CeKind.FAVORITESF);}%>//The following example shows how to retrieve a list of documents in the current user’s Inbox. See “Displaying a document list” on page 47 for the definition of getList.<%IEnterpriseSession enterpriseSession;IInfoObjects docList = null;enterpriseSession = (IEnterpriseSession) session.getAttribute("EnterpriseSession");IInfoStore iStore = (IInfoStore) session.getAttribute("InfoStore");int userID = enterpriseSession.getUserInfo().getUserID();int inboxID = getInboxFolderId(iStore, userID);docList = getList(iStore, inboxID, (String)CeKind.WEBI );%> ReportEngine Developer Guide 43
  44. 44. 3 Document Management Organizing documents in categories and folders Note: See “Displaying a document list” on page 47 for the definition of getList. Creating categories and folders You can add categories and folders by: • getting the ID of the folder or category in which you wish to create a node • getting the correct plug-in to create a node • committing the new object to the Central Management System Example: Creating a new folder or category The following example shows functions that use BusinessObjects Enterprise SDK to create a new folder or category. <%! int addFolderOrCategory(IInfoStore iStore, int parentFolderID,String name, String description, String type){ int objectID = 0; IPluginInfo plugin; try{ IPluginMgr pluginMgr = iStore.getPluginMgr(); plugin = pluginMgr.getPluginInfo(type); IInfoObjects newInfoObjects = iStore.newInfoObjectCollection(); newInfoObjects.add(plugin); IInfoObject infoObject = (IInfoObject) newInfoObjects.get(0); infoObject.setTitle (name); infoObject.setDescription (description); objectID = infoObject.getID(); infoObject.properties().setProperty( CePropertyID.SI_PARENTID, parentFolderID); iStore.commit (newInfoObjects); }catch (SDKException e) { throw new Error("Failed to add the object."); } return objectID; } %> The following code fragment shows how to use the functions declared above to create a new personal category and a new folder. <%//How to use this function //Create a new personal category addFolderOrCategory(iStore, categoryParentID, "Category Name", "Keywords",CeKind.PERSONALCAT); //Create a new personal folder addFolderOrCategory(iStore, categoryParentID, "Folder Name", "Keywords", CeKind.FOLDERS);%> 44 ReportEngine Developer Guide
  45. 45. Document Management Organizing documents in categories and folders 3Moving and renaming categories and folders You can move categories and folders from one parent to another using the IInfoObject.setParentID method. You can rename categories and folders using the IInfoObject.setTitle method. After the category or folder has been renamed or moved, IInfoStore.commit must be called with the changed IInfoObject passed as a parameter. Example: Moving and renaming categories or folders The following function changes the name of a folder or category and moves it in the folder or category hierarchy respectively. <%! String changeNameMove(IInfoStore iStore, int ID, String newName, int newParentID){ String query; IInfoObjects result; String res = ""; query = "Select SI_NAME, SI_ID From CI_INFOOBJECTS “ + “ Where SI_ID=" + ID; try{ result = iStore.query(query); if ( result.size() > 0 ){ IInfoObject currResult; currResult = (IInfoObject)result.get(0); currResult.setTitle(newName); currResult.setParentID(newParentID); iStore.commit(result); } } catch(SDKException e){ ; } return res; }Getting the properties of a category Each IInfoObject in the BusinessObjects Enterprise IInfoStore contains a collection of all properties assigned to that object, known as a “properties bag.” To retrieve IInfoObject details, request SI_NAME, SI_DESCRIPTION, SI_KEYWORD in the query string used to recuperate the IInfoObject representing a category or folder. Example: Retrieve the properties for a category The following method returns the properties of a category, folder, or document as an IInfoObject: <%! IInfoObject getProps(IInfoStore iStore, int ID){ ReportEngine Developer Guide 45
  46. 46. 3 Document Management Working with documents String query; IInfoObjects result = null; IInfoObject properties = null; String res = ""; query = "SELECT SI_FILES, SI_DESCRIPTION,” + ” SI_KEYWORD, SI_KIND"; query += " FROM CI_INFOOBJECTS WHERE SI_ID=" + ID; try{ result = iStore.query(query); if (result.size() > 0){ properties = (IInfoObject)result.get(0); } } catch(SDKException e){ return null; } return properties; } %> The following code fragment shows how to use the functions declared above to print the description and keywords of an IInfoObject object to an HTTP stream. <% int ID = Integer.parseInt(request.getParameter("ID")); PrintWriter myWriter = response.getWriter(); IInfoStore iStore = (IInfoStore) session.getAttribute("InfoStore"); IInfoObject fProperties = getProps(iStore, ID); myWriter.print( fProperties.getDescription() + "<br>n"); myWriter.print( fProperties.getKeyword() + "<br>n"); //Another way to retrieve the keyword IInfoObject Property myWriter.print( fProperties.properties().getProperty( CePropertyID.SI_KEYWORD).getValue().toString()); %> Working with documents Working with documents involves opening and listing the documents, then providing facilities for saving, sending, scheduling, and organizing documents. Opening documents After establishing a session for a user (see “Establishing a valid BusinessObjects Enterprise user’s session” on page 20) you can open a document on behalf of the user. In general, to open a document you: 46 ReportEngine Developer Guide
  47. 47. Document Management Working with documents 3 1. Establish a BusinessObjects Enterprise session for the user. 2. Get an identifier for the document. The identifier can be a storage token (see “Document state: storage tokens” on page 35), or more simply the document’s ID. 3. Retrieve the ReportEngineinstance relating to the type of document to be opened. 4. Open the document using the ReportEngine.openDocument method for Web Intelligence or Desktop Intelligence documents. See “Instantiating a ReportEngine objects depending on file type” on page 31 for an example of how this is done. Taking into account user rights and profiles Because your Web Intelligence application acts on behalf of a user, what your application can do with the document is subject to the user’s rights. They are set in the BusinessObjects Enterprise Central Management Console. You should take these rights into account in your application. You should also take into account the settings in the user’s profile. See “User preferences” on page 24.Displaying document lists To display a list of documents you: 1. Use the IInfoStore.query method to return the list of IInfoObjectss representing the root directory of the user’s folders and documents. 2. Loop through the IInfoObject list and print the values of the fields of each row. 3. Allow navigation through the folders. Note: IInfoObject is the base BusinessObjects Enterprise type. An IInfoObject can be used to store any type of object in the central management system.Refreshing a document list A document list is refreshed every time IInfoStore.query is called. The results come directly from the BusinessObjects Enterprise Central Management System (CMS) with no intermediary cache. Example: Displaying a document list The following code fragment is a helper function called getList. This function is passed an IInfoObject object as a parameter, which is then used to return a list of IInfoObject objects of a required type, in this case Folders or Web Intelligence documents. ReportEngine Developer Guide 47
  48. 48. 3 Document Management Working with documents This function is placed either at the head of the listfolders.jsp script or in a file containing helper functions included in listfolders.jsp. <%! IInfoObjects getList(IInfoStore iStore, int searchID, String kind){ IInfoObjects list = null; String query = "SELECT SI_ID, SI_NAME, SI_PARENTID,” + “ SI_KIND, SI_INSTANCE, SI_DESCRIPTION FROM” + “ CI_INFOOBJECTS WHERE SI_PARENTID=" + searchID + " AND SI_KIND = " + kind + ""; try{ list = iStore.query(query); } catch (SDKException sdke){ list = null; } return list; } %> The function getInfoList is called from listfolders.jsp. The following code fragment shows returns a list of Web Intelligence documents in the document root folder. <% int iID= 0; //ID of the root folder IInfoObjects webiDocs = null; String searchID=request.getParameter("sID"); if (searchID!=null) iID=Integer.parseInt(searchID); IInfoStore iStore = (IInfoStore)session.getAttribute("InfoStore"); webiDocs=getList(iStore,iID,(String)CeKind.WEBI); ... %> Saving documents To save a document use DocumentInstance.save and DocumentInstance.saveAs. Example: Save a document The following example shows how to open a document to be worked on, then open and save the original version of the document. <% DocumentInstance doc = myReportEngine.openDocument(docID); String docToken doc.getStorageToken(); //User perform actions on document doc... //Open the first version of the document and save. DocumentInstance docToSave = 48 ReportEngine Developer Guide

×