directly embedded subreport in JasperReports - syntax

I am so close to having this work, I am trying to directly embed one jasper subreport into the main report xml of the other. You'd think this would be easy, but I can't find a single example on doing it. Everyone seems to use files or resources or whatever. I have one report working straight from a string and I want it to contain it's subreport.
Anyone? Syntax? Thanks!

The only way I know of to do this with JasperReports is to use a separate .jrxml file for the subreport, and include it in the main report using the subreport command.
Another option you have for any embedded reports is to use subdatasets, but as far as I know they're only useful for graphs.
As it sounds like you control the code surrounding the generation of the report, you could come up with a simple format to define multiple reports in the one string, and then have your code extract each report at runtime.
When we've needed to deal with a single file but have subreports for a JasperReport, we've used Zip files, and simply zipped up the main report and all it's necessary sub reports, and then unzipped them into a temporary directory when we need to (all in code of course)

Related

Can we use control the source formats/layout in DMExpress using environment variables?

I am using DMExpress tasks to do taransformations on my business data. These business data come in multiple format/layout. I need to be able to use single task for transformation on multiple source layouts. Any DMExpress experts here??
One way that I found out for doing transformation on multiple source layouts with the help of single task was by using the Dmexpress SDK to write the script for the task rather than building the tasks using the GUI task editor. SDK gives lot more flexibility compared to the GUI editor.
But if you are bound to GUI then there is a way around for this specific purpose. You should define a common name for the source layout. Only the source layout name is binded to the task but not the actual layout definition. So you can alter the layout definition while keeping the layout name constant to get a generic task.
FYI- DMExpress is now called DMX (Syncsort changed the name about a year ago).
Do you have multiple different record types within a single file or is each type of record in a separate file? Your question is not clear on this.
If they are in separate files, this is very easy, but you will need to create a separate DMX task for each file. In each of these tasks, define one of the files as the source and create a record layout that matches the format of that file.
If they are in the SAME file, it is only a little more difficult. You can split them into separate files by creating multiple targets and defining a named condition for each target using the SourceName() function (this function returns the name of the file that the current record came from). Then you can process them as separate files (see above). This works UNLESS you have a parent-child relationship going on between the different types of records in that single file. If that is the case, please post some sample data and I can advise on how to handle it.

Creating Multiple TOC for my ROBOHELP

I am creating a robo help for my project and want to create a role based robo help i.e some pages will be hidden for some roles. For that I created multiple Table Of Contents. My question is how to call multiple TOC from my Java project depending on the roles.
You can create multiple TOCs in RoboHelp, but you can only output one at a time. In other words, each compiled Help can only contain one TOC. But you can create multiple Helps, each with different TOCs and then you just have to tell your Java code which Help you want to open.
Create one Single Source Layout for each TOC you want to produce.
Specify which TOC you want to use in each Single Source Layout (Single Source Layout >> Content settings).
Generate each Single Source Layout to different folders (Single Source Layout >> General >> Output Location settings).
Tell Java which Help to launch based on your own critera.

Converting Oracle Reports (.rdf) to BIRT reports

