public CalendarEntry parseCalno (Storage storage, String parentId, XMLCalno xmlCalNo, int sessionYear)
{
String calEntId = parentId + '-' + xmlCalNo.getNo();
CalendarEntry calEntry = new CalendarEntry();
calEntry.setOid(calEntId);
// remove all the leading 0's
calEntry.setNo(xmlCalNo.getNo().replaceAll("^0*", ""));
// Set the motion date?
// TODO: What is a motion date?
if (xmlCalNo.getMotiondate()!=null)
{
try {
Date motionDate = LRS_DATE_ONLY_FORMAT.parse(xmlCalNo.getMotiondate().getContent());
calEntry.setMotionDate(motionDate);
} catch (ParseException e) {
logger.error("unable to parse calentry " + xmlCalNo.getNo() + " motiondate");
}
}
// Get the bill for the entry, it may be marked has HIGH
if (xmlCalNo.getBill() != null)
{
calEntry.setBillHigh(xmlCalNo.getBill().getHigh());
// Get the bill from storage if possible, otherwise it makes a new one
// TODO: should it be possible to not have the bill already?
String billId = xmlCalNo.getBill().getNo();
if (!billId.isEmpty()) {
String sponsor = null;
if (xmlCalNo.getSponsor()!=null)
sponsor = xmlCalNo.getSponsor().getContent();
calEntry.setBill(getBill(storage, billId, sessionYear, sponsor));
}
}
// Get the substituted bill from storage if possible, otherwise it makes a new one
if (xmlCalNo.getSubbill()!=null)
{
String billId = xmlCalNo.getSubbill().getNo();
if (!billId.isEmpty())
{
String sponsor = null;
if (xmlCalNo.getSubsponsor()!=null)
sponsor = xmlCalNo.getSubsponsor().getContent();
calEntry.setSubBill(getBill(storage, billId, sessionYear, sponsor));
}
}
return calEntry;
}