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)
Birt update problem
georgu12
Hy,
i have designed a BIRT 2.3.1 report with the eclipse plugins and i try to run the report with the eclipse HTML viewer. As datasource i use a scripted datasource, which gets its data from a java POJO. I have copied the .class file of the POJO to the pluginsorg.eclipse.birt.report.viewerbirtWEB-INFclasses directory.
The problem is, that i cannot update the POJO. If i remove the class file from that directory, the report still works, a newly copied class file seems not to be used by the report.
Can i somehow clear a cache? Wich cache?
From wich webserver is the report run?
thanks
george
Find more posts tagged with
Comments
AndyDavey
I'm glad that I'm not the only one experiencing this problem.
Did you happen to find a workaround to the issue?
drqbass
hello andy, did you find the solution to that issue?? i'm new in birt report and i have this same problem i can't pass an array of parameters to the parameter query, con you help me?
AndyDavey
I haven't played with this side of BIRT in some time.
If my memory serves me correctly, to get the report to see changes to the POJO I had to create a no dependencies version of my business layer (using jarjar) and then add then on the resources tab of my report add this jar.
That got around the whole caching issue and meant that I didn't need to copy the jar to the birtWEB-INFclasses. I believe (but I could be wrong) that if you put you class files in the birtWEB-INFclasses folder the classes will be cached by the internal Tomcat server until you restart BIRT.
As for passing an array to the parameter query I assume you mean passing an array as an argument to a DataSet? Couldn't you set the parameter type to 'Java Object' and then do some casting?
drqbass
Yeah!! i mean that i have a query like this
select detdeb.cod_presup ,movdeb.monto_cuota, case when subcta.id_negocio is null then
(select ser.descripcion_servicio
from dbsctm.txn_servicio ser
where ser.id_txn_servicio = (select detrecinm.id_txn_servicio
from dbsctm.txn_det_recibo_inm detrecinm, dbsctm.txn_gen_recibo genrec
where genrec.id_sub_cta = (?,?,?) and
genrec.id_recibo = detrecinm.id_recibo))
else(select act.nombre_actividad
from dbsctm.cat_actividad act
where act.id_actividad = (select detrecneg.id_actividad
from dbsctm.txn_det_recibo_neg detrecneg, dbsctm.txn_gen_recibo genrec
where genrec.id_sub_cta = (?,?,?) and
genrec.id_recibo = detrecneg.id_recibo))
end
from dbsctm.txn_gen_recibo genrec, dbsctm.txn_sub_cta subcta, dbsctm.txn_mov_debito movdeb, dbsctm.txn_det_debito detdeb
where genrec.id_sub_cta = (?,?,?) and
genrec.id_sub_cta = subcta.id_sub_cta and
subcta.id_sub_cta= movdeb.id_sub_cta and
movdeb.id_sub_cta = detdeb.id_sub_cta
where the interrogations signs are the multiple params that i want to pass.
ok, for passing the parameters i put into an array all the id's that i have to use.
Having this i download a js archive but i dont know how to use this. Here is the code.
importPackage(Packages.java.util.logging);
var fileHandler = new FileHandler("/tmp/birt.log", true);
var rootLogger = Logger.getLogger("");
rootLogger.addHandler(fileHandler);
function log(str) {
Logger.getAnonymousLogger().info(str);
}
//reportContext.getReportRunnable().getReportEngine().changeLogLevel(Level.FINE);
importPackage(Packages.org.eclipse.birt.report.model.api);
//paramProcess("Accepted"); // you can specify a dataset to process this way, or process all
processAllQueries();
function processAllQueries() {
var DH = reportContext.getReportRunnable().getDesignHandle();
var dsAll = DH.getAllDataSets().toArray();
for(var ii = 0; ii < dsAll.length; ii++) {
var odaHandle = dsAll[ii];
if ( odaHandle instanceof OdaDataSetHandle ) {
paramProcess(odaHandle.getName());
}
}
}
function countParameters( arg1 ) {
var count = 0;
var index = 0;
while ( ( index = arg1.indexOf( "?", index ) ) != -1 ) {
++index;
++count;
}
return count;
}
/*
Replace an existing "placeholder" parameter binding with the first parameter from the parameter "in" list.
The others in the list will be inserted after this one.
*/
function replaceParameterBinding( curDataSet, parameterHandle, parameter, ii ) {
var params = curDataSet.parametersIterator();
var pos = 0;
while ( params.hasNext() ) {
pos++;
var obj = params.next();
if ( obj instanceof OdaDataSetParameterHandle && obj.getPosition() == ii) {
log("replacing parameter " + obj.getName() + " with " + parameter.getName());
parameterHandle.replaceItem( obj.getStructure(), parameter );
}
}
}
/*
Add or replace a parameter binding.
*/
function addParameterBinding( curDataSet, paramName, first, paramVal, overallParamPos ) {
var newParamName = paramName + "_" + overallParamPos
log("binding " + newParamName + " (" + paramVal + ") to position " + overallParamPos);
parameterHandle = curDataSet.getPropertyHandle( DataSetHandle.PARAMETERS_PROP );
parameter = StructureFactory.createOdaDataSetParameter();
parameter.setName( newParamName );
parameter.setPosition( overallParamPos );
parameter.setDataType( "integer" );
parameter.setDefaultValue( paramVal*1 );
parameter.setIsInput( true );
parameter.setIsOutput( false );
if(first==true) {
replaceParameterBinding(curDataSet, parameterHandle, parameter, overallParamPos);
} else {
log("inserting " + parameter.getName() + " at position " + overallParamPos);
parameterHandle.insertItem( parameter, overallParamPos-1 );
reOrderParameters(curDataSet);
}
}
/*
Each time we insert a new parameter, we have to shift the following parameters down
*/
function reOrderParameters( curDataSet ) {
var params = curDataSet.parametersIterator();
var pos = 0;
while ( params.hasNext() ) {
pos++;
var obj = params.next();
if ( obj instanceof OdaDataSetParameterHandle ) {
log("setPosition of " + obj.getName() + " " + obj.getPosition() + " to " + pos);
obj.setPosition( pos );
}
}
}
function listParameters( curDataSet ) {
var params = curDataSet.parametersIterator();
var pos = 0;
while ( params.hasNext() ) {
var obj = params.next();
if ( obj instanceof OdaDataSetParameterHandle ) {
log("Parameter " + obj.getName() + " at " + obj.getPosition() + " " + obj.getDataType() + " " + obj.getDefaultValue() + " " + obj.isInput() + " " + obj.getParamName());
}
}
}
function getParam(dataSetHandle, paramIndex) {
var params = dataSetHandle.parametersIterator();
var pos = 0;
var param = null;
while ( params.hasNext() ) {
param = params.next();
if ( param instanceof OdaDataSetParameterHandle && param.getPosition() == paramIndex) {
return param;
}
}
return null;
}
function updateDataSet(curDataSet, query ) {
var parts = query.split("?");
var newQuery = "";
var paramsIndex = 1;
for(var ii = 0; ii < parts.length; ii++) {
newQuery += parts[ii];
if((ii*1)+1 == parts.length) continue;
log("looking for parameter " + paramsIndex);
var param = getParam(curDataSet, paramsIndex);
var paramName = param.getParamName();
// the "paramName" here, is the Linked to Report Parameter name...
// it will be null if this parameter is not linked to a report parameter
// in which case, we'll leave it alone
log("paramName [" + ii + "] = " + paramName);
var paramValue = null;
var paramStr = "";
var pVals = null;
if(paramName != null)
paramValue = params[paramName]+"";
log("checking " + paramName + " " + paramValue + " " + paramsIndex);
if(paramValue == null)
paramStr = "?";
else {
pVals = paramValue.split(",");
var sep = "";
for ( var i = 0; i < pVals.length; i++ ) {
paramStr += sep + "?";
sep = ",";
}
}
newQuery += paramStr;
if(paramStr == "?") {
paramsIndex++;
continue;
}
log("updating parameter " + param.getName() + " " + paramValue + " pos " + param.getPosition() + " " + param.getDataType() + " " + param.getDefaultValue() + " " + param.isInput() + " " + param.getParamName());
for ( var i = 0; i < pVals.length; i++ ) {
addParameterBinding( curDataSet, paramName, (i==0)?true:false, pVals[ i ], paramsIndex++);
}
}
return newQuery;
}
function paramProcess(dataset) {
var check = dataset+"_processed";
if(reportContext.getPersistentGlobalVariable(check)=="yes")
return;
reportContext.setPersistentGlobalVariable(check, "yes");
var DH = reportContext.getReportRunnable().getDesignHandle();
var odaHandle = DH.findDataSet(dataset);
if(odaHandle == null) return;
var name = odaHandle.getName();
log("name = " + name);
var query = odaHandle.getQueryText();
log("paramProcess(" + query +")");
// for each parameter ? in the query, look up the corresponding parameter and see if it's specified as a list
// if it is, replace the ? with the correct # of ?'s and add/replace appropriate parameter entries
var paramCount = countParameters( query );
if(paramCount == 0) return;
var newQuery = updateDataSet(odaHandle, query );
odaHandle.setQueryText(newQuery);
log("query = " + newQuery);
}
please help me to understand this and if exist an easier way then i gonna be thankful =D
AndyDavey
I don't think that I will be of much help here.
I've looked at the code and I'm guessing that for certain Report Parameters you are sending a comma separated list of values (probably using a HTTP querystring). You then parse the DataSets original Query Text to ensure that the correct number of ?'s are present in the Query Text to match the number of values passed in the Report Parameters, and then create the correct number of DataSet parameter bindings to match up.
In this situation I would be inclined to skip DataSet parameters and directly modify the Query Text. So instead of:
where genrec.id_sub_cta = (?,?,?)
I would inject the values of the Report Parameters directly:
where genrec.id_sub_cta = (12,43,68)
But you would also need to protect yourself against an injection attack, which is simple if you are passing int's around, and not that much harder if you need to pass string values around.
My situation was quite different in that I am using Hibernate to perform the actual querying of the database. Hence I can tell hibernate that I have an array of values that I want to use in a where condition and it takes care of expanding the SQL appropriately. This means that I have a fixed number of DataSource parameters.
Sorry I could not be of much more help than that.