bhtmp - 2007-08-07

Hi, cewolf works ok with some static data in the produceDataset method.
However, when I tried to get data from db, I got err:
cewolfrenderer:null,
java.lang.nullpointer exception
at line,
List<PatientExerciseLogEntry> pe = logEntryService.getLogEntriesByPatientId( patientId, startDate.getTime(), endDate.getTime());

I am using spring/hibernate, and List<PatientExerciseLogEntry> is to retrieve a list of exer log entry..

Help pls!! Thx..

Following is sample of ExerciseChartData.java

public class ExerciseChartData implements DatasetProducer, CategoryToolTipGenerator, CategoryItemLinkGenerator, Serializable {

private static final Log log = LogFactory.getLog(ExerciseChartData.class);

private LogEntryService logEntryService;
private String[] categories ;
private String[] seriesNames = {"exercise"};

/**
* exercise log.
*/
public Object produceDataset(Map params) throws DatasetProduceException {
log.debug("producing data.");
DefaultCategoryDataset dataset = new DefaultCategoryDataset(){
/**
* @see java.lang.Object#finalize()
*/
protected void finalize() throws Throwable {
super.finalize();
log.debug(this +" finalized.");
}
};

GregorianCalendar endDate = new GregorianCalendar(2007, 6, 30);
GregorianCalendar startDate = (GregorianCalendar)endDate.clone();
startDate.add(Calendar.DAY_OF_YEAR, -90);
log.info("startdate in chart: " + startDate.getTime().toString());
log.info("end: " + endDate.getTime().toString());

List<PatientExerciseLogEntry> pe = logEntryService.getLogEntriesByPatientId( patientId, startDate.getTime(), endDate.getTime());
for (int i = 0; i < pe.size(); i++) {
PatientExerciseLogEntry p = pe.get(i);
categories[i] = p.getDayLoggedFor().toString();
double y = p.getCalculatedCalories();
log.debug("cal: "+ y +" day: " + categories[i] );
dataset.addValue(y, seriesNames[0], categories[i]);
}
return dataset;
}

/**
* This producer's data is invalidated after 5 seconds. By this method the
* producer can influence Cewolf's caching behaviour the way it wants to.
*/
public boolean hasExpired(Map params, Date since) {
log.debug(getClass().getName() + "hasExpired()");
return (System.currentTimeMillis() - since.getTime()) > 500000;
}

/**
* Returns a unique ID for this DatasetProducer
*/
public String getProducerId() {
return "exercise DatasetProducer";
}

/**
* Returns a link target for a special data item.
*/
public String generateLink(Object data, int series, Object category) {
return seriesNames[series];
}

/**
* @see java.lang.Object#finalize()
*/
protected void finalize() throws Throwable {
super.finalize();
log.debug(this + " finalized.");
}

/**
* @see org.jfree.chart.tooltips.CategoryToolTipGenerator# generateToolTip(CategoryDataset, int, int)
*/
public String generateToolTip(CategoryDataset arg0, int series, int arg2) {
return seriesNames[series];
}

public void setLogEntryService(LogEntryService logEntryService) {
this.logEntryService = logEntryService;
}

}