18.08.2013 Views

Crystal Enterprise 10 - SAP Developer Network

Crystal Enterprise 10 - SAP Developer Network

Crystal Enterprise 10 - SAP Developer Network

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong><br />

Using Business Views with the Java SDK<br />

Overview<br />

Contents<br />

This document discusses how to use the <strong>Crystal</strong> <strong>Enterprise</strong> Java SDK to<br />

interface with Business Views.<br />

INTRODUCTION............................................................................................ 2<br />

DYNAMIC DATA CONNECTION ......................................................................2<br />

Example .......................................................................................................3<br />

CHANGING BUSINESS VIEWS AT RUNTIME ....................................................5<br />

Repository organization...............................................................................5<br />

Example .......................................................................................................6<br />

FINDING MORE INFORMATION ......................................................................8<br />

Business Views Administrator’s Guide.......................................................8<br />

Business Views Security Whitepaper ..........................................................8<br />

7/1/2005 1:05:00 PM Copyright © 2005 Business Objects. All rights reserved. Page 1


<strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong> Using Business Views with the Java SDK<br />

Introduction<br />

Dynamic Data Connection<br />

NOTE<br />

Business Views is a new feature introduced in <strong>Crystal</strong> Reports <strong>10</strong> and<br />

<strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong> that provides view time security. When viewing a<br />

report(s) based on a Business View, only the rows and columns that the<br />

current user is entitled to view are visible.<br />

This security model applies when not only viewing reports in <strong>Crystal</strong><br />

Reports but also when scheduling reports with saved data in <strong>Crystal</strong><br />

<strong>Enterprise</strong>. Business Views are stored in the <strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong> <strong>Crystal</strong><br />

Management Server (CMS) Repository, along with other report design<br />

components.<br />

You are able to interact with Business Views in two ways using the<br />

<strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong> Java SDK. With Dynamic Data Connections, you<br />

are able to change the data connection of a Business View by passing its<br />

Cluster Unique Identifier (CUID). You are also able to change the<br />

Business View to which a report is connected. This document discusses<br />

these two methods of interaction.<br />

Dynamic Data Connections consist of a collection of pointers to different<br />

data connections. By setting a parameter value, you are able to specify<br />

which data connection to use.<br />

A Dynamic Data Connection enables you to change between data<br />

sources as needed, whereas a data connection is more static. Therefore, a<br />

Dynamic Data Connection provides additional flexibility in terms of<br />

specifying a data source, but it is not a mandatory object when you<br />

create your Business View. You are able to create Data Foundations with<br />

or without using a Dynamic Data Connection.<br />

You must first create more than one data connection before you can create a Dynamic<br />

Data Connection.<br />

Many organizations use a development, test, and production system<br />

model for housing their data. That is, the data is initially stored on a<br />

development system and then later migrated to a test system. After<br />

extensive testing, the data in the test system is ready to be used in the<br />

production system. Dynamic Data Connections can serve this purpose.<br />

When a report is connected to a Dynamic Data Connection, a report<br />

parameter is automatically created. The parameter contains the same<br />

number of default values as data connections in the Dynamic Data<br />

Connection. Each of the values represents the CUID of the data<br />

connection in the Dynamic Data Connection. The parameter description<br />

is the name of the data connection. To connect to a specific data<br />

connection, the current value of the parameter must be set to the<br />

corresponding CUID.<br />

7/1/2005 1:05:00 PM Copyright © 2005 Business Objects. All rights reserved. Page 2<br />

ce<strong>10</strong>_using_business_views_with_java_sdk.pdf


<strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong> Using Business Views with the Java SDK<br />

Example<br />

The following code demonstrates how to set the current value of the<br />

parameter to the CUID of the desired Data Connection:<br />

import com.crystaldecisions.sdk.occa.report.application.*;<br />

import com.crystaldecisions.sdk.occa.report.definition.*;<br />

import com.crystaldecisions.sdk.occa.report.data.*;<br />

import com.crystaldecisions.sdk.occa.report.lib.*;<br />

import com.crystaldecisions.sdk.framework.*;<br />

