done=false;
for (Iterator iterator = allVariables.keySet().iterator(); iterator.hasNext() && done==false;) {
String varName = (String) iterator.next();
if(oldModeRetrievingChart==true){
if(varName.equalsIgnoreCase(CHART_LABEL)){
JRFillVariable labelValueO = (JRFillVariable) allVariables.get(CHART_LABEL);
String labelValue = null;
if(labelValueO.getValue()==null){
logger.error("CHART_LABEL variable has no value");
return;
}
labelValue=(String)labelValueO.getValue();
// Set other parameters (only not system defined)
for (Iterator iterator2 = allParameters.keySet().iterator(); iterator2.hasNext();) {
String namePar = (String) iterator2.next();
JRFillParameter par=(JRFillParameter)allParameters.get(namePar);
if(!par.isSystemDefined() && par.getValue()!=null){
Object val=par.getValue();
chartParameters.put(namePar, val.toString());
}
}
logger.debug("execute chart with lable "+labelValue);
logger.debug("Calling Service");
byte[] image=proxy.executeChart(labelValue, chartParameters);
logger.debug("Back from Service");
InputStream is=new ByteArrayInputStream(image);
logger.debug("Input Stream filled, Setting variable");
if(allVariables.keySet().contains(CHART_IMAGE)){
this.setVariableValue(CHART_IMAGE, is);
}
else{
logger.error("variable where to set image chart "+CHART_IMAGE+ " not defined");
return;
}
done=true;
}
}
else if(oldModeRetrievingChart==false){
if(varName.startsWith("sbichart_")){
logger.debug("Processing variable "+varName);
JRFillVariable variable=(JRFillVariable)allVariables.get(varName);
if(variable.getValue()!=null){
chartParameters=new HashMap();
// the realVarName is the name of the target variable!
String areaValue=varName.substring(9);
// call a utility function that parse the variable, in the form var1=val1;var2=val2
String varVal=(String)variable.getValue();
// Value is defined as chart_label=label;par1=val1;par2=val2;
Map nameValuePars=parseVariable(varVal);
// check if there is the main parameters defined:
// chart_label : indicating the label of the chart that has to be called.