Access/write additional metdata fields from plugin
Hi all,
I'm looking for a solution to allow writing of new metdata/properties to those which are displayed in the "Info" tab.
I understand there's a way to do this through the UI but I couldn't find documentation on how to do this in the API.
My understanding is that AnnotatedPluginDocument.setField() sets fields displayed in the table. I expected the property fields to be set through AnnotatedPluginDocument.setAdditionalXml() but when I tried to set a test field here I couldn't see it shown in the Info tab.
Please could you let me know if I'm on the right track to set/recall this metadata in the Info/Properties tab?
Many thanks,
Alex
-
Official comment
Hi Alex,
Metadata in the Info tab can be set by creating new DocumentNotes and adding them with `DocumentNoteUtilities.addNotesTo(...)`.
You'll also need to create DocumentNoteTypes and DocumentNoteFields, here's a short example of how to do that:
DocumentNoteField field1 = DocumentNoteField.createTextNoteField("test field", "Some field", "testField", Collections.emptyList(), true);
DocumentNoteField field2 = DocumentNoteField.createTextNoteField("longer test field", "Some other field", "testField2", Collections.emptyList(), true);
DocumentNoteType noteType = DocumentNoteUtilities.createNewNoteType("test note", "testNote1", "Some description", Arrays.asList(field1, field2), true);
DocumentNoteUtilities.setNoteType(noteType);
DocumentNote note = noteType.createDocumentNote();
DocumentNoteUtilities.addNotesTo(myAPD, Collections.singletonList(note)); -
Excellent, thanks a lot for your help Jonas!
0
Please sign in to leave a comment.
Comments
2 comments