From: <rv...@us...> - 2011-04-19 10:55:16
|
Revision: 786 http://treebase.svn.sourceforge.net/treebase/?rev=786&view=rev Author: rvos Date: 2011-04-19 10:55:10 +0000 (Tue, 19 Apr 2011) Log Message: ----------- We now always set the xml:base attribute on the document root, and the Study TreeBaseIDString as the xml id. This won't be written out, but the about attribute based on it will. Also, we place the TreeBaseIDString on all objects that pass through the attachTreeBaseID method. Taxa are now found by simply checking their ID strings as opposed to having to iterate over their annotations looking for the right owl:sameAs statement. The base URIs for matrix, taxon and tree are declared as protected variables in this class. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2011-04-19 10:49:22 UTC (rev 785) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2011-04-19 10:55:10 UTC (rev 786) @@ -23,6 +23,9 @@ public class NexmlObjectConverter extends AbstractNexusConverter { private Logger logger = Logger.getLogger(NexmlObjectConverter.class); protected URI mBaseURI = Constants.BaseURI; + protected URI mTaxonBaseURI = URI.create(mBaseURI.toString() + "taxon/TB2:"); + protected URI mMatrixBaseURI = URI.create(mBaseURI.toString() + "matrix/TB2:"); + protected URI mTreeBaseURI = URI.create(mBaseURI.toString() + "tree/TB2:"); // private static String mBaseURIString = "http://purl.org/PHYLO/TREEBASE/PHYLOWS/"; // private static String mDCIdentifier = "dcterms:identifier"; public static String TreeBASE2Prefix = "TreeBASE2"; @@ -38,13 +41,14 @@ mBaseURI = URI.create(baseURI); document.setBaseURI(mBaseURI); } + document.setId(study.getTreebaseIDString().toString()); setTaxonLabelHome(taxonLabelHome); setStudy(study); setDocument(document); } public NexmlObjectConverter(Study study, TaxonLabelHome taxonLabelHome, Document document) { - this(study,taxonLabelHome,document,null); + this(study,taxonLabelHome,document,Constants.BaseURI.toString()); } @@ -65,10 +69,7 @@ */ protected void attachTreeBaseID(Annotatable annotatable,TBPersistable tbPersistable,Class<?> persistableClass) { if ( null != tbPersistable.getId() ) { - //attachAnnotation(mDCIdentifier,makeNamespacedID(tbPersistable,persistableClass),mDCURI,annotatable); -// String uriString = getDocument().getBaseURI().toString() + tbPersistable.getPhyloWSPath().toString(); -// annotatable.addAnnotationValue("owl:sameAs",Constants.OWLURI, URI.create(uriString)); -// annotatable.addAnnotationValue("dcterms:relation",Constants.DCURI, URI.create(uriString)); + annotatable.setId(tbPersistable.getTreebaseIDString().toString()); for ( org.cipres.treebase.domain.Annotation anno : tbPersistable.getAnnotations() ) { annotatable.addAnnotationValue(anno.getProperty(), anno.getURI(), anno.getValue()); } @@ -93,27 +94,15 @@ * @return */ protected Long readTreeBaseID(Annotatable annotatable) { - - // this will return the value object associated with a - // dc:identifier predicate in a nexml meta annotation, - // e.g. <meta property="dc:identifier" content="TB2:Tr231"/> - // this will return something that stringifies to TB2:Tr231 - Set<Object> dublinCoreRelationObjects = annotatable.getRelValues("owl:sameAs"); - Iterator<Object> objectIterator = dublinCoreRelationObjects.iterator(); - while ( objectIterator.hasNext() ) { - URI relationURI = (URI)objectIterator.next(); - String urlFragment = getDocument().getBaseURI().toString() + "taxon/TB2:"; - if ( relationURI.toString().startsWith(urlFragment) ) { - String rawTreebaseIDString = relationURI.toString().substring(urlFragment.length()); - try { - TreebaseIDString treebaseIDString = new TreebaseIDString(rawTreebaseIDString); - return treebaseIDString.getId(); - } catch ( MalformedTreebaseIDString e ) { - e.printStackTrace(); - } - } - } - return null; + // we no longer need to read owl:sameAs annotations because we + // use the TreebaseIDString objects as xml IDs + try { + TreebaseIDString treebaseIDString = new TreebaseIDString(annotatable.getId()); + return treebaseIDString.getId(); + } catch (MalformedTreebaseIDString e) { + e.printStackTrace(); + } + return null; } protected OTUs getOTUsById(Long taxonLabelSetId) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |