From: jprocter Date: Tue, 24 Jan 2006 15:16:26 +0000 (+0000) Subject: parameterised the default empty document construction X-Git-Tag: Release_0.2~351 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=847d5b8261484b372e556515d51d3e23a1602166;p=vamsas.git parameterised the default empty document construction git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@169 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/org/vamsas/client/simpleclient/VamsasArchive.java b/src/org/vamsas/client/simpleclient/VamsasArchive.java index 6e86407..7ff24b1 100644 --- a/src/org/vamsas/client/simpleclient/VamsasArchive.java +++ b/src/org/vamsas/client/simpleclient/VamsasArchive.java @@ -199,7 +199,7 @@ public class VamsasArchive { ? "File cannot be overwritten." : "Null Object not valid constructor parameter")); return; } - + this.vamsasdocument = vamsasdocument; if (archive.exists() && !overwrite) { this.original = archive; @@ -426,17 +426,43 @@ public class VamsasArchive { org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { return VamsasArchive.getOriginalRoots(this); } + /** + * @return original document or a new empty document (with default provenance) + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ public VamsasDocument getVamsasDocument() throws IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { + return getVamsasDocument("org.vamsas.simpleclient.VamsasArchive", "Created new empty document", null); + } + /** + * Return the original document or a new empty document with initial provenance entry. + * @param provenance_user (null sets user to be the class name) + * @param provenance_action (null sets action to be 'created new document') + * @param version (null means use latest version) + * @return (original document or a new vamsas document with supplied provenance and version info) + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public VamsasDocument getVamsasDocument(String provenance_user, String provenance_action, String version) throws IOException, + org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { if (_doc!=null) return _doc; _doc = getOriginalVamsasDocument(this, getVorba()); if (_doc!=null) return _doc; + // validate parameters + if (provenance_user==null) + provenance_user = "org.vamsas.simpleclient.VamsasArchive"; + if (provenance_action == null) + provenance_action="Created new empty document"); + if (version==null) + version = VersionEntries.latestVersion(); // Create a new document and return it _doc = DocumentStuff.newVamsasDocument(new VAMSAS[] { new VAMSAS()}, - ProvenanceStuff.newProvenance("org.vamsas.simpleclient.VamsasArchive", "Created new empty document") - , VersionEntries.latestVersion()); + ProvenanceStuff.newProvenance(provenance_user, provenance_action), version); return _doc; } /**