if (masterDependentDbRel != null) {
Iterator joinsIterator = masterDependentDbRel.getJoins().iterator();
while (joinsIterator.hasNext()) {
final DbJoin dbAttrPair = (DbJoin) joinsIterator.next();
DbAttribute dbAttribute = dbAttrPair.getTarget();
if (!attributes.contains(dbAttribute)) {
attributes.add(dbAttribute);
valueTransformers.add(new Transformer() {
public Object transform(Object input) {
ObjectId id = (ObjectId) ((ObjectDiff) input).getNodeId();
return id.getIdSnapshot().get(dbAttrPair.getSourceName());
}
});
}
}
}
}
if (usingOptimisticLocking) {
Iterator attributeIt = entity.getAttributes().iterator();
while (attributeIt.hasNext()) {
final ObjAttribute attribute = (ObjAttribute) attributeIt.next();
if (attribute.isUsedForLocking()) {
// only care about first step in a flattened attribute
DbAttribute dbAttribute = (DbAttribute) attribute
.getDbPathIterator()
.next();
if (!attributes.contains(dbAttribute)) {
attributes.add(dbAttribute);
valueTransformers.add(new Transformer() {
public Object transform(Object input) {
return ((ObjectDiff) input).getSnapshotValue(attribute
.getName());
}
});
}
}
}
Iterator relationshipIt = entity.getRelationships().iterator();
while (relationshipIt.hasNext()) {
final ObjRelationship relationship = (ObjRelationship) relationshipIt
.next();
if (relationship.isUsedForLocking()) {
// only care about the first DbRelationship
DbRelationship dbRelationship = (DbRelationship) relationship
.getDbRelationships()
.get(0);
Iterator joinsIterator = dbRelationship.getJoins().iterator();
while (joinsIterator.hasNext()) {
final DbJoin dbAttrPair = (DbJoin) joinsIterator.next();
DbAttribute dbAttribute = dbAttrPair.getSource();
// relationship transformers override attribute transformers for
// meaningful FK's... why meanigful FKs can go out of sync is
// another story (CAY-595)
int index = attributes.indexOf(dbAttribute);
if (index >= 0 && !dbAttribute.isForeignKey()) {
continue;
}
Object transformer = new Transformer() {
public Object transform(Object input) {
ObjectId targetId = ((ObjectDiff) input)
.getArcSnapshotValue(relationship.getName());
return targetId != null ? targetId.getIdSnapshot().get(
dbAttrPair.getTargetName()) : null;
}
};
if (index < 0) {
attributes.add(dbAttribute);