Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Scripted Data Source Question
dbmathis
Hi All,
I am relatively new to BIRT reporting (approximately 6 months or so) and I am using version 3.7.2 with Eclipse. My understanding of java and javascript is limited at this point, but I catch on quick.
I am trying to create a scripted data source (set?)(I think this is what I need) to use in a report that's already using an XML data source. Currently, from the XML data source I have a data set and from it I have a text field (called userString1) that has a delimited format like so...
[category,value][startdate,date][enddate,date][somefield,value];[category,value][startdate,date][enddate,date][somefield,value]
Where each [,] represents a field with a label and a value and ; equals a new row. This format is flexible and can be altered to whatever, just trying to represent the fact that I have a field with data crammed in it that needs to be parsed and converted into fields and rows that can be used in a table.
Is it possible to use this field (userString1) from the XML data source to build a scripted data source? If not what other options do I have? I need place a table on my report that contains the data from userString1.
I am hoping that someone can provide me with a good example that will not only help me with this specific task, but also jump start my understanding of java while I read and get up to speed.
Thanks in advance.
David
Find more posts tagged with
Comments
mwilliams
Hi David,
Yes, you can use a scripted dataSet to separate this field into multiple rows. In your original dataSet's onFetch script, you'd need to store the values into an array, to use in your scripted dataSet. Then, in your scripted dataSet, you'd step through the array and create your rows.
Another possibility would be to just use script to separate the field into separate rows, in a text box, within the table bound to your original dataSet.
mwilliams
Take a look at this blog post. It links to a forum post where an example was created for the exact same issue.
http://www.birt-exchange.org/org/forum/index.php/blog/14/entry-400-last-week-in-the-forums-word-output-issue-creating-separate-rows-using-a-scripted-dataset-for-a-ssv-field-and-more/
dbmathis
Thanks, would it be possible for you to provide a generic example of these? I have been struggling with this for a few days and want to make sure I have a good understanding.<br />
<br />
I will try what you have mentioned in the meantime and see if I can get it working.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="109319" data-time="1347560943" data-date="13 September 2012 - 11:29 AM"><p>
Hi David,<br />
<br />
Yes, you can use a scripted dataSet to separate this field into multiple rows. In your original dataSet's onFetch script, you'd need to store the values into an array, to use in your scripted dataSet. Then, in your scripted dataSet, you'd step through the array and create your rows.<br />
<br />
Another possibility would be to just use script to separate the field into separate rows, in a text box, within the table bound to your original dataSet.<br /></p></blockquote>
mwilliams
Not sure if you saw my second post, or not. It has a link to an example of the scripted dataSet.
dbmathis
Thanks, I just saw it. I think we replied at the same time. Reading over it now. <br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="109322" data-time="1347562116" data-date="13 September 2012 - 11:48 AM"><p>
Not sure if you saw my second post, or not. It has a link to an example of the scripted dataSet.<br /></p></blockquote>
dbmathis
Hi mwilliams,<br />
<br />
I have been working on implementing the example you provided but I am getting hung up on the java part. Feel free to laugh at my java code because I don't have a clue. Just bought a couple java books yesterday because I need to learn it
. Here's what I have.<br />
<br />
userString1 has the following:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>202406-1|STIP|9/12/2011|9/12/2012|0|35000|0~68106-1|STIP|9/12/2011|9/12/2012|0|35000|0~68106-1|STIP|9/13/2013|9/12/2013|0|35000|0</pre>
<br />
The XML data set beforeOpen<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>incentiveTarget = [];</pre>
<br />
The XML data set beforeClose<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.setPersistentGlobalVariable("incentiveTarget",incentiveTarget);</pre>
<br />
The XML data set onFetch<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>incentiveTarget = row["userString1"].split("~");</pre>
<br />
The scripted data set open<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>incentiveTarget = reportContext.getPersistentGlobalVariable("incentiveTarget");
currentRow = 0;
totalRows = incentiveTarget.length;</pre>
<br />
The scripted data set fetch<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if (currentRow < totalRows) {
rowData = incentiveTarget[currentRow].split("|");
row["id"] = rowData[0];
row["category"] = rowData[1];
row["startDate"] = rowData[2];
row["endDate"] = rowData[3];
row["minAmt"] = rowData[4];
row["targetAmt"] = rowData[5];
row["maxAmt"] = rowData[6];
currentRow++;
return (true);
}
return (false);</pre>
<br />
<br />
The errors:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>Description Resource Path Location Type
Caused by: org.eclipse.birt.data.engine.core.DataException: Column binding "category" has referred to a data set column "category" which does not exist.
at org.eclipse.birt.data.engine.impl.ResultIterator.validateManualBindingExpressions(ResultIterator.java:375)
at org.eclipse.birt.data.engine.impl.ResultIterator.<init>(ResultIterator.java:148)
at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:212)
at org.eclipse.birt.report.engine.data.dte.QueryResultSet.<init>(QueryResultSet.java:115)
at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:176)
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:267)
at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1939)
at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80)
... 47 more
CustomDesignFile.rptdesign /Reports/2.5.0/Mad Science/Total Compensation Data Structure line 15053 BIRT Viewer Problem
org.eclipse.birt.report.engine.api.EngineException: Data Set script method "Fetch" returned null; expected a Boolean value. (Element ID:1)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:244)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:233)
at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleFetch(ScriptDataSetScriptExecutor.java:165)
at org.eclipse.birt.data.engine.impl.ScriptDataSetRuntime.fetch(ScriptDataSetRuntime.java:103)
at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor$CustomDataSet.fetch(PreparedScriptDSQuery.java:260)
at org.eclipse.birt.data.engine.executor.dscache.DataSetToCache.fetchFromDataSet(DataSetToCache.java:242)
at org.eclipse.birt.data.engine.executor.dscache.DataSetToCache.fetch(DataSetToCache.java:171)
at org.eclipse.birt.data.engine.executor.cache.OdiAdapter.fetch(OdiAdapter.java:218)
at org.eclipse.birt.data.engine.executor.cache.RowResultSet.doNext(RowResultSet.java:113)
at org.eclipse.birt.data.engine.executor.cache.RowResultSet.next(RowResultSet.java:91)
at org.eclipse.birt.data.engine.executor.cache.ExpandableRowResultSet.next(ExpandableRowResultSet.java:63)
at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.populateData(SmartCacheHelper.java:316)
at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.initInstance(SmartCacheHelper.java:285)
at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.getResultSetCache(SmartCacheHelper.java:246)
at org.eclipse.birt.data.engine.executor.cache.SmartCache.<init>(SmartCache.java:73)
at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.populateOdiResultSet(PassUtil.java:132)
at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.pass(PassUtil.java:62)
at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.doSinglePass(PassManager.java:170)
at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.prepareDataSetResultSet(PassManager.java:94)
at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.populateDataSetResultSet(PassManager.java:80)
at org.eclipse.birt.data.engine.executor.transform.ResultSetPopulator.cacheDataSet(ResultSetPopulator.java:203)
at org.eclipse.birt.data.engine.executor.transform.CachedResultSet.<init>(CachedResultSet.java:142)
at org.eclipse.birt.data.engine.executor.CandidateQuery.execute(CandidateQuery.java:160)
at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor.executeOdiQuery(PreparedScriptDSQuery.java:226)
at org.eclipse.birt.data.engine.impl.QueryExecutor.execute(QueryExecutor.java:1134)
at org.eclipse.birt.data.engine.impl.ServiceForQueryResults.executeQuery(ServiceForQueryResults.java:232)
at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:177)
at org.eclipse.birt.report.engine.data.dte.QueryResultSet.<init>(QueryResultSet.java:115)
at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:176)
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:267)
at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1939)
at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80)
at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLListLM.layoutChildren(HTMLListLM.java:72)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:180)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:929)
at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973)
at org.eclipse.birt.report.service.actionhandler.BirtRunAndRenderActionHandler.__execute(BirtRunAndRenderActionHandler.java:76)
at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90)
at org.eclipse.birt.report.presentation.aggregation.layout.EngineFragment.doService(EngineFragment.java:318)
at org.eclipse.birt.report.presentation.aggregation.AbstractBaseFragment.service(AbstractBaseFragment.java:76)
at org.eclipse.birt.report.servlet.BirtEngineServlet.__doGet(BirtEngineServlet.java:120)
at org.eclipse.birt.report.servlet.BaseReportEngineServlet.doGet(BaseReportEngineServlet.java:185)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.birt.report.servlet.BaseReportEngineServlet.service(BaseReportEngineServlet.java:116)
at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:317)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.eclipse.birt.data.engine.core.DataException: Data Set script method "Fetch" returned null; expected a Boolean value.
at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleFetch(ScriptDataSetScriptExecutor.java:153)
... 76 more
CustomDesignFile.rptdesign /Reports/2.5.0/Mad Science/Total Compensation Data Structure line 2 BIRT Viewer Problem
org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "if (currentRow < totalRows) {
rowData = incentiveTarget[currentRow].split("|");
row["id"] = rowData[0];
row["category"] = rowData[1];
row["startDate"] = rowData[2];
row["endDate"] = rowData[3];
row["minAmt"] = rowData[4];
row["targetAmt"] = rowData[5];
row["maxAmt"] = rowData[6];
currentRow++;
return (true);
}
return (false);":
Fail to execute script in function __bm_FETCH(). Source:
" + if (currentRow < totalRows) {
rowData = incentiveTarget[currentRow].split("|");
row["id"] = rowData[0];
row["category"] = rowData[1];
row["startDate"] = rowData[2];
row["endDate"] = rowData[3];
row["minAmt"] = rowData[4];
row["targetAmt"] = rowData[5];
row["maxAmt"] = rowData[6];
currentRow++;
return (true);
}
return (false); + "
A BIRT exception occurred. See next exception for more information.
Error evaluating Javascript expression. Script engine error: ReferenceError: "totalRows" is not defined. (/report/data-sets/script-data-set[
@id="
;3412"]/method[
@name="
;fetch"]#1)
Script source: /report/data-sets/script-data-set[
@id="
;3412"]/method[
@name="
;fetch"], line: 0, text:
__bm_FETCH(). (Element ID:1)
at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:99)
at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.handleJS(DataSetScriptExecutor.java:256)
at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleFetch(ScriptDataSetScriptExecutor.java:143)
at org.eclipse.birt.data.engine.impl.ScriptDataSetRuntime.fetch(ScriptDataSetRuntime.java:103)
at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor$CustomDataSet.fetch(PreparedScriptDSQuery.java:260)
at org.eclipse.birt.data.engine.executor.dscache.DataSetToCache.fetchFromDataSet(DataSetToCache.java:242)
at org.eclipse.birt.data.engine.executor.dscache.DataSetToCache.fetch(DataSetToCache.java:171)
at org.eclipse.birt.data.engine.executor.cache.OdiAdapter.fetch(OdiAdapter.java:218)
at org.eclipse.birt.data.engine.executor.cache.RowResultSet.doNext(RowResultSet.java:113)
at org.eclipse.birt.data.engine.executor.cache.RowResultSet.next(RowResultSet.java:91)
at org.eclipse.birt.data.engine.executor.cache.ExpandableRowResultSet.next(ExpandableRowResultSet.java:63)
at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.populateData(SmartCacheHelper.java:316)
at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.initInstance(SmartCacheHelper.java:285)
at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.getResultSetCache(SmartCacheHelper.java:246)
at org.eclipse.birt.data.engine.executor.cache.SmartCache.<init>(SmartCache.java:73)
at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.populateOdiResultSet(PassUtil.java:132)
at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.pass(PassUtil.java:62)
at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.doSinglePass(PassManager.java:170)
at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.prepareDataSetResultSet(PassManager.java:94)
at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.populateDataSetResultSet(PassManager.java:80)
at org.eclipse.birt.data.engine.executor.transform.ResultSetPopulator.cacheDataSet(ResultSetPopulator.java:203)
at org.eclipse.birt.data.engine.executor.transform.CachedResultSet.<init>(CachedResultSet.java:142)
at org.eclipse.birt.data.engine.executor.CandidateQuery.execute(CandidateQuery.java:160)
at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor.executeOdiQuery(PreparedScriptDSQuery.java:226)
at org.eclipse.birt.data.engine.impl.QueryExecutor.execute(QueryExecutor.java:1134)
at org.eclipse.birt.data.engine.impl.ServiceForQueryResults.executeQuery(ServiceForQueryResults.java:232)
at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:177)
at org.eclipse.birt.report.engine.data.dte.QueryResultSet.<init>(QueryResultSet.java:115)
at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:176)
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:267)
at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1939)
at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80)
at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)
at org.eclipse.birt.report.engine.layout.html.HTMLListLM.layoutChildren(HTMLListLM.java:72)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:180)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:929)
at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973)
at org.eclipse.birt.report.service.actionhandler.BirtRunAndRenderActionHandler.__execute(BirtRunAndRenderActionHandler.java:76)
at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90)
at org.eclipse.birt.report.presentation.aggregation.layout.EngineFragment.doService(EngineFragment.java:318)
at org.eclipse.birt.report.presentation.aggregation.AbstractBaseFragment.service(AbstractBaseFragment.java:76)
at org.eclipse.birt.report.servlet.BirtEngineServlet.__doGet(BirtEngineServlet.java:120)
at org.eclipse.birt.report.servlet.BaseReportEngineServlet.doGet(BaseReportEngineServlet.java:185)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.birt.report.servlet.BaseReportEngineServlet.service(BaseReportEngineServlet.java:116)
at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:317)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.eclipse.birt.data.engine.core.DataException: Fail to execute script in function __bm_FETCH(). Source:
" + if (currentRow < totalRows) {
rowData = incentiveTarget[currentRow].split("|");
row["id"] = rowData[0];
row["category"] = rowData[1];
row["startDate"] = rowData[2];
row["endDate"] = rowData[3];
row["minAmt"] = rowData[4];
row["targetAmt"] = rowData[5];
row["maxAmt"] = rowData[6];
currentRow++;
return (true);
}
return (false); + "
</pre>
mwilliams
Make sure you have a report element bound to your XML dataSet prior to any element bound to your scripted dataSet in your report. The best thing to do, in a situation like this is to put a text box, bound to your original dataSet, at the very top of your design.
dbmathis
Thanks Michael,<br />
<br />
The XML data set is bound to the list element. It has something to do with my java code, and I can't figure it out. I can output debug code and see that the userString1 text is making it to the XML onFetch, but for some reason my code is behaving differently from the example you provided.<br />
<br />
For example here's your example:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>beforeOpen
eventID = [];
eventTopic = [];
eventAttendeeIDs = [];
beforeClose
reportContext.setPersistentGlobalVariable("eventID",eventID);
reportContext.setPersistentGlobalVariable("eventTopic",eventTopic);
reportContext.setPersistentGlobalVariable("eventAttendeeIDs",eventAttendeeIDs);
onFetch
eventID[eventID.length] = row["eventID"];
eventTopic[eventTopic.length] = row["eventTopic"];
eventAttendeeIDs[eventAttendeeIDs.length] = row["eventAttendeeIDs"].split(";");
logToDebugWindow(eventAttendeeIDs);
output from debug window
268,254,24,167
268,254,24,167,196
268,254,24,167,196,392,161,173,352</pre>
<br />
What I get with the same code:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>Using the following format.. row delimiter = ~ column delimiter = ;
202407-1;STIP;9/12/2011;9/12/2012;0;35000;0~68107-1;STIP;9/12/2011;9/12/2012;0;35000;0~68107-1;STIP;9/13/2013;9/12/2013;0;35000;0
beforeOpen
incentiveTarget = [];
beforeClose
reportContext.setPersistentGlobalVariable("incentiveTarget",incentiveTarget);
onFetch
if (row["userString1"] != "" ) {
incentiveTarget[incentiveTarget.length] = row["userString1"].split("~");
logToDebugWindow(incentiveTarget);
}
[Ljava.lang.String;
@4e542
[Ljava.lang.String;
@4e542
,[Ljava.lang.String;
@701420
</pre>
<br />
Then I have noticed that the open for the scripted data set, reportContext.getPersistentGlobalVariable isn't working. Not sure if it has anything to do with Ljava.lang.String;@.....<br />
<br />
Best Regards<br />
<br />
David
dbmathis
Thanks for all your help Michael, I finally got it working. I can't share the design file because it contains lots of confidential info, but here's the code.<br />
<br />
Within the XML Data Set I populated userString1 with a delimited format I came up with for two people. This looks like the following:<br />
<br />
~ is the row delimiter <br />
; is the column delimiter<br />
<br />
22406-1;STIP;9/12/2011;9/12/2012;0;35000;0~6806-1;STIP;9/12/2011;9/12/2012;0;35000;0~6806-1;STIP;9/13/2013;9/12/2013;0;35000;0<br />
<br />
And<br />
<br />
22407-1;STIP;9/12/2011;9/12/2012;0;35000;0~6807-1;STIP;9/12/2011;9/12/2012;0;35000;0~6807-1;STIP;9/13/2013;9/12/2013;0;35000;0 <br />
<br />
<br />
<br />
<strong class='bbc'>The data set code</strong><br />
<br />
XML Data Set beforeOpen<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>incentiveTarget = [];</pre>
<br />
XML Data Set beforeClose<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.setPersistentGlobalVariable("incentiveTarget",incentiveTarget);</pre>
<br />
XML Data Set onFetch<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if ( row["userString1"] != "" ) {
incentiveTarget[incentiveTarget.length] = row["userString1"].split("~");
}</pre>
<br />
Scripted Data Set open<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>incentiveTarget = reportContext.getPersistentGlobalVariable("incentiveTarget");
currentRow = 0;
currentRecord = 0;
totalRows = incentiveTarget.length;</pre>
<br />
Scripted Data Set fetch<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if (currentRow < totalRows){
record = incentiveTarget[currentRow];
if (currentRecord < record.length) {
rowData = record[currentRecord].split(";");
row["id"] = rowData[0];
row["category"] = rowData[1];
row["startDate"] = rowData[2];
row["endDate"] = rowData[3];
row["minAmt"] = rowData[4];
row["targetAmt"] = rowData[5];
row["maxAmt"] = rowData[6];
currentRecord++
if (currentRecord == record.length) {
currentRecord = 0;
currentRow++;
}
return (true);
}
}
return (false);</pre>
mwilliams
Sorry for the delay. The forums are very backed up and I try to work from the back to the front, so I hadn't quite gotten to yours. Glad you got it working. I'm not sure I notice a difference between the code you were having a problem with and what finally worked. Was the issue just with the scripted dataSet? Or is there something I'm not noticing?
dbmathis
Hi Michael,
The issue was in the way I was using both the onFetch to populate the array and then how I was grabbing and slicing the data out of my array in the fetch. I was all mixed up, but sorted it all out.
Oh, and I did end up adding the text element up top because the table was nested in the list and wasn't working quite right.
Best Regards
David