Why does WriteableDatabaseService.moveDocument(doc,progList) not move my Document?
Hi,
I struggle with another Problem here:
//get current folder
WritableDatabaseService db = (WritableDatabaseService) annotatedDocuments[0].getDatabase();
String resultFolderName;
WritableDatabaseService resultFolder = null;
//creating subfolder works OKAY
try {
resultFolderName= DocumentUtilities.getUniqueNameForDocument("primed sequences", db);
resultFolder = db.createChildFolder(resultFolderName);
} catch (DatabaseServiceException e) {
throw new DocumentOperationException("cannot save results");
}
List<AnnotatedPluginDocument> results = new ArrayList<AnnotatedPluginDocument>();
//do stuff
//adding documents into results
//now move results into subfolder, DOES NOT WORK
for (AnnotatedPluginDocument doc:results) {
try {
//NO MOVEMENT HERE
resultFolder.moveDocument(doc, ProgressListener.EMPTY);
} catch (DatabaseServiceException e) {
new DocumentOperationException("cannot save results");
}
}
Any ideas why
resultFolder.moveDocument(doc, ProgressListener.EMPTY)
does NOT my documents?
Thanks,
Stephan
-
Hi Stephan,
Have the results documents you're creating already been added to the database? If not then they need to be added to it rather than moved.
You can do this with the addDocumentCopy() method.
If they're in the database already then can you tell me if you're getting an exception or if the move method is returning false?
Cheers,
Matthew0 -
I never knew that I need to add a document to a DB. Will try this.
Thx,
Stephan0 -
Hi Stephan,
Just to clarify, Geneious core will handle the results from many of our plugin types and add them to the database for you. You will only need to manually add them if you want to do something that is not currently supported by the API or if you are writing a type of plugin that does not normally have output.
For example if you're writing a DocumentOperation then any documents you add to the OperationCallback or are returned in the result list are automatically added to the same folder as the input documents.
If you need a subfolder you can use DocumentOperation.OperationCallback.setSubFolder(String name) and any results will be added to the subfolder.
However if you want to do something more complex like saving documents to an unrelated folder then you will have to add them manually.
Cheers,
Matthew0 -
But according to the documentation I should not use performOperation.
0 -
Hi Stephan,
There are multiple variants of performOperation that have different signatures. You should be able to use one of the other variants to achieve what you need.
If you're implementing one of the variants that does not use the OperationCallback then you just need to return the document in the list.
If you tell me what type of plugin/class you are implementing then I can probably help more.
Cheers,
MatthewP.S. The advice there is to not use it to avoid any problems in future versions of Geneious. We'll remove that particular performOperation method in the next major version of the API (not the next version of Geneious). Something to keep in mind is that our API has stayed on the same major version for the last 9 years.
0 -
Case is closed!
A fresh start on Monday resolves some of strangest issues.
For other help seekers I document the solution below:
@Override
public void performOperation(AnnotatedPluginDocument[] annotatedDocuments, ProgressListener progressListener, Options options, SequenceSelection sequenceSelection, OperationCallback callback) throws DocumentOperationException
{
....
DocumentOperation primerOperation = PluginUtilities.getDocumentOperation("Operation_com.biomatters.plugins.primerDesign.DesignAnnotationGenerator");
...
try {
callback.setSubFolder("primed sequences");
} catch (DatabaseServiceException e) {
e.printStackTrace();
}
primerOperation.performOperation(new AnnotatedPluginDocument[]{document},ProgressListener.EMPTY,primerOperationOptions,sequenceSelection,callback);
}Thanks for all the helpful comments Matthew!
Stephan0 -
That's great! Glad you got it working.
0
Please sign in to leave a comment.
Comments
7 comments