![](http://content.invisioncic.com/i328763/set_resources_3/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
pebie
-
Posts
2 -
Joined
-
Last visited
Content Type
Forum
Downloads
Featured Visualizations
Knowledge Base
Documentation (PDF Downloads)
Blog
Documentation (Test Area)
Documentation
Dr. Jaspersoft Webinar Series
Security Advisories
Events
Profiles
Posts posted by pebie
-
-
Hello all,
I want to store my report definitions in a database with access for multiple users.
There will be concurrent access (upload/update, compilation, run, delete) to the report definitions.
To ensure consistency between main- and subreports locking/allocation/copying of reportdefinitions to the beginning of the report generation is neccessary to avoid inconsistencies/locks.
So i need to determine, which reports are used by the main report.
I want to put the used JasperReport objects to a hash associated to the current reporting run to avoid them to change.
As i don`t want to write my own parser, i tried to overload JRVerifier/verifySubreport (see 4).
Too bad that this method is private.
Is there a deeper reason not to declare it protected ?
Or is there a recommended way to find out my specific subreport references ?
(i have tried to use a manipulated JRXmlWriter. It works, but uses a lot of space and time to get rid of the written xml)
Thanx in advance,
pebie
--------------
(1)The snippet from the referencing main.jrxml
<subreport isUsingCache="true">
<reportElement
x="168"
y="7"
width="350"
height="31"
key="subreport-1"/>
<connectionExpression>
<![CDATA[$P{REPORT_CONNECTION}]]>
</connectionExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport">
<![CDATA[subReportResolver.getReport("subsubsub")]]>
</subreportExpression>
</subreport>
-------------
(2)The Subreport Resolver
public class SubReportResolver {
// stub implementation for testing with iReport
public static JasperReport getReport(String name) throws JRException{
String basePath="......\resources\jasper\";
String ext=".jrxml";
System.out.println("Compiling "+name);
return MyCompileManager.compileReport(basePath+name+ext);
}
}
--------------
(3)Overloaded Compiler Manager
public class MyCompileManager extends JasperCompileManager {
public static JasperReport compileReport(String sourceFileName) throws JRException
{
JasperDesign jasperDesign = JRXmlLoader.load(sourceFileName);
// c should contain accessed JasperReport objects (and maybe errors of cause)
Collection c = MyVerifier.verifyDesign(jasperDesign);
return compileReport(jasperDesign);
}
}
--------------
(4)Overloaded Verifier
public class MyVerifier extends JRVerifier {
protected MyVerifier(JasperDesign jrDesign, JRExpressionCollector expressionCollector)
{
super(jrDesign,expressionCollector);
}
public static Collection verifyDesign(JasperDesign jasperDesign, JRExpressionCollector expressionCollector)
{
// copied from base class
MyVerifier verifier = new MyVerifier(jasperDesign, expressionCollector);
return verifier.verifyDesign();
}
private void verifySubreport(JRSubreport subreport)
{
// access subreport and put it to a save haven
// subreport.getExpression().getText() matches SubReportResolver
System.out.println("Verifiying "+subreport.toString());
}
}
identify referenced subreports
in Products
Posted
Hello all,
I want to store my report definitions in a database with access for multiple users.
There will be concurrent access (upload/update, compilation, run, delete) to the report definitions.
To ensure consistency between main- and subreports locking/allocation/copying of reportdefinitions to the beginning of the report generation is neccessary to avoid inconsistencies/locks.
So i need to determine, which reports are used by the main report.
I want to put the used JasperReport objects to a hash associated to the current reporting run to avoid them to change.
As i don`t want to write my own parser, i tried to overload JRVerifier/verifySubreport (see 4).
Too bad that this method is private.
Is there a deeper reason not to declare it protected ?
Or is there a recommended way to find out my specific subreport references ?
(i have tried to use a manipulated JRXmlWriter. It works, but uses a lot of space and time to get rid of the written xml)
Thanx in advance,
pebie
PS: i have posted this in 'Discussion/Help'.
Does anyone know how to delete an unintentionally sent item ?
--------------
(1)The snippet from the referencing main.jrxml
<subreport isUsingCache="true">
<reportElement
x="168"
y="7"
width="350"
height="31"
key="subreport-1"/>
<connectionExpression>
<![CDATA[$P{REPORT_CONNECTION}]]>
</connectionExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport">
<![CDATA[subReportResolver.getReport("subsubsub")]]>
</subreportExpression>
</subreport>
-------------
(2)The Subreport Resolver
public class SubReportResolver {
// stub implementation for testing with iReport
public static JasperReport getReport(String name) throws JRException{
String basePath="......resourcesjasper";
String ext=".jrxml";
System.out.println("Compiling "+name);
return MyCompileManager.compileReport(basePath+name+ext);
}
}
--------------
(3)Overloaded Compiler Manager
public class MyCompileManager extends JasperCompileManager {
public static JasperReport compileReport(String sourceFileName) throws JRException
{
JasperDesign jasperDesign = JRXmlLoader.load(sourceFileName);
// c should contain accessed JasperReport objects (and maybe errors of cause)
Collection c = MyVerifier.verifyDesign(jasperDesign);
return compileReport(jasperDesign);
}
}
--------------
(4)Overloaded Verifier
public class MyVerifier extends JRVerifier {
protected MyVerifier(JasperDesign jrDesign, JRExpressionCollector expressionCollector)
{
super(jrDesign,expressionCollector);
}
public static Collection verifyDesign(JasperDesign jasperDesign, JRExpressionCollector expressionCollector)
{
// copied from base class
MyVerifier verifier = new MyVerifier(jasperDesign, expressionCollector);
return verifier.verifyDesign();
}
private void verifySubreport(JRSubreport subreport)
{
// access subreport and put it to a save haven
// subreport.getExpression().getText() matches SubReportResolver
System.out.println("Verifiying "+subreport.toString());
}
}