final Collection<ObjectAdapter> entityList = model.getObject();
final Function<ObjectAdapter, Event> function = new Function<ObjectAdapter, Event>() {
public Event apply(ObjectAdapter input) {
Event event = new Event();
final String associationId = dateAssociation.getId();
final String associationName = dateAssociation.getName();
final DateValueFacet facet = dateAssociation.getSpecification().getFacet(DateValueFacet.class);
final ObjectAdapter dateAdapter = dateAssociation.get(input);
final Date dateValue = facet.dateValue(dateAdapter);
if(dateValue == null) {
return null;
}
final DateTime start = new DateTime(dateValue.getTime());
final DateTime end = start;
event.setStart(start);
event.setEnd(end);
final String oidStr = input.getOid().enString(IsisContext.getOidMarshaller());
event.setId(oidStr + "-" + associationId);
event.setAllDay(true);
//event.setBackgroundColor(backgroundColor)
//event.setBorderColor(borderColor)
event.setClassName("fullCalendar-event-" + associationId);
//event.setColor(color)
event.setEditable(false);
event.setPayload(oidStr);
//event.setTextColor(textColor)
event.setTitle(input.titleString() + "\n" + associationName);
//event.setUrl(url)
return event;
}
};
final Collection<Event> events = Collections2.filter(Collections2.transform(entityList, function), NOT_NULL);
for (Event event : events) {
eventById.put(event.getId(), event);
}
}