prependReversedPath(finalPath, nextDBR);
}
while (pathIt.hasNext()) {
// components may be attributes or relationships
CayenneMapEntry next = pathIt.next();
appendPath(finalPath, next);
}
return convertToPath(finalPath);
}
// case (1)
if (path.equals(relationshipPath)) {
LinkedList<String> finalPath = new LinkedList<String>();
Iterator<CayenneMapEntry> it = resolvePathComponents(path);
// just do one step back and one step forward to create correct joins...
// find last rel...
DbRelationship lastDBR = null;
while (it.hasNext()) {
// relationship path components must be DbRelationships
lastDBR = (DbRelationship) it.next();
}
if (lastDBR != null) {
prependReversedPath(finalPath, lastDBR);
appendPath(finalPath, lastDBR);
}
return convertToPath(finalPath);
}
// case (2)
String relationshipPathWithDot = relationshipPath + Entity.PATH_SEPARATOR;
if (path.startsWith(relationshipPathWithDot)) {
return path.substring(relationshipPathWithDot.length());
}
// case (3)
Iterator<CayenneMapEntry> pathIt = resolvePathComponents(path);
Iterator<CayenneMapEntry> relationshipIt = resolvePathComponents(relationshipPath);
// for inserts from the both ends use LinkedList
LinkedList<String> finalPath = new LinkedList<String>();
while (relationshipIt.hasNext() && pathIt.hasNext()) {
// relationship path components must be DbRelationships
DbRelationship nextDBR = (DbRelationship) relationshipIt.next();
// expression components may be attributes or relationships
CayenneMapEntry next = pathIt.next();
if (nextDBR != next) {
// found split point
// consume the last iteration components,
// then break out to finish the iterators independently
prependReversedPath(finalPath, nextDBR);
appendPath(finalPath, next);
break;
}
break;
}
// append remainder of the relationship, reversing it
while (relationshipIt.hasNext()) {
DbRelationship nextDBR = (DbRelationship) relationshipIt.next();
prependReversedPath(finalPath, nextDBR);
}
while (pathIt.hasNext()) {
// components may be attributes or relationships
CayenneMapEntry next = pathIt.next();
appendPath(finalPath, next);
}
return convertToPath(finalPath);
}