Class DocumentNoteUtilities
- java.lang.Object
-
- com.biomatters.geneious.publicapi.documents.DocumentNoteUtilities
-
public final class DocumentNoteUtilities extends java.lang.Object
This gives access to the NoteTypes defined in the program. These are the "Note Types" that can be seen in the "Notes" interface of the program. The user can modify them through the user interface.
If you programatically depend on a particularDocumentNoteType
you should always deal with the codes of fields as the names can change. Also it is recommended that any note type fields that you depend on aredontAllowModification = true
so the user can not delete or modify that field.
DocumentNoteType
s can not be deleted from the program once they are added. This is because documents may already have instances of a note type. UseDocumentNoteType.setVisible(boolean)
and thensetNoteType(DocumentNoteType)
to have the NoteType not visible in the interface. This is equivalent to a note type being deleted in the user interface. Here is an example of creating a note type and adding it to a document. This could be used to add extra information to a document at the end of an operation.java.util.List
noteFields = new ArrayList (); String fieldCode = "Field1"; noteFields.add(DocumentNoteField.createTextNoteField("Field no.1", "The first field", fieldCode, Collections. emptyList(), false)); String noteTypeCode = "DocumentNoteUtilities-TestNote"; DocumentNoteType noteType = DocumentNoteUtilities.getNoteType(noteTypeCode); if (noteType == null) { //create and add the note type if it hasn't already been added noteType = DocumentNoteUtilities.createNewNoteType("Test Note", noteTypeCode, "A test note", noteFields, true); DocumentNoteUtilities.setNoteType(noteType); } DocumentNote note = noteType.createDocumentNote(); note.setFieldValue(fieldCode, "A value!"); AnnotatedPluginDocument.DocumentNotes documentNotes = annotatedDocument.getDocumentNotes(true); documentNotes.setNote(note); documentNotes.saveNotes();
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addNotesTo(AnnotatedPluginDocument document, java.util.List<DocumentNote> notesToAdd)
Adds a list of document notes to a documentstatic void
copyNotes(AnnotatedPluginDocument sourceDocument, AnnotatedPluginDocument destinationDocument)
Copies all document notes from one document to anotherstatic DocumentNoteType
createNewNoteType(java.lang.String name, java.lang.String code, java.lang.String description, java.util.List<DocumentNoteField> fields, boolean visible)
Create a newDocumentNoteType
which should be used for adding a new note type.static java.util.List<DocumentNoteType>
getAllNoteTypes()
This includes all the users custom note types.static DocumentNoteType
getNoteType(java.lang.String code)
WARNING: These are not defensive copies of the note types so do not modify them unless you are definitely going to callsetNoteType(DocumentNoteType)
to save them.static void
setNoteType(DocumentNoteType documentNoteType)
Can be used to add a newDocumentNoteType
to the program if thisDocumentNoteType
does not already exist.
-
-
-
Method Detail
-
getNoteType
public static DocumentNoteType getNoteType(java.lang.String code)
WARNING: These are not defensive copies of the note types so do not modify them unless you are definitely going to callsetNoteType(DocumentNoteType)
to save them.- Parameters:
code
- of theDocumentNoteType
- Returns:
- DocumentNoteType with code
code
or null if no DocumentNoteType with this code exists.
-
getAllNoteTypes
public static java.util.List<DocumentNoteType> getAllNoteTypes()
This includes all the users custom note types. WARNING: This is not a defensive copies of the note type so do not modify the note type unless you are definitely going to callsetNoteType(DocumentNoteType)
to save it.- Returns:
- a list of all available note types
-
createNewNoteType
public static DocumentNoteType createNewNoteType(java.lang.String name, java.lang.String code, java.lang.String description, java.util.List<DocumentNoteField> fields, boolean visible)
Create a newDocumentNoteType
which should be used for adding a new note type. usesetNoteType(DocumentNoteType)
to add the note type after setting it up.- Parameters:
name
- of the newDocumentNoteType
. Must not be null.code
- a unique identifier for this note type. Must not contain '.' or be null. Using fully qualified class name with '.' stripped is a good way to ensure uniqueness.description
- of the newDocumentNoteType
. Must not be null.fields
- for theDocumentNoteType
to contain. Must not be null or empty.visible
- true to have theDocumentNoteType
visible in the user interface, false if not.- Returns:
- The new
DocumentNoteType
. - Throws:
java.lang.IllegalArgumentException
- if the note contains characters that can't be serialized to XML
-
setNoteType
public static void setNoteType(DocumentNoteType documentNoteType)
Can be used to add a newDocumentNoteType
to the program if thisDocumentNoteType
does not already exist. Can also be used to modify an existingDocumentNoteType
by getting the original fromgetNoteType(String)
, modifying it and calling this to save the changes.
Be careful when using this because you can modify the users custom note types which is not recommended unless the users is absolutely aware of this happening and of the possible consequences.- Parameters:
documentNoteType
- to add or update- Throws:
java.lang.IllegalArgumentException
- if a type already exists with the given code andexistingNoteType == documentNoteType
is false.
-
copyNotes
public static void copyNotes(AnnotatedPluginDocument sourceDocument, AnnotatedPluginDocument destinationDocument)
Copies all document notes from one document to another- Parameters:
sourceDocument
- the document to copy notes fromdestinationDocument
- the document to copy notes to- Since:
- API 4.901 (Geneious 9.0.1)
-
addNotesTo
public static void addNotesTo(AnnotatedPluginDocument document, java.util.List<DocumentNote> notesToAdd)
Adds a list of document notes to a document- Parameters:
document
- the document to add notes tonotesToAdd
- the notes to be added to the document- Since:
- API 4.901 (Geneious 9.0.1)
-
-