You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
(1) |
Apr
(14) |
May
(36) |
Jun
(148) |
Jul
(33) |
Aug
(2) |
Sep
(17) |
Oct
(42) |
Nov
(137) |
Dec
(88) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(89) |
Feb
(80) |
Mar
(217) |
Apr
(76) |
May
(5) |
Jun
(39) |
Jul
(35) |
Aug
(4) |
Sep
(7) |
Oct
(14) |
Nov
(12) |
Dec
(9) |
2011 |
Jan
(6) |
Feb
(4) |
Mar
(11) |
Apr
(55) |
May
(90) |
Jun
(39) |
Jul
(15) |
Aug
(15) |
Sep
(23) |
Oct
(12) |
Nov
(17) |
Dec
(20) |
2012 |
Jan
(22) |
Feb
(63) |
Mar
|
Apr
(1) |
May
(6) |
Jun
(3) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(3) |
Feb
(6) |
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: SourceForge.net <no...@so...> - 2011-11-16 19:26:17
|
Bugs item #3438960, was opened at 2011-11-16 11:26 Message generated for change (Tracker Item Submitted) made by sfrgpiel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126676&aid=3438960&group_id=248804 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Priority: 9 Private: No Submitted By: William Piel (sfrgpiel) Assigned to: hshyket (hshyket) Summary: Exception on searching on taxon ID or study ID = null Initial Comment: Any number, including in the form Tx12345, will barf an exception for taxon ID. Also, if an URL to a study object is missing a study ID, there is also an exception. e.g.: http://www.treebase.org/treebase-web/search/study/summary.html?id= ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126676&aid=3438960&group_id=248804 |
From: <hs...@us...> - 2011-11-16 17:08:11
|
Revision: 981 http://treebase.svn.sourceforge.net/treebase/?rev=981&view=rev Author: hshyket Date: 2011-11-16 17:08:00 +0000 (Wed, 16 Nov 2011) Log Message: ----------- Fixing the way old browser error message was displayed (no longer a popup). Also modified so that future versions of IE are not given an incompatibility message (above IE7). Modified Paths: -------------- trunk/treebase-web/src/main/webapp/common/meta.jsp trunk/treebase-web/src/main/webapp/decorators/adminTemplate.jsp trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp trunk/treebase-web/src/main/webapp/decorators/defaultTemplate.jsp trunk/treebase-web/src/main/webapp/decorators/mainTemplate.jsp trunk/treebase-web/src/main/webapp/decorators/testTemplate.jsp trunk/treebase-web/src/main/webapp/styles/styles.css Added Paths: ----------- trunk/treebase-web/src/main/webapp/common/updateBrowser.jsp Modified: trunk/treebase-web/src/main/webapp/common/meta.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/common/meta.jsp 2011-11-02 17:48:18 UTC (rev 980) +++ trunk/treebase-web/src/main/webapp/common/meta.jsp 2011-11-16 17:08:00 UTC (rev 981) @@ -11,21 +11,23 @@ <meta name="msvalidate.01" content="D931446190993D0D2D719F2978AC44EB" /> <link rel="icon" href="<c:url value="/images/favicon.ico"/>"/> <% + String browsername = ""; + String browserversion = ""; String ua = request.getHeader( "User-Agent" ); boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 ); boolean isOldMSIE = false; if ( isMSIE ) { - isOldMSIE = ua.indexOf("MSIE 8.0") == -1; + //isOldMSIE = ua.indexOf("MSIE 8.0") == -1; + String subsString = ua.substring( ua.indexOf("MSIE")); + String Info[] = (subsString.split(";")[0]).split(" "); + browsername = Info[0]; + browserversion = Info[1]; + float version = Float.parseFloat(browserversion); + if (version < 8) { + isOldMSIE = true; + + } } %> -<!-- <%= ua %> --> -<% if( isOldMSIE ){ %> - <script type="text/javascript"> - alert("Please upgrade your browser!\n\n"+ - "The TreeBASE team simply do not have the resources to support\n"+ - "old versions of Internet Explorer. There are many good, free\n"+ - "browsers available (IE8, FireFox, Safari, Chrome, Opera, etc.),\n"+ - "please use one of those instead."); - </script> -<% } %> \ No newline at end of file +<!-- <%= ua %> --> \ No newline at end of file Added: trunk/treebase-web/src/main/webapp/common/updateBrowser.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/common/updateBrowser.jsp (rev 0) +++ trunk/treebase-web/src/main/webapp/common/updateBrowser.jsp 2011-11-16 17:08:00 UTC (rev 981) @@ -0,0 +1,10 @@ +<div id="browserupdate"> +<p>Your browser is not supported by TreeBASE. Please download one of the browsers listed below:</p> +<p><a href="http://windows.microsoft.com/en-US/internet-explorer/downloads/ie" target="_blank">Internet Explorer</a> +<a href="http://www.mozilla.org/en-US/firefox/new/" target="_blank">Firefox</a> +<a href="http://www.google.com/chrome" target="_blank">Chrome</a> +<a href="http://www.apple.com/safari/download/" target="_blank">Safari</a> +<a href="http://www.opera.com/download/" target="_blank">Opera</a> +</p> +<br /> +</div> Modified: trunk/treebase-web/src/main/webapp/decorators/adminTemplate.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/decorators/adminTemplate.jsp 2011-11-02 17:48:18 UTC (rev 980) +++ trunk/treebase-web/src/main/webapp/decorators/adminTemplate.jsp 2011-11-16 17:08:00 UTC (rev 981) @@ -26,7 +26,9 @@ </head> <body <decorator:getProperty property="body.id" writeEntireProperty="true"/>> - +<% if( isOldMSIE ){ %> +<c:import url="/common/updateBrowser.jsp"/> +<% } %> <!-- BEGIN WRAP --> <div id="wrap"> <!-- BEGIN HEADER --> Modified: trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp 2011-11-02 17:48:18 UTC (rev 980) +++ trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp 2011-11-16 17:08:00 UTC (rev 981) @@ -117,7 +117,9 @@ </head> <body <decorator:getProperty property="body.id" writeEntireProperty="true"/> onload="TreeBASE.initialize()"> - +<% if( isOldMSIE ){ %> +<c:import url="/common/updateBrowser.jsp"/> +<% } %> <!-- BEGIN WRAP --> <div id="wrap"> <!-- BEGIN HEADER --> Modified: trunk/treebase-web/src/main/webapp/decorators/defaultTemplate.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/decorators/defaultTemplate.jsp 2011-11-02 17:48:18 UTC (rev 980) +++ trunk/treebase-web/src/main/webapp/decorators/defaultTemplate.jsp 2011-11-16 17:08:00 UTC (rev 981) @@ -65,7 +65,9 @@ </head> <body <decorator:getProperty property="body.id" writeEntireProperty="true"/> onload="TreeBASE.initialize()"> - +<% if( isOldMSIE ){ %> +<c:import url="/common/updateBrowser.jsp"/> +<% } %> <!-- BEGIN WRAP --> <div id="wrap"> <!-- BEGIN HEADER --> Modified: trunk/treebase-web/src/main/webapp/decorators/mainTemplate.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/decorators/mainTemplate.jsp 2011-11-02 17:48:18 UTC (rev 980) +++ trunk/treebase-web/src/main/webapp/decorators/mainTemplate.jsp 2011-11-16 17:08:00 UTC (rev 981) @@ -16,7 +16,9 @@ </head> <body id="info" onload="TreeBASE.initialize()"> - +<% if( isOldMSIE ){ %> +<c:import url="/common/updateBrowser.jsp"/> +<% } %> <!-- BEGIN WRAP --> <div id="wrap"> <!-- BEGIN HEADER --> Modified: trunk/treebase-web/src/main/webapp/decorators/testTemplate.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/decorators/testTemplate.jsp 2011-11-02 17:48:18 UTC (rev 980) +++ trunk/treebase-web/src/main/webapp/decorators/testTemplate.jsp 2011-11-16 17:08:00 UTC (rev 981) @@ -16,7 +16,9 @@ </head> <body id="info" onload="TreeBASE.initialize()"> - +<% if( isOldMSIE ){ %> +<c:import url="/common/updateBrowser.jsp"/> +<% } %> <!-- BEGIN WRAP --> <div id="wrap"> <!-- BEGIN HEADER --> Modified: trunk/treebase-web/src/main/webapp/styles/styles.css =================================================================== --- trunk/treebase-web/src/main/webapp/styles/styles.css 2011-11-02 17:48:18 UTC (rev 980) +++ trunk/treebase-web/src/main/webapp/styles/styles.css 2011-11-16 17:08:00 UTC (rev 981) @@ -64,6 +64,19 @@ border-top: 1px solid #3d649f } +#browserupdate { + background-color: #FFFFC1; + text-align: center; + margin-bottom: -18px; +} + +#browserupdate a:link, #browserupdate a:visited, #browserupdate a:hover, #browserupdate a:active { + color: #003366; + text-decoration: none; + font-weight: bold; + margin-right: 20px; +} + /* Page Structure/Layout *******************************************************************************************/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2011-11-15 21:48:32
|
Bugs item #3438514, was opened at 2011-11-15 13:48 Message generated for change (Tracker Item Submitted) made by sfrgpiel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126676&aid=3438514&group_id=248804 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: ui Group: None Status: Open Priority: 7 Private: No Submitted By: William Piel (sfrgpiel) Assigned to: hshyket (hshyket) Summary: MSIE9 not recognized as more advanced than MSIE8 Initial Comment: Mark Miller reported the following behavior (below). At least the proper recognition of MSIE9 should be fixed. For suppressing a constant reminder, we can consider fixing this if easy to fix -- but so long as it is properly recognizing the browser, constantly annoying users doesn't matter so much given that the incompatible browsers won't work. This warning message is more important in the submission system, where submissions may be impossible to complete without a fully-compatible browser. bp Hi folks, I browsed to TreeBaseII to see how it was doing. It looks great. But there is a very annoying "feature" Every time I hit a link, it throws a message scolding me for Having an old outdated browser. In my opinion, making this happen on every click will drive people away, One warning on arrival would suffice. Second, and more importantly, I am using MSIE 9, not MSIE 8, and therefore A completely up to date browser. The code should be changed to Not view MSIE 9 as an out of date browser. Best, Mark ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126676&aid=3438514&group_id=248804 |
From: <hs...@us...> - 2011-11-02 17:48:24
|
Revision: 980 http://treebase.svn.sourceforge.net/treebase/?rev=980&view=rev Author: hshyket Date: 2011-11-02 17:48:18 +0000 (Wed, 02 Nov 2011) Log Message: ----------- Adding TreeBase title of number of trees for all tree downloads Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java 2011-11-02 15:15:55 UTC (rev 979) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java 2011-11-02 17:48:18 UTC (rev 980) @@ -275,7 +275,9 @@ //title = "List of Uploaded Tree Block"; } pBuilder.append("BEGIN TREES;\n"); - pBuilder.append(" TITLE " + StringUtil.tokenize(getTitle()) + ";\n"); + //pBuilder.append(" TITLE " + StringUtil.tokenize(getTitle()) + ";\n"); + + pBuilder.append(" TITLE " + StringUtil.tokenize(Integer.toString(getTreeList().size())) + "Trees;\n"); pBuilder.append(" LINK TAXA = " + StringUtil.tokenize(tlSet.getTitle().replaceAll("Input|Output", "")) + ";\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hs...@us...> - 2011-11-02 15:16:01
|
Revision: 979 http://treebase.svn.sourceforge.net/treebase/?rev=979&view=rev Author: hshyket Date: 2011-11-02 15:15:55 +0000 (Wed, 02 Nov 2011) Log Message: ----------- Changing name of Tree in nexus file (for all tree download) to Tree ID instead of Tree Label Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java 2011-11-01 16:29:00 UTC (rev 978) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java 2011-11-02 15:15:55 UTC (rev 979) @@ -280,7 +280,7 @@ for (PhyloTree atree : getTreeList()) { - pBuilder.append(" TREE " + StringUtil.tokenize(atree.getLabel()) + " = "); + pBuilder.append(" TREE Tr" + atree.getId() + " = "); if (atree.getRootedTree() != null) { if (atree.getRootedTree().booleanValue()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hs...@us...> - 2011-11-01 16:29:06
|
Revision: 978 http://treebase.svn.sourceforge.net/treebase/?rev=978&view=rev Author: hshyket Date: 2011-11-01 16:29:00 +0000 (Tue, 01 Nov 2011) Log Message: ----------- Removing translation table from trees Nexus file Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java 2011-10-29 13:29:35 UTC (rev 977) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/TreeBlock.java 2011-11-01 16:29:00 UTC (rev 978) @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -260,7 +261,52 @@ // } } + + @Transient + public void generateAFileDynamicallyNoTranslate(StringBuilder pBuilder) { + TaxonLabelSet tlSet = getTaxonLabelSet(); + List<TaxonLabel> txnlbllist = tlSet.getTaxonLabelsReadOnly(); + int numoftxnlbls = getTaxonNumber(); + + String title = getTitle(); + if (TreebaseUtil.isEmpty(title)) { + //use the default title: + //title = "List of Uploaded Tree Block"; + } + pBuilder.append("BEGIN TREES;\n"); + pBuilder.append(" TITLE " + StringUtil.tokenize(getTitle()) + ";\n"); + pBuilder.append(" LINK TAXA = " + StringUtil.tokenize(tlSet.getTitle().replaceAll("Input|Output", "")) + ";\n"); + + + for (PhyloTree atree : getTreeList()) { + pBuilder.append(" TREE " + StringUtil.tokenize(atree.getLabel()) + " = "); + + if (atree.getRootedTree() != null) { + if (atree.getRootedTree().booleanValue()) { + pBuilder.append("[&R] "); + } else { + pBuilder.append("[&U] "); + } + + } + String newick = atree.getNewickString(); + for (int z = 0; z < numoftxnlbls; z++) { + newick.concat(StringUtil.tokenize(txnlbllist.get(z).getTaxonLabel())); + } + // out.append(atree.getNewickString()); + pBuilder.append(newick); + pBuilder.append("\n"); + } + pBuilder.append("\n\n\nEND;\n"); + + // File did not exist and was created + // } else { + // File already exists + // } + + } + @Transient public String getTaxonLabelSetTitle() { return getTaxonLabelSet().getTitle(); Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java 2011-10-29 13:29:35 UTC (rev 977) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java 2011-11-01 16:29:00 UTC (rev 978) @@ -190,11 +190,14 @@ Set<PhyloTree> trees = treeResults.getResults(); TreeBlock treeBlock = new TreeBlock(); TaxonLabelSet taxonLabelSet = new TaxonLabelSet(); + List<String> taxonLabels = new ArrayList<String>(); + for (PhyloTree pTree : trees) { for (TaxonLabel pTaxLabel : pTree.getTreeBlock().getTaxonLabelList()) { - if (! taxonLabelSet.getTaxonLabelsReadOnly().contains(pTaxLabel)) { - taxonLabelSet.addPhyloTaxonLabel(pTaxLabel); + if (! taxonLabels.contains(pTaxLabel.getTaxonLabel())) { + taxonLabelSet.addPhyloTaxonLabel(pTaxLabel); + taxonLabels.add(pTaxLabel.getTaxonLabel()); } } treeBlock.addPhyloTree(pTree); @@ -208,7 +211,7 @@ taxonLabelSet.buildNexusBlockTaxa(builder, true, false); - treeBlock.generateAFileDynamically(builder); + treeBlock.generateAFileDynamicallyNoTranslate(builder); fileName += ".nex"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-10-29 13:29:42
|
Revision: 977 http://treebase.svn.sourceforge.net/treebase/?rev=977&view=rev Author: rvos Date: 2011-10-29 13:29:35 +0000 (Sat, 29 Oct 2011) Log Message: ----------- Changed meta tag to lower case for XHTML compliance Modified Paths: -------------- trunk/treebase-web/src/main/webapp/common/meta.jsp Modified: trunk/treebase-web/src/main/webapp/common/meta.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/common/meta.jsp 2011-10-28 15:29:36 UTC (rev 976) +++ trunk/treebase-web/src/main/webapp/common/meta.jsp 2011-10-29 13:29:35 UTC (rev 977) @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <meta name="author" content="Rutger A. Vos (rut...@gm...)"/> <meta name="google-site-verification" content="9Lr7BwyD6VMDIk5dENnSt_2YsUdpq_aEhnee0mMTxrw" /> -<META name="y_key" content="8c736195266b5ebb" /> +<meta name="y_key" content="8c736195266b5ebb" /> <meta name="msvalidate.01" content="D931446190993D0D2D719F2978AC44EB" /> <link rel="icon" href="<c:url value="/images/favicon.ico"/>"/> <% This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hs...@us...> - 2011-10-28 15:29:42
|
Revision: 976 http://treebase.svn.sourceforge.net/treebase/?rev=976&view=rev Author: hshyket Date: 2011-10-28 15:29:36 +0000 (Fri, 28 Oct 2011) Log Message: ----------- Modified Paths: -------------- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java 2011-10-28 14:08:26 UTC (rev 975) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java 2011-10-28 15:29:36 UTC (rev 976) @@ -214,9 +214,13 @@ String downloadDirName = request.getSession().getServletContext().getRealPath( TreebaseUtil.FILESEP + "NexusFileDownload") - + TreebaseUtil.FILESEP + request.getRemoteUser(); + + TreebaseUtil.FILESEP + + "TreeDownload"; + File directory = new File(downloadDirName); + directory.mkdir(); + File file = new File(downloadDirName + TreebaseUtil.FILESEP + fileName); FileWriter out = new FileWriter(file); out.write(builder.toString()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hs...@us...> - 2011-10-28 14:08:37
|
Revision: 975 http://treebase.svn.sourceforge.net/treebase/?rev=975&view=rev Author: hshyket Date: 2011-10-28 14:08:26 +0000 (Fri, 28 Oct 2011) Log Message: ----------- Updating functionality to allow download of all trees through the tree search page and also via the API query calls for Nexus and NeXML Modified Paths: -------------- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TaxonSearchController.java trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/searchResultsListControls.jsp trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java 2011-10-27 16:58:16 UTC (rev 974) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java 2011-10-28 14:08:26 UTC (rev 975) @@ -3,6 +3,8 @@ package org.cipres.treebase.web.controllers; +import java.io.File; +import java.io.FileWriter; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -12,6 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import javax.servlet.ServletException; @@ -23,16 +26,31 @@ import org.cipres.treebase.TreebaseUtil; import org.cipres.treebase.TreebaseIDString.MalformedTreebaseIDString; import org.cipres.treebase.domain.TBPersistable; +import org.cipres.treebase.domain.nexus.NexusDataSet; +import org.cipres.treebase.domain.nexus.NexusService; +import org.cipres.treebase.domain.nexus.nexml.NexmlDocumentWriter; import org.cipres.treebase.domain.search.SearchResults; import org.cipres.treebase.domain.search.SearchResultsFrozen; import org.cipres.treebase.domain.search.SearchResultsType; import org.cipres.treebase.domain.search.SearchService; import org.cipres.treebase.domain.search.StudySearchResults; +import org.cipres.treebase.domain.search.TaxonSearchResults; +import org.cipres.treebase.domain.search.TreeSearchResults; +import org.cipres.treebase.domain.taxon.Taxon; +import org.cipres.treebase.domain.taxon.TaxonLabel; +import org.cipres.treebase.domain.taxon.TaxonLabelHome; import org.cipres.treebase.domain.taxon.TaxonLabelService; +import org.cipres.treebase.domain.taxon.TaxonLabelSet; +import org.cipres.treebase.domain.taxon.TaxonVariant; +import org.cipres.treebase.domain.tree.PhyloTree; +import org.cipres.treebase.domain.tree.TreeBlock; import org.cipres.treebase.service.AbstractService; import org.cipres.treebase.web.Constants; import org.cipres.treebase.web.model.SearchCommand; import org.cipres.treebase.web.util.SearchMessageSetter; +import org.cipres.treebase.web.util.WebUtil; +import org.nexml.model.Document; +import org.nexml.model.DocumentFactory; import org.springframework.validation.BindException; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.view.RedirectView; @@ -55,6 +73,12 @@ protected String formView; private TaxonLabelService mTaxonLabelService; + protected static final int FORMAT_NEXUS = 1; + protected static final int FORMAT_NEXML = 2; + private static String mNexmlContentType = "application/xml; charset=UTF-8"; + protected String mFormatParameter = "format"; + private TaxonLabelHome mTaxonLabelHome; + protected abstract ModelAndView handleQueryRequest(HttpServletRequest request,HttpServletResponse response,BindException errors,String query) throws CQLParseException, IOException, InstantiationException, ParseException; /** @@ -122,7 +146,11 @@ onSubmitDiscardResults(request, response, command, errors); } else if ( action.equals("refineSearch") ){ onSubmitRefineSearch(request,response,command,errors); - } else { + } else if ( action.equals("downloadAllTrees") ) { + downloadAllTrees(request, response, errors); + return null; + } + else { throw new Error("Unknown action '" + action + "'"); } } else { @@ -140,6 +168,116 @@ return selectResultsView(request); } + protected void downloadAllTrees(HttpServletRequest request, + HttpServletResponse response, BindException errors) { + // TODO Auto-generated method stub + + try { + java.util.Date date= new java.util.Date(); + + TreeSearchResults treeResults = searchResults(request).convertToTrees(); + + String fileName = "TB" + date.getTime(); + StringBuilder builder = new StringBuilder(); + + if ( getFormat(request) == FORMAT_NEXML ) { + Document doc = DocumentFactory.safeCreateDocument(); + NexmlDocumentWriter ndw = new NexmlDocumentWriter(null,getTaxonLabelHome(), doc); + ndw.fromTreeBaseToXml(treeResults); + builder.append(doc.getXmlString()); + } + else { + Set<PhyloTree> trees = treeResults.getResults(); + TreeBlock treeBlock = new TreeBlock(); + TaxonLabelSet taxonLabelSet = new TaxonLabelSet(); + + for (PhyloTree pTree : trees) { + for (TaxonLabel pTaxLabel : pTree.getTreeBlock().getTaxonLabelList()) { + if (! taxonLabelSet.getTaxonLabelsReadOnly().contains(pTaxLabel)) { + taxonLabelSet.addPhyloTaxonLabel(pTaxLabel); + } + } + treeBlock.addPhyloTree(pTree); + } + + treeBlock.setTaxonLabelSet(taxonLabelSet); + taxonLabelSet.setTitle("TB" + date.getTime()); + + + builder.append("#NEXUS\n\n"); + + taxonLabelSet.buildNexusBlockTaxa(builder, true, false); + + treeBlock.generateAFileDynamically(builder); + fileName += ".nex"; + } + + String downloadDirName = request.getSession().getServletContext().getRealPath( + TreebaseUtil.FILESEP + "NexusFileDownload") + + TreebaseUtil.FILESEP + request.getRemoteUser(); + + + File file = new File(downloadDirName + TreebaseUtil.FILESEP + fileName); + FileWriter out = new FileWriter(file); + out.write(builder.toString()); + out.close(); + + if ( getFormat(request) == FORMAT_NEXML ) { + WebUtil.downloadFile(response, downloadDirName, fileName, mNexmlContentType); + } + else { + WebUtil.downloadFile(response, downloadDirName, fileName); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + /** + * + * @param request + * @return + */ + protected int getFormat (HttpServletRequest request) { + String requestedFormat = request.getParameter(mFormatParameter); + if ( null != requestedFormat ) { + if ( requestedFormat.equalsIgnoreCase("nexml") ) { + return FORMAT_NEXML; + } + else { + return FORMAT_NEXUS; // default + } + } + else { + return FORMAT_NEXUS; // default + } + } + + protected Properties getDefaultProperties(HttpServletRequest request) { + Properties properties = new Properties(); + + properties.setProperty("nexml.uri.base", TreebaseUtil.getPurlBase()); + return properties; + } + + /** + * + * @return + */ + public TaxonLabelHome getTaxonLabelHome() { + return mTaxonLabelHome; + } + + /** + * + * @param nexmlService + */ + public void setTaxonLabelHome(TaxonLabelHome taxonLabelHome) { + mTaxonLabelHome = taxonLabelHome; + } + protected ModelAndView searchResultsAsRDF (SearchResults<?> searchResults,HttpServletRequest request,CQLNode root, String schema, String original) throws UnsupportedEncodingException { //${baseURL} //${phyloWSPath} Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TaxonSearchController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TaxonSearchController.java 2011-10-27 16:58:16 UTC (rev 974) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TaxonSearchController.java 2011-10-28 14:08:26 UTC (rev 975) @@ -409,7 +409,10 @@ Set<Taxon> queryResults = doCQLQuery(root, new HashSet<Taxon>(),request); TaxonSearchResults tsr = new TaxonSearchResults(queryResults); saveSearchResults(request, tsr); - if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) { + if ( TreebaseUtil.isEmpty(request.getParameter("format")) || + (! request.getParameter("format").equals("rss1") && + ! request.getParameter("format").equals("nexus") && + ! request.getParameter("format").equals("nexml")) ) { return samePage(request); } else { @@ -428,7 +431,16 @@ } } this.saveSearchResults(request, res); - return this.searchResultsAsRDF(res, request, root,schema,"taxon"); + + if (schema.equals("tree") && + ( request.getParameter("format").equals("nexus") || + request.getParameter("format").equals("nexml") )) { + super.downloadAllTrees(request, response, errors); + return null; + } + else { + return this.searchResultsAsRDF(res, request, root,schema,"taxon"); + } } } Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/searchResultsListControls.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/searchResultsListControls.jsp 2011-10-27 16:58:16 UTC (rev 974) +++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/searchResultsListControls.jsp 2011-10-28 14:08:26 UTC (rev 975) @@ -24,5 +24,8 @@ <input style="align: right;" type="submit" id="discardResults" value="Discard All Results" onclick="confirmDiscard()"/> <a href="#" class="openHelp" onclick="openHelp('s+res+discard-these-results+btn')"><img class="iconButton" src="<fmt:message key="icons.help"/>" /></a> - + <c:if test="${resultSet.resultType == 'TREE'}"> + <input style="align: right;" type="submit" id="downloadAllTrees" value="Download All Trees" onclick="doAction('downloadAllTrees')"/> + <a href="#" class="openHelp" onclick="openHelp('s+res+download-all-treess+btn')"><img class="iconButton" src="<fmt:message key="icons.help"/>" /></a> + </c:if> </c:if> Modified: trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml 2011-10-27 16:58:16 UTC (rev 974) +++ trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml 2011-10-28 14:08:26 UTC (rev 975) @@ -749,7 +749,8 @@ <property name="commandName"><value>search</value></property> <property name="commandClass"><value>org.cipres.treebase.web.model.SearchCommand</value></property> <property name="taxonLabelService"><ref bean="taxonLabelService"></ref></property> - <property name="searchService"><ref bean="searchService"></ref></property> + <property name="searchService"><ref bean="searchService"></ref></property> + <property name="taxonLabelHome"><ref bean="taxonLabelHome"></ref></property> </bean> <!-- bean id="mainSearchController" parent="searchController" class="org.cipres.treebase.web.controllers.MainSearchController"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-10-27 16:58:23
|
Revision: 974 http://treebase.svn.sourceforge.net/treebase/?rev=974&view=rev Author: rvos Date: 2011-10-27 16:58:16 +0000 (Thu, 27 Oct 2011) Log Message: ----------- So far, the NeXML converters were working on the assumption that a single study/nexusdataset would be converted to NeXML. It turns out there are use cases where a search result set needs to be converted. This means that we also want to be able to generate NeXML documents that don't have all the annotations that go with serializing a single study (e.g. its ID, authors, title, etc.), but rather a place holder document into which search results (e.g. entire studies, sets of taxa, matrices, trees) can be added and jointly serialized. This commit includes some refactorings in the Nexml*Writer classes and a JUnit test class that demonstrates this new behavior. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUWriter.java 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/NexmlTreeBlockWriter.java Added Paths: ----------- trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlSearchResultConverterTest.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java 2011-10-13 18:50:53 UTC (rev 973) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java 2011-10-27 16:58:16 UTC (rev 974) @@ -1,12 +1,28 @@ package org.cipres.treebase.domain.nexus.nexml; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import org.cipres.treebase.Constants; import org.cipres.treebase.domain.matrix.CharacterMatrix; +import org.cipres.treebase.domain.matrix.Matrix; import org.cipres.treebase.domain.nexus.NexusDataSet; +import org.cipres.treebase.domain.search.MatrixSearchResults; +import org.cipres.treebase.domain.search.SearchResults; +import org.cipres.treebase.domain.search.SearchResultsType; +import org.cipres.treebase.domain.search.StudySearchResults; +import org.cipres.treebase.domain.search.TaxonSearchResults; +import org.cipres.treebase.domain.search.TreeSearchResults; import org.cipres.treebase.domain.study.Study; +import org.cipres.treebase.domain.taxon.Taxon; +import org.cipres.treebase.domain.taxon.TaxonLabel; import org.cipres.treebase.domain.taxon.TaxonLabelHome; import org.cipres.treebase.domain.taxon.TaxonLabelSet; +import org.cipres.treebase.domain.tree.PhyloTree; import org.nexml.model.Document; +import org.nexml.model.OTUs; +import org.nexml.model.TreeBlock; public class NexmlDocumentWriter extends NexmlObjectConverter { @@ -41,7 +57,7 @@ NexmlMatrixWriter nmc = new NexmlMatrixWriter(getStudy(),getTaxonLabelHome(),getDocument()); for (org.cipres.treebase.domain.matrix.Matrix matrix : pNexusDataSet.getMatrices() ) { if ( matrix instanceof CharacterMatrix ) { - nmc.fromTreeBaseToXml((CharacterMatrix)matrix); + nmc.fromTreeBaseToXml((CharacterMatrix)matrix,null); } } @@ -71,7 +87,7 @@ NexmlMatrixWriter nmc = new NexmlMatrixWriter(getStudy(),getTaxonLabelHome(),getDocument()); for (org.cipres.treebase.domain.matrix.Matrix matrix : pStudy.getMatrices() ) { if ( matrix instanceof CharacterMatrix ) { - nmc.fromTreeBaseToXml((CharacterMatrix)matrix); + nmc.fromTreeBaseToXml((CharacterMatrix)matrix,null); } } @@ -82,5 +98,91 @@ return getDocument(); } + + public Document fromTreeBaseToXml(SearchResults<?> searchResults) { + getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using "+this.toString()+" $Rev$"); + SearchResultsType srt = searchResults.resultType(); + switch(srt) { + case STUDY : return fromTreeBaseToXml((StudySearchResults) searchResults); + case MATRIX : return fromTreeBaseToXml((MatrixSearchResults) searchResults); + case TREE : return fromTreeBaseToXml((TreeSearchResults) searchResults); + case TAXON : return fromTreeBaseToXml((TaxonSearchResults) searchResults); + case NONE : ; break; + } + return null; + } + + public Document fromTreeBaseToXml(StudySearchResults searchResults) { + NexmlOTUWriter noc = new NexmlOTUWriter(null,getTaxonLabelHome(),getDocument()); + NexmlMatrixWriter nmc = new NexmlMatrixWriter(null,getTaxonLabelHome(),getDocument()); + NexmlTreeBlockWriter ntc = new NexmlTreeBlockWriter(null,getTaxonLabelHome(),getDocument()); + for ( Study pStudy : searchResults.getResults() ) { + for ( TaxonLabelSet taxonLabelSet : pStudy.getTaxonLabelSets() ) { + noc.fromTreeBaseToXml(taxonLabelSet); + } + for (org.cipres.treebase.domain.matrix.Matrix matrix : pStudy.getMatrices() ) { + if ( matrix instanceof CharacterMatrix ) { + nmc.fromTreeBaseToXml((CharacterMatrix)matrix,null); + } + } + for ( org.cipres.treebase.domain.tree.TreeBlock treeBlock : pStudy.getTreeBlocks() ) { + ntc.fromTreeBaseToXML(treeBlock); + } + } + return getDocument(); + } + + public Document fromTreeBaseToXml(MatrixSearchResults searchResults) { + + // create a merged set of all taxon labels in all matrices + Set<TaxonLabel> mergedLabels = new HashSet<TaxonLabel>(); + for (Matrix m : searchResults.getResults()) { + List<TaxonLabel> labelsInTree = m.getAllTaxonLabels(); + mergedLabels.addAll(labelsInTree); + } + + // convert merged set of taxon labels to XML OTUs + NexmlOTUWriter noc = new NexmlOTUWriter(null,getTaxonLabelHome(),getDocument()); + OTUs xmlOTUs = noc.fromTreeBaseToXml(mergedLabels); + + // convert matrices to XML trees + NexmlMatrixWriter nmc = new NexmlMatrixWriter(null,getTaxonLabelHome(),getDocument()); + for (Matrix m : searchResults.getResults()) { + nmc.fromTreeBaseToXml((CharacterMatrix)m,xmlOTUs); + } + + return getDocument(); + } + public Document fromTreeBaseToXml(TreeSearchResults searchResults) { + + // create a merged set of all taxon labels in all trees + Set<TaxonLabel> mergedLabels = new HashSet<TaxonLabel>(); + for (PhyloTree t : searchResults.getResults()) { + Set<TaxonLabel> labelsInTree = t.getAllTaxonLabels(); + mergedLabels.addAll(labelsInTree); + } + + // convert merged set of taxon labels to XML OTUs + NexmlOTUWriter noc = new NexmlOTUWriter(null,getTaxonLabelHome(),getDocument()); + OTUs xmlOTUs = noc.fromTreeBaseToXml(mergedLabels); + + // convert phylotrees to XML trees + NexmlTreeBlockWriter ntc = new NexmlTreeBlockWriter(null,getTaxonLabelHome(),getDocument()); + TreeBlock xmlTreeBlock = getDocument().createTreeBlock(xmlOTUs); + for (PhyloTree t : searchResults.getResults()) { + ntc.fromTreeBaseToXml(t, xmlTreeBlock); + } + return getDocument(); + } + + public Document fromTreeBaseToXml(TaxonSearchResults searchResults) { + NexmlOTUWriter noc = new NexmlOTUWriter(null,getTaxonLabelHome(),getDocument()); + OTUs xmlOTUs = getDocument().createOTUs(); + for (Taxon t : searchResults.getResults()) { + noc.fromTreeBaseToXml(t, xmlOTUs); + } + return getDocument(); + } + } Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java 2011-10-13 18:50:53 UTC (rev 973) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java 2011-10-27 16:58:16 UTC (rev 974) @@ -57,8 +57,10 @@ * @param tbMatrix * @return an xml matrix with empty rows */ - private CategoricalMatrix fromTreeBaseToXml(StandardMatrix tbMatrix) { - OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); + private CategoricalMatrix fromTreeBaseToXml(StandardMatrix tbMatrix,OTUs xmlOTUs) { + if ( null == xmlOTUs ) { + xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); + } CategoricalMatrix xmlMatrix = getDocument().createCategoricalMatrix(xmlOTUs); setMatrixAttributes(xmlMatrix,tbMatrix); @@ -108,8 +110,10 @@ * @param tbMatrix * @return an xml matrix with empty rows */ - private MolecularMatrix fromTreeBaseToXml(DiscreteMatrix tbMatrix) { - OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); + private MolecularMatrix fromTreeBaseToXml(DiscreteMatrix tbMatrix,OTUs xmlOTUs) { + if ( null == xmlOTUs ) { + xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); + } String tbDataType = tbMatrix.getDataType().getDescription(); MolecularMatrix xmlMatrix = null; CharacterStateSet xmlStateSet = null; @@ -156,8 +160,10 @@ * @param tbMatrix * @return an xml matrix with empty rows */ - private org.nexml.model.ContinuousMatrix fromTreeBaseToXml(ContinuousMatrix tbMatrix) { - OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); + private org.nexml.model.ContinuousMatrix fromTreeBaseToXml(ContinuousMatrix tbMatrix,OTUs xmlOTUs) { + if ( null == xmlOTUs ) { + xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); + } org.nexml.model.ContinuousMatrix xmlMatrix = getDocument().createContinuousMatrix(xmlOTUs); setMatrixAttributes(xmlMatrix,tbMatrix); @@ -204,19 +210,19 @@ // public static final String MATRIX_DATATYPE_DISTANCE = "Distance"; // public static final String MATRIX_DATATYPE_MIXED = "Mixed"; @SuppressWarnings("unchecked") - public org.nexml.model.Matrix<?> fromTreeBaseToXml(CharacterMatrix tbMatrix) { + public org.nexml.model.Matrix<?> fromTreeBaseToXml(CharacterMatrix tbMatrix,OTUs xmlOTUs) { org.nexml.model.Matrix<?> xmlMatrix = null; if ( tbMatrix instanceof DiscreteMatrix ) { if ( tbMatrix.getDataType().getDescription().equals(MatrixDataType.MATRIX_DATATYPE_STANDARD) ) { - xmlMatrix = fromTreeBaseToXml((StandardMatrix) tbMatrix); + xmlMatrix = fromTreeBaseToXml((StandardMatrix) tbMatrix,xmlOTUs); } else { - xmlMatrix = fromTreeBaseToXml((DiscreteMatrix) tbMatrix); + xmlMatrix = fromTreeBaseToXml((DiscreteMatrix) tbMatrix,xmlOTUs); } populateXmlMatrix((org.nexml.model.Matrix<CharacterState>)xmlMatrix,(DiscreteMatrix)tbMatrix); } else if ( tbMatrix instanceof ContinuousMatrix ) { - xmlMatrix = fromTreeBaseToXml((ContinuousMatrix) tbMatrix); + xmlMatrix = fromTreeBaseToXml((ContinuousMatrix) tbMatrix,xmlOTUs); populateXmlMatrix((org.nexml.model.ContinuousMatrix)xmlMatrix,(ContinuousMatrix)tbMatrix); } Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUWriter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUWriter.java 2011-10-13 18:50:53 UTC (rev 973) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUWriter.java 2011-10-27 16:58:16 UTC (rev 974) @@ -1,7 +1,10 @@ package org.cipres.treebase.domain.nexus.nexml; +import java.util.Set; + import org.cipres.treebase.Constants; import org.cipres.treebase.domain.study.Study; +import org.cipres.treebase.domain.taxon.Taxon; import org.cipres.treebase.domain.taxon.TaxonLabel; import org.cipres.treebase.domain.taxon.TaxonLabelHome; import org.cipres.treebase.domain.taxon.TaxonLabelSet; @@ -42,11 +45,30 @@ /** * + * @param taxonLabelSet + * @return + */ + protected OTUs fromTreeBaseToXml(Set<TaxonLabel> taxonLabelSet) { + OTUs xmlOTUs = getDocument().createOTUs(); + + // attach base uri and skos:historyNote + xmlOTUs.setBaseURI(mTaxonBaseURI); + xmlOTUs.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using "+this.toString()+" $Rev$"); + + for ( TaxonLabel taxonLabel : taxonLabelSet ) { + fromTreeBaseToXml(taxonLabel,xmlOTUs); + } + return xmlOTUs; + + } + + /** + * * @param taxonLabel * @param xmlOTUs * @return */ - private OTU fromTreeBaseToXml(TaxonLabel taxonLabel,OTUs xmlOTUs) { + protected OTU fromTreeBaseToXml(TaxonLabel taxonLabel,OTUs xmlOTUs) { OTU xmlOTU = xmlOTUs.createOTU(); if ( null != taxonLabel.getTaxonLabel() ) { xmlOTU.setLabel(taxonLabel.getTaxonLabel()); @@ -54,5 +76,20 @@ attachTreeBaseID(xmlOTU,taxonLabel,TaxonLabel.class); return xmlOTU; } + + /** + * + * @param taxon + * @param xmlOTUs + * @return + */ + protected OTU fromTreeBaseToXml(Taxon taxon,OTUs xmlOTUs) { + OTU xmlOTU = xmlOTUs.createOTU(); + if ( null != taxon.getLabel() ) { + xmlOTU.setLabel(taxon.getLabel()); + } + attachTreeBaseID(xmlOTU,taxon,Taxon.class); + return xmlOTU; + } } 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-10-13 18:50:53 UTC (rev 973) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java 2011-10-27 16:58:16 UTC (rev 974) @@ -36,7 +36,9 @@ if ( null != baseURI ) { document.setBaseURI(URI.create(baseURI)); } - document.setId(study.getTreebaseIDString().toString()); + if ( null != study ) { + document.setId(study.getTreebaseIDString().toString()); + } setTaxonLabelHome(taxonLabelHome); setStudy(study); setDocument(document); Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlTreeBlockWriter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlTreeBlockWriter.java 2011-10-13 18:50:53 UTC (rev 973) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlTreeBlockWriter.java 2011-10-27 16:58:16 UTC (rev 974) @@ -33,7 +33,7 @@ * @param phyloTree * @return */ - private Tree<?> fromTreeBaseToXml(PhyloTree phyloTree,org.nexml.model.TreeBlock xmlTreeBlock) { + protected Tree<?> fromTreeBaseToXml(PhyloTree phyloTree,org.nexml.model.TreeBlock xmlTreeBlock) { Tree<FloatEdge> xmlTree = xmlTreeBlock.createFloatTree(); if ( null != phyloTree.getLabel() ) { xmlTree.setLabel(phyloTree.getLabel()); Added: trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlSearchResultConverterTest.java =================================================================== --- trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlSearchResultConverterTest.java (rev 0) +++ trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlSearchResultConverterTest.java 2011-10-27 16:58:16 UTC (rev 974) @@ -0,0 +1,133 @@ +package org.cipres.treebase.domain.nexus; + +import java.util.Collection; +import java.util.HashSet; + +import org.cipres.treebase.dao.AbstractDAOTest; +import org.cipres.treebase.domain.matrix.Matrix; +import org.cipres.treebase.domain.search.MatrixSearchResults; +import org.cipres.treebase.domain.search.StudySearchResults; +import org.cipres.treebase.domain.search.TaxonSearchResults; +import org.cipres.treebase.domain.search.TreeSearchResults; +import org.cipres.treebase.domain.study.Study; +import org.cipres.treebase.domain.study.StudyHome; +import org.cipres.treebase.domain.taxon.TaxonLabel; +import org.cipres.treebase.domain.taxon.TaxonLabelHome; +import org.cipres.treebase.domain.tree.PhyloTree; +import org.cipres.treebase.domain.nexus.nexml.NexmlDocumentWriter; +import org.nexml.model.Document; +import org.nexml.model.DocumentFactory; + +public class NexmlSearchResultConverterTest extends AbstractDAOTest { + + private TaxonLabelHome mTaxonLabelHome; + private StudyHome mStudyHome; + + private StudySearchResults ssr = null; + + private Collection<Study> studies = null; + private Collection<Matrix> matrices = null; + private Collection<PhyloTree> trees = null; + private Collection<TaxonLabel> taxa = null; + + @Override + protected void onSetUp() throws Exception { + super.onSetUp(); + + studies = getTestData(); + ssr = new StudySearchResults(studies); + + // populate set of matrices from test data + matrices = new HashSet<Matrix> (); + for (Study s : studies) { + matrices.addAll(s.getMatrices()); + } + + // populate set of trees from test data + trees = new HashSet<PhyloTree> (); + for (Study s : studies) { + trees.addAll(s.getTrees()); + } + + // populate set of taxa from test data + taxa = new HashSet<TaxonLabel>(); + for ( Study s : studies) { + taxa.addAll(s.getTaxonLabels()); + } + } + + public NexmlSearchResultConverterTest() { + super(); + } + + public void testTrivial() { + assertNotNull(getTaxonLabelHome()); + assertNotNull(getStudyHome()); + } + + public void testQuickCheck() { + assertFalse(studies.size() == 0); + assertFalse(matrices.size() == 0); + assertFalse(trees.size() == 0); + assertFalse(taxa.size() == 0); + } + + private Collection<Study> getTestData(String accessionNumber) { + Collection<Study> studies = new HashSet<Study>(); + studies.add(getStudyHome().findByAccessionNumber(accessionNumber)); + assertFalse(studies.size() == 0); + return studies; + } + + private Collection<Study> getTestData() { + return getTestData("S1787"); + } + + public void testStudySearchSerialization() { + Document doc = DocumentFactory.safeCreateDocument(); + NexmlDocumentWriter ndw = new NexmlDocumentWriter(null, mTaxonLabelHome, doc); + ndw.fromTreeBaseToXml(ssr); + assertNotNull(doc.getXmlString()); + } + + public void testTaxonSearchSerialization() { + Document doc = DocumentFactory.safeCreateDocument(); + NexmlDocumentWriter ndw = new NexmlDocumentWriter(null, mTaxonLabelHome, doc); + TaxonSearchResults tasr = ssr.convertToTaxa(); + ndw.fromTreeBaseToXml(tasr); + assertNotNull(doc.getXmlString()); + } + + public void testMatrixSearchSerialization() { + Document doc = DocumentFactory.safeCreateDocument(); + NexmlDocumentWriter ndw = new NexmlDocumentWriter(null, mTaxonLabelHome, doc); + MatrixSearchResults msr = ssr.convertToMatrices(); + ndw.fromTreeBaseToXml(msr); + assertNotNull(doc.getXmlString()); + } + + public void testTreeSearchSerialization() { + Document doc = DocumentFactory.safeCreateDocument(); + NexmlDocumentWriter ndw = new NexmlDocumentWriter(null, mTaxonLabelHome, doc); + TreeSearchResults tsr = ssr.convertToTrees(); + ndw.fromTreeBaseToXml(tsr); + assertNotNull(doc.getXmlString()); + } + + public TaxonLabelHome getTaxonLabelHome() { + return mTaxonLabelHome; + } + + public void setTaxonLabelHome(TaxonLabelHome pNewTaxonLabelHome) { + mTaxonLabelHome = pNewTaxonLabelHome; + } + + public StudyHome getStudyHome() { + return mStudyHome; + } + + public void setStudyHome(StudyHome studyHome) { + mStudyHome = studyHome; + } + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2011-10-26 19:38:44
|
Bugs item #3428863, was opened at 2011-10-26 14:38 Message generated for change (Tracker Item Submitted) made by rscherle You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126676&aid=3428863&group_id=248804 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: data Group: None Status: Open Priority: 5 Private: No Submitted By: Ryan Scherle (rscherle) Assigned to: William Piel (sfrgpiel) Summary: Storage of temporary content from Dryad Initial Comment: Files that Dryad sends to Treebase are being stored in /home/apache-tomcat-5.5.28/webapps/treebase-web/DryadFileUpload. Any time the Treebase webapp is redeployed, these files will be lost. It is quite likely that data would be deleted between the time Dryad sends the file to Treebase and the time the user actually imports the file into their account (some users may wait weeks). We have one account of a user problem which may have been caused by this storage technique (Christine Lambkin's submission of doi:10.5061/dryad.5j64k aka dryad_34861 aka TB2:S12050) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126676&aid=3428863&group_id=248804 |
From: <rv...@us...> - 2011-10-13 18:50:59
|
Revision: 973 http://treebase.svn.sourceforge.net/treebase/?rev=973&view=rev Author: rvos Date: 2011-10-13 18:50:53 +0000 (Thu, 13 Oct 2011) Log Message: ----------- Changed skos:historyNote message serialization Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUWriter.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlTreeBlockWriter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java 2011-10-13 18:40:28 UTC (rev 972) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java 2011-10-13 18:50:53 UTC (rev 973) @@ -61,7 +61,7 @@ */ public Document fromTreeBaseToXml(Study pStudy) { attachTreeBaseID(getDocument(), pStudy,Study.class); - getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlDocumentConverter $Rev$"); + getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using "+this.toString()+" $Rev$"); NexmlOTUWriter noc = new NexmlOTUWriter(getStudy(),getTaxonLabelHome(),getDocument()); for ( TaxonLabelSet taxonLabelSet : pStudy.getTaxonLabelSets() ) { Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUWriter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUWriter.java 2011-10-13 18:40:28 UTC (rev 972) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUWriter.java 2011-10-13 18:50:53 UTC (rev 973) @@ -30,7 +30,7 @@ // attach base uri and skos:historyNote xmlOTUs.setBaseURI(mTaxonBaseURI); - xmlOTUs.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlOTUConverter $Rev$"); + xmlOTUs.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using "+this.toString()+" $Rev$"); xmlOTUs.setLabel(taxonLabelSet.getTitle()); attachTreeBaseID(xmlOTUs,taxonLabelSet,TaxonLabelSet.class); Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlTreeBlockWriter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlTreeBlockWriter.java 2011-10-13 18:40:28 UTC (rev 972) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlTreeBlockWriter.java 2011-10-13 18:50:53 UTC (rev 973) @@ -54,7 +54,7 @@ org.nexml.model.TreeBlock xmlTreeBlock = getDocument().createTreeBlock(xmlOTUs); // attach base uri and skos:historyNote - xmlTreeBlock.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlTreeBlockConverter $Rev$"); + xmlTreeBlock.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using "+this.toString()+" $Rev$"); xmlTreeBlock.setBaseURI(mTreeBaseURI); if ( null != treeBlock.getTitle() ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-10-13 18:40:34
|
Revision: 972 http://treebase.svn.sourceforge.net/treebase/?rev=972&view=rev Author: rvos Date: 2011-10-13 18:40:28 +0000 (Thu, 13 Oct 2011) Log Message: ----------- Factored out methods to apply default attributes to matrices and characters Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java 2011-10-13 16:26:47 UTC (rev 971) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java 2011-10-13 18:40:28 UTC (rev 972) @@ -59,15 +59,13 @@ */ private CategoricalMatrix fromTreeBaseToXml(StandardMatrix tbMatrix) { OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); - CategoricalMatrix xmlMatrix = getDocument().createCategoricalMatrix(xmlOTUs); + CategoricalMatrix xmlMatrix = getDocument().createCategoricalMatrix(xmlOTUs); + setMatrixAttributes(xmlMatrix,tbMatrix); - // attach base uri and history note - xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); - xmlMatrix.setBaseURI(mMatrixBaseURI); - List<List<DiscreteCharState>> tbStateLabels = tbMatrix.getStateLabels(); List<MatrixColumn> tbColumns = tbMatrix.getColumnsReadOnly(); for ( int i = 0; i < tbColumns.size(); i++ ) { + MatrixColumn tbColumn = tbColumns.get(i); CharacterStateSet xmlStateSet = xmlMatrix.createCharacterStateSet(); for ( DiscreteCharState tbState : tbStateLabels.get(i) ) { CharacterState xmlState = xmlStateSet.createCharacterState(tbState.getSymbol().toString()); @@ -77,14 +75,31 @@ attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); } org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(xmlStateSet); - PhyloChar tbCharacter = tbColumns.get(i).getCharacter(); - if ( null != tbCharacter.getDescription() ) { - xmlCharacter.setLabel(tbCharacter.getDescription()); - } - attachTreeBaseID((Annotatable)xmlCharacter,tbColumns.get(i),MatrixColumn.class); + setCharacterAttributes(tbColumn, xmlCharacter); } return xmlMatrix; } + + private void setCharacterAttributes(MatrixColumn tbColumn,org.nexml.model.Character xmlCharacter) { + PhyloChar tbCharacter = tbColumn.getCharacter(); + if ( null != tbCharacter.getDescription() ) { + xmlCharacter.setLabel(tbCharacter.getLabel()); + } + attachTreeBaseID((Annotatable)xmlCharacter,tbColumn,MatrixColumn.class); + } + + private void setMatrixAttributes(org.nexml.model.Matrix<?> xmlMatrix,CharacterMatrix tbMatrix) { + xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using "+this.toString()+" $Rev$"); + xmlMatrix.setBaseURI(mMatrixBaseURI); + xmlMatrix.setLabel(tbMatrix.getLabel()); + + // attach matrix identifiers + attachTreeBaseID((Annotatable)xmlMatrix, tbMatrix,Matrix.class); + String tb1MatrixID = tbMatrix.getTB1MatrixID(); + if ( null != tb1MatrixID ) { + ((Annotatable)xmlMatrix).addAnnotationValue("tb:identifier.matrix.tb1", Constants.TBTermsURI, tb1MatrixID); + } + } /** * Creates and populates characters (i.e. columns) with their annotations, @@ -112,11 +127,8 @@ xmlMatrix = getDocument().createMolecularMatrix(xmlOTUs, MolecularMatrix.Protein); xmlStateSet = ((MolecularMatrix)xmlMatrix).getProteinCharacterStateSet(); } + setMatrixAttributes(xmlMatrix,tbMatrix); - // attach base uri and history note - xmlMatrix.setBaseURI(mMatrixBaseURI); - xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); - // lookup the equivalent state in tb and attach identifiers for(StateSet tbStateSet : tbMatrix.getStateSets() ) { for (DiscreteCharState tbState : tbStateSet.getStates() ) { @@ -132,7 +144,7 @@ // create columns and attach identifiers for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(xmlStateSet); - attachTreeBaseID((Annotatable)xmlCharacter,tbColumn,MatrixColumn.class); + setCharacterAttributes(tbColumn, xmlCharacter); } return xmlMatrix; } @@ -147,19 +159,11 @@ private org.nexml.model.ContinuousMatrix fromTreeBaseToXml(ContinuousMatrix tbMatrix) { OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); org.nexml.model.ContinuousMatrix xmlMatrix = getDocument().createContinuousMatrix(xmlOTUs); + setMatrixAttributes(xmlMatrix,tbMatrix); - // attach base uri and history note - xmlMatrix.setBaseURI(mMatrixBaseURI); - xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); - for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(); - PhyloChar tbCharacter = tbColumn.getCharacter(); - if ( null != tbCharacter.getDescription() ) { - xmlCharacter.setLabel(tbCharacter.getDescription()); - ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", Constants.DCTermsURI, tbCharacter.getDescription()); - } - attachTreeBaseID((Annotatable)xmlCharacter,tbColumn,MatrixColumn.class); + setCharacterAttributes(tbColumn, xmlCharacter); //coerce the tbMatrix into a character matrix to get its character sets CharacterMatrix tbCharacterMatrix = (CharacterMatrix)tbMatrix; @@ -215,12 +219,8 @@ xmlMatrix = fromTreeBaseToXml((ContinuousMatrix) tbMatrix); populateXmlMatrix((org.nexml.model.ContinuousMatrix)xmlMatrix,(ContinuousMatrix)tbMatrix); } - xmlMatrix.setLabel(tbMatrix.getTitle()); - attachTreeBaseID((Annotatable)xmlMatrix, tbMatrix,Matrix.class); - String tb1MatrixID = tbMatrix.getTB1MatrixID(); - if ( null != tb1MatrixID ) { - ((Annotatable)xmlMatrix).addAnnotationValue("tb:identifier.matrix.tb1", Constants.TBTermsURI, tb1MatrixID); - } + + // here we copy the character sets for all matrix types Set<CharSet> tbCharSets = tbMatrix.getCharSets(); for ( CharSet tbCharSet : tbCharSets ) { Collection<ColumnRange> tbColumnRanges = tbCharSet.getColumns(tbMatrix); @@ -234,6 +234,12 @@ // increment from beginning to end. This number is probably either null, for a // contiguous range, or perhaps 3 for codon positions int tbInc = 1; + + // need to do this to prevent nullpointerexceptions + if ( null != tbColumnRange.getRepeatInterval()) { + tbInc = tbColumnRange.getRepeatInterval(); + } + // create the equivalent nexml character set Subset nexSubset = xmlMatrix.createSubset(tbCharSet.getLabel()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rv...@us...> - 2011-10-13 16:26:56
|
Revision: 971 http://treebase.svn.sourceforge.net/treebase/?rev=971&view=rev Author: rvos Date: 2011-10-13 16:26:47 +0000 (Thu, 13 Oct 2011) Log Message: ----------- This refactoring splits NeXML reading and writing into separate classes and hides some more of the visibility of methods that only deal with the conversion of deeply nested objects. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/MatrixJDBC.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlConverter.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlObjectConverter.java trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceNexml.java trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceRDFa.java trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlAnalysisConverterTest.java trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlMatrixConverterTest.java trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlSerializationTest.java Added Paths: ----------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentReader.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixReader.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUReader.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUWriter.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlTreeBlockReader.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlTreeBlockWriter.java Removed Paths: ------------- 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/NexmlMatrixConverter.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUConverter.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlTreeBlockConverter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java 2011-10-05 17:43:48 UTC (rev 970) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java 2011-10-13 16:26:47 UTC (rev 971) @@ -20,7 +20,8 @@ import org.cipres.treebase.domain.matrix.ContinuousMatrix; import org.cipres.treebase.domain.matrix.ItemDefinition; import org.cipres.treebase.domain.nexus.mesquite.MesquiteMatrixConverter; -import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixConverter; +import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixWriter; +import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixReader; /** * Helper class for direct Matrix related SQL operations. Bypass the hibernate framework for high @@ -67,7 +68,7 @@ private org.nexml.model.ContinuousMatrix mNexmlCharacterData; - private NexmlMatrixConverter mNexmlMatrixConverter; + private NexmlMatrixWriter mNexmlMatrixConverter; // Note: currently we support only one set of item definitions for the entire matrix. // It is modeled in continuousMatrix.itemDefinitions. @@ -105,7 +106,7 @@ public ContinuousMatrixJDBC(ContinuousMatrix tbMatrix, org.nexml.model.ContinuousMatrix xmlMatrix, - NexmlMatrixConverter nexmlMatrixConverter) { + NexmlMatrixReader nexmlMatrixConverter) { this(); setCharacterMatrix(tbMatrix); setNexmlCharacterData(xmlMatrix); Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java 2011-10-05 17:43:48 UTC (rev 970) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java 2011-10-13 16:26:47 UTC (rev 971) @@ -23,7 +23,8 @@ import org.cipres.treebase.domain.matrix.DiscreteChar; import org.cipres.treebase.domain.matrix.DiscreteCharState; import org.cipres.treebase.domain.nexus.mesquite.MesquiteMatrixConverter; -import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixConverter; +import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixWriter; +import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixReader; /** * Helper class for direct Matrix related SQL operations. Bypass the hibernate framework for high @@ -107,7 +108,7 @@ public DiscreteMatrixJDBC(CharacterMatrix tbMatrix, org.nexml.model.CategoricalMatrix xmlMatrix, - NexmlMatrixConverter nexmlMatrixConverter) { + NexmlMatrixReader nexmlMatrixConverter) { this(); setCharacterMatrix(tbMatrix); setNexmlCharacterData(xmlMatrix); Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/MatrixJDBC.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/MatrixJDBC.java 2011-10-05 17:43:48 UTC (rev 970) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/MatrixJDBC.java 2011-10-13 16:26:47 UTC (rev 971) @@ -19,7 +19,8 @@ import org.cipres.treebase.domain.matrix.CharacterMatrix; import org.cipres.treebase.domain.matrix.ContinuousMatrix; import org.cipres.treebase.domain.nexus.mesquite.MesquiteMatrixConverter; -import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixConverter; +import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixWriter; +import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixReader; /** * Helper class for direct Matrix related SQL operations. Bypass the hibernate framework for high @@ -69,7 +70,7 @@ private List<MatrixColumnJDBC> mMatrixColumnJDBCs; private MesquiteMatrixConverter mMesqMatrixConverter; - private NexmlMatrixConverter mNexmlMatrixConverter; + private NexmlMatrixReader mNexmlMatrixConverter; private Matrix mNexmlCharacterData; /** @@ -295,7 +296,7 @@ } protected void setNexmlMatrixConverter( - NexmlMatrixConverter nexmlMatrixConverter) { + NexmlMatrixReader nexmlMatrixConverter) { mNexmlMatrixConverter = nexmlMatrixConverter; } Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlConverter.java 2011-10-05 17:43:48 UTC (rev 970) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlConverter.java 2011-10-13 16:26:47 UTC (rev 971) @@ -42,13 +42,13 @@ } // Taxa - NexmlOTUConverter noc = new NexmlOTUConverter(pStudy,getTaxonLabelHome(),document); + NexmlOTUReader noc = new NexmlOTUReader(pStudy,getTaxonLabelHome(),document); for ( OTUs xmlOTUs : document.getOTUsList() ) { pDataSet.addTaxonLabelSet(xmlOTUs, noc.fromXmlToTreeBase(xmlOTUs)); } // Matrices - NexmlMatrixConverter nmc = new NexmlMatrixConverter(pStudy,getTaxonLabelHome(),document); + NexmlMatrixReader nmc = new NexmlMatrixReader(pStudy,getTaxonLabelHome(),document); for ( org.nexml.model.Matrix<?> xmlMatrix : document.getMatrices() ) { Matrix tbMatrix = nmc.fromXmlToTreeBase(xmlMatrix); tbMatrix.setNexusFileName(pFile.getName()); @@ -56,7 +56,7 @@ } // Trees - NexmlTreeBlockConverter ntbc = new NexmlTreeBlockConverter(pStudy,getTaxonLabelHome(),document); + NexmlTreeBlockReader ntbc = new NexmlTreeBlockReader(pStudy,getTaxonLabelHome(),document); for ( org.nexml.model.TreeBlock xmlTreeBlock : document.getTreeBlockList() ) { TreeBlock tbTreeBlock = ntbc.fromXmlToTreeBase(xmlTreeBlock); for ( PhyloTree phyloTree : tbTreeBlock.getTreeList() ) { Deleted: 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-10-05 17:43:48 UTC (rev 970) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentConverter.java 2011-10-13 16:26:47 UTC (rev 971) @@ -1,123 +0,0 @@ -package org.cipres.treebase.domain.nexus.nexml; - -//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; -//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); - } - - public NexmlDocumentConverter(Study study, TaxonLabelHome taxonLabelHome, - Document document,String baseURI) { - super(study, taxonLabelHome, document,baseURI); - } - - /** - * - * @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() ) { - if ( matrix instanceof CharacterMatrix ) { - nmc.fromTreeBaseToXml((CharacterMatrix)matrix); - } - } - - NexmlTreeBlockConverter ntc = new NexmlTreeBlockConverter(getStudy(),getTaxonLabelHome(),getDocument()); - for ( org.cipres.treebase.domain.tree.TreeBlock treeBlock : pNexusDataSet.getTreeBlocks() ) { - ntc.fromTreeBaseToXML(treeBlock); - } - - return getDocument(); - - } - - /** - * - * @param pStudy - * @return - */ - 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() ) { - noc.fromTreeBaseToXml(taxonLabelSet); - } - - NexmlMatrixConverter nmc = new NexmlMatrixConverter(getStudy(),getTaxonLabelHome(),getDocument()); - for (org.cipres.treebase.domain.matrix.Matrix matrix : pStudy.getMatrices() ) { - if ( matrix instanceof CharacterMatrix ) { - nmc.fromTreeBaseToXml((CharacterMatrix)matrix); - } - } - - NexmlTreeBlockConverter ntc = new NexmlTreeBlockConverter(getStudy(),getTaxonLabelHome(),getDocument()); - for ( org.cipres.treebase.domain.tree.TreeBlock treeBlock : pStudy.getTreeBlocks() ) { - ntc.fromTreeBaseToXML(treeBlock); - } - - return getDocument(); - } - -} Added: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentReader.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentReader.java (rev 0) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentReader.java 2011-10-13 16:26:47 UTC (rev 971) @@ -0,0 +1,49 @@ +package org.cipres.treebase.domain.nexus.nexml; + +import org.cipres.treebase.domain.nexus.NexusDataSet; +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 NexmlDocumentReader extends NexmlObjectConverter { + + public NexmlDocumentReader(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); + + NexmlOTUReader noc = new NexmlOTUReader(getStudy(),getTaxonLabelHome(),pDocument); + for ( OTUs xmlOTUs : pDocument.getOTUsList() ) { + TaxonLabelSet taxonLabelSet = noc.fromXmlToTreeBase(xmlOTUs); + nexusDataSet.addTaxonLabelSet(xmlOTUs, taxonLabelSet); + } + + NexmlMatrixReader nmc = new NexmlMatrixReader(getStudy(),getTaxonLabelHome(),pDocument); + for ( Matrix<?> xmlMatrix : pDocument.getMatrices() ) { + org.cipres.treebase.domain.matrix.Matrix matrix = nmc.fromXmlToTreeBase(xmlMatrix); + nexusDataSet.getMatrices().add(matrix); + } + + NexmlTreeBlockReader ntc = new NexmlTreeBlockReader(getStudy(),getTaxonLabelHome(),pDocument); + for ( TreeBlock xmlTreeBlock : pDocument.getTreeBlockList() ) { + org.cipres.treebase.domain.tree.TreeBlock treeBlock = ntc.fromXmlToTreeBase(xmlTreeBlock); + nexusDataSet.getTreeBlocks().add(treeBlock); + } + + return nexusDataSet; + } + +} Copied: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java (from rev 970, 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/NexmlDocumentWriter.java (rev 0) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlDocumentWriter.java 2011-10-13 16:26:47 UTC (rev 971) @@ -0,0 +1,86 @@ +package org.cipres.treebase.domain.nexus.nexml; + +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.Study; +import org.cipres.treebase.domain.taxon.TaxonLabelHome; +import org.cipres.treebase.domain.taxon.TaxonLabelSet; +import org.nexml.model.Document; + +public class NexmlDocumentWriter extends NexmlObjectConverter { + + /** + * + * @param study + * @param taxonLabelHome + * @param document + */ + public NexmlDocumentWriter(Study study, TaxonLabelHome taxonLabelHome, + Document document) { + super(study, taxonLabelHome, document); + } + + public NexmlDocumentWriter(Study study, TaxonLabelHome taxonLabelHome, + Document document,String baseURI) { + super(study, taxonLabelHome, document,baseURI); + } + + /** + * + * @param pNexusDataSet + * @return + */ + public Document fromTreeBaseToXml(NexusDataSet pNexusDataSet) { + + NexmlOTUWriter noc = new NexmlOTUWriter(getStudy(),getTaxonLabelHome(),getDocument()); + for ( TaxonLabelSet taxonLabelSet : pNexusDataSet.getTaxonLabelSets() ) { + noc.fromTreeBaseToXml(taxonLabelSet); + } + + NexmlMatrixWriter nmc = new NexmlMatrixWriter(getStudy(),getTaxonLabelHome(),getDocument()); + for (org.cipres.treebase.domain.matrix.Matrix matrix : pNexusDataSet.getMatrices() ) { + if ( matrix instanceof CharacterMatrix ) { + nmc.fromTreeBaseToXml((CharacterMatrix)matrix); + } + } + + NexmlTreeBlockWriter ntc = new NexmlTreeBlockWriter(getStudy(),getTaxonLabelHome(),getDocument()); + for ( org.cipres.treebase.domain.tree.TreeBlock treeBlock : pNexusDataSet.getTreeBlocks() ) { + ntc.fromTreeBaseToXML(treeBlock); + } + + return getDocument(); + + } + + /** + * + * @param pStudy + * @return + */ + public Document fromTreeBaseToXml(Study pStudy) { + attachTreeBaseID(getDocument(), pStudy,Study.class); + getDocument().addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlDocumentConverter $Rev$"); + + NexmlOTUWriter noc = new NexmlOTUWriter(getStudy(),getTaxonLabelHome(),getDocument()); + for ( TaxonLabelSet taxonLabelSet : pStudy.getTaxonLabelSets() ) { + noc.fromTreeBaseToXml(taxonLabelSet); + } + + NexmlMatrixWriter nmc = new NexmlMatrixWriter(getStudy(),getTaxonLabelHome(),getDocument()); + for (org.cipres.treebase.domain.matrix.Matrix matrix : pStudy.getMatrices() ) { + if ( matrix instanceof CharacterMatrix ) { + nmc.fromTreeBaseToXml((CharacterMatrix)matrix); + } + } + + NexmlTreeBlockWriter ntc = new NexmlTreeBlockWriter(getStudy(),getTaxonLabelHome(),getDocument()); + for ( org.cipres.treebase.domain.tree.TreeBlock treeBlock : pStudy.getTreeBlocks() ) { + ntc.fromTreeBaseToXML(treeBlock); + } + + return getDocument(); + } + +} Deleted: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-10-05 17:43:48 UTC (rev 970) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2011-10-13 16:26:47 UTC (rev 971) @@ -1,739 +0,0 @@ -package org.cipres.treebase.domain.nexus.nexml; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.cipres.treebase.Constants; -import org.cipres.treebase.dao.jdbc.ContinuousMatrixElementJDBC; -import org.cipres.treebase.dao.jdbc.ContinuousMatrixJDBC; -import org.cipres.treebase.dao.jdbc.DiscreteMatrixElementJDBC; -import org.cipres.treebase.dao.jdbc.DiscreteMatrixJDBC; -import org.cipres.treebase.dao.jdbc.MatrixColumnJDBC; -import org.cipres.treebase.domain.matrix.CharSet; -import org.cipres.treebase.domain.matrix.CharacterMatrix; -import org.cipres.treebase.domain.matrix.ColumnRange; -import org.cipres.treebase.domain.matrix.ContinuousChar; -import org.cipres.treebase.domain.matrix.ContinuousMatrix; -import org.cipres.treebase.domain.matrix.ContinuousMatrixElement; -import org.cipres.treebase.domain.matrix.DiscreteChar; -import org.cipres.treebase.domain.matrix.DiscreteCharState; -import org.cipres.treebase.domain.matrix.DiscreteMatrix; -import org.cipres.treebase.domain.matrix.DiscreteMatrixElement; -import org.cipres.treebase.domain.matrix.Matrix; -import org.cipres.treebase.domain.matrix.MatrixColumn; -import org.cipres.treebase.domain.matrix.MatrixDataType; -import org.cipres.treebase.domain.matrix.MatrixElement; -import org.cipres.treebase.domain.matrix.MatrixRow; -import org.cipres.treebase.domain.matrix.PhyloChar; -import org.cipres.treebase.domain.matrix.RowSegment; -import org.cipres.treebase.domain.matrix.StandardMatrix; -import org.cipres.treebase.domain.matrix.StateSet; -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.Annotatable; -import org.nexml.model.CategoricalMatrix; -import org.nexml.model.CharacterState; -import org.nexml.model.CharacterStateSet; -import org.nexml.model.Document; -import org.nexml.model.MatrixCell; -import org.nexml.model.MolecularMatrix; -import org.nexml.model.OTUs; -import org.nexml.model.OTU; -import org.nexml.model.Subset; - -public class NexmlMatrixConverter extends NexmlObjectConverter { - - private static final int MAX_GRANULAR_NCHAR = 1000; - private static final int MAX_GRANULAR_NTAX = 30; - - /** - * - * @param study - * @param taxonLabelHome - */ - public NexmlMatrixConverter(Study study,TaxonLabelHome taxonLabelHome,Document document) { - super(study,taxonLabelHome,document); - } - - /** - * - * @param xmlMatrix - * @return - */ - public Matrix fromXmlToTreeBase(CategoricalMatrix xmlMatrix) { - DiscreteMatrix tbMatrix = new DiscreteMatrix(); - DiscreteMatrixJDBC matrixJDBC = new DiscreteMatrixJDBC(tbMatrix, xmlMatrix, this); - List<MatrixColumnJDBC> columnJDBCs = new ArrayList<MatrixColumnJDBC>(); - long[] colIds = matrixJDBC.getColIDs(); - long[] rowIds = matrixJDBC.getRowIDs(); - List<DiscreteMatrixElementJDBC> elements = new ArrayList<DiscreteMatrixElementJDBC>(); - int colIndex = 0; - for ( org.nexml.model.Character xmlCharacter : xmlMatrix.getCharacters() ) { - String charName = xmlCharacter.getLabel(); - DiscreteChar tbChar = new DiscreteChar(); - tbChar.setDescription(charName); - MatrixColumnJDBC aColumnJDBC = new MatrixColumnJDBC(); - aColumnJDBC.setPhyloChar(tbChar); - columnJDBCs.add(aColumnJDBC); - int rowIndex = 0; - for ( OTU xmlOTU : xmlMatrix.getOTUs().getAllOTUs() ) { - @SuppressWarnings("unused") - MatrixCell<CharacterState> xmlCell = xmlMatrix.getCell(xmlOTU, xmlCharacter); - DiscreteMatrixElementJDBC element = new DiscreteMatrixElementJDBC(); - //element.setValue(xmlCell.getValue()); // XXX nested stateset lookup song & dance here - element.setElementOrder(colIndex); - element.setMatrixRowID(rowIds[rowIndex]); - element.setMatrixColID(colIds[colIndex]); - elements.add(element); - rowIndex++; - } - colIndex++; - } - DiscreteMatrixElementJDBC.batchDiscreteElements(elements, getTaxonLabelHome().getConnection()); - return tbMatrix; - } - - /** - * - * @param xmlMatrix - * @return - */ - public Matrix fromXmlToTreeBase(org.nexml.model.ContinuousMatrix xmlMatrix) { - ContinuousMatrix tbMatrix = new ContinuousMatrix(); - ContinuousMatrixJDBC matrixJDBC = new ContinuousMatrixJDBC(tbMatrix, xmlMatrix, this); - List<MatrixColumnJDBC> columnJDBCs = new ArrayList<MatrixColumnJDBC>(); - long[] colIds = matrixJDBC.getColIDs(); - long[] rowIds = matrixJDBC.getRowIDs(); - List<ContinuousMatrixElementJDBC> elements = new ArrayList<ContinuousMatrixElementJDBC>(); - - int colIndex = 0; - for ( org.nexml.model.Character xmlCharacter : xmlMatrix.getCharacters() ) { - String charName = xmlCharacter.getLabel(); - ContinuousChar tbChar = new ContinuousChar(); - tbChar.setDescription(charName); - MatrixColumnJDBC aColumnJDBC = new MatrixColumnJDBC(); - aColumnJDBC.setPhyloChar(tbChar); - columnJDBCs.add(aColumnJDBC); - int rowIndex = 0; - for ( OTU xmlOTU : xmlMatrix.getOTUs().getAllOTUs() ) { - MatrixCell<Double> xmlCell = xmlMatrix.getCell(xmlOTU, xmlCharacter); - ContinuousMatrixElementJDBC element = new ContinuousMatrixElementJDBC(); - element.setValue(xmlCell.getValue()); - element.setElementOrder(colIndex); - element.setMatrixRowID(rowIds[rowIndex]); - element.setMatrixColID(colIds[colIndex]); - elements.add(element); - rowIndex++; - } - colIndex++; - } - ContinuousMatrixElementJDBC.batchContinuousElements(elements, getTaxonLabelHome().getConnection()); - return tbMatrix; - } - - /** - * - * @param xmlMatrix - * @return - */ - public Matrix fromXmlToTreeBase(org.nexml.model.Matrix<?> xmlMatrix) { - OTUs xmlOTUs = xmlMatrix.getOTUs(); - Matrix tbMatrix = null; - TaxonLabelSet tbTaxa = null; - Long tbTaxonLabelSetID = readTreeBaseID((Annotatable) xmlOTUs); - if ( null != tbTaxonLabelSetID ) { - tbTaxa = getTaxonLabelHome() - .findPersistedObjectByID(TaxonLabelSet.class, tbTaxonLabelSetID); - } - if ( xmlMatrix instanceof CategoricalMatrix ) { - tbMatrix = fromXmlToTreeBase((CategoricalMatrix) xmlMatrix); - } - else if ( xmlMatrix instanceof org.nexml.model.ContinuousMatrix ) { - tbMatrix = fromXmlToTreeBase((org.nexml.model.ContinuousMatrix) xmlMatrix); - } - if ( null != tbMatrix ) { - attachTreeBaseID((Annotatable) xmlMatrix, tbMatrix,Matrix.class); - if ( null != tbTaxa ) { - tbMatrix.setTaxa(tbTaxa); - } - tbMatrix.setStudy(getStudy()); - tbMatrix.setTitle(xmlMatrix.getLabel()); - tbMatrix.setPublished(false); - } - return tbMatrix; - } - - /** - * Creates and populates characters (i.e. columns) with their annotations, - * and state sets, with their annotations - * - * @param tbMatrix - * @return an xml matrix with empty rows - */ - public CategoricalMatrix fromTreeBaseToXml(StandardMatrix tbMatrix) { - OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); - CategoricalMatrix xmlMatrix = getDocument().createCategoricalMatrix(xmlOTUs); - - // attach base uri and history note - xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); - xmlMatrix.setBaseURI(mMatrixBaseURI); - - List<List<DiscreteCharState>> tbStateLabels = tbMatrix.getStateLabels(); - List<MatrixColumn> tbColumns = tbMatrix.getColumnsReadOnly(); - for ( int i = 0; i < tbColumns.size(); i++ ) { - CharacterStateSet xmlStateSet = xmlMatrix.createCharacterStateSet(); - for ( DiscreteCharState tbState : tbStateLabels.get(i) ) { - CharacterState xmlState = xmlStateSet.createCharacterState(tbState.getSymbol().toString()); - if ( null != tbState.getDescription() ) { - xmlState.setLabel(tbState.getDescription()); - } - attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); - } - org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(xmlStateSet); - PhyloChar tbCharacter = tbColumns.get(i).getCharacter(); - if ( null != tbCharacter.getDescription() ) { - xmlCharacter.setLabel(tbCharacter.getDescription()); - } - attachTreeBaseID((Annotatable)xmlCharacter,tbColumns.get(i),MatrixColumn.class); - } - return xmlMatrix; - } - - /** - * Creates and populates characters (i.e. columns) with their annotations, - * and state sets, with their annotations - * - * @param tbMatrix - * @return an xml matrix with empty rows - */ - public MolecularMatrix fromTreeBaseToXml(DiscreteMatrix tbMatrix) { - OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); - String tbDataType = tbMatrix.getDataType().getDescription(); - MolecularMatrix xmlMatrix = null; - CharacterStateSet xmlStateSet = null; - - // create the matrix and constant state set - if ( tbDataType.equals(MatrixDataType.MATRIX_DATATYPE_DNA) ) { - xmlMatrix = getDocument().createMolecularMatrix(xmlOTUs, MolecularMatrix.DNA); - xmlStateSet = ((MolecularMatrix)xmlMatrix).getDNACharacterStateSet(); - } - else if ( tbDataType.equals(MatrixDataType.MATRIX_DATATYPE_RNA) ) { - xmlMatrix = getDocument().createMolecularMatrix(xmlOTUs, MolecularMatrix.RNA); - xmlStateSet = ((MolecularMatrix)xmlMatrix).getRNACharacterStateSet(); - } - else if ( tbDataType.equals(MatrixDataType.MATRIX_DATATYPE_PROTEIN) ) { - xmlMatrix = getDocument().createMolecularMatrix(xmlOTUs, MolecularMatrix.Protein); - xmlStateSet = ((MolecularMatrix)xmlMatrix).getProteinCharacterStateSet(); - } - - // attach base uri and history note - xmlMatrix.setBaseURI(mMatrixBaseURI); - xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); - - // lookup the equivalent state in tb and attach identifiers - for(StateSet tbStateSet : tbMatrix.getStateSets() ) { - for (DiscreteCharState tbState : tbStateSet.getStates() ) { - String tbSymbol = tbState.getSymbol().toString().toUpperCase(); - CharacterState xmlState = xmlStateSet.lookupCharacterStateBySymbol(tbSymbol); - if ( null == xmlState ) { - xmlState = xmlStateSet.createCharacterState(tbSymbol); - } - attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); - } - } - - // create columns and attach identifiers - for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { - org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(xmlStateSet); - attachTreeBaseID((Annotatable)xmlCharacter,tbColumn,MatrixColumn.class); - } - return xmlMatrix; - } - - /** - * Creates and populates characters (i.e. columns) with their annotations, - * and state sets, with their annotations - * - * @param tbMatrix - * @return an xml matrix with empty rows - */ - public org.nexml.model.ContinuousMatrix fromTreeBaseToXml(ContinuousMatrix tbMatrix) { - OTUs xmlOTUs = getOTUsById(tbMatrix.getTaxa().getId()); - org.nexml.model.ContinuousMatrix xmlMatrix = getDocument().createContinuousMatrix(xmlOTUs); - - // attach base uri and history note - xmlMatrix.setBaseURI(mMatrixBaseURI); - xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using NexmlMatrixConverter $Rev$"); - - for ( MatrixColumn tbColumn : tbMatrix.getColumnsReadOnly() ) { - org.nexml.model.Character xmlCharacter = xmlMatrix.createCharacter(); - PhyloChar tbCharacter = tbColumn.getCharacter(); - if ( null != tbCharacter.getDescription() ) { - xmlCharacter.setLabel(tbCharacter.getDescription()); - ((Annotatable)xmlCharacter).addAnnotationValue("dcterms:description", Constants.DCTermsURI, tbCharacter.getDescription()); - } - attachTreeBaseID((Annotatable)xmlCharacter,tbColumn,MatrixColumn.class); - - //coerce the tbMatrix into a character matrix to get its character sets - CharacterMatrix tbCharacterMatrix = (CharacterMatrix)tbMatrix; - Set<CharSet> tbCharSets = tbCharacterMatrix.getCharSets(); - for ( CharSet tbCharSet : tbCharSets ) { - Collection<ColumnRange> tbColumnRanges = tbCharSet.getColumns(tbCharacterMatrix); - - for ( ColumnRange tbColumnRange : tbColumnRanges ) { - - // these are the beginning and end of the range - int tbStart = tbColumnRange.getStartColIndex(); - int tbStop = tbColumnRange.getEndColIndex(); - - // increment from beginning to end. This number is probably either null, for a - // contiguous range, or perhaps 3 for codon positions - int tbInc = 1; - // create the equivalent nexml character set - Subset nexSubset = xmlMatrix.createSubset(tbCharSet.getLabel()); - - // assign character objects to the subset. Here we get the full list - List<org.nexml.model.Character> nexCharacters = xmlMatrix.getCharacters(); - - // now we iterate over the coordinates and assign the nexml characters to the set - for ( int i = tbStart; i <= tbStop; i += tbInc ) { - nexSubset.addThing(nexCharacters.get(i)); - } - } - } - - } - - return xmlMatrix; - } - - -// XXX doesn't handle the following data types: -// public static final String MATRIX_DATATYPE_NUCLEOTIDE = "Nucleotide"; -// public static final String MATRIX_DATATYPE_DISTANCE = "Distance"; -// public static final String MATRIX_DATATYPE_MIXED = "Mixed"; - @SuppressWarnings("unchecked") - public org.nexml.model.Matrix<?> fromTreeBaseToXml(CharacterMatrix tbMatrix) { - org.nexml.model.Matrix<?> xmlMatrix = null; - if ( tbMatrix instanceof DiscreteMatrix ) { - if ( tbMatrix.getDataType().getDescription().equals(MatrixDataType.MATRIX_DATATYPE_STANDARD) ) { - xmlMatrix = fromTreeBaseToXml((StandardMatrix) tbMatrix); - } - else { - xmlMatrix = fromTreeBaseToXml((DiscreteMatrix) tbMatrix); - } - populateXmlMatrix((org.nexml.model.Matrix<CharacterState>)xmlMatrix,(DiscreteMatrix)tbMatrix); - } - else if ( tbMatrix instanceof ContinuousMatrix ) { - xmlMatrix = fromTreeBaseToXml((ContinuousMatrix) tbMatrix); - populateXmlMatrix((org.nexml.model.ContinuousMatrix)xmlMatrix,(ContinuousMatrix)tbMatrix); - } - xmlMatrix.setLabel(tbMatrix.getTitle()); - attachTreeBaseID((Annotatable)xmlMatrix, tbMatrix,Matrix.class); - String tb1MatrixID = tbMatrix.getTB1MatrixID(); - if ( null != tb1MatrixID ) { - ((Annotatable)xmlMatrix).addAnnotationValue("tb:identifier.matrix.tb1", Constants.TBTermsURI, tb1MatrixID); - } - Set<CharSet> tbCharSets = tbMatrix.getCharSets(); - for ( CharSet tbCharSet : tbCharSets ) { - Collection<ColumnRange> tbColumnRanges = tbCharSet.getColumns(tbMatrix); - - for ( ColumnRange tbColumnRange : tbColumnRanges ) { - - // these are the beginning and end of the range - int tbStart = tbColumnRange.getStartColIndex(); - int tbStop = tbColumnRange.getEndColIndex(); - - // increment from beginning to end. This number is probably either null, for a - // contiguous range, or perhaps 3 for codon positions - int tbInc = 1; - // create the equivalent nexml character set - Subset nexSubset = xmlMatrix.createSubset(tbCharSet.getLabel()); - - // assign character objects to the subset. Here we get the full list - List<org.nexml.model.Character> nexCharacters = xmlMatrix.getCharacters(); - - // now we iterate over the coordinates and assign the nexml characters to the set - for ( int i = tbStart; i <= tbStop; i += tbInc ) { - nexSubset.addThing(nexCharacters.get(i)); - } - } - } - - return xmlMatrix; - } - - /** - * - * @param xmlMatrix - * @param tbMatrix - * @param xmlOTUs - * @param stateSet - */ - private void populateXmlMatrix( - org.nexml.model.Matrix<CharacterState> xmlMatrix, - DiscreteMatrix tbMatrix) { - OTUs xmlOTUs = xmlMatrix.getOTUs(); - List<org.nexml.model.Character> characterList = xmlMatrix.getCharacters(); - for ( MatrixRow tbRow : tbMatrix.getRowsReadOnly() ) { - Set<RowSegment> tbSegments = tbRow.getSegmentsReadOnly(); - OTU xmlOTU = getOTUById(xmlOTUs, tbRow.getTaxonLabel().getId()); - int charIndex = 0; - if ( characterList.size() <= MAX_GRANULAR_NCHAR && xmlOTUs.getAllOTUs().size() <= MAX_GRANULAR_NTAX ) { - for ( MatrixColumn tbColumn : ((CharacterMatrix)tbMatrix).getColumns() ) { - String seq = tbRow.buildElementAsString(); - xmlMatrix.setSeq(seq, xmlOTU); - org.nexml.model.Character xmlCharacter = characterList.get(charIndex); - MatrixCell<CharacterState> xmlCell = xmlMatrix.getCell(xmlOTU, xmlCharacter); - - attachTreeBaseID ((Annotatable) xmlCell, tbColumn , DiscreteMatrixElement.class); - - //The following is commented out as tbRow.getElements() does not work directly and crashes the loop. - //The above for loop fixes this issue. - /* - for ( MatrixElement tbCell : tbRow.getElements() ) { - org.nexml.model.Character xmlCharacter = characterList.get(charIndex); - MatrixCell<CharacterState> xmlCell = xmlMatrix.getCell(xmlOTU, xmlCharacter); - DiscreteCharState tbState = ((DiscreteMatrixElement)tbCell).getCharState(); - String tbSymbolString = ( null == tbState ) ? "?" : tbState.getSymbol().toString(); - CharacterState xmlState = xmlCharacter.getCharacterStateSet().lookupCharacterStateBySymbol(tbSymbolString); - xmlCell.setValue(xmlState); - attachTreeBaseID((Annotatable)xmlCell,tbCell,DiscreteMatrixElement.class); - */ - - for ( RowSegment tbSegment : tbSegments ) { - if ( tbSegment.getStartIndex() <= charIndex && charIndex <= tbSegment.getEndIndex() ) { - //declare variables for row-segment annotations - String title = tbSegment.getTitle(); - String institutionCode = tbSegment.getSpecimenLabel().getInstAcronym(); - String collectionCode = tbSegment.getSpecimenLabel().getCollectionCode(); - String catalogNumber = tbSegment.getSpecimenLabel().getCatalogNumber(); - String accessionNumber = tbSegment.getSpecimenLabel().getGenBankAccession(); - String otherAccessionNumber = tbSegment.getSpecimenLabel().getOtherAccession(); - String dateSampled = tbSegment.getSpecimenLabel().getSampleDateString(); - String scientificName = tbSegment.getSpecimenTaxonLabelAsString(); - String collector = tbSegment.getSpecimenLabel().getCollector(); - Double latitude = tbSegment.getSpecimenLabel().getLatitude(); - Double longitude = tbSegment.getSpecimenLabel().getLongitude(); - Double elevation = tbSegment.getSpecimenLabel().getElevation(); - String country = tbSegment.getSpecimenLabel().getCountry(); - String state = tbSegment.getSpecimenLabel().getState(); - String locality = tbSegment.getSpecimenLabel().getLocality(); - String notes = tbSegment.getSpecimenLabel().getNotes(); - - //if the value is not null, output the xmlOTU annotation. - //DwC refers to the Darwin Core term vocabulary for the associated annotation - if (null != title){ - //output name identifying the data set from which the record was derived - ((Annotatable)xmlCell).addAnnotationValue("DwC:datasetName", Constants.DwCURI, title); - } - if ( null != institutionCode ) { - //output name or acronym of institution that has custody of information referred to in record - ((Annotatable)xmlCell).addAnnotationValue("DwC:institutionCode", Constants.DwCURI, institutionCode); - } - if ( null != collectionCode ) { - //output name or code that identifies collection or data set from which record was derived - ((Annotatable)xmlCell).addAnnotationValue ("DwC:collectionCode", Constants.DwCURI, collectionCode); - } - if ( null != catalogNumber ){ - //output unique (usually) identifier for the record within data set or collection - ((Annotatable)xmlCell).addAnnotationValue("DwC:catalogNumber", Constants.DwCURI, catalogNumber); - } - if ( null != accessionNumber) { - //output a list of genetic sequence information associated with occurrence - ((Annotatable)xmlCell).addAnnotationValue("DwC:associatedSequences", Constants.DwCURI, accessionNumber); - } - if ( null != otherAccessionNumber ) { - //list of previous or alternate fully catalog numbers (i.e. Genbank) or human-used identifiers - ((Annotatable)xmlCell).addAnnotationValue("DwC:otherCatalogNumbers", Constants.DwCURI, otherAccessionNumber); - } - if ( null != dateSampled ) { - //output date sampled in ISO 8601 format - ((Annotatable)xmlCell).addAnnotationValue("DwC:eventDate", Constants.DwCURI, dateSampled); - } - if ( null != scientificName ) { - //output full scientific name - ((Annotatable)xmlCell).addAnnotationValue("DwC:scientificName", Constants.DwCURI, scientificName); - } - if ( null != collector ) { - //output names of people associated with recording of original occurrence - ((Annotatable)xmlCell).addAnnotationValue("DwC:recordedBy", Constants.DwCURI, collector); - } - if ( null != latitude ) { - //output geographic latitude in decimal degrees using geodeticDatum spatial reference system - ((Annotatable)xmlCell).addAnnotationValue("DwC:decimalLatitude", Constants.DwCURI, latitude); - } - if ( null != longitude ) { - //output geographic longitude in decimal degrees using geodeticDatum spatial reference system - ((Annotatable)xmlCell).addAnnotationValue("DwC:decimalLongitude", Constants.DwCURI, longitude); - } - if ( null != elevation ) { - //there are two different Darwin Core terms for elevation depending on elevation value - //outputs geographic elevation of sample - if ( elevation >= 0) { - //above local surface in meters - ((Annotatable)xmlCell).addAnnotationValue("DwC:verbatimElevation", Constants.DwCURI, elevation); - } - else { - //below local surface in meters - ((Annotatable)xmlCell).addAnnotationValue("DwC:verbatimDepth", Constants.DwCURI, elevation); - } - } - if ( null != country ) { - //output country in which location occurs - ((Annotatable)xmlCell).addAnnotationValue("DwC:country", Constants.DwCURI, country); - } - if ( null != state ) { - //output name of next smaller administrative region than country (i.e. state, province, region) - ((Annotatable)xmlCell).addAnnotationValue ("DwC:stateProvince", Constants.DwCURI, state); - } - if ( null != locality) { - //output brief description of sample location - ((Annotatable)xmlCell).addAnnotationValue("DwC:locality", Constants.DwCURI, locality); - } - if ( null != notes ) { - //output any additional information about specimen - ((Annotatable)xmlCell).addAnnotationValue("DwC:occurenceRemarks", Constants.DwCURI, notes); - } - } - } - charIndex++; - } - } - else { - String seq = tbRow.buildElementAsString(); - if ( tbMatrix.getDataType().getDescription().equals(MatrixDataType.MATRIX_DATATYPE_STANDARD) ) { - StringBuilder sb = new StringBuilder(); - for ( int i = 0; i < seq.length(); i++ ) { - sb.append(seq.charAt(i)); - if ( i < seq.length() - 1 ) { - sb.append(' '); - } - } - } - xmlMatrix.setSeq(seq,xmlOTU); - } - for ( RowSegment tbSegment : tbSegments ) { - //declare variables for row-segment annotations - String title = tbSegment.getTitle(); - String institutionCode = tbSegment.getSpecimenLabel().getInstAcronym(); - String collectionCode = tbSegment.getSpecimenLabel().getCollectionCode(); - String catalogNumber = tbSegment.getSpecimenLabel().getCatalogNumber(); - String accessionNumber = tbSegment.getSpecimenLabel().getGenBankAccession(); - String otherAccessionNumber = tbSegment.getSpecimenLabel().getOtherAccession(); - String dateSampled = tbSegment.getSpecimenLabel().getSampleDateString(); - String scientificName = tbSegment.getSpecimenTaxonLabelAsString(); - String collector = tbSegment.getSpecimenLabel().getCollector(); - Double latitude = tbSegment.getSpecimenLabel().getLatitude(); - Double longitude = tbSegment.getSpecimenLabel().getLongitude(); - Double elevation = tbSegment.getSpecimenLabel().getElevation(); - String country = tbSegment.getSpecimenLabel().getCountry(); - String state = tbSegment.getSpecimenLabel().getState(); - String locality = tbSegment.getSpecimenLabel().getLocality(); - String notes = tbSegment.getSpecimenLabel().getNotes(); - - //if the value is not null, output the xmlOTU annotation. - //DwC refers to the Darwin Core term vocabulary for the associated annotation - if (null != title){ - //output name identifying the data set from which the record was derived - xmlOTU.addAnnotationValue("DwC:datasetName", Constants.DwCURI, title); - } - if ( null != institutionCode ) { - //output name or acronym of institution that has custody of information referred to in record - xmlOTU.addAnnotationValue("DwC:institutionCode", Constants.DwCURI, institutionCode); - } - if ( null != collectionCode ) { - //output name or code that identifies collection or data set from which record was derived - xmlOTU.addAnnotationValue ("DwC:collectionCode", Constants.DwCURI, collectionCode); - } - if ( null != catalogNumber ){ - //output unique (usually) identifier for the record within data set or collection - xmlOTU.addAnnotationValue("DwC:catalogNumber", Constants.DwCURI, catalogNumber); - } - if ( null != accessionNumber) { - //output a list of genetic sequence information associated with occurrence - xmlOTU.addAnnotationValue("DwC:associatedSequences", Constants.DwCURI, accessionNumber); - } - if ( null != otherAccessionNumber ) { - //list of previous or alternate fully catalog numbers (i.e. Genbank) or human-used identifiers - xmlOTU.addAnnotationValue("DwC:otherCatalogNumbers", Constants.DwCURI, otherAccessionNumber); - } - if ( null != dateSampled ) { - //output date sampled in ISO 8601 format - xmlOTU.addAnnotationValue("DwC:eventDate", Constants.DwCURI, dateSampled); - } - if ( null != scientificName ) { - //output full scientific name - xmlOTU.addAnnotationValue("DwC:scientificName", Constants.DwCURI, scientificName); - } - if ( null != collector ) { - //output names of people associated with recording of original occurrence - xmlOTU.addAnnotationValue("DwC:recordedBy", Constants.DwCURI, collector); - } - if ( null != latitude ) { - //output geographic latitude in decimal degrees using geodeticDatum spatial reference system - xmlOTU.addAnnotationValue("DwC:decimalLatitude", Constants.DwCURI, latitude); - } - if ( null != longitude ) { - //output geographic longitude in decimal degrees using geodeticDatum spatial reference system - xmlOTU.addAnnotationValue("DwC:decimalLongitude", Constants.DwCURI, longitude); - } - if ( null != elevation ) { - //there are two different Darwin Core terms for elevation depending on elevation value - //outputs geographic elevation of sample - if ( elevation >= 0) { - //above local surface in meters - xmlOTU.addAnnotationValue("DwC:verbatimElevation", Constants.DwCURI, elevation); - } - else { - //below local surface in meters - xmlOTU.addAnnotationValue("DwC:verbatimDepth", Constants.DwCURI, elevation); - } - } - if ( null != country ) { - //output country in which location occurs - xmlOTU.addAnnotationValue("DwC:country", Constants.DwCURI, country); - } - if ( null != state ) { - //output name of next smaller administrative region than country (i.e. state, province, region) - xmlOTU.addAnnotationValue ("DwC:stateProvince", Constants.DwCURI, state); - } - if ( null != locality) { - //output brief description of sample location - xmlOTU.addAnnotationValue("DwC:locality", Constants.DwCURI, locality); - } - if ( null != notes ) { - //output any additional information about specimen - xmlOTU.addAnnotationValue("DwC:occurenceRemarks", Constants.DwCURI, notes); - } - } - } - } - - /** - * - * @param xmlMatrix - * @param tbMatrix - */ - private void populateXmlMatrix(org.nexml.model.ContinuousMatrix xmlMatrix, - ContinuousMatrix tbMatrix) { - List<org.nexml.model.Character> characterList = xmlMatrix.getCharacters(); - OTUs xmlOTUs = xmlMatrix.getOTUs(); - for ( MatrixRow tbRow : tbMatrix.getRowsReadOnly() ) { - List<MatrixElement> elements = tbRow.getElements(); - OTU xmlOTU = getOTUById(xmlOTUs, tbRow.getTaxonLabel().getId()); - if ( characterList.size() <= MAX_GRANULAR_NCHAR && xmlOTUs.getAllOTUs().size() <= MAX_GRANULAR_NTAX ) { - for ( int elementIndex = 0; elementIndex < tbMatrix.getnChar(); elementIndex++ ) { - ContinuousMatrixElement tbCell = (ContinuousMatrixElement)elements.get(elementIndex); - MatrixCell<Double> xmlCell = xmlMatrix.getCell(xmlOTU, characterList.get(elementIndex)); - xmlCell.setValue(tbCell.getValue()); - attachTreeBaseID((Annotatable)xmlCell,tbCell,DiscreteMatrixElement.class); - } - } - else { - String seq = tbRow.buildElementAsString(); - xmlMatrix.setSeq(seq,xmlOTU); - } - Set<RowSegment> tbSegments = tbRow.getSegmentsReadOnly(); - for ( RowSegment tbSegment : tbSegments ) { - //declare variables for row-segment annotations - String title = tbSegment.getTitle(); - String institutionCode = tbSegment.getSpecimenLabel().getInstAcronym(); - String collectionCode = tbSegment.getSpecimenLabel().getCollectionCode(); - String catalogNumber = tbSegment.getSpecimenLabel().getCatalogNumber(); - String accessionNumber = tbSegment.getSpecimenLabel().getGenBankAccession(); - String otherAccessionNumber = tbSegment.getSpecimenLabel().getOtherAccession(); - String dateSampled = tbSegment.getSpecimenLabel().getSampleDateString(); - String scientificName = tbSegment.getSpecimenTaxonLabelAsString(); - String collector = tbSegment.getSpecimenLabel().getCollector(); - Double latitude = tbSegment.getSpecimenLabel().getLatitude(); - Double longitude = tbSegment.getSpecimenLabel().getLongitude(); - Double elevation = tbSegment.getSpecimenLabel().getElevation(); - String country = tbSegment.getSpecimenLabel().getCountry(); - String state = tbSegment.getSpecimenLabel().getState(); - String locality = tbSegment.getSpecimenLabel().getLocality(); - String notes = tbSegment.getSpecimenLabel().getNotes(); - - //if the value is not null, output the xmlOTU annotation. - //DwC refers to the Darwin Core term vocabulary for the associated annotation - if (null != title){ - //output name identifying the data set from which the record was derived - xmlOTU.addAnnotationValue("DwC:datasetName", Constants.DwCURI, title); - } - if ( null != institutionCode ) { - //output name or acronym of institution that has custody of information referred to in record - xmlOTU.addAnnotationValue("DwC:institutionCode", Constants.DwCURI, institutionCode); - } - if ( null != collectionCode ) { - //output name or code that identifies collection or data set from which record was derived - xmlOTU.addAnnotationValue ("DwC:collectionCode", Constants.DwCURI, collectionCode); - } - if ( null != catalogNumber ){ - //output unique (usually) identifier for the record within data set or collection - xmlOTU.addAnnotationValue("DwC:catalogNumber", Constants.DwCURI, catalogNumber); - } - if ( null != accessionNumber) { - //output a list of genetic sequence information associated with occurrence - xmlOTU.addAnnotationValue("DwC:associatedSequences", Constants.DwCURI, accessionNumber); - } - if ( null != otherAccessionNumber ) { - //list of previous or alternate fully catalog numbers (i.e. Genbank) or human-used identifiers - xmlOTU.addAnnotationValue("DwC:otherCatalogNumbers", Constants.DwCURI, otherAccessionNumber); - } - if ( null != dateSampled ) { - //output date sampled in ISO 8601 format - xmlOTU.addAnnotationValue("DwC:eventDate", Constants.DwCURI, dateSampled); - } - if ( null != scientificName ) { - //output full scientific name - xmlOTU.addAnnotationValue("DwC:scientificName", Constants.DwCURI, scientificName); - } - if ( null != collector ) { - //output names of people associated with recording of original occurrence - xmlOTU.addAnnotationValue("DwC:recordedBy", Constants.DwCURI, collector); - } - if ( null != latitude ) { - //output geographic latitude in decimal degrees using geodeticDatum spatial reference system - xmlOTU.addAnnotationValue("DwC:decimalLatitude", Constants.DwCURI, latitude); - } - if ( null != longitude ) { - //output geographic longitude in decimal degrees using geodeticDatum spatial reference system - xmlOTU.addAnnotationValue("DwC:decimalLongitude", Constants.DwCURI, longitude); - } - if ( null != elevation ) { - //there are two different Darwin Core terms for elevation depending on elevation value - //outputs geographic elevation of sample - if ( elevation >= 0) { - //above local surface in meters - xmlOTU.addAnnotationValue("DwC:verbatimElevation", Constants.DwCURI, elevation); - } - else { - //below local surface in meters - xmlOTU.addAnnotationValue("DwC:verbatimDepth", Constants.DwCURI, elevation); - } - } - if ( null != country ) { - //output country in which location occurs - xmlOTU.addAnnotationValue("DwC:country", Constants.DwCURI, country); - } - if ( null != state ) { - //output name of next smaller administrative region than country (i.e. state, province, region) - xmlOTU.addAnnotationValue ("DwC:stateProvince", Constants.DwCURI, state); - } - if ( null != locality) { - //output brief description of sample location - xmlOTU.addAnnotationValue("DwC:locality", Constants.DwCURI, locality); - } - if ( null != notes ) { - //output any additional information about specimen - xmlOTU.addAnnotationValue("DwC:occurenceRemarks", Constants.DwCURI, notes); - } - } - } - } - -} Added: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixReader.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixReader.java (rev 0) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixReader.java 2011-10-13 16:26:47 UTC (rev 971) @@ -0,0 +1,142 @@ +package org.cipres.treebase.domain.nexus.nexml; + +import java.util.ArrayList; +import java.util.List; + +import org.cipres.treebase.dao.jdbc.ContinuousMatrixElementJDBC; +import org.cipres.treebase.dao.jdbc.ContinuousMatrixJDBC; +import org.cipres.treebase.dao.jdbc.DiscreteMatrixElementJDBC; +import org.cipres.treebase.dao.jdbc.DiscreteMatrixJDBC; +import org.cipres.treebase.dao.jdbc.MatrixColumnJDBC; +import org.cipres.treebase.domain.matrix.ContinuousChar; +import org.cipres.treebase.domain.matrix.ContinuousMatrix; +import org.cipres.treebase.domain.matrix.DiscreteChar; +import org.cipres.treebase.domain.matrix.DiscreteMatrix; +import org.cipres.treebase.domain.matrix.Matrix; +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.Annotatable; +import org.nexml.model.CategoricalMatrix; +import org.nexml.model.CharacterState; +import org.nexml.model.Document; +import org.nexml.model.MatrixCell; +import org.nexml.model.OTU; +import org.nexml.model.OTUs; + +public class NexmlMatrixReader extends NexmlObjectConverter { + + public NexmlMatrixReader(Study study, TaxonLabelHome taxonLabelHome, + Document document) { + super(study, taxonLabelHome, document); + } + + /** + * + * @param xmlMatrix + * @return + */ + private Matrix fromXmlToTreeBase(CategoricalMatrix xmlMatrix) { + DiscreteMatrix tbMatrix = new DiscreteMatrix(); + DiscreteMatrixJDBC matrixJDBC = new DiscreteMatrixJDBC(tbMatrix, xmlMatrix, this); + List<MatrixColumnJDBC> columnJDBCs = new ArrayList<MatrixColumnJDBC>(); + long[] colIds = matrixJDBC.getColIDs(); + long[] rowIds = matrixJDBC.getRowIDs(); + List<DiscreteMatrixElementJDBC> elements = new ArrayList<DiscreteMatrixElementJDBC>(); + int colIndex = 0; + for ( org.nexml.model.Character xmlCharacter : xmlMatrix.getCharacters() ) { + String charName = xmlCharacter.getLabel(); + DiscreteChar tbChar = new DiscreteChar(); + tbChar.setDescription(charName); + MatrixColumnJDBC aColumnJDBC = new MatrixColumnJDBC(); + aColumnJDBC.setPhyloChar(tbChar); + columnJDBCs.add(aColumnJDBC); + int rowIndex = 0; + for ( OTU xmlOTU : xmlMatrix.getOTUs().getAllOTUs() ) { + @SuppressWarnings("unused") + MatrixCell<CharacterState> xmlCell = xmlMatrix.getCell(xmlOTU, xmlCharacter); + DiscreteMatrixElementJDBC element = new DiscreteMatrixElementJDBC(); + //element.setValue(xmlCell.getValue()); // XXX nested stateset lookup song & dance here + element.setElementOrder(colIndex); + element.setMatrixRowID(rowIds[rowIndex]); + element.setMatrixColID(colIds[colIndex]); + elements.add(element); + rowIndex++; + } + colIndex++; + } + DiscreteMatrixElementJDBC.batchDiscreteElements(elements, getTaxonLabelHome().getConnection()); + return tbMatrix; + } + + /** + * + * @param xmlMatrix + * @return + */ + private Matrix fromXmlToTreeBase(org.nexml.model.ContinuousMatrix xmlMatrix) { + ContinuousMatrix tbMatrix = new ContinuousMatrix(); + ContinuousMatrixJDBC matrixJDBC = new ContinuousMatrixJDBC(tbMatrix, xmlMatrix, this); + List<MatrixColumnJDBC> columnJDBCs = new ArrayList<MatrixColumnJDBC>(); + long[] colIds = matrixJDBC.getColIDs(); + long[] rowIds = matrixJDBC.getRowIDs(); + List<ContinuousMatrixElementJDBC> elements = new ArrayList<ContinuousMatrixElementJDBC>(); + + int colIndex = 0; + for ( org.nexml.model.Character xmlCharacter : xmlMatrix.getCharacters() ) { + String charName = xmlCharacter.getLabel(); + ContinuousChar tbChar = new ContinuousChar(); + tbChar.setDescription(charName); + MatrixColumnJDBC aColumnJDBC = new MatrixColumnJDBC(); + aColumnJDBC.setPhyloChar(tbChar); + columnJDBCs.add(aColumnJDBC); + int rowIndex = 0; + for ( OTU xmlOTU : xmlMatrix.getOTUs().getAllOTUs() ) { + MatrixCell<Double> xmlCell = xmlMatrix.getCell(xmlOTU, xmlCharacter); + ContinuousMatrixElementJDBC element = new ContinuousMatrixElementJDBC(); + element.setValue(xmlCell.getValue()); + element.setElementOrder(colIndex); + element.setMatrixRowID(rowIds[rowIndex]); + element.setMatrixColID(colIds[colIndex]); + elements.add(element); + rowIndex++; + } + colIndex++; + } + ContinuousMatrixElementJDBC.batchContinuousElements(elements, getTaxonLabelHome().getConnection()); + return tbMatrix; + } + + /** + * + * @param xmlMatrix + * @return + */ + public Matrix fromXmlToTreeBase(org.nexml.model.Matrix<?> xmlMatrix) { + OTUs xmlOTUs = xmlMatrix.getOTUs(); + Matrix tbMatrix = null; + TaxonLabelSet tbTaxa = null; + Long tbTaxonLabelSetID = readTreeBaseID((Annotatable) xmlOTUs); + if ( null != tbTaxonLabelSetID ) { + tbTaxa = getTaxonLabelHome() + .findPersistedObjectByID(TaxonLabelSet.class, tbTaxonLabelSetID); + } + if ( xmlMatrix instanceof CategoricalMatrix ) { + tbMatrix = fromXmlToTreeBase((CategoricalMatrix) xmlMatrix); + } + else if ( xmlMatrix instanceof org.nexml.model.ContinuousMatrix ) { + tbMatrix = fromXmlToTreeBase((org.nexml.model.ContinuousMatrix) xmlMatrix); + } + if ( null != tbMatrix ) { + attachTreeBaseID((Annotatable) xmlMatrix, tbMatrix,Matrix.class); + if ( null != tbTaxa ) { + tbMatrix.setTaxa(tbTaxa); + } + tbMatrix.setStudy(getStudy()); + tbMatrix.setTitle(xmlMatrix.getLabel()); + tbMatrix.setPublished(false); + } + return tbMatrix; + } + +} Copied: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java (from rev 970, trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java) =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java (rev 0) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java 2011-10-13 16:26:47 UTC (rev 971) @@ -0,0 +1,622 @@ +package org.cipres.treebase.domain.nexus.nexml; + +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import org.cipres.treebase.Constants; +import org.cipres.treebase.domain.matrix.CharSet; +import org.cipres.treebase.domain.matrix.CharacterMatrix; +import org.cipres.treebase.domain.matrix.ColumnRange; +impo... [truncated message content] |
From: <hs...@us...> - 2011-10-05 17:43:54
|
Revision: 970 http://treebase.svn.sourceforge.net/treebase/?rev=970&view=rev Author: hshyket Date: 2011-10-05 17:43:48 +0000 (Wed, 05 Oct 2011) Log Message: ----------- Modified Paths: -------------- trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js Modified: trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js =================================================================== --- trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js 2011-10-05 16:56:12 UTC (rev 969) +++ trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js 2011-10-05 17:43:48 UTC (rev 970) @@ -19,12 +19,11 @@ //protocol, host, hostname, port, pathname, search, hash if (hrefs[l].protocol == "mailto:") { startListening(hrefs[l],"click",trackMailto); - //} else if (hrefs[l].hostname == location.host) { } else if (hrefs[l].hostname == location.host) { var path = hrefs[l].pathname + hrefs[l].search; var pathFile = hrefs[l].pathname; var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3|nex)($|\&|\?)/); - var isDownload = pathFile.match(/(?:downloadATree|downloadANexusFile|downloadAMatrix|downloadANexusFile|downloadAnAnalysisStep)/); + var isDownload = pathFile.match(/(?:downloadATree|downloadANexusFile|downloadAMatrix|downloadAnAnalysisStep)/); if (isDoc || isDownload) { startListening(hrefs[l],"click",trackDownloads); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hs...@us...> - 2011-10-05 16:56:18
|
Revision: 969 http://treebase.svn.sourceforge.net/treebase/?rev=969&view=rev Author: hshyket Date: 2011-10-05 16:56:12 +0000 (Wed, 05 Oct 2011) Log Message: ----------- Modified Paths: -------------- trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js Modified: trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js =================================================================== --- trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js 2011-10-05 15:49:04 UTC (rev 968) +++ trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js 2011-10-05 16:56:12 UTC (rev 969) @@ -20,7 +20,7 @@ if (hrefs[l].protocol == "mailto:") { startListening(hrefs[l],"click",trackMailto); //} else if (hrefs[l].hostname == location.host) { - } else if (true) { + } else if (hrefs[l].hostname == location.host) { var path = hrefs[l].pathname + hrefs[l].search; var pathFile = hrefs[l].pathname; var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3|nex)($|\&|\?)/); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hs...@us...> - 2011-10-05 15:49:10
|
Revision: 968 http://treebase.svn.sourceforge.net/treebase/?rev=968&view=rev Author: hshyket Date: 2011-10-05 15:49:04 +0000 (Wed, 05 Oct 2011) Log Message: ----------- Fixing analytics script Modified Paths: -------------- trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js Modified: trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js =================================================================== --- trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js 2011-10-05 13:47:19 UTC (rev 967) +++ trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js 2011-10-05 15:49:04 UTC (rev 968) @@ -19,10 +19,13 @@ //protocol, host, hostname, port, pathname, search, hash if (hrefs[l].protocol == "mailto:") { startListening(hrefs[l],"click",trackMailto); - } else if (hrefs[l].hostname == location.host) { + //} else if (hrefs[l].hostname == location.host) { + } else if (true) { var path = hrefs[l].pathname + hrefs[l].search; - var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3|nex|downloadATree|downloadANexusFile|downloadAMatrix|downloadANexusFile|downloadAnAnalysisStep)($|\&|\?)/); - if (isDoc) { + var pathFile = hrefs[l].pathname; + var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3|nex)($|\&|\?)/); + var isDownload = pathFile.match(/(?:downloadATree|downloadANexusFile|downloadAMatrix|downloadANexusFile|downloadAnAnalysisStep)/); + if (isDoc || isDownload) { startListening(hrefs[l],"click",trackDownloads); } } else if (hrefs[l].hostname != location.hostname) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hs...@us...> - 2011-10-05 13:47:25
|
Revision: 967 http://treebase.svn.sourceforge.net/treebase/?rev=967&view=rev Author: hshyket Date: 2011-10-05 13:47:19 +0000 (Wed, 05 Oct 2011) Log Message: ----------- Updating Google Analytics script to capture clicks on the links that are for downloading matrices, trees, etc. Modified Paths: -------------- trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js Modified: trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js =================================================================== --- trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js 2011-09-30 16:40:00 UTC (rev 966) +++ trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js 2011-10-05 13:47:19 UTC (rev 967) @@ -21,7 +21,7 @@ startListening(hrefs[l],"click",trackMailto); } else if (hrefs[l].hostname == location.host) { var path = hrefs[l].pathname + hrefs[l].search; - var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3|nex)($|\&|\?)/); + var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3|nex|downloadATree|downloadANexusFile|downloadAMatrix|downloadANexusFile|downloadAnAnalysisStep)($|\&|\?)/); if (isDoc) { startListening(hrefs[l],"click",trackDownloads); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hs...@us...> - 2011-09-30 16:40:06
|
Revision: 966 http://treebase.svn.sourceforge.net/treebase/?rev=966&view=rev Author: hshyket Date: 2011-09-30 16:40:00 +0000 (Fri, 30 Sep 2011) Log Message: ----------- Changing size of search content area to fill the user's browser Modified Paths: -------------- trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp trunk/treebase-web/src/main/webapp/styles/styles.css Modified: trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp 2011-09-26 14:47:20 UTC (rev 965) +++ trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp 2011-09-30 16:40:00 UTC (rev 966) @@ -141,7 +141,7 @@ <!-- BEGIN RIGHT COLUMN --> - <div id="content"> + <div id="content" class="contentsearch"> <div class="gutter"> <c:if test="${not empty page.heading}"> <h2><decorator:getProperty property="page.heading"/></h2> Modified: trunk/treebase-web/src/main/webapp/styles/styles.css =================================================================== --- trunk/treebase-web/src/main/webapp/styles/styles.css 2011-09-26 14:47:20 UTC (rev 965) +++ trunk/treebase-web/src/main/webapp/styles/styles.css 2011-09-30 16:40:00 UTC (rev 966) @@ -94,6 +94,11 @@ width: 67% } +.contentsearch { + float: left; + width: 100% !important; +} + /* This sidebar ID is also used for the 3column right sidebar */ #sidebar { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sfr...@us...> - 2011-09-26 14:47:26
|
Revision: 965 http://treebase.svn.sourceforge.net/treebase/?rev=965&view=rev Author: sfrgpiel Date: 2011-09-26 14:47:20 +0000 (Mon, 26 Sep 2011) Log Message: ----------- fixing broken links to images. Modified Paths: -------------- trunk/treebase-web/src/main/webapp/WEB-INF/pages/journal.jsp Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/journal.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/pages/journal.jsp 2011-09-26 12:57:11 UTC (rev 964) +++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/journal.jsp 2011-09-26 14:47:20 UTC (rev 965) @@ -122,7 +122,7 @@ <p><a href="http://www.cryptogamie.com/pagint_en/editeur/revue_bryo.php" title="Cryptogamie Bryologie"> <img class="journal" - src="images/journal_files/fd_algo.gif" alt="Cryptogamie Bryologie"/> + src="images/journal_files/fd_bryo.gif" alt="Cryptogamie Bryologie"/> </a> </p> </td> @@ -140,7 +140,7 @@ <p><a href="http://www.cryptogamie.com/pagint_en/editeur/revue_bryo.php" title="Cryptogamie Mycologie"> <img class="journal" - src="images/journal_files/fd_algo.gif" alt="Cryptogamie Mycologie"/> + src="images/journal_files/fd_myco.gif" alt="Cryptogamie Mycologie"/> </a> </p> </td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hs...@us...> - 2011-09-26 12:57:17
|
Revision: 964 http://treebase.svn.sourceforge.net/treebase/?rev=964&view=rev Author: hshyket Date: 2011-09-26 12:57:11 +0000 (Mon, 26 Sep 2011) Log Message: ----------- Fixing API query calls with no format Modified Paths: -------------- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/StudySearchController.java Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/StudySearchController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/StudySearchController.java 2011-09-23 17:15:15 UTC (rev 963) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/StudySearchController.java 2011-09-26 12:57:11 UTC (rev 964) @@ -395,10 +395,8 @@ root = normalizeParseTree(root); Set<Study> queryResults = doCQLQuery(root, new HashSet<Study>(),request, response, errors); StudySearchResults tsr = new StudySearchResults(queryResults); - if (! request.getParameter("format").equals("rss1")) { + if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) { saveSearchResults(request, tsr); - } - if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) { return new ModelAndView("search/studySearch", Constants.RESULT_SET, tsr); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hs...@us...> - 2011-09-23 17:15:22
|
Revision: 963 http://treebase.svn.sourceforge.net/treebase/?rev=963&view=rev Author: hshyket Date: 2011-09-23 17:15:15 +0000 (Fri, 23 Sep 2011) Log Message: ----------- When uploading RowSegment data, some of the fields will truncate to the column size rather than stop inserting Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/RowSegment.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/RowSegment.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/RowSegment.java 2011-09-20 15:16:58 UTC (rev 962) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/RowSegment.java 2011-09-23 17:15:15 UTC (rev 963) @@ -1,5 +1,6 @@ package org.cipres.treebase.domain.matrix; +import java.lang.reflect.Method; import java.util.List; import java.util.Map; @@ -335,54 +336,152 @@ for (int i = 0; i < pMappedFields.size(); i++) { RowSegmentField mappedField = pMappedFields.get(i); + + try { - if (mappedField == RowSegmentField.TITLE) { - setTitle(pValues.get(i)); - } else if (mappedField == RowSegmentField.TAXONLABEL) { - String rowTaxonLabel = pValues.get(i); + if (mappedField == RowSegmentField.TITLE) { + setTitle(pValues.get(i)); + } else if (mappedField == RowSegmentField.TAXONLABEL) { + String rowTaxonLabel = pValues.get(i); - if (rowTaxonLabel != null) { - MatrixRow row = pTaxonLabelRowMap.get(rowTaxonLabel); - setMatrixRow(row); + if (rowTaxonLabel != null) { + MatrixRow row = pTaxonLabelRowMap.get(rowTaxonLabel); + setMatrixRow(row); + } + } else if (mappedField == RowSegmentField.START_INDEX) { + setStartIndex(Integer.parseInt(pValues.get(i))); + } else if (mappedField == RowSegmentField.END_INDEX) { + setEndIndex(Integer.parseInt(pValues.get(i))); + } else if (mappedField == RowSegmentField.INST_ACRONYM) { + + Method getMethod = SpecimenLabel.class.getMethod("getInstAcronym"); + Column getColumn = getMethod.getAnnotation(Column.class); + + if (pValues.get(i).length() > getColumn.length()) { + pValues.set(i, pValues.get(i).substring(0, getColumn.length())); + pExecution.addErrorMessage("The Institutional Acroynm field was truncated due to its length"); + } + + getSpecimenLabel().setInstAcronym(pValues.get(i)); + + } else if (mappedField == RowSegmentField.COLLECTION_CODE) { + + Method getMethod = SpecimenLabel.class.getMethod("getCollectionCode"); + Column getColumn = getMethod.getAnnotation(Column.class); + + if (pValues.get(i).length() > getColumn.length()) { + pValues.set(i, pValues.get(i).substring(0, getColumn.length())); + pExecution.addErrorMessage("The Collection Code field was truncated due to its length"); + } + + getSpecimenLabel().setCollectionCode(pValues.get(i)); + + } else if (mappedField == RowSegmentField.CATALOG_NUM) { + + Method getMethod = SpecimenLabel.class.getMethod("getCatalogNumber"); + Column getColumn = getMethod.getAnnotation(Column.class); + + if (pValues.get(i).length() > getColumn.length()) { + pValues.set(i, pValues.get(i).substring(0, getColumn.length())); + pExecution.addErrorMessage("The Catalog Number field was truncated due to its length"); + } + + getSpecimenLabel().setCatalogNumber(pValues.get(i)); + + } else if (mappedField == RowSegmentField.GENBANK_ACC_NUM) { + + Method getMethod = SpecimenLabel.class.getMethod("getGenBankAccession"); + Column getColumn = getMethod.getAnnotation(Column.class); + + if (pValues.get(i).length() > getColumn.length()) { + pValues.set(i, pValues.get(i).substring(0, getColumn.length())); + pExecution.addErrorMessage("The GenBank Accession Number field was truncated due to its length"); + } + + getSpecimenLabel().setGenBankAccession(pValues.get(i)); + + } else if (mappedField == RowSegmentField.OTHER_ACC_NUM) { + + Method getMethod = SpecimenLabel.class.getMethod("getOtherAccession"); + Column getColumn = getMethod.getAnnotation(Column.class); + + if (pValues.get(i).length() > getColumn.length()) { + pValues.set(i, pValues.get(i).substring(0, getColumn.length())); + pExecution.addErrorMessage("The Other Accession Number field was truncated due to its length"); + } + + getSpecimenLabel().setOtherAccession(pValues.get(i)); + + } else if (mappedField == RowSegmentField.SAMPLE_DATE) { + getSpecimenLabel().setSampleDate( + TreebaseUtil.parseDate(pValues.get(i), true, pExecution)); + } else if (mappedField == RowSegmentField.SAMPLE_TAXONLABEL) { + setSpecimenTaxonLabelStr(pValues.get(i)); + } else if (mappedField == RowSegmentField.COLLECTOR) { + + Method getMethod = SpecimenLabel.class.getMethod("getCollector"); + Column getColumn = getMethod.getAnnotation(Column.class); + + if (pValues.get(i).length() > getColumn.length()) { + pValues.set(i, pValues.get(i).substring(0, getColumn.length())); + pExecution.addErrorMessage("The Collector field was truncated due to its length"); + } + + getSpecimenLabel().setCollector(pValues.get(i)); + + } else if (mappedField == RowSegmentField.LATITUDE) { + getSpecimenLabel() + .setLatitude(TreebaseUtil.parseDouble(pValues.get(i), pExecution)); + } else if (mappedField == RowSegmentField.LONGITUDE) { + getSpecimenLabel().setLongitude( + TreebaseUtil.parseDouble(pValues.get(i), pExecution)); + } else if (mappedField == RowSegmentField.ELEVATION) { + getSpecimenLabel().setElevation( + TreebaseUtil.parseDouble(pValues.get(i), pExecution)); + } else if (mappedField == RowSegmentField.COUNTRY) { + + Method getMethod = SpecimenLabel.class.getMethod("getCountry"); + Column getColumn = getMethod.getAnnotation(Column.class); + + int length = getColumn.length(); + + if (pValues.get(i).length() > getColumn.length()) { + pValues.set(i, pValues.get(i).substring(0, getColumn.length())); + pExecution.addErrorMessage("The Country field was truncated due to its length"); + } + + getSpecimenLabel().setCountry(pValues.get(i)); + + } else if (mappedField == RowSegmentField.STATE) { + + Method getMethod = SpecimenLabel.class.getMethod("getState"); + Column getColumn = getMethod.getAnnotation(Column.class); + + if (pValues.get(i).length() > getColumn.length()) { + pValues.set(i, pValues.get(i).substring(0, getColumn.length())); + pExecution.addErrorMessage("The State field was truncated due to its length"); + } + + getSpecimenLabel().setState(pValues.get(i)); + + } else if (mappedField == RowSegmentField.LOCALITY) { + + Method getMethod = SpecimenLabel.class.getMethod("getLocality"); + Column getColumn = getMethod.getAnnotation(Column.class); + + if (pValues.get(i).length() > getColumn.length()) { + pValues.set(i, pValues.get(i).substring(0, getColumn.length())); + pExecution.addErrorMessage("The Locality field was truncated due to its length"); + } + + getSpecimenLabel().setLocality(pValues.get(i)); } - } else if (mappedField == RowSegmentField.START_INDEX) { - setStartIndex(Integer.parseInt(pValues.get(i))); - } else if (mappedField == RowSegmentField.END_INDEX) { - setEndIndex(Integer.parseInt(pValues.get(i))); - } else if (mappedField == RowSegmentField.INST_ACRONYM) { - getSpecimenLabel().setInstAcronym(pValues.get(i)); - } else if (mappedField == RowSegmentField.COLLECTION_CODE) { - getSpecimenLabel().setCollectionCode(pValues.get(i)); - } else if (mappedField == RowSegmentField.CATALOG_NUM) { - getSpecimenLabel().setCatalogNumber(pValues.get(i)); - } else if (mappedField == RowSegmentField.GENBANK_ACC_NUM) { - getSpecimenLabel().setGenBankAccession(pValues.get(i)); - } else if (mappedField == RowSegmentField.OTHER_ACC_NUM) { - getSpecimenLabel().setOtherAccession(pValues.get(i)); - } else if (mappedField == RowSegmentField.SAMPLE_DATE) { - getSpecimenLabel().setSampleDate( - TreebaseUtil.parseDate(pValues.get(i), true, pExecution)); - } else if (mappedField == RowSegmentField.SAMPLE_TAXONLABEL) { - setSpecimenTaxonLabelStr(pValues.get(i)); - } else if (mappedField == RowSegmentField.COLLECTOR) { - getSpecimenLabel().setCollector(pValues.get(i)); - } else if (mappedField == RowSegmentField.LATITUDE) { - getSpecimenLabel() - .setLatitude(TreebaseUtil.parseDouble(pValues.get(i), pExecution)); - } else if (mappedField == RowSegmentField.LONGITUDE) { - getSpecimenLabel().setLongitude( - TreebaseUtil.parseDouble(pValues.get(i), pExecution)); - } else if (mappedField == RowSegmentField.ELEVATION) { - getSpecimenLabel().setElevation( - TreebaseUtil.parseDouble(pValues.get(i), pExecution)); - } else if (mappedField == RowSegmentField.COUNTRY) { - getSpecimenLabel().setCountry(pValues.get(i)); - } else if (mappedField == RowSegmentField.STATE) { - getSpecimenLabel().setState(pValues.get(i)); - } else if (mappedField == RowSegmentField.LOCALITY) { - getSpecimenLabel().setLocality(pValues.get(i)); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - + } } @@ -439,6 +538,7 @@ * Returns a string representation of the segment. * * @return + */ @Transient public String getSegmentData() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2011-09-22 20:50:43
|
Bugs item #3413049, was opened at 2011-09-22 16:50 Message generated for change (Tracker Item Submitted) made by sfrgpiel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126676&aid=3413049&group_id=248804 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: ui Group: None Status: Open Priority: 7 Private: No Submitted By: William Piel (sfrgpiel) Assigned to: hshyket (hshyket) Summary: Download selection of trees Initial Comment: As discussed, it would be valuable to have a button to download the current selection of trees. At a minimum, this generates a NEXUS file with the trees all in the same tree block and with the name of each tree being the tree_id. Ideally, it would build a distinct list of all taxon labels in the trees and use that to generate a taxon block and a translation table in the tree block (as in treeBlock.generateAFileDynamically). But this may prove too slow for large collections of trees, in which case it is better just to dump the nexickstring inside a trees block. Perhaps do a "number of trees" test, where fewer than 100 trees can use the TAXA BLOCK and TRANSLATION table, while more than 100 trees would just dump the newickstring. Also ideally a parallel download option would also be available if getFormat(request) == FORMAT_NEXML -- but if too hard to implement, then never mind. For a NeXML download, the tree name does not need to be substituted with the tree_id because this can be supplied as metadata. e.g. for tree_id 4105 and study_id 1000, express like so: <tree about="#Tr4105" id="Tr4105" label="ML tree" xsi:type="nex:FloatTree"> <meta href="http://purl.org/phylo/treebase/phylows/study/TB2:S1000" id="meta60715" rel="rdfs:isDefinedBy" xsi:type="nex:ResourceMeta"/> The priority is for the NEXUS download button (or the NeXML download button) to be used in the UI. But ultimately it would be great if our API had the same functionality. For example, currently a set of trees can only be viewed in RSS: http://purl.org/phylo/treebase/phylows/taxon/find?query=dcterms.title==%22Homo%20sapiens%22&format=rss1&recordSchema=tree but ideally the same query (get me all trees with humans) would be downloadable as a single NEXUS file like so: http://purl.org/phylo/treebase/phylows/taxon/find?query=dcterms.title==%22Homo%20sapiens%22&format=nexus&recordSchema=tree or NeXML like so: http://purl.org/phylo/treebase/phylows/taxon/find?query=dcterms.title==%22Homo%20sapiens%22&format=nexml&recordSchema=tree bp ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126676&aid=3413049&group_id=248804 |
From: SourceForge.net <no...@so...> - 2011-09-22 19:16:41
|
Bugs item #3410646, was opened at 2011-09-16 14:07 Message generated for change (Comment added) made by sfrgpiel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126676&aid=3410646&group_id=248804 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: ui Group: None Status: Open Priority: 8 Private: No Submitted By: William Piel (sfrgpiel) Assigned to: hshyket (hshyket) Summary: Uncaught Exception when uploading row segment file Initial Comment: There is some instability when uploading row segment files. This may have to do with return keys (unix vs mac vs win), missing values, and limits on the length of a column value. At any rate, it needs to be made more robust. Here is an example of a problem. First create a submission and upload the attached nexus file. Then try uploading the columns Row Taxon Label, Start Index, End Index, Inst. Acronym, Catalog Number, Genbank Accession, Other Accession, Collector, Country, State, Locality, Notes -- from the attached row segment file. The result is the uncaught exception. bp Uncaught Exception Encountered java.lang.IndexOutOfBoundsException: Index: 15, Size: 15 at java.util.ArrayList.rangeCheck(ArrayList.java:571) at java.util.ArrayList.get(ArrayList.java:349) at org.cipres.treebase.domain.matrix.RowSegment.update(RowSegment.java:379) at org.cipres.treebase.service.matrix.RowSegmentServiceImpl.mapToSegments(RowSegmentServiceImpl.java:380) at org.cipres.treebase.service.matrix.RowSegmentServiceImpl.createSegments(RowSegmentServiceImpl.java:287) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy75.createSegments(Unknown Source) at org.cipres.treebase.web.controllers.RowSegmentDataTableController.onSubmit(RowSegmentDataTableController.java:112) at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267) at org.springframework.web.servlet.mvc.CancellableFormController.processFormSubmission(CancellableFormController.java:140) at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265) at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:858) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:164) at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141) at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90) at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:406) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119) at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264) at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107) at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274) at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274) at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:217) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274) at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:191) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274) at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148) at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:90) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:837) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286) at java.lang.Thread.run(Thread.java:636) Cookies: __utmz=[5099126.1305666484.1.1.utmcsr] __utmc=[5099126] __utmb=[5099126.43.9.1316195477908] __utma=[5099126.226138284.1305666484.1316186851.1316194155.50] itemToHighlight=[http%3A//treebase-dev.nescent.org/treebase-web/user/matrixList.html] JSESSIONID=[4660E6A549004EB9B896A6CDBB35A18D] __utmz=[53240375.1315795401.152.31.utmccn] __utma=[53240375.1924499357.1236724314.1315764093.1315795401.152] ---------------------------------------------------------------------- >Comment By: William Piel (sfrgpiel) Date: 2011-09-22 15:16 Message: Thanks for the fix. A new problem: trying the upload the attached row segment file still causes a problem because one of the "other accession number" column has a value that exceeds the schema size. This needs fixing: crop incoming data, perhaps providing a warning that some values were cropped. bp Data Access Failure Could not execute JDBC batch update; nested exception is org.hibernate.exception.DataException: Could not execute JDBC batch update org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.DataException: Could not execute JDBC batch update Caused by: org.hibernate.exception.DataException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:578) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:314) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy75.createSegments(Unknown Source) at org.cipres.treebase.web.controllers.RowSegmentDataTableController.onSubmit(RowSegmentDataTableController.java:112) at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267) at org.springframework.web.servlet.mvc.CancellableFormController.processFormSubmission(CancellableFormController.java:140) at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265) at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:858) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:164) at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141) at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90) at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:406) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119) at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264) at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107) at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274) at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274) at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:217) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274) at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:191) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274) at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148) at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:90) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:837) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286) at java.lang.Thread.run(Thread.java:636) Caused by: java.sql.BatchUpdateException: Batch entry 8 insert into ROWSEGMENT (VERSION, EndIndex, MATRIXROW_ID, CatalogNum, CollectionCode, Collector, Country, Elevation, GenBAccession, InstAcronym, Latitude, Locality, Longitude, Notes, OtherAccession, SampleDate, State, StartIndex, TAXONLABEL_ID, Title, ROWSEGMENT_ID) values (0, 852, 764320, , NULL, NULL, France, NULL, EU041861, , NULL, NULL, NULL, NULL, CBS 157.54; ATCC 15680; MUCL 1081; MUCL 7992; MUCL 15756, NULL, , 1, NULL, NULL, 9264) was aborted. Call getNextException to see the cause. at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2537) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1328) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:351) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2674) at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246) ... 75 more ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126676&aid=3410646&group_id=248804 |
From: <hs...@us...> - 2011-09-20 15:17:04
|
Revision: 962 http://treebase.svn.sourceforge.net/treebase/?rev=962&view=rev Author: hshyket Date: 2011-09-20 15:16:58 +0000 (Tue, 20 Sep 2011) Log Message: ----------- Correcting issue where row segment file can still be uploaded even if the proper amount of tabs are not present (adds tabs to make sure there are 19) Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/service/matrix/RowSegmentServiceImpl.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/service/matrix/RowSegmentServiceImpl.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/service/matrix/RowSegmentServiceImpl.java 2011-09-15 19:37:28 UTC (rev 961) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/service/matrix/RowSegmentServiceImpl.java 2011-09-20 15:16:58 UTC (rev 962) @@ -276,7 +276,20 @@ TSVFileParser parser = new TSVFileParser(); List<List<String>> values = parser.parseFile(pFile, pSkipFirstRow, returnVal); - + + //checks to make sure there are 19 tabs present in each list + for (int x = 0; x < values.size(); x++) { + + if (values.get(x).size() < 19) { + + for (int y = values.get(x).size(); y < 19; y++ ) { + + values.get(x).add(""); + + } + } + } + // check whether parsing is successful: if (returnVal.isSuccessful()) { List<RowSegment> newRS = new ArrayList<RowSegment>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |