Class DocumentOperation.OperationCallback
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.DocumentOperation.OperationCallback
-
- Direct Known Subclasses:
DocumentOperation.OperationCallback.Wrapper
- Enclosing class:
- DocumentOperation
public static class DocumentOperation.OperationCallback extends java.lang.Object
Provides a callback facility to DocumentOperations. You can set a resumable state at regular intervals when your operation is running, and you will be able to retrieve it by callinggetResumableState()
. When your operation is first run, you should check whethergetResumableState()
returns a non-null value, and use it to resume the operation. You can also add documents while your operation is running by callingaddDocument(PluginDocument, boolean, ProgressListener)
} oraddDocument(AnnotatedPluginDocument, boolean, ProgressListener)
. These documents are treated as intermediate documents, so you should still return a list of the final documents (you may add documents to the callback, and return them in the list)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DocumentOperation.OperationCallback.Wrapper
Creates a wrapper OperationCallback that delegates all methods to another OperationCallback
-
Constructor Summary
Constructors Constructor Description OperationCallback()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AnnotatedPluginDocument
addDocument(AnnotatedPluginDocument doc, boolean dontSelectDocumentWhenComplete, jebl.util.ProgressListener progress)
returns a document from the operation while the operation is still in progress.AnnotatedPluginDocument
addDocument(PluginDocument doc, boolean dontSelectDocumentWhenComplete, jebl.util.ProgressListener progress)
returns a document from the operaiton while the operation is still in progress.void
addInvolvedIntervals(URN targetUrn, URN sourceUrn, java.util.List<SequenceSelection.SelectionInterval> intervals)
Add intervals of document which are involved in this operation.boolean
canResume()
org.jdom.Element
getResumableState()
returns the persistent information that was set with the last call tosetResumableState(org.jdom.Element)
(this call may have been before the operation was paused)boolean
isInterestedInParentDescendants()
void
setAdditionalInformation(java.lang.String additionalInformation)
Set additional information that is shown on the operation node in the Lineage tabvoid
setMarkUnselectedDocumentsUnread(boolean markUnselectedDocumentsUnread)
Sets whether or not documents added to the callback that can't be immediately selected are marked as unread.void
setOptionsForActivelyLinkedDescendants(org.jdom.Element optionsElement, java.util.List<AnnotatedPluginDocument> inputDocuments, java.util.List<AnnotatedPluginDocument> additionalParentDocuments)
This method will only have an effect ifisInterestedInParentDescendants()
returns true.void
setOptionsForActivelyLinkedDescendants(org.jdom.Element optionsElement, java.util.List<AnnotatedPluginDocument> inputDocuments, java.util.List<AnnotatedPluginDocument> additionalParentDocuments, java.lang.String additionalInformation)
This method will only have an effect ifisInterestedInParentDescendants()
returns true.void
setRemoteJobId(GeneiousService service, java.lang.String jobId)
This method is only provided for core Geneious use when implementing a remote service such as a Geneious Server or a Green Button service.void
setResumableState(org.jdom.Element e)
Sets a resumable state for your operation.void
setSubFolder(java.lang.String name)
Specify the name of a subfolder that the results of the operation should go in.void
stopCreatingOperationRecords()
Stops anyoperation records
from being created for subsequent documents added usingaddDocument
.
-
-
-
Method Detail
-
setResumableState
public void setResumableState(org.jdom.Element e)
Sets a resumable state for your operation. You should store all information that you need to resume the operation in the xml you pass in. You do not need to serialise theAnnotatedPluginDocuments
,Options
orSequenceSelections
passed in to your operation - the same ones will be passed in when your operation is resumed.- Parameters:
e
- all the information necessary to resume the operation, or null to set this operation to be non-resumable.
-
getResumableState
public org.jdom.Element getResumableState()
returns the persistent information that was set with the last call tosetResumableState(org.jdom.Element)
(this call may have been before the operation was paused)- Returns:
- the persistent information stored in the last call to
setResumableState(org.jdom.Element)
(this call may have been before the operation was paused), or null if it was never called.
-
canResume
public boolean canResume()
- Returns:
- true if this operation can resume (ie if
setResumableState(org.jdom.Element)
has been called with a non-null argument.
-
setSubFolder
public void setSubFolder(java.lang.String name) throws DatabaseServiceException
Specify the name of a subfolder that the results of the operation should go in. The callback handles creating the folder if necessary. Some callbacks may ignore this, eg. if another plugin is calling performOperation. This method can be called more than once. The subfolder is created immediately but will be deleted if the operation is canceled and the folder is empty.- Parameters:
name
- name of the subfolder or null to not put the results in a subfolder. Defaults to null.- Throws:
DatabaseServiceException
- if failed to create subfolder, in which case the parent folder is used. This exception may be ignored if that is acceptable- Since:
- API 4.14 (Geneious 5.1)
-
setMarkUnselectedDocumentsUnread
public void setMarkUnselectedDocumentsUnread(boolean markUnselectedDocumentsUnread)
Sets whether or not documents added to the callback that can't be immediately selected are marked as unread. An implementation may choose to ignore this request. The default behaviour is to mark unselectable documents as unread- Parameters:
markUnselectedDocumentsUnread
-- Since:
- API 4.710 (Geneious 7.1.0)
-
addDocument
public final AnnotatedPluginDocument addDocument(PluginDocument doc, boolean dontSelectDocumentWhenComplete, jebl.util.ProgressListener progress) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
returns a document from the operaiton while the operation is still in progress.- Parameters:
doc
- a document to returndontSelectDocumentWhenComplete
- should Geneious select the document when the operation is complete- Returns:
- an
AnnotatedPluginDocument
that contains the givenPluginDocument
- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if the document could not be added for some reason.
-
addDocument
public AnnotatedPluginDocument addDocument(AnnotatedPluginDocument doc, boolean dontSelectDocumentWhenComplete, jebl.util.ProgressListener progress) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
returns a document from the operation while the operation is still in progress.- Parameters:
doc
- a document to returndontSelectDocumentWhenComplete
- should Geneious select the document when the operation is complete- Returns:
- either the given
AnnotatedPluginDocument
or a copy if the document was added to the local database. - Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if the document could not be added for some reason.
-
setRemoteJobId
public void setRemoteJobId(GeneiousService service, java.lang.String jobId)
This method is only provided for core Geneious use when implementing a remote service such as a Geneious Server or a Green Button service. Plugin developers should never need to call or implement it, except when delegating a callback.- Parameters:
service
- The location the operation is running. Must not be null.jobId
- A unique identifier for a running operation. This identifier must be unique across all jobs for the service.- Since:
- API 4.14 (Geneious 5.1)
-
setOptionsForActivelyLinkedDescendants
public void setOptionsForActivelyLinkedDescendants(org.jdom.Element optionsElement, java.util.List<AnnotatedPluginDocument> inputDocuments, java.util.List<AnnotatedPluginDocument> additionalParentDocuments, java.lang.String additionalInformation) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
This method will only have an effect ifisInterestedInParentDescendants()
returns true. If not, then this method won't do anything if you try and use it. Furthermore if an operation modifies input documents as part of providing parent/descendant functionality (for example adding invisible annotations) then it must not do that ifisInterestedInParentDescendants()
returns false.
Creates an operation record that will include all descendant documents added afterwards usingaddDocument
. These documents can be recreated later usingDocumentOperation.getOptions(org.jdom.Element, List, List)
in conjunction with a performOperation call. This method may be called multiple times for different sets of output from the operation. For example when batch creating results, each result may be produced as an independent parent/descendant data set that can be recreated later independently of other results.- Parameters:
optionsElement
- an xml form of the options that, when deserialized, allows this operation to be rerun with exactly the same results as when it was first run in this (and any future) version of Geneious, usingDocumentOperation.getOptions(org.jdom.Element, List, List)
. If the options never change between versions of Geneious, and the operation ignores the Sequence Selection, then this is as simple as callingOptions.valuesToXML(String)
and usingOptions.valuesFromXML(org.jdom.Element)
inDocumentOperation.getOptions(org.jdom.Element, List, List)
.
A robust implementation should ideally store a plugin version number in some form, and additionally should serialize theSequenceSelection
if necessary, along with any other relevant information required to completely rerun the operation exactly. For example, callOptions.valuesToXML()
and then callsetAttribute
("version","2.3")
This may be null to indicate that documents generated should not be actively linked.inputDocuments
- those parent documents that should be supplied to performOperation as parameters for future runs of the operation. Most of the time this should be the input documents to the operation, except when performing a batch operation.additionalParentDocuments
- those parent documents that shouldn't be supplied directly as parameters to performOperation, but that are supplied via some other mechanism (e.g.DocumentSelectionOption.DocumentChooser
)).additionalInformation
- additional information to show in the operation record (in addition to the operationId and the timeAtWhichOperationWasRun).- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if there is a problem writing to the database- Since:
- API 4.910 (Geneious 9.1.0)
-
addInvolvedIntervals
public void addInvolvedIntervals(URN targetUrn, URN sourceUrn, java.util.List<SequenceSelection.SelectionInterval> intervals)
Add intervals of document which are involved in this operation. For an example of what this means, seeOperationRecordDocument.addIntervals(URN, URN, List)
- Parameters:
targetUrn
- urn of target documentsourceUrn
- urn of source documentintervals
- intervals in source document and have immediate relationship with target document- Since:
- API 4.1000 (Geneious 10.0.0)
- See Also:
OperationRecordDocument.addIntervals(URN, URN, List)
-
setAdditionalInformation
public void setAdditionalInformation(java.lang.String additionalInformation)
Set additional information that is shown on the operation node in the Lineage tab- Parameters:
additionalInformation
-- Since:
- API 4.1011 (Geneious 10.1.1)
- See Also:
OperationRecordDocument.setAdditionalInformation(String)
-
setOptionsForActivelyLinkedDescendants
public void setOptionsForActivelyLinkedDescendants(org.jdom.Element optionsElement, java.util.List<AnnotatedPluginDocument> inputDocuments, java.util.List<AnnotatedPluginDocument> additionalParentDocuments) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
This method will only have an effect ifisInterestedInParentDescendants()
returns true. If not, then this method won't do anything if you try and use it. Furthermore if an operation modifies input documents as part of providing parent/descendant functionality (for example adding invisible annotations) then it must not do that ifisInterestedInParentDescendants()
returns false.
Creates an operation record that will include all descendant documents added afterwards usingaddDocument
. These documents can be recreated later usingDocumentOperation.getOptions(org.jdom.Element, List, List)
in conjunction with a performOperation call. This method may be called multiple times for different sets of output from the operation. For example when batch creating results, each result may be produced as an independent parent/descendant data set that can be recreated later independently of other results.- Parameters:
optionsElement
- an xml form of the options that, when deserialized, allows this operation to be rerun with exactly the same results as when it was first run in this (and any future) version of Geneious, usingDocumentOperation.getOptions(org.jdom.Element, List, List)
. If the options never change between versions of Geneious, and the operation ignores the Sequence Selection, then this is as simple as callingOptions.valuesToXML(String)
and usingOptions.valuesFromXML(org.jdom.Element)
inDocumentOperation.getOptions(org.jdom.Element, List, List)
.
A robust implementation should ideally store a plugin version number in some form, and additionally should serialize theSequenceSelection
if necessary, along with any other relevant information required to completely rerun the operation exactly. For example, callOptions.valuesToXML()
and then callsetAttribute
("version","2.3")
This may be null to indicate that documents generated should not be actively linked.inputDocuments
- those parent documents that should be supplied to performOperation as parameters for future runs of the operation. Most of the time this should be the input documents to the operation, except when performing a batch operation.additionalParentDocuments
- those parent documents that shouldn't be supplied directly as parameters to performOperation, but that are supplied via some other mechanism (e.g.DocumentSelectionOption.DocumentChooser
)).- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if there is a problem writing to the database- Since:
- API 4.60 (Geneious 5.6.0)
-
isInterestedInParentDescendants
public boolean isInterestedInParentDescendants()
- Returns:
- true if the callback is interested in parent/descendants, and supports
setOptionsForActivelyLinkedDescendants
. You should diverge your code paths so that, for example, any additional work for parent/descendants you do such as creating invisible annotations on parent documents doesn't get done unnecessarily. If this returns false, then they shouldn't do that or make any other sort of changes to the parent/input documents - Since:
- API 4.61 (Geneious 5.6.1)
-
stopCreatingOperationRecords
public void stopCreatingOperationRecords() throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
Stops anyoperation records
from being created for subsequent documents added usingaddDocument
. This can be undone for later documents you wish to add by callingsetOptionsForActivelyLinkedDescendants(org.jdom.Element, List, List)
- documents added subsequent to that call will then have records created in the manner described in by that method.- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if a problem occurs- Since:
- API 4.60 (Geneious 5.6.0)
-
-