// 3. memberships
Map<Long, MembershipTO> updatedMembs = updated.getMembershipMap();
Map<Long, MembershipTO> originalMembs = original.getMembershipMap();
for (Map.Entry<Long, MembershipTO> entry : updatedMembs.entrySet()) {
MembershipMod membMod = new MembershipMod();
membMod.setRole(entry.getValue().getRoleId());
if (originalMembs.containsKey(entry.getKey())) {
// if memberships are actually same, just make the isEmpty() call below succeed
if (entry.getValue().equals(originalMembs.get(entry.getKey()))) {
membMod.setRole(0);
} else {
diff(entry.getValue(), originalMembs.get(entry.getKey()), membMod, false);
}
} else {
for (AttributeTO attr : entry.getValue().getAttrs()) {
AttributeMod attrMod = new AttributeMod();
attrMod.setSchema(attr.getSchema());
attrMod.getValuesToBeAdded().addAll(attr.getValues());
if (!attrMod.isEmpty()) {
membMod.getAttrsToUpdate().add(attrMod);
membMod.getAttrsToRemove().add(attrMod.getSchema());
}
}
for (AttributeTO attr : entry.getValue().getDerAttrs()) {
membMod.getDerAttrsToAdd().add(attr.getSchema());
}
for (AttributeTO attr : entry.getValue().getVirAttrs()) {
AttributeMod attrMod = new AttributeMod();
attrMod.setSchema(attr.getSchema());
attrMod.getValuesToBeAdded().addAll(attr.getValues());
if (!attrMod.isEmpty()) {
membMod.getVirAttrsToUpdate().add(attrMod);
membMod.getAttrsToRemove().add(attrMod.getSchema());
}
}
}
if (!membMod.isEmpty()) {
result.getMembershipsToAdd().add(membMod);
}
}
if (!incremental) {