Re: Saving NSDictionary to DB
On 24.03.2014 22:56, Oscar González wrote: Hi all,I need to save a NSDictionary to the DB and then recovery it back. Is there some formatter to do this? You can use 'blobDictionary' or 'stringDictionary' prototype. Everything should be handled automatically. Be aware that you also need ERAttributeExtension.framework for this. Cheers, Michael -- ___ Michael Schmiedgen, BSc Senior Software Engineer Takwa GmbH Friedrich-List-Str. 36 99096 Erfurt GERMANY Tel +49 361 6534096 Fax +49 361 6534097 Mail schmied...@takwa.de Web http://www.takwa.de/ ___ Amtsgericht Jena HRB 112964 Geschäftsführung: Ingo Buchholz ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: Saving NSDictionary to DB
Thanks Micha De: Michael Schmiedgen Enviado: 3/25/2014 3:38 AM Para: Oscar González; webobjects-dev@lists.apple.com Asunto: Re: Saving NSDictionary to DB On 24.03.2014 22:56, Oscar González wrote: Hi all,I need to save a NSDictionary to the DB and then recovery it back. Is there some formatter to do this? You can use 'blobDictionary' or 'stringDictionary' prototype. Everything should be handled automatically. Be aware that you also need ERAttributeExtension.framework for this. Cheers, Michael -- ___ Michael Schmiedgen, BSc Senior Software Engineer Takwa GmbH Friedrich-List-Str. 36 99096 Erfurt GERMANY Tel +49 361 6534096 Fax +49 361 6534097 Mail schmied...@takwa.de Web http://www.takwa.de/ ___ Amtsgericht Jena HRB 112964 Geschäftsführung: Ingo Buchholz ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Saving NSDictionary to DB
Hi all,I need to save a NSDictionary to the DB and then recovery it back. Is there some formatter to do this? Saludos, Oscar González PérezTECH in AGRO S.A. ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Saving NSDictionary to DB
See NSPropertyListSerialization. There should be examples in Wonder and maybe support for using it. Chuck On 2014-03-24, 2:56 PM, Oscar González wrote: Hi all, I need to save a NSDictionary to the DB and then recovery it back. Is there some formatter to do this? Saludos, Oscar González Pérez TECH in AGRO S.A. ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: Saving NSDictionary to DB
Thanks Chuck,I'll see that class. Saludos, Oscar González PérezTECH in AGRO S.A. From: ch...@global-village.net To: racso...@hotmail.com; webobjects-dev@lists.apple.com Subject: Re: Saving NSDictionary to DB Date: Mon, 24 Mar 2014 22:00:05 + See NSPropertyListSerialization. There should be examples in Wonder and maybe support for using it. Chuck On 2014-03-24, 2:56 PM, Oscar González wrote: Hi all, I need to save a NSDictionary to the DB and then recovery it back. Is there some formatter to do this? Saludos, Oscar González Pérez TECH in AGRO S.A. ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Saving NSDictionary to DB
you can serialize it into a property list string and back. there may even be a “transformable” on the modeler, I can’t recall but likely you can write a transformer to read and write to and from a string which would work just fine I think. make sense? On Mar 24, 2014, at 5:56 PM, Oscar González racso...@hotmail.com wrote: Hi all, I need to save a NSDictionary to the DB and then recovery it back. Is there some formatter to do this? Saludos, Oscar González Pérez TECH in AGRO S.A. ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/jtayler%40oeinc.com This email sent to jtay...@oeinc.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Saving NSDictionary to DB
Chuck - stop typing so fast… :) To add to Chuck’s response, you can serialize to XML: String xml = NSPropertyListSerialization.xmlStringFromPropertyList(dictionary, false); but then there ARE Wonder additions: NSData info = er.extensions.foundation.ERXPropertyListSerialization.dataFromPropertyList(dictionary, er.extensions.foundation.ERXPropertyListSerialization.PListFormat.NSPropertyListBinaryFormat_v1_0, null); The first could be stored in a large database string, the second could be stored in a blob. Ken On Mar 24, 2014, at 6:00 PM, Chuck Hill ch...@global-village.net wrote: See NSPropertyListSerialization. There should be examples in Wonder and maybe support for using it. Chuck On 2014-03-24, 2:56 PM, Oscar González wrote: Hi all, I need to save a NSDictionary to the DB and then recovery it back. Is there some formatter to do this? Saludos, Oscar González Pérez TECH in AGRO S.A. ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/kenlists%40anderhome.com This email sent to kenli...@anderhome.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: Saving NSDictionary to DB
Hi Jessie,I can see in the EntityModeler a prototype mutableDictionary.Basically has a external type bytea, and a custom data type ERXMutableDictionary with factory method fromBlob and conversion method toBlob.I'm going to try with that. Thanks, Oscar González PérezTECH in AGRO S.A. Subject: Re: Saving NSDictionary to DB From: jtay...@oeinc.com Date: Mon, 24 Mar 2014 18:04:04 -0400 CC: webobjects-dev@lists.apple.com To: racso...@hotmail.com you can serialize it into a property list string and back. there may even be a “transformable” on the modeler, I can’t recall but likely you can write a transformer to read and write to and from a string which would work just fine I think. make sense? On Mar 24, 2014, at 5:56 PM, Oscar González racso...@hotmail.com wrote: Hi all, I need to save a NSDictionary to the DB and then recovery it back. Is there some formatter to do this? Saludos, Oscar González Pérez TECH in AGRO S.A. ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/jtayler%40oeinc.com This email sent to jtay...@oeinc.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Saving NSDictionary to DB
Here is how I implemented such attribute: { adaptorValueConversionClassName = er.extensions.foundation.ERXPropertyListSerialization; adaptorValueConversionMethodName = jsonStringFromPropertyList; allowsNull = Y; columnName = dictionary; externalType = VARCHAR2; factoryMethodArgumentType = EOFactoryMethodArgumentIsNSString; name = dictionary; valueClassName = Object; valueFactoryClassName = er.extensions.foundation.ERXPropertyListSerialization; valueFactoryMethodName = dictionaryForJSONString; valueType = S; width = 4000; }, Once the entity generated to a class, you have to change the _TheEntity.java file and change the type of the attribute from Object to NSDictionary *1*. Since there is a problem with mutable object as attribute (maybe there is another way to fix it?), you have to consider the attribute as immutable and use cover method to a mutable one. So when you need to deal with an immutable version, do it with mutableDictionary(). If you just need to ask contents, simply use dictionary(); Use the following code in TheEntity.java: LeanMutableDictionary _mutableDictionary = null; public LeanMutableDictionary mutableDictionary() { if (_mutableDictionary == null) { _mutableDictionary = new LeanMutableDictionary(); } return _mutableDictionary; } /** * Cover class to ease KVC. This « lean » version remove key when value is null or Boolean.false. */ public class LeanMutableDictionary implements NSKeyValueCoding { @Override public Object valueForKey(final String key) { final NSDictionary dict = userInfoDict(); if (dict != null) { return dict.valueForKey(key); } return null; } @Override @SuppressWarnings(unused) public void takeValueForKey(final Object val, final String key) { NSDictionary dict = userInfoDict(); if (dict == null) { dict = NSDictionary.EmptyDictionary; } dict = dict.mutableClone(); if (val == null || val.equals(Boolean.FALSE)) { // remove that key from the dictionary dict.remove(key); } else { dict.takeValueForKey(val, key); } setUserInfoDict(dict.immutableClone()); } } [1] This is because the type (valueClassName) will be used to find the right method (with the type argument) and the method is defined in ERXPropertyListSerialization with Object, not NSDictionary. So you have to keep it Object. - jfv Le 2014-03-24 à 17:56, Oscar González racso...@hotmail.com a écrit : Hi all, I need to save a NSDictionary to the DB and then recovery it back. Is there some formatter to do this? Saludos, Oscar González Pérez TECH in AGRO S.A. ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/jean_francois_veillette%40yahoo.ca This email sent to jean_francois_veille...@yahoo.ca ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Saving NSDictionary to DB
Fix: So when you need to deal with an immutable version, do it with mutableDictionary(). So when you need to deal with a MUTABLE version, do it with mutableDictionary(). jfv ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com