The Wayback Machine - https://web.archive.org/web/20181226174229/http://java.sys-con.com:80/node/1118330

Welcome!

Java IoT Authors: Yeshim Deniz, Pat Romanski, Liz McMillan, Zakia Bouachraoui, Carmen Gonzalez

Related Topics: Java IoT, Eclipse

Java IoT: Product Review

Reporting Solutions Using Crystal Reports for Eclipse

Modeled for ease of use, with an intuitive report design and toolset

SAP (Business Objects) has recently released Crystal Reports for Eclipse version 2.0 to provide reporting solutions for Java-based applications. This is available as free to use (within an organization) and has the advantage that it is built on the most tested and reliable component (Java Reporting Component in Crystal Reports) that has been in market for quite a few years now. This article discusses the features of CR4Ev2.0, usability of its designer and API, and starting off with an overview of Crystal Reports product architecture.

Crystal Reports - Product Overview
Crystal Reports is delivered in three editions with features added upon with each edition and its core feature diagrammatically depicted in Figure 1.

Crystal Reports Developer and Server editions have SDKs for Report Integration that aid in report viewing, printing and exporting in applications, customizable report viewers and report creation APIs. In case of Developer editions, the report processing resides within application and in Server editions it can be offloaded to a Reporting Server.

There are two sets of SDKs available for each of SAP (Business Objects) supported technology platforms (Java and .NET) and for Java these are namely:

  • Java Reporting Component (JRC): This is used to perform report processing within application.
  • Report Application Server SDK (RAS SDK): This is used to work with Report Application Server where report processing is done on the server and Java application uses RAS SDK for communication with the server.

JRC shares many classes with the RAS SDK, and the JRC-specific classes are thin wrappers around RAS classes.

CR4E vs JRC
JRC was introduced in Crystal Reports 9 and is a reliable component in Crystal Reports product. Crystal Reports have refined this component and bundled it as a separate package known as CR4E, which contains Crystal Reports for Java (CRJ) and Crystal Reports Designer components. The designer component is available as a plug-in to Eclipse and is used for designing and previewing reports. The Crystal Reports for Java component is used for the runtime generation of reports within Java applications.

RAS SDK is the client component for the RAS server-client reporting solution, where the SDK communicates with the RAS server for report processing. With the CRJ SDK, the same classes as that of RAS SDK are used but report processing requests are sent to an in-process Java Report Engine.

A great enhancement of CRJ over JRC is the introduction of RAS-type report creation and modification capabilities. With the CRJ, it's possible to programmatically modify a report on-the-fly: create new fields, introduce new data connections and tables, modify images, add lines and boxes, etc. Anything that can be done to a report using the CR4E embedded designer can also be done programmatically using CRJ as the designer uses the same SDK.

Few points in comparison between CR4E and JRC are jotted in Table 1.

Features of CR4E
Already, few features of CR4E are exposed through its comparison with the JRC above, the following makes the list complete:

  1. Ability to integrate reporting into Java-based web or desktop applications.
  2. Provides SDK that enables report creation and modification within Java code.
  3. Helps Java developer switch on to the Report designer role easily in reporting projects.
  4. POJO can also be used as a data source for reports.
  5. Accesses all major databases from within Eclipse IDE as report template data source.
  6. Supports for all major operating systems and browsers.
  7. Comes with extension SDKs to extend and enhance the default Eclipse editor.
  8. Use of Eclipse Update Manager to check and install updates automatically.

Aspects of CR4E Designer
CR4Ev2.0 is provided as a plug-in for Eclipse IDE and works for an Eclipse version greater than 3.4.1. Figure 2 captures the commonly used aspects in the designer and same is detailed further.

Layout tab: Layout tab is the designer view and has the palette with all reporting controls. The controls from palette can be dragged & dropped onto the designer area at the required position.

Preview tab: Preview tab is used to preview the report designed in layout view and the report can also be directly edited in this view. The data source for the report is changed using the ‘Set Datasource Location' menu item under ‘Crystal Reports'.

Datasource Explorer wizard: This wizard is used to create a connection profile for the datasource used in the reports. The CR4E supports relational databases, flat file, web services, XML and POJO as datasources.  Once the connection profile is created, the required objects in datasource can be dragged & dropped onto the data view (tab).

Field Explorer wizard: This wizard displays the database objects in the data pane for use in the report. Also, parameters and formulas are created using this view and then placed on to the report layout.

Usage of CR4E APIs
After creating report templates using CR4E designer, the common reporting need is to generate reports dynamically from report templates based on the parameters passed to it. This scenario is walked through below to demonstrate the use of CR4E APIs for generating reports from a standalone Java application (see Figure 3).

The use of CR4E API programmatically in each of this task is explained below:

1)      Initiate
Report processing is done by Crystal Report Java component (and not by Report Application Server) and this component is initiated as below:

