Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Overwrite JNDI Name String in Java Code NOT ScriptedDataSourceEventAdapter
Alex Zot
<p>Hi everyone,</p>
<p> </p>
<p>I need a way to change the jndi name string in the dataSource beside the ScriptedDataSourceEventAdapter.</p>
<p>I cannot use because in Joint DataSets it is never called when attached to sql data sources.</p>
<p> </p>
<p>I´ve already tried this in an extension of ReportEventAdapter/beforeFactory:</p>
<p> </p>
<p>1.)</p>
<p>String jndiNameString = (String) element.getUserPropertyExpression("odaJndiName");</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>element.setUserProperty("odaJndiName", jndiNameString);</p>
<p> </p>
<p>2.)</p>
<p>IDataSource dataSource = report.getDataSource("Data Set");</p>
<p>dataSource.getPrivateDriverProperty("odaJndiName"); // which does not know of odaJndiName</p>
<p> </p>
<p>Please help, because we need to change the jndi String depending on input parameters</p>
Find more posts tagged with
Comments
Alex Zot
<p>Now I´ve trief to change it with:</p>
<p> </p>
<p> </p>
<p>ReportingContext ownContext = (ReportingContext) reportContext.getParameterValue(ReportParameters.IReportContext.CTX);<br>
SlotHandle handle = reportContext.getDesignHandle().getDataSources();<br>
int count = handle.getCount();<br>
for(int i = 0; i<count;i++ ){<br>
DesignElementHandle elementHandle = handle.get(i);<br>
if(elementHandle instanceof OdaDataSourceHandle){<br>
OdaDataSourceHandle dataSetHandle = (OdaDataSourceHandle) elementHandle;<br>
OdaDataSource dataSource = (OdaDataSource) dataSetHandle.getElement();<br>
dataSetHandle.getName().equals("Data Source");<br>
String jndiNameString = (String)dataSetHandle.getProperty("odaJndiName");<br>
<br>
............<br>
<br>
try {<br>
dataSetHandle.setProperty("odaJndiName", jndiNameString);<br>
} catch (SemanticException e) {<br>
// TODO Auto-generated catch block<br>
e.printStackTrace();<br>
}<br>
<br>
<br>
}<br>
<br>
}</p>
<p> </p>
<p>in the Method afterfactory. That does actually change the data to the correct information, but has NO Effect on the report.</p>
<p> </p>
<p>Does anybody have an idea?</p>
Alex Zot
<p>Yesss! We found a solution.</p>
<p>For whoever has the same problem.</p>
<p>This is the solution:</p>
<p> </p>
<p>in the beforefactory method use the code from above (copied here):<br>
SlotHandle handle = reportContext.getDesignHandle().getDataSources();<br>
int count = handle.getCount();<br>
for(int i = 0; i<count;i++ ){<br>
DesignElementHandle elementHandle = handle.get(i);<br>
if(elementHandle instanceof OdaDataSourceHandle){<br>
OdaDataSourceHandle dataSetHandle = (OdaDataSourceHandle) elementHandle;<br>
OdaDataSource dataSource = (OdaDataSource) dataSetHandle.getElement();<br>
dataSetHandle.getName().equals("Data Source");<br>
String jndiNameString = (String)dataSetHandle.getProperty("odaJndiName");<br>
<br>
............<br>
<br>
try {<br>
dataSetHandle.setProperty("odaJndiName", jndiNameString);<br>
} catch (SemanticException e) {<br>
// TODO Auto-generated catch block<br>
e.printStackTrace();<br>
}<br>
<br>
<br>
}<br>
<br>
}</p>
<p> </p>
<p> </p>
<p>So basically we overwrite the jndi String before the element is opened and therefore the correct jndi String is opened and the problem with the jointdataset does not bother us anymore!!</p>