import com.crystaldecisions.sdk.occa.managedreports.*;<br />

import com.crystaldecisions.sdk.occa.infostore.*;<br />

import com.crystaldecisions.sdk.plugin.desktop.report.*;<br />

import com.crystaldecisions.sdk.plugin.desktop.common.*;<br />

import com.crystaldecisions.report.web.viewer.*;<br />

import<br />

com.crystaldecisions.sdk.occa.report.reportsource.IReportSo<br />

urce;<br />

import java.util.*;<br />

/* Connect to <strong>Crystal</strong> <strong>Enterprise</strong> */<br />

<strong>Crystal</strong><strong>Enterprise</strong> ce = new <strong>Crystal</strong><strong>Enterprise</strong>();<br />

ISessionMgr sm = ce.getSessionMgr();<br />

I<strong>Enterprise</strong>Session es = sm.logon(“cmsUser”, “cmsPassword”,<br />

“mAPSName”,<br />

“mAuthType”);<br />

/* Get the InfoStore service from <strong>Crystal</strong> <strong>Enterprise</strong> */<br />

IInfoStore infoStore = (IInfoStore)es.getService("",<br />

"InfoStore");<br />

/* Retrieve the report by name from <strong>Crystal</strong> <strong>Enterprise</strong> */<br />

IInfoObjects oInfoObjects = infoStore.query("Select * From<br />

CI_INFOOBJECTS<br />

Where SI_NAME = 'reportName'");<br />

/* Open the report into a Report Document object */<br />

IInfoObject oInfoObject = (IInfoObject)oInfoObjects.get(0);<br />

IReport report = (IReport)oInfoObject;<br />

/* create a new Fields collection to represent the report’s<br />

parameters */<br />

Fields params = new Fields();<br />

/* Get the old IReportParameter object */<br />

7/1/2005 1:05:00 PM Copyright © 2005 Business Objects. All rights reserved. Page 3<br />

ce<strong>10</strong>_using_business_views_with_java_sdk.pdf


<strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong> Using Business Views with the Java SDK<br />

IReportParameter oldParam =<br />

(IReportParameter)report.getReportParameters().get(0);<br />

/* Convert the IReportParameter object to the<br />

ParameterField object that the viewer accepts */<br />

ParameterField newParamField =<br />

oldParam.getParameterField();<br />

/* Get the Description of the parameter value for<br />

demonstration purposes */<br />

String description =<br />

((IReportParameterSingleValue)oldParam.getDefaultValues().g<br />

et(0)).getDescription();<br />

out.println( "Parameter Value Description = " + description<br />

+ "" );<br />

ParameterFieldDiscreteValue newDiscreteValue =<br />

new ParameterFieldDiscreteValue();<br />

IReportParameterValues oldDefaultValues =<br />

(IReportParameterValues)oldParam.getDefaultValues();<br />

String CUIDofDataConnection0 =<br />

((IReportParameterSingleValue)oldDefaultValues.get(0)).getV<br />

alue();<br />

out.println( "CUID --> " + CUIDofDataConnection0 + ""<br />

);<br />

/* Pass the CUID of the Business View to the value object<br />

*/<br />

newDiscreteValue.setValue( CUIDofDataConnection0 );<br />

/* Pass the value object into the new Parameter Field */<br />

Values values = new Values();<br />

newParamField.setCurrentValues( values );<br />

newParamField.getCurrentValues().add( newDiscreteValue );<br />

out.println( "Currnet Values = " +<br />

((IParameterFieldDiscreteValue)newParamField.getCurrentValu<br />

es().getValue(0)).getValue() );<br />

/* Add the new parameter field to the collection of<br />

parameters */<br />

params.add( newParamField );<br />

/* Create a Report source object to pass to the Viewer */<br />

7/1/2005 1:05:00 PM Copyright © 2005 Business Objects. All rights reserved. Page 4<br />

ce<strong>10</strong>_using_business_views_with_java_sdk.pdf


<strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong> Using Business Views with the Java SDK<br />

NOTE<br />

IReportSourceFactory factoryPS = (IReportSourceFactory)<br />

es.getService("PSReportFactory");<br />

IReportSource reportSource =<br />

factoryPS.openReportSource(oInfoObject,Locale.ENGLISH);<br />

/* View the Report */<br />

<strong>Crystal</strong>ReportViewer viewer = new <strong>Crystal</strong>ReportViewer();<br />

viewer.set<strong>Enterprise</strong>Logon(es);<br />

viewer.setReportSource( reportSource );<br />

viewer.setParameterFields( params );<br />

viewer.processHttpRequest(request, response,<br />

getServletConfig().getServletContext(), out);<br />

Changing Business Views at Runtime<br />

Refer to the <strong>Crystal</strong> Java <strong>Developer</strong>’s Library that is included on the <strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong><br />

CD for more information.<br />

With the Report Application Server (RAS) SDK in <strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong>,<br />

you are able to change a report’s Business View, as well as any of its<br />

implemented security constraints, at runtime. To change a Business View<br />

at runtime, the new Business View must be identical in schema, name,<br />

and number of Business Elements (see Table 1).<br />

Original Business View Destination Business View<br />

Business Element Employee Business Element Employee<br />

Business Element Customer Business Element Customer<br />

Table 1<br />

In the example in Table 1, the Employee Business Element in the original<br />

Business View is replaced by the Employee Business Element in the<br />

destination Business View. They are identical in name and number of<br />

elements.<br />

Repository organization<br />

To have multiple Business Elements with the same name in one<br />

repository system, the elements must be organized in separate folders.<br />

Each Business View should be stored in its own folder that contains all<br />

its Business Elements.<br />

7/1/2005 1:05:00 PM Copyright © 2005 Business Objects. All rights reserved. Page 5<br />

ce<strong>10</strong>_using_business_views_with_java_sdk.pdf


<strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong> Using Business Views with the Java SDK<br />

Example<br />

The following code demonstrates how to change a report’s Business<br />

View at runtime:<br />

import com.crystaldecisions.sdk.occa.infostore.*;<br />

import com.crystaldecisions.sdk.framework.*;<br />

import com.crystaldecisions.sdk.occa.report.application.*;<br />

import com.crystaldecisions.sdk.occa.report.definition.*;<br />

import com.crystaldecisions.sdk.occa.report.data.*;<br />

import com.crystaldecisions.sdk.occa.report.lib.*;<br />

import com.crystaldecisions.sdk.occa.managedreports.*;<br />

import<br />

com.crystaldecisions.report.web.viewer.<strong>Crystal</strong>ReportViewer;<br />

import java.util.*;<br />

/* Login to <strong>Crystal</strong> <strong>Enterprise</strong> and retrieve a Session */<br />

I<strong>Enterprise</strong>Session es =<br />

<strong>Crystal</strong><strong>Enterprise</strong>.getSessionMgr().logon( “cmsuser”,<br />

“cmspassword”, “CMSName”, “cmsAuthType” );<br />

/* Retrieve a RAS report service */<br />

IReportAppFactory rptAppFactory =<br />

(IReportAppFactory)es.getService("", "RASReportService");<br />

/* Get the InfoStore service from <strong>Crystal</strong> <strong>Enterprise</strong> */<br />

IInfoStore infoStore = (IInfoStore)es.getService("",<br />

"InfoStore");<br />

/* Retrieve the report by name from <strong>Crystal</strong> <strong>Enterprise</strong> */<br />

IInfoObjects oInfoObjects = infoStore.query("Select SI_ID<br />

From CI_INFOOBJECTS<br />

Where SI_NAME = 'reportName'");<br />

/* Convert the report into a Report Document object */<br />

ReportClientDocument clientDoc =<br />

rptAppFactory.openDocument((IInfoObject)oInfoObjects.get(0)<br />

, 0, Locale.ENGLISH);<br />

/* Retrieve the DatabaseController */<br />

DatabaseController oDatabaseController =<br />

clientDoc.getDatabaseController();<br />

7/1/2005 1:05:00 PM Copyright © 2005 Business Objects. All rights reserved. Page 6<br />

ce<strong>10</strong>_using_business_views_with_java_sdk.pdf


<strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong> Using Business Views with the Java SDK<br />

/* Retrieve the 'Xtreme Production Business View' */<br />

String query = "SELECT SI_CUID FROM CI_APPOBJECTS WHERE<br />

SI_NAME =<br />

'VisNetView' ";<br />

oInfoObjects = null;<br />

oInfoObjects = infoStore.query(query);<br />

IInfoObject oBusinessView =<br />

(IInfoObject)oInfoObjects.get(0);<br />

/* Set the datasource to another Business View */<br />

oDatabaseController.setDataSource( oBusinessView );<br />

/* View the report */<br />

<strong>Crystal</strong>ReportViewer viewer = new <strong>Crystal</strong>ReportViewer();<br />

viewer.set<strong>Enterprise</strong>Logon(es);<br />

viewer.setName("<strong>Crystal</strong>_Report_Viewer");<br />

viewer.setOwnPage(true);<br />

viewer.setReportSource(clientDoc.getReportSource() );<br />

viewer.processHttpRequest(request, response,<br />

getServletConfig().getServletContext, out);<br />

NOTE Refer to the <strong>Crystal</strong> Java <strong>Developer</strong>’s Library that is included on the <strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong><br />

CD for more information.<br />

7/1/2005 1:05:00 PM Copyright © 2005 Business Objects. All rights reserved. Page 7<br />

ce<strong>10</strong>_using_business_views_with_java_sdk.pdf


<strong>Crystal</strong> <strong>Enterprise</strong> <strong>10</strong> Using Business Views with the Java SDK<br />

Finding More Information<br />

Business Views Administrator’s Guide<br />

http://support.businessobjects.com/communityCS/TechnicalPapers/ce<br />

<strong>10</strong>_businessview_en.pdf.asp<br />

Business Views security whitepaper<br />

http://support.businessobjects.com/communityCS/TechnicalPapers/C<br />

E<strong>10</strong>_BusinessViews_Security.pdf.asp<br />

For more information and resources, refer to the product documentation<br />

and visit the support area of the web site at<br />

http://www.businessobjects.com/<br />

www.businessobjects.com<br />

No part of the computer software or this document may be reproduced or transmitted in any form or by any means,<br />

electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system,<br />

without permission in writing from Business Objects.<br />

The information in this document is subject to change without notice. Business Objects does not warrant that this<br />

document is error free.<br />

This software and documentation is commercial computer software under Federal Acquisition regulations, and is<br />

provided only under the Restricted Rights of the Federal Acquisition Regulations applicable to commercial computer<br />

software provided at private expense. The use, duplication, or disclosure by the U.S. Government is subject to<br />

restrictions set forth in subdivision (c) (1) (ii) of the Rights in Technical Data and Computer Software clause at<br />

252.227-7013.<br />

The Business Objects product and technology are protected by US patent numbers 5,555,403; 6,247,008;<br />

6,578,027; 6,490,593; and 6,289,352. The Business Objects logo, the Business Objects tagline,<br />

BusinessObjects, BusinessObjects Broadcast Agent, BusinessQuery, <strong>Crystal</strong> Analysis, <strong>Crystal</strong> Analysis<br />

Holos, <strong>Crystal</strong> Applications, <strong>Crystal</strong> <strong>Enterprise</strong>, <strong>Crystal</strong> Info, <strong>Crystal</strong> Reports, Rapid Mart, and<br />

WebIntelligence are trademarks or registered trademarks of Business Objects SA in the United States<br />

and/or other countries. Various product and service names referenced herein may be trademarks of<br />

Business Objects SA. All other company, product, or brand names mentioned herein, may be the<br />

trademarks of their respective owners. Specifications subject to change without notice. Not responsible for<br />

errors or omissions.<br />

Copyright © 2005 Business Objects SA. All rights reserved.<br />

7/1/2005 1:05:00 PM Copyright © 2005 Business Objects. All rights reserved. Page 8<br />

ce<strong>10</strong>_using_business_views_with_java_sdk.pdf

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!