Mailing List webobjects-dev@wocommunity.org Message #486
From: Susanne Schneider <susanne.schneider@interactive-systems.de>
Subject: Re: [WO-DEV] Ideas for arbitrary to-one associations
Date: Mon, 15 Jan 2024 15:39:49 +0100
To: <markus.ruggiero@rucotec.ch>
Cc: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
Hi Markus,

we had a roughly similar requirement some time ago where we needed to store optional translations of all user-specified text that is stored in a, let's say, relative complex data model for various entities and properties.

My collegue Marc (hi Marc!) has come up with a similar aproach as yours to store all translations in a single table with holds the entity, primary key and property name of the related to-be-translated attribute in text form as the relation description (together with language and translated text, of course). If both eos are created at the same moment, the save of the translation is delayed until the save of the to-be-translated eo by use of function parameters that are executed after the initial save in our custom EOEditingContext. A hurray to functional programming! :-)

Because the translation depends on the translated eo, there is no need for us to prevent deleting the eo when a translation exists. We only have to manage the necessary deletion cascade.

The best of the implementation is, that in 90 percent of time, no developer has to care about it. It just works :-)

I hope, this (very short) description was of any value for you?

Good luck!
Susanne

Am 15.01.2024 um 13:45 schrieb Markus Ruggiero (rucotec):
I am looking for ideas / strategies to implement the following requirement:

I want to implement something I call GeneralNote. It should be possible to create such a note anywhere in the application and associate it with the current EO, whatever this may be. Thus any EO can potentially have 0 to many GeneralNote objects hanging off it. One GeneralNote however is not shared, thus it is a real to-one relationship from GeneralNote to an EO.
It is obviously not possible (well, more like totally impractical) to model a to-one relationship from GeneralNote to any/all possible destination entities in my EOModel.

Any ideas on how to do this? I want to leverage as much as possible the power of EOF. I was experimenting with code that puts the destination entity and the destination object’s primary key value in attributes of GeneralNote. I also have code that can find GlobalNote objects for an EO by using its entity name and primary key for fetching. All our EOs share a common base class that can easily accommodate such code generically. But what if the EO and a note is created at the same time? There is no primary key value yet! And how can I prevent an EO from being deleted and leaving orphaned notes behind? Would overriding willDelete() be a good place to also delete the notes? What about not allowing EO deletion when there still are notes?

Thanks for any ideas!
---markus---


--
Susanne Schneider
Coordinator secuTrial® Development

interActive Systems GmbH
Glogauer Str. 19, D-10999 Berlin

fon    +49 30 22 50 50 - 498mul
fax    +49 30 22 50 50 - 451
mail   susanne.schneider@interActive-Systems.de
web    http://www.secuTrial.de

----------------------------------------------------
Geschäftsführer: Dr. Marko Reschke, Thomas Fritzsche
Sitz der Gesellschaft: Berlin
Amtsgericht Berlin Charlottenburg, HRB 106103B
----------------------------------------------------
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster