}
ChangeLogger.setContext(file, modifiedDate);
for(Object obj:senateData.getSencalendarOrSencalendaractive()) {
Calendar calendar = null;
String action = null;
Supplemental supplemental = null;
if (obj instanceof XMLSencalendar) {
XMLSencalendar xmlCalendar = (XMLSencalendar)obj;
action = xmlCalendar.getAction();
calendar = getCalendar(storage, "floor",xmlCalendar.getNo(),xmlCalendar.getYear(),xmlCalendar.getSessyr());
supplemental = parseSupplemental(storage, calendar,xmlCalendar.getSupplemental());
if(supplemental.getSequences() != null
|| (supplemental.getSections() != null && !supplemental.getSections().isEmpty())) {
supplemental.setCalendar(calendar);
calendar.addSupplemental(supplemental);
}
}
else if (obj instanceof XMLSencalendaractive) {
XMLSencalendaractive xmlActiveList = (XMLSencalendaractive)obj;
action = xmlActiveList.getAction();
calendar = getCalendar(storage, "active",xmlActiveList.getNo(),xmlActiveList.getYear(),xmlActiveList.getSessyr());
supplemental = parseSupplemental(storage, calendar,xmlActiveList.getSupplemental());
if(supplemental.getSequences() != null
|| (supplemental.getSections() != null && !supplemental.getSections().isEmpty())) {
supplemental.setCalendar(calendar);
calendar.addSupplemental(supplemental);
}
} else {
logger.warn("Unknown calendar type found: "+obj);
continue;
}
if (action.equals("remove") && removeObject != null) {
logger.info("REMOVING: " + removeObject.getClass() + "=" + removeObjectId);
if(removeObject instanceof Supplemental) {
if(calendar.getSupplementals() != null) {
int indexOf = -1;
if((indexOf = calendar.getSupplementals().indexOf(removeObject)) != -1) {
calendar.getSupplementals().remove(indexOf);
}
}
}
else if (removeObject instanceof Sequence && calendar.getSupplementals() != null){
int supSize = calendar.getSupplementals().size();
for(int i = 0; i < supSize; i++) {
Supplemental sup = calendar.getSupplementals().get(i);
int indexOf = -1;
if((indexOf = sup.getSequences().indexOf(removeObject)) != -1) {
calendar.getSupplementals().get(i).getSequences().remove(indexOf);
break;
}
}
} else {
logger.warn("Unknown calendar subdocument found: "+obj);
}
}
calendar.addDataSource(file.getName());
calendar.setModifiedDate(modifiedDate);
if (calendar.getPublishDate() == null) {
calendar.setPublishDate(modifiedDate);
}
storage.set(calendar);
ChangeLogger.record(storage.key(calendar), storage);
removeObject = null;
}