private void executeUpsert(DbSession session, ActiveRuleChange.Type type, List<ChangeLog> changes) {
Iterator<ChangeLog> changeLogIterator = changes.iterator();
if (changeLogIterator.hasNext()) {
// startCase
ChangeLog change = changeLogIterator.next();
int currentId = change.getId();
Date currentTimeStamp = change.getCreatedAt();
String currentAuthor = change.getUserLogin();
ActiveRuleChange ruleChange = newActiveRuleChance(type, change);
processRuleChange(ruleChange, change);
while (changeLogIterator.hasNext()) {
change = changeLogIterator.next();
int id = change.getId();
if (id != currentId) {
saveActiveRuleChange(session, ruleChange, currentAuthor, currentTimeStamp);
currentId = id;
currentTimeStamp = change.getCreatedAt();
currentAuthor = change.getUserLogin();
ruleChange = newActiveRuleChance(type, change);
}
processRuleChange(ruleChange, change);
}
// save the last