From: <rv...@us...> - 2009-06-19 02:15:46
|
Revision: 63 http://treebase.svn.sourceforge.net/treebase/?rev=63&view=rev Author: rvos Date: 2009-06-19 02:14:12 +0000 (Fri, 19 Jun 2009) Log Message: ----------- Added attachAnnotation(String key,String value,URI,Annotatable) method and mPrismURI static field. 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 2009-06-19 02:12:51 UTC (rev 62) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2009-06-19 02:14:12 UTC (rev 63) @@ -15,7 +15,9 @@ public class NexmlObjectConverter extends AbstractNexusConverter { protected static URI mDCURI; + protected static URI mPrismURI; private static String mDCURIString = "http://purl.org/dc/elements/1.1/"; + private static String mPrismURIString = "http://prismstandard.org/namespaces/1.2/basic/"; private static String mDCIdentifier = "dc:identifier"; public static String TreeBASE2Prefix = "TreeBASE2"; private Document mDocument; @@ -28,9 +30,10 @@ public NexmlObjectConverter(Study study, TaxonLabelHome taxonLabelHome, Document document) { try { mDCURI = new URI(mDCURIString); + mPrismURI = new URI(mPrismURIString); } catch (URISyntaxException e) { e.printStackTrace(); - } + } setTaxonLabelHome(taxonLabelHome); setStudy(study); setDocument(document); @@ -57,12 +60,23 @@ * @param tbPersistable */ protected void attachTreeBaseID(Annotatable annotatable,TBPersistable tbPersistable) { - annotatable.addAnnotationValue(mDCIdentifier, mDCURI, makeNamespacedID(tbPersistable)); + attachAnnotation(mDCIdentifier,makeNamespacedID(tbPersistable),mDCURI,annotatable); } /** * + * @param key + * @param value + * @param namespace * @param annotatable + */ + protected void attachAnnotation(String key,String value,URI namespace,Annotatable annotatable) { + annotatable.addAnnotationValue(key, namespace, value); + } + + /** + * + * @param annotatable * @param persistableClass * @return */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-24 03:22:32
|
Revision: 94 http://treebase.svn.sourceforge.net/treebase/?rev=94&view=rev Author: rvos Date: 2009-06-24 03:22:30 +0000 (Wed, 24 Jun 2009) Log Message: ----------- Retrieving (and throwing away) created Annotation (this in an empty to localize a NoSuchMethod exception) 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 2009-06-24 02:47:09 UTC (rev 93) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2009-06-24 03:22:30 UTC (rev 94) @@ -15,6 +15,7 @@ import org.cipres.treebase.domain.study.Study; import org.cipres.treebase.domain.taxon.TaxonLabelHome; import org.nexml.model.Annotatable; +import org.nexml.model.Annotation; import org.nexml.model.Document; import org.nexml.model.OTU; import org.nexml.model.OTUs; @@ -74,7 +75,7 @@ * @param annotatable */ protected void attachAnnotation(String key,String value,URI namespace,Annotatable annotatable) { - annotatable.addAnnotationValue(key, namespace, value); // FIXME! Attaches meta element as last child + Annotation annotation = annotatable.addAnnotationValue(key, namespace, value); // FIXME! Attaches meta element as last child } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-25 02:52:25
|
Revision: 113 http://treebase.svn.sourceforge.net/treebase/?rev=113&view=rev Author: rvos Date: 2009-06-25 02:52:19 +0000 (Thu, 25 Jun 2009) Log Message: ----------- attachTreebaseID now also attaches a dc:relation annotation with the canonical URL for the annotated resource 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 2009-06-25 02:50:10 UTC (rev 112) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2009-06-25 02:52:19 UTC (rev 113) @@ -63,7 +63,13 @@ */ protected void attachTreeBaseID(Annotatable annotatable,TBPersistable tbPersistable,Class<?> persistableClass) { if ( null != tbPersistable.getId() ) { - attachAnnotation(mDCIdentifier,makeNamespacedID(tbPersistable,persistableClass),mDCURI,annotatable); + attachAnnotation(mDCIdentifier,makeNamespacedID(tbPersistable,persistableClass),mDCURI,annotatable); + String uriString = "http://localhost:8080/treebase-web/PhyloWS/" + makeNamespacedID(tbPersistable,persistableClass); + try { + annotatable.addAnnotationValue("dc:relation",mDCURI, new URI(uriString)); + } catch ( Exception e ) { + + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-26 03:48:11
|
Revision: 126 http://treebase.svn.sourceforge.net/treebase/?rev=126&view=rev Author: rvos Date: 2009-06-26 03:48:04 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Now only sets baseURI if one is supplied to the constructor 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 2009-06-25 13:41:20 UTC (rev 125) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2009-06-26 03:48:04 UTC (rev 126) @@ -49,7 +49,9 @@ } catch (URISyntaxException e) { e.printStackTrace(); } - document.setBaseURI(mBaseURI); + if ( null != baseURI ) { + document.setBaseURI(mBaseURI); + } setTaxonLabelHome(taxonLabelHome); setStudy(study); setDocument(document); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2010-02-12 04:35:30
|
Revision: 493 http://treebase.svn.sourceforge.net/treebase/?rev=493&view=rev Author: rvos Date: 2010-02-12 04:35:22 +0000 (Fri, 12 Feb 2010) Log Message: ----------- Added DarwinCore namespace 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 2010-02-11 16:37:07 UTC (rev 492) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2010-02-12 04:35:22 UTC (rev 493) @@ -24,7 +24,9 @@ protected static URI mDCURI; protected static URI mPrismURI; protected static URI mTBTermsURI; - protected URI mBaseURI; + protected static URI mDwCURI; + protected URI mBaseURI; + private static String mDwCString = "http://rs.tdwg.org/dwc/terms/"; private static String mTBTermsString = "http://treebase.org/terms#"; private static String mDCURIString = "http://purl.org/dc/terms/"; private static String mPrismURIString = "http://prismstandard.org/namespaces/1.2/basic/"; @@ -43,6 +45,7 @@ mDCURI = new URI(mDCURIString); mPrismURI = new URI(mPrismURIString); mTBTermsURI = new URI(mTBTermsString); + mDwCURI = new URI(mDwCString); if ( null != baseURI ) { mBaseURI = new URI(baseURI); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2010-03-12 23:36:26
|
Revision: 566 http://treebase.svn.sourceforge.net/treebase/?rev=566&view=rev Author: rvos Date: 2010-03-12 23:36:19 +0000 (Fri, 12 Mar 2010) Log Message: ----------- Added logging messages. 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 2010-03-12 23:34:13 UTC (rev 565) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2010-03-12 23:36:19 UTC (rev 566) @@ -7,6 +7,7 @@ import java.util.Iterator; import java.util.Set; +import org.apache.log4j.Logger; import org.cipres.treebase.TreebaseIDString; import org.cipres.treebase.NamespacedGUID; import org.cipres.treebase.TreebaseIDString.MalformedTreebaseIDString; @@ -21,6 +22,7 @@ import org.nexml.model.OTUs; public class NexmlObjectConverter extends AbstractNexusConverter { + private Logger logger = Logger.getLogger(NexmlObjectConverter.class); protected static URI mDCURI; protected static URI mPrismURI; protected static URI mTBTermsURI; @@ -87,6 +89,7 @@ if ( null != tbPersistable.getId() ) { //attachAnnotation(mDCIdentifier,makeNamespacedID(tbPersistable,persistableClass),mDCURI,annotatable); String uriString = getDocument().getBaseURI().toString() + tbPersistable.getPhyloWSPath().toString(); + annotatable.addAnnotationValue("tb:resource",mTBTermsURI, URI.create(uriString)); annotatable.addAnnotationValue("dcterms:relation",mDCURI, URI.create(uriString)); } } @@ -133,8 +136,10 @@ } protected OTUs getOTUsById(Long taxonLabelSetId) { - for ( OTUs otus : getDocument().getOTUsList() ) { + logger.debug("Going to look for taxa block "+taxonLabelSetId); + for ( OTUs otus : getDocument().getOTUsList() ) { Long annotatedID = readTreeBaseID(otus); + logger.debug("Seen taxa block "+annotatedID); if ( taxonLabelSetId.equals(annotatedID) ) { return otus; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2010-03-15 01:07:24
|
Revision: 573 http://treebase.svn.sourceforge.net/treebase/?rev=573&view=rev Author: rvos Date: 2010-03-15 01:07:17 +0000 (Mon, 15 Mar 2010) Log Message: ----------- Now calls getAnnotations() to let the object decide what metadata to add as opposed to fiddling with the object here. 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 2010-03-15 01:06:19 UTC (rev 572) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2010-03-15 01:07:17 UTC (rev 573) @@ -1,15 +1,14 @@ package org.cipres.treebase.domain.nexus.nexml; import java.net.URI; -import java.net.URISyntaxException; import java.text.CharacterIterator; import java.text.StringCharacterIterator; import java.util.Iterator; import java.util.Set; import org.apache.log4j.Logger; +import org.cipres.treebase.Constants; import org.cipres.treebase.TreebaseIDString; -import org.cipres.treebase.NamespacedGUID; import org.cipres.treebase.TreebaseIDString.MalformedTreebaseIDString; import org.cipres.treebase.domain.TBPersistable; import org.cipres.treebase.domain.nexus.AbstractNexusConverter; @@ -23,17 +22,9 @@ public class NexmlObjectConverter extends AbstractNexusConverter { private Logger logger = Logger.getLogger(NexmlObjectConverter.class); - protected static URI mDCURI; - protected static URI mPrismURI; - protected static URI mTBTermsURI; - protected static URI mDwCURI; - protected URI mBaseURI; - private static String mDwCString = "http://rs.tdwg.org/dwc/terms/"; - private static String mTBTermsString = "http://treebase.org/terms#"; - private static String mDCURIString = "http://purl.org/dc/terms/"; - private static String mPrismURIString = "http://prismstandard.org/namespaces/1.2/basic/"; - private static String mBaseURIString = "http://purl.org/PHYLO/TREEBASE/PHYLOWS/"; - private static String mDCIdentifier = "dcterms:identifier"; + protected URI mBaseURI = Constants.BaseURI; +// private static String mBaseURIString = "http://purl.org/PHYLO/TREEBASE/PHYLOWS/"; +// private static String mDCIdentifier = "dcterms:identifier"; public static String TreeBASE2Prefix = "TreeBASE2"; private Document mDocument; @@ -43,21 +34,8 @@ * @param taxonLabelHome */ public NexmlObjectConverter(Study study, TaxonLabelHome taxonLabelHome, Document document, String baseURI) { - try { - mDCURI = new URI(mDCURIString); - mPrismURI = new URI(mPrismURIString); - mTBTermsURI = new URI(mTBTermsString); - mDwCURI = new URI(mDwCString); - if ( null != baseURI ) { - mBaseURI = new URI(baseURI); - } - else { - mBaseURI = new URI(mBaseURIString); - } - } catch (URISyntaxException e) { - e.printStackTrace(); - } if ( null != baseURI ) { + mBaseURI = URI.create(baseURI); document.setBaseURI(mBaseURI); } setTaxonLabelHome(taxonLabelHome); @@ -75,10 +53,10 @@ * @param tbPersistable * @return */ - private String makeNamespacedID (TBPersistable tbPersistable,Class<?> persistableClass) { - TreebaseIDString tbIDString = new TreebaseIDString(persistableClass,tbPersistable.getId()); - return tbIDString.getNamespacedGUID().toString(); - } +// private String makeNamespacedID (TBPersistable tbPersistable,Class<?> persistableClass) { +// TreebaseIDString tbIDString = new TreebaseIDString(persistableClass,tbPersistable.getId()); +// return tbIDString.getNamespacedGUID().toString(); +// } /** * @@ -88,9 +66,12 @@ 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("tb:resource",mTBTermsURI, URI.create(uriString)); - annotatable.addAnnotationValue("dcterms:relation",mDCURI, URI.create(uriString)); +// 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)); + for ( org.cipres.treebase.domain.Annotation anno : tbPersistable.getAnnotations() ) { + annotatable.addAnnotationValue(anno.getProperty(), anno.getURI(), anno.getValue()); + } } } @@ -117,7 +98,7 @@ // 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("dcterms:relation"); + Set<Object> dublinCoreRelationObjects = annotatable.getRelValues("owl:sameAs"); Iterator<Object> objectIterator = dublinCoreRelationObjects.iterator(); while ( objectIterator.hasNext() ) { URI relationURI = (URI)objectIterator.next(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2012-02-03 22:41:25
|
Revision: 1046 http://treebase.svn.sourceforge.net/treebase/?rev=1046&view=rev Author: rvos Date: 2012-02-03 22:41:19 +0000 (Fri, 03 Feb 2012) Log Message: ----------- Added caching of taxon and taxa block lookups using hash maps 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 2012-02-03 22:38:37 UTC (rev 1045) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2012-02-03 22:41:19 UTC (rev 1046) @@ -3,6 +3,8 @@ import java.net.URI; import java.text.CharacterIterator; import java.text.StringCharacterIterator; +import java.util.HashMap; +import java.util.Map; import org.apache.log4j.Logger; import org.cipres.treebase.Constants; @@ -26,6 +28,8 @@ protected static URI mStudyBaseURI = URI.create(Constants.BaseURI.toString() + "study/TB2:"); public static String TreeBASE2Prefix = "TreeBASE2"; private Document mDocument; + private Map<Long,OTU> otuById = new HashMap<Long,OTU>(); + private Map<Long,OTUs> otusById = new HashMap<Long,OTUs>(); /** * @@ -44,6 +48,12 @@ setDocument(document); } + /** + * + * @param study + * @param taxonLabelHome + * @param document + */ public NexmlObjectConverter(Study study, TaxonLabelHome taxonLabelHome, Document document) { this(study,taxonLabelHome,document,mStudyBaseURI.toString()); } @@ -51,16 +61,6 @@ /** * - * @param tbPersistable - * @return - */ -// private String makeNamespacedID (TBPersistable tbPersistable,Class<?> persistableClass) { -// TreebaseIDString tbIDString = new TreebaseIDString(persistableClass,tbPersistable.getId()); -// return tbIDString.getNamespacedGUID().toString(); -// } - - /** - * * @param annotatable * @param tbPersistable */ @@ -91,8 +91,6 @@ * @return */ protected Long readTreeBaseID(Annotatable annotatable) { - // 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(); @@ -102,36 +100,68 @@ return null; } + /** + * + * @param taxonLabelSetId + * @return + */ protected OTUs getOTUsById(Long taxonLabelSetId) { logger.debug("Going to look for taxa block "+taxonLabelSetId); + if ( otusById.containsKey(taxonLabelSetId) ) { + return otusById.get(taxonLabelSetId); + } for ( OTUs otus : getDocument().getOTUsList() ) { Long annotatedID = readTreeBaseID(otus); logger.debug("Seen taxa block "+annotatedID); if ( taxonLabelSetId.equals(annotatedID) ) { + otusById.put(taxonLabelSetId, otus); return otus; } } return null; } + /** + * + * @param otus + * @param taxonLabelId + * @return + */ protected OTU getOTUById(OTUs otus,Long taxonLabelId) { + if ( otuById.containsKey(taxonLabelId) ) { + return otuById.get(taxonLabelId); + } for ( OTU otu : otus.getAllOTUs() ) { Long annotatedID = readTreeBaseID(otu); if ( taxonLabelId.equals(annotatedID) ) { + otuById.put(taxonLabelId, otu); return otu; } } return null; } + /** + * + * @return + */ public Document getDocument() { return mDocument; } + /** + * + * @param document + */ public void setDocument(Document document) { mDocument = document; } + /** + * Encodes some common x(ht)ml entities + * @param aText + * @return + */ public static String forXML(String aText){ final StringBuilder result = new StringBuilder(); final StringCharacterIterator iterator = new StringCharacterIterator(aText); @@ -157,10 +187,18 @@ return result.toString(); } + /** + * + * @return + */ public URI getBaseURI() { return mBaseURI; } + /** + * + * @param baseURI + */ public void setBaseURI(URI baseURI) { mBaseURI = baseURI; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2009-06-28 10:09:49
|
Revision: 134 http://treebase.svn.sourceforge.net/treebase/?rev=134&view=rev Author: rvos Date: 2009-06-28 10:09:22 +0000 (Sun, 28 Jun 2009) Log Message: ----------- Now attaches dc:relation annotations to link to enclosed resources, no longer uses dc:identifier 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 2009-06-27 07:04:54 UTC (rev 133) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2009-06-28 10:09:22 UTC (rev 134) @@ -79,14 +79,9 @@ */ protected void attachTreeBaseID(Annotatable annotatable,TBPersistable tbPersistable,Class<?> persistableClass) { if ( null != tbPersistable.getId() ) { - attachAnnotation(mDCIdentifier,makeNamespacedID(tbPersistable,persistableClass),mDCURI,annotatable); - String uriString = mBaseURI.toString() + makeNamespacedID(tbPersistable,persistableClass); - try { - annotatable.addAnnotationValue("dc:relation",mDCURI, new URI(uriString)); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + //attachAnnotation(mDCIdentifier,makeNamespacedID(tbPersistable,persistableClass),mDCURI,annotatable); + String uriString = getDocument().getBaseURI().toString() + tbPersistable.getPhyloWSPath().toString(); + annotatable.addAnnotationValue("dc:relation",mDCURI, URI.create(uriString)); } } @@ -98,7 +93,7 @@ * @param annotatable */ protected void attachAnnotation(String key,String value,URI namespace,Annotatable annotatable) { - Annotation annotation = annotatable.addAnnotationValue(key, namespace, value); // FIXME! Attaches meta element as last child + Annotation annotation = annotatable.addAnnotationValue(key, namespace, value); } /** @@ -113,19 +108,19 @@ // 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> dublinCoreIdentifierObjects = annotatable.getAnnotationValues(mDCIdentifier); - Iterator<Object> objectIterator = dublinCoreIdentifierObjects.iterator(); + Set<Object> dublinCoreRelationObjects = annotatable.getRelValues("dc:relation"); + Iterator<Object> objectIterator = dublinCoreRelationObjects.iterator(); while ( objectIterator.hasNext() ) { - TreebaseIDString treebaseIDString = null; - NamespacedGUID namespacedGUID = null; - try { - namespacedGUID = new NamespacedGUID(objectIterator.next().toString()); - treebaseIDString = namespacedGUID.getTreebaseIDString(); - return treebaseIDString.getId(); - } catch ( MalformedTreebaseIDString e ) { - // XXX do nothing, it's OK, it means we're - // parsing an id from a different naming - // authority, e.g. uBio or NCBI + 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <rv...@us...> - 2011-04-19 11:10:59
|
Revision: 788 http://treebase.svn.sourceforge.net/treebase/?rev=788&view=rev Author: rvos Date: 2011-04-19 11:10:53 +0000 (Tue, 19 Apr 2011) Log Message: ----------- Now setting the xml:base attribute to <phylowsPurl>/study/TB2: on every document. 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:59:49 UTC (rev 787) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2011-04-19 11:10:53 UTC (rev 788) @@ -26,6 +26,7 @@ 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:"); + protected static URI mStudyBaseURI = URI.create(Constants.BaseURI.toString() + "study/TB2:"); // private static String mBaseURIString = "http://purl.org/PHYLO/TREEBASE/PHYLOWS/"; // private static String mDCIdentifier = "dcterms:identifier"; public static String TreeBASE2Prefix = "TreeBASE2"; @@ -38,8 +39,7 @@ */ public NexmlObjectConverter(Study study, TaxonLabelHome taxonLabelHome, Document document, String baseURI) { if ( null != baseURI ) { - mBaseURI = URI.create(baseURI); - document.setBaseURI(mBaseURI); + document.setBaseURI(URI.create(baseURI)); } document.setId(study.getTreebaseIDString().toString()); setTaxonLabelHome(taxonLabelHome); @@ -48,7 +48,7 @@ } public NexmlObjectConverter(Study study, TaxonLabelHome taxonLabelHome, Document document) { - this(study,taxonLabelHome,document,Constants.BaseURI.toString()); + this(study,taxonLabelHome,document,mStudyBaseURI.toString()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |