Adding values to a BIRT report through servlet - java

Please before you say its repeated please understand my problem.
Im developing Java EE 8 application which makes use of BIRT to generate a pdf and send it on to client. I've already completed report design, and webpages to take the data, and also servlets to process render and send the generated pdf(generic).
But i want to add the data received from the request directly to the generated pdf ie without adding them to a database(so i cannot add the values by binding data source).Ive even added the names in report design to enable me to add values at run time.
Ive seen How do you set and pass a parameter to a BIRT report created by the BIRT Report Designer through the BIRT API? and understood idea there but my problem is i have date columns in my design which has to be set as well.
What im hoping with this question is
A simple example to the provided solution in the linked post.Or a
better solution if present.
Which is the class which can populate the BIRT-date since java.util.Date is deprecated.
And to know if BIRT api provides way to manuplate the report elements via name or id in a servlet or a model java class.
thankyou for your help
forgiving me if i have bored you with a long question.
Ashwin

Why don't you just consider using a string representation of the date values instead?

Related

How to create new defect/s in HP ALM 12 using REST

I am working on a Java application to connect with HP ALM 12 using their REST API programmatically and have been hitting some road blocks as they don't seem to provide any examples for that in their documentation, unless I am looking at the wrong place.
So far, I have been able to do the following:
Authenticate a user
Get a list of all existing entities, defects
Has anyone been able to do the following
Get a list of fields (for any new defect) in any particular release
Determine if those fields are required (mandatory) or not
Then based on that create a new defect and save that defect in ALM using the REST API ?
Get a confirmation for the created defect, such as a Defect ID.
Any example or suggestions are welcome.
After some digging through their documentation, I figured out the schema elements for the defect type and all its dependencies. I then generated JAXB classes out of them using Java's xjc utility. Then used it to marshall an XML that I was able to insert in ALM 12 with no issues. There, however, seem to be certain fields within ALM 12 that need special attention (i.e, DetectedInRelease etc) that store an internal folder structure instead of a straight value. Other than that, it seemed straightforward. I will try to write up a blog article with sample code as soon as I find some free time.
Meanwhile, if anyone has specific questions about the process, please post them here and I will try to answer them to the best of my knowledge.

How to create Report from DB information in PDF format without using jasper

I want to create reports in PDF using the data available in database. I want to do some data manipulation and use the charts and details to be shown in pdf to the user.Suppose say there are 2 columns in DB a and b . I want to show in the PDF, the value of a and b and the addition of a and b. What i can use to generate this pdf report?
I thought of using jasper, but i donot want to use it. Instead is there any other logic in java that can help to solve this problem. Please suggest with examples.
Thanks
Birt is a tool that can be used to generate all sorts of reports. There are plugins for Eclipse that you can use to help you get going and you can definitely add logic in Java. It can output your report in multiple formats including PDF, HTML, and I believe even Word docs.
If you've used Eclipse before you should be able to figure out the basics, but it can get as complicated as you want. In its simplest form you attach data sources (such as a database with a JDBC connection) and you structure your joins and layout fields onto a form. You can even tie it into a Java EE container if needed.
There are examples on their website and it has a rather large community to help with questions.

Reporting framework for Java spring web application

Am working on a java spring web application. I want to implement reporting features for it. the main feature i want to implement in reporting is that i should be able to select some parameters. depending on that the reports should be generated. Parameter selection mean: i select 2 dates and the report should be generated for the data within those 2 dates. this is just an example. can anyone suggest me on what i should be using?
Taking off from your question in the comments section on using parameters in JasperReports:
4.1. Parameters
Parameters are useful for passing data to the report engine that it can not find > in its data source or when data changes depending on different runtime > > conditions.
We can also change portions or even the entire SQL query with parameters received > in the report filling operation.
The section 4.1 of blog should help you with creating a query statement with the parameters.

Configuring & Generating BIRT Reports Dynamically

