use of com.storedobject.core.AbstractCheckList in project SODevelopment by syampillai.
the class ProcessCheckList method process.
@Override
protected boolean process() {
ArrayList<AbstractCheckList> modified = new ArrayList<>();
AbstractCheckList node;
Date date;
boolean completed;
for (Object[] row : items) {
if (((DateField) row[1]).isReadOnly()) {
continue;
}
node = (AbstractCheckList) row[0];
completed = ((Checkbox) row[2]).getValue();
date = ((DateField) row[1]).getValue();
if (node.getCompleted() == completed && date.compareTo(node.getCompletedOn()) == 0) {
continue;
}
node.setCompletedOn(date);
node.setCompleted(completed);
modified.add(node);
}
if (modified.isEmpty()) {
message("No changes done");
return true;
}
completed = transact(t -> {
for (AbstractCheckList m : modified) {
m.save(t);
}
});
if (!completed) {
return true;
}
// noinspection SuspiciousMethodCalls
items.removeIf(r -> modified.contains(r[0]));
modified.clear();
items.removeIf(r -> {
AbstractCheckList item = (AbstractCheckList) r[0];
if (item.getCompleted() == item.checkCompleteness()) {
return true;
}
modified.add(item);
return false;
});
transact(t -> {
for (AbstractCheckList m : modified) {
m.save(t);
}
});
return true;
}
Aggregations