Hi,
do I understand correctly that when adding a FieldInstance – no matter if via the DocumentService or directly on the IDocument – intermediary group instances will only be created if the group in question is non-repeatable?
This isn’t clear from the docs but seems to be the behaviour I’m observing.
If this is the case, why wouldn’t Kernel be able to add repeatable group instances as needed, as is apparently the case with non-repeatable group instances?
Hi @marcel-calm-dew, when adding an IFieldInstance, neither IDocumentService#setValue nor IDocument#addEntityInstance create group instances for the ancestors (what I interpret as intermediary groups) in the corresponding IDocument, no matter if they are repeatable or non-repeatable.
How do you observe the behaviour that you described?
Hi Gildardo, thanks for the reply – I think to be more accurate, the missing intermediary group instances will be added when the document is serialised, but this is not possible if there are any missing repeatable group instances (this is enforced by DocumentSerializerImpl.checkGaps).
I see that I missunderstood what you meant with intermediary group instances:
Adding following field instances
- /RG[1]/RepG[1]/F[1]
- /RG[1]/RepG[3]/F[1]
The intermediary group instance would be /RG[1]/RepG[2], right?
If so, Kernel does not add such group instances.
The following aspects support the current behavior:
- By default in A12 models, a specific repetition should not have a semantic meaning and that’s why, it makes no sense to have gaps in the data.
- If a gap should be accepted, the application should explicitly add it as stated in the Javadoc of
IDocument#addEntityInstance: “…But to indicate that a {@link IGroupInstance} exists without any {@link IFieldInstance}, it must be added explicitly…”.
You mentioned that intermediary group instances are added for non-repeatable groups, what is that for you?
Hi Gildardo, thanks for the reply. I understand that this is the expected behavior from the A12 perspective. As for the Jdoc documentation, I felt it is not quite clear on the issue of gaps – the comment you referenced seems to me to only indicate that you need to explicitly add empty group instances if you want them to exist without any contained field instances.
@marcel-calm-dew: fyi, I have just made an improvement in the Kernel documentation to make clear that gaps are not closed when adding entity instances to the document.
Hi @gildardo-cached-canyon , great, that makes things clearer. Thanks!