final String cacheKey = getCacheKey(params);
if (cacheReadEnable) {
final Query q = ds.find(Cache.class);
q.filter("cacheKey", cacheKey).filter("servletName", this.getClass().getName());
final Cache c = (Cache) q.get();
if (c == null) {
log.info("cacheKey:" + cacheKey + " on servletName: " + this.getClass().getName() + " not found");
}
if (c != null) {
final GridFSDBFile imageForOutput = MongoConnectionHelper.getGridFS().findOne(new ObjectId(c.getGridId()));
if (imageForOutput != null) {
ds.save(c);
try {
response.setHeader("Content-Length", "" + imageForOutput.getLength());
response.setHeader("Content-Disposition", "inline; filename=\"" + imageForOutput.getFilename() + "\"");
final OutputStream out = response.getOutputStream();
final InputStream in = imageForOutput.getInputStream();
final byte[] content = new byte[(int) imageForOutput.getLength()];
in.read(content);
out.write(content);
in.close();
out.close();
return;
} catch (Exception e) {
log.error(e);
}
} else {
log.error("file not in db");
}
}
}
final Query q = ds.createQuery(MapReduceMinMax.class).disableValidation();
final Date dFrom = DateTimeUtil.getDate("yyyy-MM-dd hh:mm:ss", from);
final Date dTo = DateTimeUtil.getDate("yyyy-MM-dd hh:mm:ss", to);
final String formatIn = getFormatIn(period);
final String formatOut = getFormatOut(period);
final List<Date> datesIn = getRangeDate(dFrom, dTo);
final HashSet<String> datesInString = new HashSet<String>();
for (Date d : datesIn) {
datesInString.add(DateTimeUtil.dateFormat(formatIn, d));
}
if (datesIn != null && !datesIn.isEmpty()) {
q.filter("_id in", datesInString);
}
q.order("_id");
final List<MapReduceMinMax> mapReduceResult = q.asList();
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
ChartEnumMinMaxHelper chartEnum = ChartEnumMinMaxHelper.getByFieldAndType(field, type);
for (MapReduceMinMax m : mapReduceResult) {