}
// Connects last selected DbRelationship in the path to the
// last DbEntity, creating a dummy relationship if needed.
private void connectEnds() {
Relationship last = null;
int size = dbRelationshipPath.size();
if (size > 0) {
EntityRelationshipsModel wrapper =
(EntityRelationshipsModel) dbRelationshipPath.get(size - 1);
last = wrapper.getSelectedRelationship();
}
Entity target = getEndEntity();
if (last == null || last.getTargetEntity() != target) {
// try to connect automatically, if we can't use dummy connector
Entity source = (last == null) ? getStartEntity() : last.getTargetEntity();
Relationship anyConnector = source.getAnyRelationship(target);
EntityRelationshipsModel connector = null;
connector =
(anyConnector == null)
? new EntityRelationshipsModel(source, getEndEntity())