On 17/03/2011 18:47, Kevin Meyer - KMZ wrote:
In the SQL object store AbstractJdbcFieldMapping, the method
...
to create an object adapter from the string.

This is quite messy and obviously will kill anything like a BLOB (e.g. an
image!)
Well, not necessarily.  There's nothing to prevent your value type to
encode itself as a string, eg using base 64 encoding.
Eeek! Do you hear 30% data bloat? ;)
Well, any encoding will do.  Base 64 is just easy, that's all.

We could, I suppose, extend ValueSemanticsProvider to support two different types of Encoders, the current org.apache.isis.applib.adapters.EncoderDecoder that encodes/decodes to Strings, and another one that encodes to byte[]. The marshalling could perhaps ask for the former, but fall back to the latter.

If you want to try a spike on it, go ahead.



How do I directly create (for example) an ObjectAdapter containing an Isis
applib Date value, to pass on to
"((OneToOneAssociation) field).initAssociation(object, restoredValue);"

I guess the real requirement is creating the ObjectAdapter (for the
retrieved value object) to pass on to "initAssociation".
I'm not sure that you do need to do this if you use VSPs, but to answer
your question: you can use:

IsisContext().getPersistenceSession().getAdapterManager().adapterFor(object).
Thanks - I'll give this a try. I'm assuming that the following'll work:

Date newDateValue = rs.getDate(columnName);

ObjectAdapter  restoredValue =  IsisContext(). \
        getPersistenceSession().\
        getAdapterManager(). \
        adapterFor(newDateValue);

((OneToOneAssociation) field).initAssociation(object, restoredValue)

Yeah, sounds about right.

Dan


PS: as you saw a few weeks ago, I've moved all this stuff into runtimes.dflt (previously it was in core.runtime). That's because I want to allow for other runtime implementations, that perhaps have less moving parts and leverage more existing stuff, eg JDO 3.0 (ISIS-14), or even very simple pojos that wrap maps and that are persisted as JSON in Mongo/Couch. I see these alternative runtime implementations as supporting adapters just by new'ing up, ie new ObjectAdapterImpl(dataValue) ... the point would mostly be to provide access into the ObjectSpecification (ie metamodel).


Reply via email to