I have some Oracle Reports (.rdf) that I am considering converting to BIRT reports. Is there a way to convert .rdf files to BIRT report design files?
A fully automated solution is probably not possible. You can partially automate the conversion process as follows:
Convert the RDF files to XML.
Extract the report query.
Convert the XML to BIRT (or JRXML) using XSLT.
XML Conversion
The first step is fairly simple, using Cygwin:
cd /path/to/reports/
mkdir xml
for i in *.rdf; do
rwconverter.exe batch=yes source="$i" dest=xml/"$i".xml dtype=xmlfile \
userid=scott/tiger#xe
done
Extraction
The second step is also relatively easy, using starlet (rename xml.exe to starlet.exe to avoid conflicts with Oracle's xml.exe):
starlet.exe sel -t -v "/report/data/dataSource/select" filename.rdf.xml
You can also use xmllint, but it includes the select and CDATA elements, which you'd have to parse separately:
xmllint --xpath /report/data/dataSource/select filename.rdf.xml
Format Conversion
The third step is challenging. Create an XSL template that reads the RDF layouts (e.g., <displayInfo x="0.74377" y="0.97913" width="1.29626" height="1.62695" />). Then convert those layouts to the corresponding format used by the destination report engine (such as BIRT or JasperReports).
You wouldn't get a 100% solution, but an 80% solution could significantly reduce the amount of monotonous, error-prone work required to convert the reports.
I once had a job to convert *.rdf files to Jasper reports. Since I don't know BIRT, I have no idea if this approach would work with BIRT, too.
Anyway, I exported the *.rdf files as xml and parsed the output with Perl and wrote the Jasper definitions, also as xml. For most reports, this worked pretty well. I have -however- one report in mind that I couldn't translate automatically: that was a report where the result set of two queries were laid out side by side.
I haven't found any tools which do this. Some might call this a business opportunity.
RDF files, as far as I can tell, are in some funky binary format. To even have a shot at this, I'd probably convert it first into a REX file, which is supposed to be portable xml. Then, it is a matter of transforming from the REX structure to the BIRT structure. Honestly, I have no idea how documented the REX file is, but maybe since you know how it looks from the visual side you can make sense of it.
Good luck!

Eliminating code duplication in a single file

Sadly, a project that I have been working on lately has a large amount of copy-and-paste code, even within single files. Are there any tools or techniques that can detect duplication or near-duplication within a single file? I have Beyond Compare 3 and it works well for comparing separate files, but I am at a loss for comparing single files.
Thanks in advance.
Edit:
Thanks for all the great tools! I'll definitely check them out.
This project is an ASP.NET/C# project, but I work with a variety of languages including Java; I'm interested in what tools are best (for any language) to remove duplication.
Check out Atomiq. It finds code that is duplicate that is prime for extracting to one location.
http://www.getatomiq.com/
If you're using Eclipse, you can use the copy paste detector (CPD) https://olex.openlogic.com/packages/cpd.
You don't say what language you are using, which is going to affect what tools you can use.
For Python there is CloneDigger. It also supports Java but I have not tried that. It can find code duplication both with a single file and between files, and gives you the result as a diff-like report in HTML.
See SD CloneDR, a tool for detecting copy-paste-edit code within and across multiple files. It detects exact copyies, copies that have been reformatted, and near-miss copies with different identifiers, literals, and even different seqeunces of statements.
The CloneDR handles many languages, including Java (1.4,1.5,1.6) and C# especially up to C#4.0. You can see sample clone detection reports at the website, also including one for C#.
Resharper does this automagically - it suggests when it thinks code should be extracted into a method, and will do the extraction for you
Check out PMD , once you have configured it (which is tad simple) you can run its copy paste detector to find duplicate code.
One with some Office skills can do following sequence in 1 minute:
use ordinary formatter to unify the code style, preferably without line wrapping
feed the code text into Microsoft Excel as a single column
search and replace all dual spaces with single one and do other replacements
sort column
At this point the keywords for duplicates will be already well detected. But to go further
add comparator formula to 2nd column and counter to 3rd
copy and paste values again, sort and see the most repetitive lines
There is an analysis tool, called Simian, which I haven't yet tried. Supposedly it can be run on any kind of text and point out duplicated items. It can be used via a command line interface.
Another option similar to those above, but with a different tool chain: https://www.npmjs.com/package/jscpd

Can JasperReports include a pdf in a report?

Is it possible to include an existing pdf file in a JasperReport?
We really want to append new data to an existing report with out regenerating the existing report. We will be exporting back to pdf. I'm looking at using iText's PdfCopy to merge two pdfs, but was hoping JasperReports might have an easier way...
I don't think you could do that in JasperReports, but it would be fairly simple in iText.
Generate the JasperReport, and then use PdfCopy to append the new report to the original (or vice-versa).

Resources