0

I have a document type that has a property with two sub properties. The property can be multivalue each value contains two strings.

In Json format it would be for example:

documentIds: [
    {
       "id": "ID-9900022",
       "type": "internal id"
    },
    {
       "id": "ID-990333",
       "type": "Public id"
    }
]

Could someone give me an example that uses the Java API to write this property?

Marco Altieri
  • 3,726
  • 2
  • 33
  • 47

1 Answers1

1

This is one way. Suppose the field is in schema "mydoc":

Document testDocument = ... // Retrieve by fetch or query

testDocument.set("mydoc:documentIds", "[{\"id\":\"ID-9900022\", \"type\":\"internal id\"}, {\"id\":\"ID-990333", \"type\":\"Public id\"}]");

DocumentService docService = session.getAdapter(DocumentService.class);
DocRef docRef = new DocRef(testDocument.getId());
docService.update(testDocument);
Andrew Spencer
  • 15,164
  • 4
  • 29
  • 48
  • Thank you Andrew. It is a bit too late now. I asked this question almost one year ago. I am not working on this project any more and I cannot test your answer unfortunately. I can only upvote. Of course I will accept your answer if someone else confirms that it works. – Marco Altieri Jan 28 '16 at 17:56
  • Don't worry I saw it was an old one, but I had almost the exact code snippet to hand, since I just had to solve the same issue. – Andrew Spencer Jan 29 '16 at 10:05