Jump to content
We've recently updated our Privacy Statement, available here ×

  • ernestoo
    • Version: v5.5 Product: JasperReports® Server

    Overview

    This is an example report developed using Jaspersoft Studio and then published to JasperReports Server. All the data comes from a single MongoDB collection called "cases". 

    Features of the reports are:

    • Aggregation framework
    • Geospacial features of MongoDB including the $geoNear operator
    • Parametrized queries, including the $in operator passed to a collection
    • JasperReports Map component
    • Drill through from map
    • Sub-reports

    Requirements

    • JasperReports Server v5.5 Professional or Enterprise (I used HTML5 charts, otherwise this would work in CE)
    • MongoDB >2.4 (I use geospatial features not available in older versions)

    Getting the Data

    For those wanting to generate the data themselves:

    The data was generated randomly using http://www.json-generator.com/ - you are welcome to recreate the data yourself using this as a template. You can save the generated JSON to a file and then run these commands:

    Import the raw json file to mongodb:

    mongoimport -c cases --jsonArray --drop --file ~/Desktop/json_file.json
    

    Cast the dates to ISO dates:

    mongo --eval "db.cases.find().forEach(function(doc){doc.CaseOpenDatetime = new Date(doc.CaseOpenDatetime);db.cases.save(doc)});"
    
    mongo --eval "db.cases.find().forEach(function(doc){doc.CaseBeginDatetime = new Date(doc.CaseBeginDatetime);db.cases.save(doc)});"
    
    mongo --eval "db.cases.find().forEach(function(doc){doc.CaseCurrentStatusDatetime = new Date(doc.CaseCurrentStatusDatetime);db.cases.save(doc)});"
    

    Add a Geospatial index for the lat/longitude :

    mongo --eval " db.cases.ensureIndex({"location" : "2dsphere" } );”
    

    For those wanting to get started quickly:

    You can simply download the collection mongodb_cases.json - you will then need to import it

    Import data :

    mongoimport --host localhost --db test --collection cases < mongodb_cases.json
    

    Add a Geospatial index for the lat/longitude :

    mongo --eval " db.cases.ensureIndex({"location" : "2dsphere" } );”
    

    Getting the Reports

    You should be running JasperReports Server v5.5 for this to work - it likely works in previous versions but not guaranteed. You will simply need to log in as superuser and import this repository export.

    The import should bring in a folder under /public/ called MongoDB. It will also import a Topic that you can use in Ad-Hoc, that topic will alse be under the Public Topics folder.

    Screenshots

    The main report in action:

    ScreenShot2013-12-01at4_31_44PM.png.eb090ab9b0d2ef21313941b1a4c08e1e.png

    Page 2 of the drill through report showing off the $near operator of MongoDB:

    ScreenShot2013-12-01at4_28_52PM.png.18bdbaa7130de33e31544e5b1e432c9e.png

    Data Exploration

    This section was contributed by emistry

    This data was used to setup Adhoc Data Exploration from JasperReports Server using a Domain . The schema used when setting up the data source was :

    CREATE FOREIGN TABLE cases (
    CaseID varchar(255) PRIMARY KEY,
    CaseCurrentStatus varchar(255),
    ServiceName varchar(255),
    CaseLat float,
    CaseLong float,
    gender varchar(255),
    age integer)
    OPTIONS (UPDATABLE 'TRUE');
    

    A link to a short video to explain the whole process of setting up Adhoc Data Exploration is found http://youtu.be/ahvzBZrlVaM

     

    mongodb_cases.json

    mongodbcitydashboard.zip


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...