ReportClientDocument boReportClientDocument = new ReportClientDocument();
boReportClientDocument.setReportAppServer (ReportClientDocument.inprocConnectionString);

2)      Load
Next task is loading the report template for report generation as below:

boReportClientDocument.open("SampleReport.rpt", OpenReportOptions._openAsReadOnly);

3)      Read

This task is a two-step process; one is to set the connection information for datasource and next is to set the values for input parameters in the report.

a)   Set connection information: In most cases, the datasource configured in report template during report design will not be the same one used by the report generation application. So, the datasource connection information for the report template needs to be replaced thro' the following lines of code:

dbController.replaceConnection(oldConnectionInfo, newConnectionInfo, pFields, replaceParams);

dbController - DatabaseController object that is retrieved from ReportClientDocument object for managing database connections

oldConnectionInfo - ConnectionInfo object that is retrieved from  DatabaseController object and contains details of existing datasource such as database URL, Server Type, username, password etc.

newConnectionInfo - New ConnectionInfo object that is constructed to replace oldConnectionInfo object

b)   Set input parameters: Data displayed on the report is restricted based on the parameter values supplied to the report, same is programmatically done below:

ParameterFieldController parameterFieldController =
boReportClientDocument.getDataDefController().getParameterFieldController();
parameterFieldController.setCurrentValue("","a","123");

4)   Export
The final step is to export the generated report in required format as in lines of code below:

PrintOutputController printOutputController =
boReportClientDocument.getPrintOutputController();
ByteArrayInputStream byteIS =    (ByteArrayInputStream) printOutputController.export(ReportExportFormat.PDF);

The report stream can be written to a file etc. as needed.

An important point to note during development using CR4E is that it contains both JRC and CRJ APIs and both the APIs have most classes with same name so import statement is critical in determining which APIs are used.  To use CRJ, import classes under package name:

com.crystaldecisions.sdk.occa.report.application and for JRC, package name is com.crystaldecisions.reports.sdk

Conclusion
The design and development of reporting solution using CR4E is done using the designer plug-in for Eclipse and Crystal Reports for Java components that are enhanced from reliable Java Reporting Component of Crystal Reports. Modeled with ease of use, intuitive report design and toolset, simple licensing and support from SAP (Business Objects) helps CR4E to be considered as a reporting solution for Java projects.

Reference

More Stories By Ravi M

M.Ravi is a Senior Technical Architect, specialized in providing architecture and design solutions on broad of spectrum of areas such as JEE, SOA, ESB, BI, CRM & SAS.

Comments (1)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
Digital Transformation is much more than a buzzword. The radical shift to digital mechanisms for almost every process is evident across all industries and verticals. This is often especially true in financial services, where the legacy environment is many times unable to keep up with the rapidly shifting demands of the consumer. The constant pressure to provide complete, omnichannel delivery of customer-facing solutions to meet both regulatory and customer demands is putting enormous pressure on...
IoT is rapidly becoming mainstream as more and more investments are made into the platforms and technology. As this movement continues to expand and gain momentum it creates a massive wall of noise that can be difficult to sift through. Unfortunately, this inevitably makes IoT less approachable for people to get started with and can hamper efforts to integrate this key technology into your own portfolio. There are so many connected products already in place today with many hundreds more on the h...
The standardization of container runtimes and images has sparked the creation of an almost overwhelming number of new open source projects that build on and otherwise work with these specifications. Of course, there's Kubernetes, which orchestrates and manages collections of containers. It was one of the first and best-known examples of projects that make containers truly useful for production use. However, more recently, the container ecosystem has truly exploded. A service mesh like Istio addr...
Digital Transformation: Preparing Cloud & IoT Security for the Age of Artificial Intelligence. As automation and artificial intelligence (AI) power solution development and delivery, many businesses need to build backend cloud capabilities. Well-poised organizations, marketing smart devices with AI and BlockChain capabilities prepare to refine compliance and regulatory capabilities in 2018. Volumes of health, financial, technical and privacy data, along with tightening compliance requirements by...
Charles Araujo is an industry analyst, internationally recognized authority on the Digital Enterprise and author of The Quantum Age of IT: Why Everything You Know About IT is About to Change. As Principal Analyst with Intellyx, he writes, speaks and advises organizations on how to navigate through this time of disruption. He is also the founder of The Institute for Digital Transformation and a sought after keynote speaker. He has been a regular contributor to both InformationWeek and CIO Insight...
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
To Really Work for Enterprises, MultiCloud Adoption Requires Far Better and Inclusive Cloud Monitoring and Cost Management … But How? Overwhelmingly, even as enterprises have adopted cloud computing and are expanding to multi-cloud computing, IT leaders remain concerned about how to monitor, manage and control costs across hybrid and multi-cloud deployments. It’s clear that traditional IT monitoring and management approaches, designed after all for on-premises data centers, are falling short in ...
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...