Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » skip ODA lib script in design time (skip ODA lib script in design time )
skip ODA lib script in design time [message #731826] Mon, 03 October 2011 08:52 Go to next message
Paulo Mising name is currently offline Paulo Mising nameFriend
Messages: 13
Registered: July 2009
Junior Member
Hello i Have this script in my Library on (before open) ODA


importPackage( Packages.java.lang );
importPackage( Packages.java.util );
importPackage( Packages.javax.servlet.http);

httpServletReq = reportContext.getHttpServletRequest();
session = httpServletReq.getSession();
if ( reportContext.getHttpServletRequest().getParameter("urlB") != null &&
reportContext.getHttpServletRequest().getParameter("usrB") != null &&
reportContext.getHttpServletRequest().getParameter("pasB") != null
)
{

this.setExtensionProperty("odaURL", reportContext.getHttpServletRequest().getParameter("DatabaseUrl"));
this.setExtensionProperty("odaUser", reportContext.getHttpServletRequest().getParameter("DatabaseUserName"));
this.setExtensionProperty("odaPassword",reportContext.getHttpServletRequest().getParameter("DatabasePassword"));
}

if ( reportContext.getHttpServletRequest().getParameter("DatabaseJndi") != null)
{

// set the birt variable jndi to the jndi url parameter
this.setExtensionProperty("odaJndiName", reportContext.getHttpServletRequest().getParameter("DatabaseJndi"));
}
if ( session.getAttribute("sessionJndi") != null &&
session.getAttribute("sessionJndiPrivilege") != null )
{

}

// if all of this fail the birt report will try to execute with the development variables set on the report it self.

true;




it works fine on the web container getting the jndi connection from the session, but in design (Eclipe ou BIRT RCP DESIGNER ) time when on the data set - query the output columns it crash.

Of course because of the reportContext.getHttpServletRequest not available in design time on the eclipse.

Can some one please help me find a way of knowing when i'm in design time (ECLIPSE BIRT RCP DESIGNER) and skip this javascipt block , and not in the web container ?


Thanks in advance

Paulo Costa


Re: skip ODA lib script in design time [message #731953 is a reply to message #731826] Mon, 03 October 2011 14:42 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Paulo,

Try wrapping in an if with this statement:
if(
!reportContext.getHttpServletRequest().getAttribute("attributeBean").isDesigner()){

}

Jason

On 10/3/2011 4:52 AM, Paulo wrote:
> Hello i Have this script in my Library on (before open) ODA
>
>
> importPackage( Packages.java.lang );
> importPackage( Packages.java.util );
> importPackage( Packages.javax.servlet.http);
>
> httpServletReq = reportContext.getHttpServletRequest();
> session = httpServletReq.getSession(); if (
> reportContext.getHttpServletRequest().getParameter("urlB") != null &&
> reportContext.getHttpServletRequest().getParameter("usrB") != null &&
> reportContext.getHttpServletRequest().getParameter("pasB") != null
> ) {
>
> this.setExtensionProperty("odaURL",
> reportContext.getHttpServletRequest().getParameter("DatabaseUrl"));
> this.setExtensionProperty("odaUser",
> reportContext.getHttpServletRequest().getParameter("DatabaseUserName"));
> this.setExtensionProperty("odaPassword",reportContext.getHttpServletRequest().getParameter("DatabasePassword"));
> }
>
> if ( reportContext.getHttpServletRequest().getParameter("DatabaseJndi")
> != null)
> {
>
> // set the birt variable jndi to the jndi url parameter
> this.setExtensionProperty("odaJndiName",
> reportContext.getHttpServletRequest().getParameter("DatabaseJndi"));
> }
> if ( session.getAttribute("sessionJndi") != null &&
> session.getAttribute("sessionJndiPrivilege") != null )
> { }
>
> // if all of this fail the birt report will try to execute with the
> development variables set on the report it self.
>
> true;
>
>
>
>
> it works fine on the web container getting the jndi connection from the
> session, but in design (Eclipe ou BIRT RCP DESIGNER ) time when on the
> data set - query the output columns it crash.
>
> Of course because of the reportContext.getHttpServletRequest not
> available in design time on the eclipse.
>
> Can some one please help me find a way of knowing when i'm in design
> time (ECLIPSE BIRT RCP DESIGNER) and skip this javascipt block , and not
> in the web container ?
>
>
> Thanks in advance
> Paulo Costa
>
>
>
Re: skip ODA lib script in design time [message #731994 is a reply to message #731953] Mon, 03 October 2011 15:54 Go to previous messageGo to next message
Paulo Mising name is currently offline Paulo Mising nameFriend
Messages: 13
Registered: July 2009
Junior Member
index.php/fa/4128/0/Hello Jason.

It does work you can see error message on atach file.

I have found on this url a similar if not the same problem, please take a look at

http://www.birt-exchange.org/org/forum/index.php/topic/21126-connection-profile-url/ on the post started at 21 December 2010 - 01:20 PM

index.php/fa/4128/0/

thank you very much
Paulo
  • Attachment: eclipse.tiff
    (Size: 184.82KB, Downloaded 529 times)
Re: skip ODA lib script in design time [message #733879 is a reply to message #731994] Wed, 05 October 2011 20:42 Go to previous messageGo to next message
Taras Kopets is currently offline Taras KopetsFriend
Messages: 3
Registered: October 2011
Junior Member
Paulo,

Did you managed to solve this issue?

Regards,
Taras
Re: skip ODA lib script in design time [message #733979 is a reply to message #733879] Thu, 06 October 2011 07:51 Go to previous messageGo to next message
Paulo Mising name is currently offline Paulo Mising nameFriend
Messages: 13
Registered: July 2009
Junior Member
Good Morning Taras.
No I did not find a solution yet.
I'm waiting for help.
Do you have any idea about it ?
Thanks
Regard
Paulo Costa
Re: skip ODA lib script in design time [message #734034 is a reply to message #733979] Thu, 06 October 2011 12:51 Go to previous messageGo to next message
Taras Kopets is currently offline Taras KopetsFriend
Messages: 3
Registered: October 2011
Junior Member
Yesterday I found your post, which is very similar to one I had before and you already mentioned it (link to birt-exchange).

I devoted some time yesterday investigating this issue and found out the solution which works.

I found out that when error happens the
reportContext.getClass().getName()
is different.

When reportContext class is
org.eclipse.birt.report.data.adapter.api.script.ReportContextObject
then I get the exception,
and when reportContext class is
org.eclipse.birt.report.engine.script.internal.ReportContextImpl
then everything is fine and we can safely use reportContext methods.

Maybe there is other elegant way to fix this, until then
adding some more checks leads to working code without errors.

// Packages.java.lang.System.out.println("---- reportContext class name ----");
// Packages.java.lang.System.out.println(reportContext.getClass().getName());
// Packages.java.lang.System.out.println("-------------- END ---------------");
// OK - "org.eclipse.birt.report.engine.script.internal.ReportContextImpl"
// FAIL - "org.eclipse.birt.report.data.adapter.api.script.ReportContextObject"

if(reportContext.getClass().getName() != "org.eclipse.birt.report.data.adapter.api.script.ReportContextObject") 
{
    // check if reportContext contains HttpServletRequest 
    if (reportContext.getAppContext().containsKey('BIRT_VIEWER_HTTPSERVET_REQUEST')) {
        var request = reportContext.getHttpServletRequest();
        // check if request is valid
        if (request != null) {
            if (!request.getAttribute("attributeBean").isDesigner()) {
                var myresourcefolder = reportContext.getDesignHandle().getResourceFolder();
                this.setExtensionProperty("OdaConnProfileStorePath", myresourcefolder+"/profilestore.xml");
                this.setExtensionProperty("OdaConnProfileName", params["rpStrConnProfile"].value);
            }
        }
    }
}


I hope you can easily modify my example to resolve your issue.
Let me know if this helps.

Regards,
Taras
Re: skip ODA lib script in design time [message #734093 is a reply to message #734034] Thu, 06 October 2011 16:11 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

When are you getting this type:
org.eclipse.birt.report.data.adapter.api.script.ReportContextObject
Specifically what script and how are you running it?

Jason


On 10/6/2011 8:52 AM, Taras Kopets wrote:
> Yesterday I found your post, which is very similar to one I had before
> and you already mentioned it (link to birt-exchange).
>
> I devoted some time yesterday investigating this issue and found out the
> solution which works.
>
> I found out that when error happens the
> reportContext.getClass().getName() is different.
>
> When reportContext class is
> org.eclipse.birt.report.data.adapter.api.script.ReportContextObject then
> I get the exception,
> and when reportContext class is
> org.eclipse.birt.report.engine.script.internal.ReportContextImpl then
> everything is fine and we can safely use reportContext methods.
>
> Maybe there is other elegant way to fix this, until then
> adding some more checks leads to working code without errors.
>
>
> // Packages.java.lang.System.out.println("---- reportContext class name
> ----");
> //
> Packages.java.lang.System.out.println(reportContext.getClass().getName());
> // Packages.java.lang.System.out.println("-------------- END
> ---------------");
> // OK - "org.eclipse.birt.report.engine.script.internal.ReportContextImpl"
> // FAIL -
> "org.eclipse.birt.report.data.adapter.api.script.ReportContextObject"
>
> if(reportContext.getClass().getName() !=
> "org.eclipse.birt.report.data.adapter.api.script.ReportContextObject") {
> // check if reportContext contains HttpServletRequest if
> (reportContext.getAppContext().containsKey('BIRT_VIEWER_HTTPSERVET_REQUEST'))
> {
> var request = reportContext.getHttpServletRequest();
> // check if request is valid
> if (request != null) {
> if (!request.getAttribute("attributeBean").isDesigner()) {
> var myresourcefolder = reportContext.getDesignHandle().getResourceFolder();
> this.setExtensionProperty("OdaConnProfileStorePath",
> myresourcefolder+"/profilestore.xml");
> this.setExtensionProperty("OdaConnProfileName",
> params["rpStrConnProfile"].value);
> }
> }
> }
> }
>
>
> I hope you can easily modify my example to resolve your issue.
> Let me know if this helps.
>
> Regards,
> Taras
Re: skip ODA lib script in design time [message #734112 is a reply to message #734093] Thu, 06 October 2011 17:51 Go to previous messageGo to next message
Taras Kopets is currently offline Taras KopetsFriend
Messages: 3
Registered: October 2011
Junior Member
Hi Jason,
This error happens when I edit dataSET in library.
The script is used in "beforeOpen" of dataSOURCE in the same library.

Edit dataset means: Open dataset, press "preview results" then "OK".
When you press OK, you will get
org.eclipse.birt.report.data.adapter.api.script.ReportContextObject
possibly several times in a row.
Re: skip ODA lib script in design time [message #734118 is a reply to message #734112] Thu, 06 October 2011 18:09 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Understood. I do not see an easy way around this.

On 10/6/2011 1:51 PM, Taras Kopets wrote:
> Hi Jason,
> This error happens when I edit dataSET in library.
> The script is used in "beforeOpen" of dataSOURCE in the same library.
>
> Edit dataset means: Open dataset, press "preview results" then "OK".
> When you press OK, you will get
> org.eclipse.birt.report.data.adapter.api.script.ReportContextObject
> possibly several times in a row.
Re: skip ODA lib script in design time [message #734353 is a reply to message #734112] Fri, 07 October 2011 14:18 Go to previous message
Paulo Mising name is currently offline Paulo Mising nameFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Taras, good afternoon.
I Want yo say that your suggestion worked like a charm !!!

if(reportContext.getClass().getName() != "org.eclipse.birt.report.data.adapter.api.script.ReportContextObject")
{

Could be not the a beautiful code but IT WORKED thank you very much.

Also that you Jason as well.

Paulo Costa

CLOSED
Previous Topic:BIRT Bug 202330 - [Crosstab improvements] Ability to put headers for dimensions on crosstabs
Next Topic:Decimal to Hours:Minute conversion
Goto Forum:
  


Current Time: Sun Nov 23 11:16:33 GMT 2014

Powered by FUDForum. Page generated in 0.02880 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software