Manipulating of Documents outside of JSON-RPC

We have several requirements that require us to do extensive manipulations directly on A12 documents outside of JSON-RPC-Operations. That includes creation of Documents with complex data from scratch, or copying/deleting large repeatable groups. These operations are triggered independently, not by HTTP endpoints of any sort.

We currently achieve this partly by replicating models as Java Classes, partly working on JSON Nodes. Especially the first approach seems not optimal to me, since it couples backend code to the A12 model and entails a risk of data-loss.

Are there any recommendations / best practises here?

This sounds very much like a usecase for the A12/A12 Document Mapping which is scheduled for the next release.

Not sure where some documentation/explanation/presentation is I could link to but this is from the A12 ticket “A12/A12 Document Mapping (Step 1)”

Introduce the possibility to specify a mapping between multiple source documents into a target document. […] The target document may already contain data.

Though this sounds interesting, it is not really a mapping problem. We have to manipulate documents as part of our business logic, in response of messages from a message broker and other events that are not part of the A12 domain

When you represent the broker message as an A12 document you have 2 input documents and an output document. And in between you have logic represented in the mapping. Can you explain why you don’t see this as a fit?

Hm, the broker messages can not be represented by single A12 documents but themselves contain encoded information in various formats (bas64, xml, json) so that would be quite tedious. But regardless of this, as I said we might have to manipulate documents in response of messages or other events, like deleting portions or copying portions to other documents with the same model but different id. So I do not understand this as a mapping problem.

We also need to simply add information from these broker messages to existing documents, possibly replacing values, not sure if this can be handled as a sort of one on one mapping, but it sounds counterintuitive to me

Heyho,

did i get you right, that you want to know which way can be used to modify documents with data coming from various sources ? I’m not quite sure if the Document Mapping feature, mentioned by @andreas-fresh-mesa, might be something that you can use and will at least solve the problem on a modelling level. But i’m not fully aware how this is works, so put it aside :slight_smile:

Furthermore if you just looking for another way of editing documents and not using the Json-Node approach, you could use the Document V2 way. It will creates you Java classes during build time and you can use them by setting groups and fields. However this feature is quite new and feels slightly chunky at some points. Nevertheless you get a explicit related java class for your model, so breaking changes to the model will result in a compile problem.

Thanks, I will look into it…