// 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())) {
diff(entry.getValue(), originalMembs.get(entry.getKey()), membMod, false);
} else {
for (AttributeTO attr : entry.getValue().getAttributes()) {
AttributeMod attrMod = new AttributeMod();
attrMod.setSchema(attr.getSchema());
attrMod.setValuesToBeAdded(attr.getValues());
if (!attrMod.isEmpty()) {
membMod.addAttributeToBeUpdated(attrMod);
membMod.addAttributeToBeRemoved(attrMod.getSchema());
}
}
for (AttributeTO attr : entry.getValue().getDerivedAttributes()) {
membMod.addDerivedAttributeToBeAdded(attr.getSchema());
}
for (AttributeTO attr : entry.getValue().getVirtualAttributes()) {
AttributeMod attrMod = new AttributeMod();
attrMod.setSchema(attr.getSchema());
attrMod.setValuesToBeAdded(attr.getValues());
if (!attrMod.isEmpty()) {
membMod.addVirtualAttributeToBeUpdated(attrMod);
membMod.addAttributeToBeRemoved(attrMod.getSchema());
}
}
membMod.setResourcesToBeAdded(entry.getValue().getResources());
}
if (!membMod.isEmpty()) {
result.addMembershipToBeAdded(membMod);
}
}
if (!incremental) {