public Sequence parseSequence (Storage storage, Supplemental supplemental, XMLSequence xmlSequence) {
String sequenceId = supplemental.getId() + "-seq-" + xmlSequence.getNo();
Sequence sequence = new Sequence();
sequence.setId(sequenceId);
sequence.setNo(xmlSequence.getNo());
// Attempt to set the Actcal Date
// TODO: what is actcal date?
if (xmlSequence.getActcaldate()!=null) {
try {
Date actCalDate = LRS_DATE_ONLY_FORMAT.parse(xmlSequence.getActcaldate().getContent());
sequence.setActCalDate(actCalDate);
}
catch (ParseException e) {
logger.error("unable to parse sequence actCalDate",e);
}
}
// Set release date time if possible
if (xmlSequence.getReleasedate()!=null && xmlSequence.getReleasetime()!=null) {
try {
Date relDateTime = LRS_DATETIME_FORMAT.parse(xmlSequence.getReleasedate().getContent() + xmlSequence.getReleasetime().getContent());
sequence.setReleaseDateTime(relDateTime);
}
catch (ParseException e) {
logger.error("unable to parse sequence release date/time format",e);
}
}
// Notes?
if (xmlSequence.getNotes()!=null)
sequence.setNotes(xmlSequence.getNotes().replaceAll("\n", ""));
// Sequence Entries, just like a section?
List<CalendarEntry> calendarEntries = new ArrayList<CalendarEntry>();
if (xmlSequence.getCalnos()!=null) {
for(XMLCalno xmlCalno:xmlSequence.getCalnos().getCalno()) {
CalendarEntry cEntry = parseCalno(storage, sequence.getId(),xmlCalno, supplemental.getCalendar().getSession());
cEntry.setSequence(sequence);
if (!calendarEntries.contains(cEntry))
calendarEntries.add(cEntry);
}
}
sequence.setCalendarEntries(calendarEntries);
return sequence;
}