• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Converting my dynamic report with JasperReports

 
Greenhorn
Posts: 20
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I'm developing a web app for writing reports on the quality of service provided by businesses. Its for a company that does tests, they go to a business as clients and take note of various aspects of the services provided. The report will have parts divided into question groups on particular topics, each of which will have questions. The questions can be of a few different types each of which needs to be printed accordingly (questions with plain text answers, multiple choice questions, etc). The report parts, question groups and questions are dynamic and they will be different for different clients.

So my question is, which would be the best way to go to generate pdf's for such reports? So I need to loop through the report parts, question groups and questions and print the answers. Multiple choice questions should have checkmarks where appropriate. The report should obviously also have headers and footers, a background image, nice front page etc. Will it be feasible to fetch the report parts, question groups and questions from database using JasperReports (the ReportTemplate object will have these as properties) as well as the answers given in a particular report. A Report object will have an ArrayList<Answer> listing the provided answers (plain text answers, multiple choice, etc) in the order that they are iterated in the relevant ReportTemplate. Does this sound feasible and how would you do it?

I could of course first produce xml of the questions and answers if it's not possible to fetch all of these from a database.

So how would you do this? JasperReports or something else?

 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Jarno

I remember your first few posts about your project.

When it comes to reports, the problem boils down to sql, whether you use table or view to store the final output for the report.

So how is your question and answer tables set up? Can these 2 tables join together to give some output similar to:
User1 Q1 MC A
User1 Q2 FreeText 'bla bla bla'
User2 Q3 MC A
User2 Q3 MC B
User2 Q1 MC C

Note that using the above example:
Q1 is a multiple choice single selection
Q2 is free form text
Q3 is multiple choice multiple select

 
Jarno Virta
Greenhorn
Posts: 20
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Thanks again for your answer and help! Yeah, I figured I'd make a separate question of the pdf generation side. At the moment I'm just trying to figure out which way to go and what technology could be most useful. I have a few things to fix in my code and then I'll have to start getting into pdf stuff. I have never worked with JasperReports, so I'll have to learn as I go. I have printed the guide to iReport and the library.

The report is not going to be a bunch of answers by a bunch of people like a list of questionnaire answers. Rather, the guys I'm writing the program for will have someone visit a business as a client and observe the quality of service and write a report on that. The businesses are auto repair shops and the clients of my friend will be importers of motor vehicles. So basically they will provide pick an auto repair shop and send someone over with a car with defects and rate the performance. So its one set of answers per report.

Based on the other thread I revamped the class structure of the program. As I mentioned earlier, the questions for each client (importer) will be different. So I have a class called ReportTemplate which has a List of ReportParts, and they in turn have a List of QuestionGroups, which in turn have a List of Questions. Based on the earlier discussion I removed all that relates to answers and made a separate class called Report the instances of which will contain the answers. So Report has a reference to the relevant ReportTemplate and an ArrayList of Answers. When the report is filled out or shown, the parts and groups and questions in ReportTemplate are iterated through. I figured Report doesn't need a Map<Question, Answer> but an ArrayList<Answer> is sufficient and answers will be stored in the order of the questions in ReportTemplate (starting with ReportPart[0], QuestionGroup[0], Question[0]). This may change if need be, but for now I think this is sufficient.

So I think this class structure is ok now and it works fine for filling in and showing the reports. Also, saving the report in database and fetching it works. So when fetching a particular report, I'm going to get the instance of Report which references ReportTemplate and iterate through them as described.

As I said earlier, I'm very much a noob when it comes to ORM. I'm learning as I go. And since I have never used JasperReports, I don't really have an idea of how well it will work for this kind of report and which would be the easiest way of generating a pdf file of the report. So to be honest, I cant really say for now what I can and can't do with JasperReports and SQL.

I'm interested in all ideas as to which way to go. Then, based on any guidance I'll get here, I'll break out my books and guides and learn what I need. It's just that any pointers would be very useful so that I'll hopefully take off on the right path as I'm sure there will be quite a bit to learn and do to get the pdf generation done. For now, I have a working solution to print to pdf using PDFCreator and it produces fairly nice looking reports but it's not a convenient enough solution in the long run.

 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!