C2Birt 1.1

 

More info

 

Downloads

 

Contact

 

License

 

What's new in v1.1

 

Home

 

C2BIRT 1.1 Guide

 

System requirements:

 

In the development environment :

·        Java Development Kit [1]

·        BIRT Engine runtime [2]

·        MS Windows [3]

·        MS Visual C++ (6.0 and later)

In the target environment :

·        Java Runtime [4]

·        BIRT Engine runtime

·        MS Windows

 

Preparing the environment

 

In the development environment :

·        C2Birt static library (C2Birt_clib.lib)

·        C2Birt header file (C2Birt.h)

·        c2birt.jar

In the target environment :

·        c2birt.jar

·        If the application is on the server side (for example made by means of the ISAPI extension) the configuration file C2Birt-config.xml

    1. must be present in the same folder of the server process executable
    2. must be precompiled in all nodes

 

 

Customization of the VC++ Project

·        in the compiler / preprocessor configuration add the following include directories

o       “<pathTo>\ jdkX.X.X_XX\include”

o       “<pathTo>\ jdkX.X.X_XX\\include\win32”

·        choose a location for C2Birt_clib.lib and  C2Birt.h

·        in the linker configuration add the pathname of the C2Birt_clib.lib

·        in the StdAfx.h file add the include statement for the C2Birt.h file

 

Usage of the class C2Birt  in VC++ code

          The constructor checks and manages the configuration. Because of this,           statically or dynamically, is very important when the object is instantiated.

Another fundamental aspect bound to the constructor is that it initializes the JVM and this cannot be done more than once in the same windows process (ask Sun/Oracle and Microsoft about the reason for this); from this descends that the C2Birt object cannot be instantiated more than once in the whole application and during the entire respective life cycle.

 

Reference (VC++ C2Birt class)

Methods:

C2Birt() 

          Is the constructor.

BOOL Init()

          Instantiates the C2Birt.Config java object and through the call of                     the C2Birt.Renderer.Init java method initializes the BIRT Report                    engine.

                   Return value: FALSE if something went wrong.

void SetReportName (LPCTSTR name)

          specifies name of the report design file

          parameters

 name : is the name of the .rptdesign file without extension.

void SetRenderType (LPCTSTR type);

          sets the output format of the report

          parameters

type : available types are :  "pdf", "xls", "html", "ppt",           "doc" and "postscript".

void AddIntParam (LPCTSTR name, int intVal)

          adds the specification of a report parameter of Integer type

          parameters

name : the parameter name

intVal : the integer value

void AddStrParam (LPCTSTR name, LPCTSTR strVal)

          adds the specification of a report parameter of String type

          parameters

name : the parameter name

strVal: the text value

CString RunAndRenderReport ()

          Perfoms the RunAndRender Task

                   Return value: “ok” if all was correct else the description of                              the error

CString RunReport ()

          Perfoms the Run Task      

                   Return value: “ok” if all was correct else the description of                              the error

CString RenderReport ()

          Perfoms the Render Task  

                   Return value: “ok” if all was correct else the description of                              the error

CString RunThenRenderReport ()

          Perfoms the Run Task and after that the Render Task 

                   Return value: “ok” if all was correct else the description of                              the error

void ShowException (CException *e)

          Exposed because is able to direct C2Birt logging; so that the                    application can make use of it to trace the exception caught in the                    C2Birt_log.log file when C2Birt logging is on (if the logging is off                    the behavior is that of a normal alert)

          parameters

e: the exception caught (pointer to)

 

Member variables:

          JNIEnv *m_env

                   The environment pointer different from NULL if the JVM has been            successfully created

          CString m_defaultPathForBrowse

                   The default path for directory browsing

          CString m_rptdesignsPath

                   The path containing all the .rptdesign files (*)

          CString m_rptdocumentPath

                   The path where the BIRT Engine (Run task)  generates                            the document (*)

          CString m_rptOutputPath

                   The path where the BIRT Engine generates the report                              output (*)

          CString m_logsPath

                   The path where the BIRT Engine writes the logs (*)

          CString m_libPath

                   The path containing the C2Birt.jar file (the java                                       library side of C2Birt) (*)

          CString m_birtPath

                   The path of the BIRT Engine libraries (jars).

 NOTE : It cannot be empty !

                  

          (*) If empty C2Birt will search or create the file/s in the directory where                    the process executable is located

         

The Configuration file (C2Birt_config.xml)

          Its structure is as follows:

 

<Configuration>

            <Directories>

                        <lib>....</lib>

                        <birtlibs>....</birtlibs>

                        <rptdesigns>....</rptdesigns>

                        <rptdocuments>....</rptdocuments>

                        <rptOutput>....rptOutput>

                        <rptlogs>....</rptlogs>

            </Directories>

            <c2birt_logging>off</c2birt_logging>

</Configuration>

 

          If it is missing, C2Birt, interactively, drives the user to build it.

          By referring to C2Birt member variables a correspondence with the nodes of the     file does exist:

                  

Node

C2Birt member vars

lib

m_libPath

birtlibs

m_birtPath

rptdesigns

m_rptdesignsPath

rptdocuments

m_rptdocumentsPath

rptOutput

m_rptOutputPath

rptlogs

m_logsPath

 

          The effects of the setting of each node can be derived by the description of the           correspondent C2Birt member variable.

         

Sample application project   

          It is small application that helps the developer to see the C2Birt features and           serves as a model for the real application in addressing C2Birt;

          It is a made by a panel in which the user can see most of the configuration           paths.

          The application opens a report design called SampleRep.rptdesign that, for           simplicity of the demo, has a flat file (customer.csv)  datasource. So that no           dbms datasource must be configured;

          Furthermore the design ha two parameters:

1.     the initial letter of the “last name” by which the set is filtered

2.     the path of the design needed to address the flat file (must be absolute)

 

The C2Birt logger

          It is active only if the node ‘c2birt_logging’ of the configuration file is set to ‘on’.

          It is a simple substitution of the alert messaging for the interactive application.

          Since C2Birt is properly a bridge between VC++ and the BIRT Engine there is           no needs to trace the history of the logs: once the bridge is settled any problem       that is relative to data or report are traced by the BIRT Engine in its log (as     BIRT   does).

          C2Birt log notifies:

1.     configuration problems, that is faults happened during initialization process because of some missing component (see Requirements)

2.     incorrect C2Birt calls written by the VC++ programmer Environment

a.      missing report design files

b.     wrong parameter list associated with each report design file

being all of these problems such that must be fixed before  the end of a typical development process.

          Because of this the log file (C2Birt_log.log), is re-written at every launch of the           application.

          The log file is created in the folder of the application process executable and           only if the problems above occur.

 

Note for the Java developer

          Inside the Renderer class is the method WriteLog that can be used to           trace   the java code in a log named C2Birt_jlog.log, provided that            m_c2birt_config.m_c2birt_JLogging is set to true.

 

 

A part from C2Birt all other marks mentioned in this guide are trade marks or registered trade marks owning to the respective owners.

 

 

 

@ 2012 Stefano Pizzocaro

 


[1] jdk1.6.0_33 and jdk 7 have been tested in this release

[2] version 3.7.2 and version 4.2 have been tested in this release

[3] Here Windows XP and Windows 7 are successfully tested

[4] jre1.6.0_33 and jre 7 have been tested in this release