- (let ((new-instance
- (call-component
- (parent slot)
- (make-instance (or (cadr (mewa:find-attribute finstance :presentation-search))
- 'mewa::mewa-presentation-search)
- :search-presentation
- (mewa:make-presentation finstance
- :type :search-presentation)
- :list-presentation
- (mewa:make-presentation finstance
- :type :listing)))))
- (setf (slot-value instance (slot-name slot)) (slot-value new-instance foreign-slot-name))
- (meta-model:sync-instance instance :fill-gaps-only-p (fill-gaps-only-p self)))))
-
+ (let ((new-instance (new-instance self)))
+ (unless new-instance
+ (setf (new-instance self)
+ (call-component
+ (ucw::parent slot)
+ (make-instance (or (cadr (mewa:find-attribute finstance :presentation-search))
+ 'mewa::mewa-presentation-search)
+ :search-presentation
+ (mewa:make-presentation finstance
+ :type :search-presentation)
+ :list-presentation
+ (mewa:make-presentation finstance
+ :type :listing)))))
+ (sync-foreign-instance slot new-instance))))
+
+(defmethod sync-foreign-instance ((slot mewa-relation-slot-presentation) foreign-instance)
+ (let ((instance (instance (ucw::parent slot))))
+ (multiple-value-bind (foo f-slot-name)
+ (meta-model:explode-foreign-key instance (slot-name slot))
+ (setf (slot-value instance (slot-name slot)) (slot-value foreign-instance f-slot-name))
+ (meta-model:sync-instance instance :fill-gaps-only-p (fill-gaps-only-p slot)))))
+
+