From: <rv...@us...> - 2009-06-19 02:15:52
|
Revision: 62 http://treebase.svn.sourceforge.net/treebase/?rev=62&view=rev Author: rvos Date: 2009-06-19 02:12:51 +0000 (Fri, 19 Jun 2009) Log Message: ----------- Adding NexmlDocumentConverter class Added Paths: ----------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java Added: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java (rev 0) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java 2009-06-19 02:12:51 UTC (rev 62) @@ -0,0 +1,149 @@ +package org.cipres.treebase.domain.nexus.nexml; + +import org.cipres.treebase.domain.admin.Person; +import org.cipres.treebase.domain.nexus.NexusDataSet; +import org.cipres.treebase.domain.study.ArticleCitation; +import org.cipres.treebase.domain.study.Citation; +import org.cipres.treebase.domain.study.Study; +import org.cipres.treebase.domain.taxon.TaxonLabelHome; +import org.cipres.treebase.domain.taxon.TaxonLabelSet; +import org.nexml.model.Document; +import org.nexml.model.Matrix; +import org.nexml.model.OTUs; +import org.nexml.model.TreeBlock; + +public class NexmlDocumentConverter extends NexmlObjectConverter { + + /** + * + * @param study + * @param taxonLabelHome + * @param document + */ + public NexmlDocumentConverter(Study study, TaxonLabelHome taxonLabelHome, + Document document) { + super(study, taxonLabelHome, document); + } + + /** + * + * @param pDocument + * @return + */ + public NexusDataSet fromXmlToTreeBase(Document pDocument) { + NexusDataSet nexusDataSet = new NexusDataSet(); + nexusDataSet.setNexmlProject(pDocument); + + NexmlOTUConverter noc = new NexmlOTUConverter(getStudy(),getTaxonLabelHome(),pDocument); + for ( OTUs xmlOTUs : pDocument.getOTUsList() ) { + TaxonLabelSet taxonLabelSet = noc.fromXmlToTreeBase(xmlOTUs); + nexusDataSet.addTaxonLabelSet(xmlOTUs, taxonLabelSet); + } + + NexmlMatrixConverter nmc = new NexmlMatrixConverter(getStudy(),getTaxonLabelHome(),pDocument); + for ( Matrix<?> xmlMatrix : pDocument.getMatrices() ) { + org.cipres.treebase.domain.matrix.Matrix matrix = nmc.fromXmlToTreeBase(xmlMatrix); + nexusDataSet.getMatrices().add(matrix); + } + + NexmlTreeBlockConverter ntc = new NexmlTreeBlockConverter(getStudy(),getTaxonLabelHome(),pDocument); + for ( TreeBlock xmlTreeBlock : pDocument.getTreeBlockList() ) { + org.cipres.treebase.domain.tree.TreeBlock treeBlock = ntc.fromXmlToTreeBase(xmlTreeBlock); + nexusDataSet.getTreeBlocks().add(treeBlock); + } + + return nexusDataSet; + } + + /** + * + * @param pNexusDataSet + * @return + */ + public Document fromTreeBaseToXml(NexusDataSet pNexusDataSet) { + + NexmlOTUConverter noc = new NexmlOTUConverter(getStudy(),getTaxonLabelHome(),getDocument()); + for ( TaxonLabelSet taxonLabelSet : pNexusDataSet.getTaxonLabelSets() ) { + noc.fromTreeBaseToXml(taxonLabelSet); + } + + NexmlMatrixConverter nmc = new NexmlMatrixConverter(getStudy(),getTaxonLabelHome(),getDocument()); + for (org.cipres.treebase.domain.matrix.Matrix matrix : pNexusDataSet.getMatrices() ) { + nmc.fromTreeBaseToXml(matrix); + } + + NexmlTreeBlockConverter ntc = new NexmlTreeBlockConverter(getStudy(),getTaxonLabelHome(),getDocument()); + for ( org.cipres.treebase.domain.tree.TreeBlock treeBlock : pNexusDataSet.getTreeBlocks() ) { + ntc.fromTreeBaseToXML(treeBlock); + } + + return getDocument(); + + } + + /** + * + * @param citation + * @param document + */ + private void copyCitationMetadata(Citation citation,Document document) { + attachAnnotation("prism:publicationDate",citation.getPublishYear().toString(),mPrismURI,document); + attachAnnotation("prism:doi",citation.getDoi(),mPrismURI,document); + String[] pages = citation.getPages().split("-"); + if ( pages.length > 2 ) { + attachAnnotation("prism:startingPage",pages[0],mPrismURI,document); + attachAnnotation("prism:endingPage",pages[1],mPrismURI,document); + attachAnnotation("prism:pageRange",citation.getPages(),mPrismURI,document); + } + String[] keywords = citation.getKeywords().split(", "); + for ( int i = 0; i < keywords.length; i++ ) { + attachAnnotation("prism:keyword",keywords[i],mPrismURI,document); + } + if ( citation instanceof ArticleCitation ) { + attachAnnotation("prism:publicationName",((ArticleCitation)citation).getJournal(),mPrismURI,document); + attachAnnotation("prism:volume",((ArticleCitation)citation).getVolume(),mPrismURI,document); + attachAnnotation("prism:number",((ArticleCitation)citation).getIssue(),mPrismURI,document); + } + } + + /** + * + * @param pStudy + * @return + */ + public Document fromTreeBaseToXml(Study pStudy) { + attachTreeBaseID(getDocument(), pStudy); + attachAnnotation("dc:title", pStudy.getName(), mDCURI, getDocument()); + attachAnnotation("dc:abstract",pStudy.getCitation().getAbstract(), mDCURI,getDocument()); + attachAnnotation( + "dc:creator", + pStudy.getSubmission().getSubmitter().getPerson().getFullNameCitationStyle(), + mDCURI, + getDocument() + ); + for ( Person person : pStudy.getAuthors() ) { + String personName = person.getFullNameCitationStyle(); + attachAnnotation("dc:contributor",personName,mDCURI,getDocument()); + } + attachAnnotation("prism:creationDate",pStudy.getSubmission().getCreateDate().toString(),mPrismURI,getDocument()); + attachAnnotation("prism:embargoDate",pStudy.getReleaseDate().toString(),mPrismURI,getDocument()); + copyCitationMetadata(pStudy.getCitation(),getDocument()); + + NexmlOTUConverter noc = new NexmlOTUConverter(getStudy(),getTaxonLabelHome(),getDocument()); + for ( TaxonLabelSet taxonLabelSet : pStudy.getTaxonLabelSets() ) { + noc.fromTreeBaseToXml(taxonLabelSet); + } + + NexmlMatrixConverter nmc = new NexmlMatrixConverter(getStudy(),getTaxonLabelHome(),getDocument()); + for (org.cipres.treebase.domain.matrix.Matrix matrix : pStudy.getMatrices() ) { + nmc.fromTreeBaseToXml(matrix); + } + + NexmlTreeBlockConverter ntc = new NexmlTreeBlockConverter(getStudy(),getTaxonLabelHome(),getDocument()); + for ( org.cipres.treebase.domain.tree.TreeBlock treeBlock : pStudy.getTreeBlocks() ) { + ntc.fromTreeBaseToXML(treeBlock); + } + return getDocument(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2010-02-10 02:05:01
|
Revision: 488 http://treebase.svn.sourceforge.net/treebase/?rev=488&view=rev Author: rvos Date: 2010-02-10 02:04:54 +0000 (Wed, 10 Feb 2010) Log Message: ----------- Fixed typo in prism property Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java 2010-02-09 20:51:58 UTC (rev 487) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java 2010-02-10 02:04:54 UTC (rev 488) @@ -95,7 +95,7 @@ * @param document */ private void copyCitationMetadata(Citation citation,Document document) { - attachAnnotation("dcterms.bibliographicCitation",citation.getAuthorsCitationStyleWithoutHtml(),mDCURI,document); + attachAnnotation("dcterms:bibliographicCitation",citation.getAuthorsCitationStyleWithoutHtml(),mDCURI,document); if ( null != citation.getTitle() ) { attachAnnotation("tb:title.study",citation.getTitle(),mTBTermsURI,document); } 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:04:45
|
Revision: 571 http://treebase.svn.sourceforge.net/treebase/?rev=571&view=rev Author: rvos Date: 2010-03-15 01:04:39 +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/NexmlDocumentConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java 2010-03-15 01:02:39 UTC (rev 570) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java 2010-03-15 01:04:39 UTC (rev 571) @@ -1,10 +1,11 @@ package org.cipres.treebase.domain.nexus.nexml; -import org.cipres.treebase.domain.admin.Person; +//import org.cipres.treebase.Constants; +//import org.cipres.treebase.domain.admin.Person; import org.cipres.treebase.domain.matrix.CharacterMatrix; import org.cipres.treebase.domain.nexus.NexusDataSet; -import org.cipres.treebase.domain.study.ArticleCitation; -import org.cipres.treebase.domain.study.Citation; +//import org.cipres.treebase.domain.study.ArticleCitation; +//import org.cipres.treebase.domain.study.Citation; import org.cipres.treebase.domain.study.Study; import org.cipres.treebase.domain.taxon.TaxonLabelHome; import org.cipres.treebase.domain.taxon.TaxonLabelSet; @@ -91,55 +92,11 @@ /** * - * @param citation - * @param document - */ - private void copyCitationMetadata(Citation citation,Document document) { - attachAnnotation("dcterms:bibliographicCitation",citation.getAuthorsCitationStyleWithoutHtml(),mDCURI,document); - if ( null != citation.getTitle() ) { - attachAnnotation("tb:title.study",citation.getTitle(),mTBTermsURI,document); - } - if ( null != citation.getPublishYear() ) { - attachAnnotation("prism:publicationDate",citation.getPublishYear().toString(),mPrismURI,document); - } - if ( null != citation.getDoi() ) { - attachAnnotation("prism:doi",citation.getDoi(),mPrismURI,document); - } - if ( null != citation.getPages() ) { - String[] pages = citation.getPages().split("\\-"); - if ( pages.length == 2 ) { - attachAnnotation("prism:startingPage",pages[0],mPrismURI,document); - attachAnnotation("prism:endingPage",pages[1],mPrismURI,document); - attachAnnotation("prism:pageRange",citation.getPages(),mPrismURI,document); - } - } - if ( null != citation.getKeywords() ) { - String[] keywords = citation.getKeywords().split(", "); - for ( int i = 0; i < keywords.length; i++ ) { - attachAnnotation("dcterms:subject",keywords[i],mDCURI,document); - } - } - if ( citation instanceof ArticleCitation ) { - ArticleCitation ac = (ArticleCitation)citation; - if ( null != ac.getJournal() ) { - attachAnnotation("prism:publicationName",ac.getJournal(),mPrismURI,document); - } - if ( null != ac.getVolume() ) { - attachAnnotation("prism:volume",ac.getVolume(),mPrismURI,document); - } - if ( null != ac.getIssue() ) { - attachAnnotation("prism:number",ac.getIssue(),mPrismURI,document); - } - } - } - - /** - * * @param pStudy * @return */ public Document fromTreeBaseToXml(Study pStudy) { - copyMetadata(pStudy); + attachTreeBaseID(getDocument(), pStudy,Study.class); NexmlOTUConverter noc = new NexmlOTUConverter(getStudy(),getTaxonLabelHome(),getDocument()); for ( TaxonLabelSet taxonLabelSet : pStudy.getTaxonLabelSets() ) { @@ -161,37 +118,4 @@ return getDocument(); } - private void copyMetadata(Study pStudy) { - attachTreeBaseID(getDocument(), pStudy,Study.class); - attachAnnotation("tb:identifier.study",pStudy.getId().toString(), mTBTermsURI, getDocument()); - attachAnnotation("tb:identifier.study.tb1",pStudy.getTB1StudyID(), mTBTermsURI, getDocument()); - if ( null != pStudy.getName() ) { - attachAnnotation("tb:title.study", pStudy.getName(), mTBTermsURI, getDocument()); - } - for ( Person person : pStudy.getAuthors() ) { - String personName = person.getFullNameCitationStyle(); - attachAnnotation("dcterms:contributor",personName,mDCURI,getDocument()); - } - if ( null != pStudy.getReleaseDate() ) { - attachAnnotation("prism:embargoDate",pStudy.getReleaseDate().toString(),mPrismURI,getDocument()); - } - if ( null != pStudy.getSubmission() ) { - if ( null != pStudy.getSubmission().getSubmitter() ) { - attachAnnotation( - "dcterms:creator", - pStudy.getSubmission().getSubmitter().getPerson().getFullNameCitationStyle(), - mDCURI, - getDocument() - ); - } - if ( null != pStudy.getSubmission().getCreateDate() ) { - attachAnnotation("prism:creationDate",pStudy.getSubmission().getCreateDate().toString(),mPrismURI,getDocument()); - } - } - if ( null != pStudy.getCitation() ) { - //attachAnnotation("dc:abstract",forXML(pStudy.getCitation().getAbstract()), mDCURI,getDocument()); - copyCitationMetadata(pStudy.getCitation(),getDocument()); - } - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-08-25 14:24:26
|
Revision: 942 http://treebase.svn.sourceforge.net/treebase/?rev=942&view=rev Author: rvos Date: 2011-08-25 14:24:16 +0000 (Thu, 25 Aug 2011) Log Message: ----------- Added skos:historyNote to keep track of which version of the converter we're using Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java Property Changed: ---------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java 2011-08-25 13:59:02 UTC (rev 941) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java 2011-08-25 14:24:16 UTC (rev 942) @@ -2,6 +2,7 @@ //import org.cipres.treebase.Constants; //import org.cipres.treebase.domain.admin.Person; +import org.cipres.treebase.Constants; import org.cipres.treebase.domain.matrix.CharacterMatrix; import org.cipres.treebase.domain.nexus.NexusDataSet; //import org.cipres.treebase.domain.study.ArticleCitation; @@ -97,6 +98,7 @@ */ public Document fromTreeBaseToXml(Study pStudy) { attachTreeBaseID(getDocument(), pStudy,Study.class); + getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlDocumentConverter $Rev$"); NexmlOTUConverter noc = new NexmlOTUConverter(getStudy(),getTaxonLabelHome(),getDocument()); for ( TaxonLabelSet taxonLabelSet : pStudy.getTaxonLabelSets() ) { Property changes on: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java ___________________________________________________________________ Added: svn:keywords + Rev This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |