for (final Iterator<?> it = dataSource.getItemIds().iterator(); it
.hasNext();) {
final Object itemId = it.next();
final Item item = dataSource.getItem(itemId);
Property p = item.getItemProperty(itemStartPropertyId);
Date start = (Date) p.getValue();
Date end = start; // assume same day
if (itemEndPropertyId != null) {
p = item.getItemProperty(itemEndPropertyId);
end = (Date) p.getValue();
if (end == null) {
end = start;
} else if (end.before(start)) {
final Date tmp = start;
start = end;
end = tmp;
}
}
// TODO half-done lazyloading logic (hence broken)
if (start != null) {
if ((start.getMonth() <= month || end.getMonth() >= month)) {
target.startTag("item");
// TODO different id?
target.addAttribute("id", itemId.hashCode());
if (itemStyleNamePropertyId != null) {
p = item.getItemProperty(itemStyleNamePropertyId);
final String styleName = (String) p.getValue();
target.addAttribute("styleName", styleName);
}
SimpleDateFormat sdf = new SimpleDateFormat(
"d MM yyyy HH:mm:ss Z");
target.addAttribute("Z", start.getTimezoneOffset());
target.addAttribute("start", "" + sdf.format(start));
if (end != start) {
target.addAttribute("end", "" + sdf.format(end));
}
if (itemTitlePropertyId != null) {
p = item.getItemProperty(itemTitlePropertyId);
final Object val = p.getValue();
if (val != null) {
target.addAttribute("title", val.toString());
}
}
if (itemDescriptionPropertyId != null) {
p = item.getItemProperty(itemDescriptionPropertyId);
final Object val = p.getValue();
if (val != null) {
target.addAttribute("description", val
.toString());
}
}
if (itemNotimePropertyId != null) {
p = item.getItemProperty(itemNotimePropertyId);
final Object val = p.getValue();
if (val != null) {
target.addAttribute("notime", ((Boolean) val)
.booleanValue());
}
}