2014-10-27 46 views
0

我必须使用查询中应使用的3个参数来生成birt报告。参数是两个日期和一个字符串。在BIRT中使用mongodb进行动态查询

我试图在beforeOpen数据集中执行它,如sql查询所示,但它没有奏效。

我写beforeOpen表达数据集:

this.queryText = '{ 
"findQueryExpr": { "ref": "'+params["ref"].value+'", "sts": { $gt: "'+params["startDate"].value+'" , $lte: "'+params["endDate"].value+'"} } , 
"operationType" : "FIND" , 
"collectionName" : "events", 
"queryReadPreference" : "secondary" , 
"selectedFields" : [ "ref" , "sts" , "rts" , "c.value" , "c.type" , "c.quality" , "r.value" , "r.type" , "r.quality"] 
}'; 

,查询是在集合中的文档总数投掷参数无关。

可以使用参数在Birt中进行mongo查询吗?

回答

0

双击您的数据集,选择“属性绑定”并在查询文本中输入您的函数。

您还应该将查询字符串设置为全局持久变量,并将其打印在您的报告中进行调试,以确保您的最终陈述是有效的。日期可以在报告和数据库中使用不同格式,并且不会限制结果集:

reportContext.setPersistentGlobalVariable("testglobal", queryString);// in the script of your data source. 
reportContext.getPersistentGlobalVariable('testglobal');//in a dynamic text fild.