Jump to content
JasperReports Library 7.0 is now available ×

Mongo Database and the required 0.9 Interface


edmundhaley

Recommended Posts

Our company is presently attempting to inject Japser Reports into our Cloud Application.  Having utilized Jasper Reports in the past with relational databases, I did not believe this to be a problem; however the database being utilized by the company is a NOSQL, or in other words MONGO.  Having found the required Mongo Datasource Interface, Version 0.9, I downloaded and installed the plugin as instructed.   The MONGO Queries appear to work fine as long as ObjectId's are not a field of the data query.  More specifically I am unable to utilze the MONGO ObjectId Field within the "findQuery" parameter of the query being passed to the JasperReport .JRXML Template.  Presently I am receiving a JSON Parsing Error and the stacktrace is suggesting it does not understand the MONGO ObjectId.......Are there any suggestions or helpful tips to overcome this obstacle.

 

Looking forward to your response.

 

Maurice Johnson

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I was actually able to resolve the issue.  In going through the JasperForge Forum and cross referencing mutlitple Mongo and Jasper Forums and Tutorials.  It turned out to be how the Mongo Database Query String was composed. 

 

Here is the original query string from my JRXML Template File:

    <queryString>
        <![CDATA[{
        'collectionName':'LabOrder',
        'findFields':{'pat':1, 'oNum':1, 'oDate':1, 'stat':1, 'resStat':1, 'crit':1, 'pri':1},
        'sort':{'oDate':1},
        'findQuery':{'pat':'$P!{PatientId}'}
        }]]>
    </queryString>

 

And here is how I resolved the matter:

    <queryString>
        <![CDATA[{
        'collectionName':'LabOrder',
        'findFields':{'pat':1, 'oNum':1, 'oDate':1, 'stat':1, 'resStat':1, 'crit':1, 'pri':1},
        'sort':{'oDate':1},
        'findQuery':{'pat':{'$oid':'$P!{PatientId}'}}
        }]]>
    </queryString>

 

I had to introduce the use of the $oid for the Mongo Query Builder and the Query Executer to recognize the use of the BSON ObjectId being passed as a paramter via String......

Hopefully my find will assist others....this was kind of a pain to figure out......just not enough documenation really on Mongo and Jaser Reports.

 

Maurice

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...