From watching the 2-part YouTube videos and perusing the BIRT manual, my understanding of it is the the worflow goes something like this:
Create a new Report in Eclipse
Use the BIRT Report Designer (Eclipse plug-in) to design a report
Populate the report with Data Sources (JDBC drivers & databases) and Data Sets (specific tables)
Generate/export/print the report
As cool as this tool seems to be, I cannot find any documentation that leads me to believe that this is a Java tool and not an Eclipse-only tool (meaning, it has a Java API and can interact with Java apps, as opposed to a pure Eclipe plug-in which requires manual/human interaction from the Eclipse IDE.
Specifically, I want to confirm that BIRT either can or cannot do the following:
Configure a report (layout, UI widget placement, data sources/sets, etc.) programmatically; i.e. in the same way that JasperReport API has the iReport designer that generates JRXML, is the same true for BIRT?
Kick off a report "generation" through a Java API whereby data gets read-in realtime and populates the report and the report can be sent out or stored on a file system
Create HTML and PDF versions of the same report
Answers to your questions:
Yes. BIRT may not be as powerful as JasperReports, but it can achieve most of the common needs.
BIRT designer generates a .rptdesign file similar to JRXML in JasperReports.
About your question: almost everything is possible to achieve programmatically in BIRT. BIRT Report Engine APIs is the best source for you to get started with all the functionalities you have mentioned. It has good examples given for every functionality.
Not sure. BIRT usually fetches pre-saved data from DB and generates the report. You could though see the real time data representation (in the form of a flash chart may be) with the help of some external libraries (See if this thread and this example helps). But I am not aware of a direct way of converting the real time data to PDF/HTML report. You will have to find some hack(s).
Yes of course. Refer the APIs. To be specific, irendertask.
Sources to get more information/answers:
There are several example reports given on the website. A quick glance through them might give you more insights.
For discussions and troubleshooting, refer eclipse community forum and BIRTExchange (heavily used by BIRT users).
BIRT: A Field Guide to Reporting is an excellent book. I've used it myself from time to time.
I can confirm that the two BIRT components you are interested in using (BIRT Design Engine and Report Engine) will work in a pure-Java context and are deployable without Eclipse. I have deployed BIRT reports to run out of standalone Tomcat servers as well as Pentaho BI Server, and have exercised report definitions at the command line using shell scripts (no Eclipse involved).
Answers to your questions:
Configure a report programmatically: use the Design Engine API. I am not familiar with the Jasper Reports API so cannot comment on whether the BIRT method is similar, but the example code provides a good illustration. In particular, note lines 120-133 which add and manipulate widgets in the report, and how line 136 calls saveAs to save the report design file.
Generate a report in realtime: use the Report Engine. The sample code for the IRunAndRenderTask may be the most useful for you at first, but the engine has the ability to separate the data processing (extract and aggregate) of the report from the rendering and paging. I believe the examples focus on running reports from a Servlet, but it is easy to extract that logic from the servlet container logic.
Create both HTML and PDF versions: easily handled in the Report Engine via the IRenderTask. Once you've been through all the other setup work, changing the output format to produce PDF vs HTML is something of a joy. In my experience, it just works.
I found it useful to start out with a very simple Java class (adapted from the very old code here) to run a test report, called from the command line.
you can use the report engine API to configure reports:
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php#ireportrunnable
You can create HTML or PDF versions of a report by setting a variable in the url to generate the report or if using the report engine programmatically:
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php#irendertask
We use Eclipse to build and design reports. The report engine is deployed as part of a reports_war, the war has its own connection to the database. Our Java based web application uses urls to interact with the report templates (variables are set in the urls).
The BIRT Exchange is a good place for more information
There is not much difference between Birt and jasper as designing point of view except birt have eclipse plugin.
1)yes,you can configure it by java program or methods.
2)yes,this is possible.
3)yes again for export your report in different formats is easy for birt report by java
BIRT is a good and easy tool fro report generating.
you can design your pages in BIRT.
-
Create datasets and can pass the values from your web pages to your BIRT design using jsp tag lib.
BIRT fulfills all your requirement. Its so easy to use. first i use jasper, then tried crystal atlast Birt gies the output.
tag lib
i refer this link to view BIRTVIEWVER in my web page. PDF creation is so perfect in BIRT. You can generate PDF, DOC, HTML also.
you can pass values to your birt . while creating dataset there is option for passing params.
to do all this you have to install BIRTREPORT inyour eclipse BIRT Report designer

Creating reports in Java without using a database

Is there a simple way to create reports in Java without using a database (like SQL)?
What I want to do is to get a number of strings in an ArrayList of objects and then put them on a printable report. Also, i want to put values from a comma-separated file to the printable report. I've found this JavaDoc but, based from what I've understood, it's not possible to design the report using this. (Correct me if I'm wrong)
Try JasperReports, it's the most common open source tool for reporting in the Java world, and you can create reports from multiple data sources, not only data bases.
Reports are view, separate from the source of data. I don't see how a report would know the difference between a database and a list of strings.
Data is data, regardless of where it comes from. I didn't bother to read the link you included, because tying a report to a particular type of data doesn't make sense to me.

Categories