A 'current' resolver could resolve "FooBar" as:
- currentDocRef^FooBar when of type object (the object (as per ii, iii or iv) of
type FooBar in the current document, as resolved by the
CurrentStringDocumentReferenceResolver resolver)
- currentDocRef^currentDocRef#FooBar when of type property (the property FooBar
in the current document (as resolved by the
CurrentStringDocumentReferenceResolver resolver), of the object (as per ii, iii
or iv) of the class defined by the document reference)
In similar manner, a 'default' resolver could resolve "FooBar" as:
- defaultDocRef^FooBar when of type object
- defaultDocRef^defaultClass#FooBar when of type property (where defaultClass is
either defaultDocRef (see above) or a different class, which we agree to be the
default)
Also, a string like wiki:Space.Page#prop parsed as object would have to be
interpreted as 'FooBar' above, and parsed as property, would have the property
specified as "prop" of the object obtained by parsing
'wiki:Space.Page" as
'FooBar' above.
WDYT?
(I hope I didn't mess it up, I know it's complicated, but it has to make sense.)
I think it's not that bad that they'd throw, IMO it's a particular case the
one
we have now where all serializations make sense and can be interpreted as valid
(in other words, having a factory that requires a format for the strings it
parses is only normal).
> ii) all objects of class className in the document
I don't think it's valid. What would wiki:Space.Page^className#property mean?
could mean, by extension, the list of all values for property for all objects of
class className in the document.
Which means we'd need to define OBJECT_LIST and PROPERTY_VALUE_LIST or something
as EntityTypes.
Actually, if we add new types for this, then we still have to find a way to
interpret wiki:Space.Page^className as Object or Property (since everything has
to make sense as everything), which brigs us in a bit of a loop.
>
>> iii) first object of that class in the document (as
>> XWikiDocument#getObject(className) does)
If considering as invalid is harder than parsing, I go for this one:
+1
Thanks,
Anca
>>
>>> iv) a shortcut for wiki:Space.Page^className[0] (which, note, does not
>>> necessarily mean the first object in that document, since indexing of objs in
a
>>> document is not recomputed when objects are deleted).
>>
>> What is the reason? So that object names don't move when objects are
added/removed?
>
> yes, because they are identified by their index.
>
>>
>> I don't know enough but +0 for iii) or iv).
>>
>> Thanks
>> -Vincent
>>
>>> WDYT?
>>>
>>> Thanks,
>>> Anca
>>>
>>> On 01/13/2010 02:42 PM, Anca Luca wrote:
>>>> Hi devs,
>>>>
>>>> Short story:
>>>> 1/ add the CLASS, OBJECT, PROPERTY EntityTypes in the model
>>>>
>>>> +1
>>>>
>>>> 2/ serialization for referencing a property of an object
>>>> a) wiki:Space.Page^className[objectNumber]#property
>>>> b) wiki:Space.Page^className#objectNumber$property
>>>> +0.75 for b)
>>>>
>>>> Long story:
>>>>
>>>> 1/ I would need to extend the EntityReference to be able to target a
>>>> property in an object in a document.
>>>> For this, I will need to add
>>>>
>>>> /**
>>>> * Represents a Class Entity
>>>> */
>>>> CLASS,
>>>>
>>>> /**
>>>> * Represents an Object Entity.
>>>> */
>>>> OBJECT,
>>>>
>>>> /**
>>>> * Represents a Property Entity
>>>> */
>>>> PROPERTY,
>>>>
>>>> in the EntityType. Although I would prefer an extensible framework that
>>>> would allow to extend the possible entity types without changing an enum
>>>> in the platform (for any API user to be able to define its own
>>>> references), I think this is fairly extensible (these are key concepts
>>>> in the xwiki model and I don't think they would be changed that
soon,
>>>> and their interpretation is flexible, they could be combined with any
>>>> parent to generate either references to class definitions or instances).
>>>> here's my +1 for this.
>>>>
>>>> 2/ I would also need a 'standard' string serialization for these.
Now,
>>>> there's also the option to do it in my own module (annotations)
because
>>>> only I need it ftm, but I prefer to have a platform wide approach.
Opinions?
>>>> There are 2 choices, with a potentially different combination of
separators:
>>>>
>>>> a/ wiki:Space.Page^className[objectNumber]#property
>>>>
>>>> pros: it's a suggestive way to access objects by number ([] is the
>>>> standard syntax for array indexed access and the objects are accessed by
>>>> index), [] is supported by JCR so maybe we should support it too
>>>> cons: [] is somewhat inconsistent with all other separators which are
>>>> just one separator, to the left (right) of the entity, harder to
>>>> implement the [] separators on the current framework
>>>>
>>>> b/ wiki:Space.Page^className#objectNumber$property
>>>>
>>>> pros: inline with the separator usage we already have (and easier to
>>>> implement for this reason), could be easier refactored to contain an
>>>> object name instead of the number
>>>> cons: $ separator can collide with velocity syntax (can potentially
>>>> cause trouble when used in velocity -- an alternative could be the pipe
>>>> |), could be harder to drop the object number part of the reference to
>>>> refer a property in a class (if wanted, in the future)
>>>>
>>>> I have no other argument between a) and b) but the implementation speed
>>>> one, so I'd go for a b)-like approach, in the spirit of the current
>>>> separators.
>>>>
>>>> WDYT?
>>>>
>>>> Thanks,
>>>> Anca
_______________________________________________
devs mailing list
devs(a)xwiki.org