On 17 May 2017, at 12:44, Sven Van Caekenberghe <sven@stfx.eu> wrote:
Hi Cyril,
This can be done quite easily in STON, I will make you a small example and add it to the unit tests.
=== Name: STON-Tests-SvenVanCaekenberghe.79 Author: SvenVanCaekenberghe Time: 17 May 2017, 1:43:03.944446 pm UUID: fb472e87-180c-0d00-b559-fec60aee7555 Ancestors: STON-Tests-SvenVanCaekenberghe.78 Add STONWriteReadTests>>#testKnownObjects as an example of how to serialize only an ID and resolve that ID upon materialization Add STONTestKnownObject with custom #stonOn: and class side #fromSton: === You basically (over)write 2 methods, instance side "protocol: ston-core" stonOn: stonWriter "We only write out our id" stonWriter writeObject: self listSingleton: self id asString and class side "protocol: ston-core" fromSton: stonReader ^ self fromId: stonReader parseListSingleton The #fromId: methods retrieves an existing instance. HTH, Sven
Sven
On 17 May 2017, at 12:19, Cyril Ferlicot D. <cyril.ferlicot@gmail.com> wrote:
Hi!
At Synectique sometimes we use Ston to export models that contains some MooseEntities.
Moose entities been complex, we usually export only the moose name of the entity then we retrieve the entity during the import. But we did not find any "easy" way to do this in Ston.
I used voyage and it has a system like this. Example:
Amount class>>mongoCurrency <mongoDescription>
^ VOMongoToOneDescription new attributeName: 'currency'; accessor: (MAPluggableAccessor read: [ :amount | amount currency abbreviation ] write: [ :amount :value | amount currency: (Currency fromAbbreviation: value) ]); yourself
With this Voyage know how to read/write the instance variable "currency".
I think it would be cool to be able to easily customize import/export variables with Ston. Maybe it is already possible but I missed the way to do it?
I would like your thoughts about that. :)
-- Cyril Ferlicot https://ferlicot.fr
http://www.synectique.eu 2 rue Jacques Prévert 01, 59650 Villeneuve d'ascq France