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: <rv...@us...> - 2009-07-02 10:47:58
|
Revision: 160
http://treebase.svn.sourceforge.net/treebase/?rev=160&view=rev
Author: rvos
Date: 2009-07-02 10:47:20 +0000 (Thu, 02 Jul 2009)
Log Message:
-----------
Adding a controller that prepares a generic SearchResults object for display in an RSS1.0 file. This controller expects there to be a "searchResults" session variable (i.e. req.getSession().getAttribute("searchResults")) as stored by the search controllers to be in the environment.
Added Paths:
-----------
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchResultsAsRDFController.java
Added: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchResultsAsRDFController.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchResultsAsRDFController.java (rev 0)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchResultsAsRDFController.java 2009-07-02 10:47:20 UTC (rev 160)
@@ -0,0 +1,118 @@
+/**
+ *
+ */
+package org.cipres.treebase.web.controllers;
+
+import java.net.URLEncoder;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.cipres.treebase.NamespacedGUID;
+import org.cipres.treebase.PhyloWSPath;
+import org.cipres.treebase.TreebaseIDString;
+import org.cipres.treebase.TreebaseUtil;
+import org.cipres.treebase.domain.matrix.Matrix;
+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.study.Study;
+import org.cipres.treebase.domain.tree.PhyloTree;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+import org.z3950.zing.cql.CQLNode;
+import org.z3950.zing.cql.CQLParser;
+
+/**
+ * @author rvosa
+ *
+ */
+public class SearchResultsAsRDFController implements Controller {
+
+ public ModelAndView handleRequest(HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ SearchResultsFrozen frozenResults = (SearchResultsFrozen) request.getSession().getAttribute("searchResults");
+ if ( null != frozenResults ) {
+ String phyloWSPath = request.getSession().getAttribute("originalSection") + "/find";
+ SearchResults<?> searchResults = frozenResults.thaw();
+ request.getSession().setAttribute("searchResultsThawed", searchResults);
+// SearchResultsType searchResultsType = searchResults.getResultType();
+// switch(searchResultsType) {
+// case NONE : phyloWSPath = ""; break;
+// case STUDY : phyloWSPath = "study/find"; break;
+// case MATRIX : phyloWSPath = "matrix/find"; break;
+// case TREE : phyloWSPath = "tree/find"; break;
+// case TAXON : phyloWSPath = "taxon/find"; break;
+// }
+
+ StringBuffer domainAddress = new StringBuffer("http://");
+ domainAddress
+ .append(request.getServerName())
+ .append(':')
+ .append(request.getServerPort());
+ StringBuffer baseURL = new StringBuffer(domainAddress);
+ baseURL.append("/treebase-web/phylows");
+ request.getSession().setAttribute("recordSchema", request.getSession().getAttribute("recordSchema"));
+ request.getSession().setAttribute("format", "rss1");
+ request.getSession().setAttribute("baseURL", baseURL.toString());
+ request.getSession().setAttribute("domainAddress", domainAddress.toString());
+ request.getSession().setAttribute("phyloWSPath", phyloWSPath);
+ if ( null != request.getParameter("query") ) {
+ String query = request.getParameter("query");
+ if ( ! TreebaseUtil.isEmpty(query) ) {
+ CQLParser parser = new CQLParser();
+ CQLNode root = parser.parse(query);
+ request.getSession().setAttribute("normalizedCQLQuery", URLEncoder.encode(root.toCQL(),"UTF-8"));
+ }
+ }
+ }
+ return new ModelAndView("searchResultsAsRDF");
+
+
+ /*
+
+ NamespacedGUID namespacedGUID = new NamespacedGUID(request.getParameter("namespacedGUID"));
+ TreebaseIDString treebaseIDString = null;
+ PhyloWSPath phyloWSPath = null;
+ request.setAttribute("hasWebPage", false);
+ request.setAttribute("hasNexus", false);
+ request.setAttribute("hasNeXML", false);
+ request.setAttribute("hasRdf", false);
+ try {
+ treebaseIDString = namespacedGUID.getTreebaseIDString();
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ if ( null != treebaseIDString ) {
+ if ( null != treebaseIDString.getTypePrefix() ) {
+ Class<?> theClass = TreebaseIDString.getClassForPrefix(treebaseIDString.getTypePrefix());
+ if ( null != theClass ) {
+ if ( theClass.isAssignableFrom(PhyloTree.class)
+ || theClass.isAssignableFrom(Matrix.class)
+ || theClass.isAssignableFrom(Study.class) ) {
+ request.setAttribute("hasWebPage", true);
+ request.setAttribute("hasNexus", true);
+ request.setAttribute("hasNeXML", true);
+ request.setAttribute("hasRdf", true);
+ }
+ phyloWSPath = new PhyloWSPath(theClass.getPackage(),namespacedGUID);
+ }
+ }
+ }
+ request.getSession().setAttribute("namespacedGUID", namespacedGUID.toString());
+ // <c:set var="baseURL" value="http://localhost:8080/treebase-web/PhyloWS"/>
+ StringBuffer domainAddress = new StringBuffer("http://");
+ domainAddress
+ .append(request.getServerName())
+ .append(':')
+ .append(request.getServerPort());
+ StringBuffer baseURL = new StringBuffer(domainAddress);
+ baseURL.append("/treebase-web/phylows");
+ request.getSession().setAttribute("baseURL", baseURL.toString());
+ request.getSession().setAttribute("domainAddress", domainAddress.toString());
+ request.getSession().setAttribute("phyloWSPath", phyloWSPath);
+ return new ModelAndView("anyObjectAsRDF");
+ */
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-07-02 10:43:55
|
Revision: 159
http://treebase.svn.sourceforge.net/treebase/?rev=159&view=rev
Author: rvos
Date: 2009-07-02 10:43:46 +0000 (Thu, 02 Jul 2009)
Log Message:
-----------
Major refactoring to facilitate CQL queries and RSS1.0 result sets
Modified Paths:
--------------
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/MatrixSearchController.java
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/StudySearchController.java
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TaxonSearchController.java
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TreeSearchController.java
Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/MatrixSearchController.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/MatrixSearchController.java 2009-07-02 10:41:25 UTC (rev 158)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/MatrixSearchController.java 2009-07-02 10:43:46 UTC (rev 159)
@@ -20,13 +20,16 @@
package org.cipres.treebase.web.controllers;
+import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
+import org.cipres.treebase.TreebaseUtil;
import org.cipres.treebase.RangeExpression.MalformedRangeExpression;
import org.cipres.treebase.domain.matrix.CharacterMatrix;
import org.cipres.treebase.domain.matrix.Matrix;
@@ -34,11 +37,21 @@
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.TreeSearchResults;
import org.cipres.treebase.web.Constants;
import org.cipres.treebase.web.util.RequestMessageSetter;
import org.cipres.treebase.web.util.SearchMessageSetter;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
+import org.z3950.zing.cql.CQLAndNode;
+import org.z3950.zing.cql.CQLBooleanNode;
+import org.z3950.zing.cql.CQLNode;
+import org.z3950.zing.cql.CQLNotNode;
+import org.z3950.zing.cql.CQLOrNode;
+import org.z3950.zing.cql.CQLParseException;
+import org.z3950.zing.cql.CQLParser;
+import org.z3950.zing.cql.CQLRelation;
+import org.z3950.zing.cql.CQLTermNode;
/**
* MatrixSearchController.java
@@ -72,50 +85,162 @@
clearMessages(request);
String formName = request.getParameter("formName");
+ String query = request.getParameter("query");
LOGGER.info("formName is '" + formName + "'");
-
+ if ( ! TreebaseUtil.isEmpty(query) ) {
+ /*
+ CQLParser parser = new CQLParser();
+ CQLNode root = parser.parse(query);
+ root = normalizeParseTree(root);
+ Set<Matrix> queryResults = doCQLQuery(root, new HashSet<Matrix>(),request, response, errors);
+ MatrixSearchResults tsr = new MatrixSearchResults(queryResults);
+ saveSearchResults(request, tsr);
+ if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
+ return new ModelAndView("search/matrixSearch", Constants.RESULT_SET, tsr);
+ }
+ else {
+ return this.searchResultsAsRDF(tsr, request, root);
+ }
+ */
+ return this.handleQueryRequest(request, response, errors);
+ }
+
if (formName.equals("matrixSimple")) {
String buttonName = request.getParameter("searchButton");
-
+ Set<Matrix> matches = new HashSet<Matrix>();
+ String searchTerm = convertStars(request.getParameter("searchTerm"));
+ SearchMessageSetter mSetter = new RequestMessageSetter(request);
+ MatrixSearchResults oldRes;
+ {
+ SearchResults<?> sr = searchResults(request);
+ if (sr != null) {
+ oldRes = (MatrixSearchResults) sr.convertToMatrices();
+ } else {
+ oldRes = new MatrixSearchResults (); // TODO: Convert existing search results to new type
+ }
+ }
if (buttonName.equals("matrixID")) {
- return doSearch(request, response, SearchType.byID, errors);
+ matches.addAll(doSearch(request, response, SearchType.byID, errors,searchTerm));
} else if (buttonName.equals("matrixTitle")) {
- return doSearch(request, response, SearchType.byTitle, errors);
+ matches.addAll(doSearch(request, response, SearchType.byTitle, errors,searchTerm));
} else if (buttonName.equals("matrixType")) {
- return doSearch(request, response, SearchType.byType, errors);
+ matches.addAll(doSearch(request, response, SearchType.byType, errors,searchTerm));
} else if (buttonName.equals("matrixNTAX")) {
- return doSearch(request, response, SearchType.byNTAX, errors);
+ matches.addAll(doSearch(request, response, SearchType.byNTAX, errors,searchTerm));
} else if (buttonName.equals("matrixNCHAR")) {
- return doSearch(request, response, SearchType.byNCHAR, errors);
+ matches.addAll(doSearch(request, response, SearchType.byNCHAR, errors,searchTerm));
} else {
throw new Error("Unknown search button name '" + buttonName + "'");
}
- } else {
+ if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
+ SearchResults<Matrix> newRes = intersectSearchResults(oldRes,
+ new MatrixSearchResults(matches), mSetter, "No matching matrices found");
+ saveSearchResults(request, newRes);
+ return new ModelAndView("search/matrixSearch", Constants.RESULT_SET, newRes);
+ }
+ else {
+ return this.searchResultsAsRDF(new MatrixSearchResults(matches), request, null, "matrix", "matrix");
+ }
+ }
+
+ else {
return super.onSubmit(request, response, command, errors);
}
}
- private ModelAndView doSearch(
+ private Set<Matrix> doCQLQuery(
+ CQLNode node,
+ Set<Matrix> results,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ BindException errors
+ ) throws InstantiationException {
+ if ( node instanceof CQLBooleanNode ) {
+ Set<Matrix> resultsLeft = doCQLQuery(((CQLBooleanNode)node).left,results, request, response, errors);
+ Set<Matrix> resultsRight = doCQLQuery(((CQLBooleanNode)node).right,results, request, response, errors);
+ if ( node instanceof CQLNotNode ) {
+ for ( Matrix rightMatrix : resultsRight ) {
+ if ( resultsLeft.contains(rightMatrix) )
+ resultsLeft.remove(rightMatrix);
+ }
+ }
+ else if ( node instanceof CQLOrNode ) {
+ resultsLeft.addAll(resultsRight);
+ }
+ else if ( node instanceof CQLAndNode ) {
+ Set<Matrix> resultsUnion = new HashSet<Matrix>();
+ for ( Matrix leftMatrix : resultsLeft ) {
+ if ( resultsRight.contains(leftMatrix) )
+ resultsUnion.add(leftMatrix);
+ }
+ resultsLeft = resultsUnion;
+ }
+ results = resultsLeft;
+ }
+ else if ( node instanceof CQLTermNode ) {
+ CQLTermNode term = (CQLTermNode)node;
+ String index = term.getIndex();
+ if ( index.startsWith("tb.title") ) {
+ results.addAll(doSearch(request, response, SearchType.byTitle, errors, term.getTerm()));
+ } else if ( index.startsWith("tb.identifier") ) {
+ results.addAll(doSearch(request, response, SearchType.byID, errors, term.getTerm()));
+ } else if ( index.startsWith("tb.type") ) {
+ results.addAll(doSearch(request, response, SearchType.byType, errors, term.getTerm()));
+ } else if ( index.startsWith("tb.ntax") ) {
+ results.addAll(doSearch(request, response, SearchType.byNTAX, errors, term.getTerm()));
+ } else if ( index.startsWith("tb.nchar") ) {
+ results.addAll(doSearch(request, response, SearchType.byNTAX, errors, term.getTerm()));
+ } else {
+ // issue warnings
+ addMessage(request, "Unsupported index: " + index);
+ }
+ }
+ logger.debug(node);
+ return results;
+ }
+
+ private CQLNode normalizeParseTree(CQLNode node) {
+ if ( node instanceof CQLBooleanNode ) {
+ ((CQLBooleanNode)node).left = normalizeParseTree(((CQLBooleanNode)node).left);
+ ((CQLBooleanNode)node).right = normalizeParseTree(((CQLBooleanNode)node).right);
+ return node;
+ }
+ else if ( node instanceof CQLTermNode ) {
+ String index = ((CQLTermNode)node).getIndex();
+ String term = ((CQLTermNode)node).getTerm();
+ CQLRelation relation = ((CQLTermNode)node).getRelation();
+ index = index.replaceAll("dcterms.title", "tb.title.matrix");
+ index = index.replaceAll("dcterms.identifier", "tb.identifier.matrix");
+ index = index.replaceAll("dcterms.extent", "tb.ntax.matrix");
+ return new CQLTermNode(index,relation,term);
+ }
+ logger.debug(node);
+ return node;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Collection<Matrix> doSearch(
HttpServletRequest request,
HttpServletResponse response,
SearchType searchType,
- BindException errors) throws InstantiationException {
+ BindException errors,
+ String searchTerm) throws InstantiationException {
- String searchTerm = convertStars(request.getParameter("searchTerm"));
- String keywordSearchTerm = "%" + searchTerm + "%";
- SearchMessageSetter mSetter = new RequestMessageSetter(request);
+// String searchTerm = convertStars(request.getParameter("searchTerm"));
+// String keywordSearchTerm = "%" + searchTerm + "%";
+// SearchMessageSetter mSetter = new RequestMessageSetter(request);
- MatrixSearchResults oldRes;
- {
- SearchResults<?> sr = searchResults(request);
- if (sr != null) {
- oldRes = (MatrixSearchResults) sr.convertToMatrices();
- } else {
- oldRes = new MatrixSearchResults (); // TODO: Convert existing search results to new type
- }
- }
+// MatrixSearchResults oldRes;
+// {
+// SearchResults<?> sr = searchResults(request);
+// if (sr != null) {
+// oldRes = (MatrixSearchResults) sr.convertToMatrices();
+// } else {
+// oldRes = new MatrixSearchResults (); // TODO: Convert existing search results to new type
+// }
+// }
Collection<Matrix> matches = null;
MatrixService matrixService = getSearchService().getMatrixService();
@@ -164,13 +289,14 @@
}
}
matches.removeAll(orphanedMatrices);
-
- SearchResults<Matrix> newRes = intersectSearchResults(oldRes,
- new MatrixSearchResults(matches), mSetter, "No matching matrices found");
-
- saveSearchResults(request, newRes);
+ return matches;
- return new ModelAndView("search/matrixSearch", Constants.RESULT_SET, newRes);
+// SearchResults<Matrix> newRes = intersectSearchResults(oldRes,
+// new MatrixSearchResults(matches), mSetter, "No matching matrices found");
+//
+// saveSearchResults(request, newRes);
+//
+// return new ModelAndView("search/matrixSearch", Constants.RESULT_SET, newRes);
}
@@ -183,4 +309,36 @@
return "matrixSearch.html";
}
+ @Override
+ protected ModelAndView handleQueryRequest(HttpServletRequest request,HttpServletResponse response,BindException errors) throws CQLParseException, IOException, InstantiationException {
+ String query = request.getParameter("query");
+ CQLParser parser = new CQLParser();
+ CQLNode root = parser.parse(query);
+ root = normalizeParseTree(root);
+ Set<Matrix> queryResults = doCQLQuery(root, new HashSet<Matrix>(),request, response, errors);
+ MatrixSearchResults tsr = new MatrixSearchResults(queryResults);
+ saveSearchResults(request, tsr);
+ if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
+ return new ModelAndView("search/matrixSearch", Constants.RESULT_SET, tsr);
+ }
+ else {
+ SearchResults<?> res = tsr;
+ String schema = null, original = "matrix";
+ if ( ! TreebaseUtil.isEmpty(request.getParameter("recordSchema")) ) {
+ schema = request.getParameter("recordSchema");
+ if ( schema.equals("tree") ) {
+ res = tsr.convertToTrees();
+ }
+ else if ( schema.equals("taxon") ) {
+ res = tsr.convertToTaxa();
+ }
+ else if ( schema.equals("study") ) {
+ res = tsr.convertToStudies();
+ }
+ }
+ this.saveSearchResults(request, res);
+ return this.searchResultsAsRDF(res, request, root, schema, original);
+ }
+ }
+
}
Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java 2009-07-02 10:41:25 UTC (rev 158)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java 2009-07-02 10:43:46 UTC (rev 159)
@@ -70,29 +70,33 @@
+ "', should be /${class}/${NamespacedGUID}");
}
String[] pathComponents = pathInfo.split("/");
- String rawNamespacedGUID = pathComponents[pathComponents.length-1];
- if ( rawNamespacedGUID.startsWith("uBio:") ) {
- url = uBioBaseUrl + rawNamespacedGUID.substring("uBio:".length());
- }
- else if ( rawNamespacedGUID.startsWith("NCBI:") ) {
- url = ncbiBaseUrl + rawNamespacedGUID.substring("NCBI:".length());
- }
- else {
- NamespacedGUID namespacedGUID = new NamespacedGUID(rawNamespacedGUID);
- TreebaseIDString tbID = namespacedGUID.getTreebaseIDString();
- if ( hasWebPage(pathComponents) ) {
- if ( TreebaseUtil.isEmpty(req.getParameter(format)) ) {
- url = domain + "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
- }
- else if ( req.getParameter(format).equals("html") ) {
- url = domain + createUrl(tbID.getTypePrefix(),tbID.getId());
- }
- else {
- url = domain + createDownloadUrl(tbID.getTypePrefix(),tbID.getId(),req.getParameter(format));
- }
+ if ( pathComponents[pathComponents.length-1].equals("find") ) {
+ url = domain + createSearchUrl(pathComponents[pathComponents.length-2],req);
+ } else {
+ String rawNamespacedGUID = pathComponents[pathComponents.length-1];
+ if ( rawNamespacedGUID.startsWith("uBio:") ) {
+ url = uBioBaseUrl + rawNamespacedGUID.substring("uBio:".length());
}
+ else if ( rawNamespacedGUID.startsWith("NCBI:") ) {
+ url = ncbiBaseUrl + rawNamespacedGUID.substring("NCBI:".length());
+ }
else {
- url = domain + "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
+ NamespacedGUID namespacedGUID = new NamespacedGUID(rawNamespacedGUID);
+ TreebaseIDString tbID = namespacedGUID.getTreebaseIDString();
+ if ( hasWebPage(pathComponents) ) {
+ if ( TreebaseUtil.isEmpty(req.getParameter(format)) ) {
+ url = domain + "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
+ }
+ else if ( req.getParameter(format).equals("html") ) {
+ url = domain + createUrl(tbID.getTypePrefix(),tbID.getId());
+ }
+ else {
+ url = domain + createDownloadUrl(tbID.getTypePrefix(),tbID.getId(),req.getParameter(format));
+ }
+ }
+ else {
+ url = domain + "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
+ }
}
}
} catch ( MalformedTreebaseIDString e ) {
@@ -109,6 +113,20 @@
return null;
}
+ private String createSearchUrl(String path,HttpServletRequest request) {
+ StringBuilder sb = new StringBuilder();
+ sb
+ .append("/treebase-web/search/")
+ .append(path)
+ .append("Search.html?query=")
+ .append(request.getParameter("query"))
+ .append("&format=")
+ .append(request.getParameter("format"))
+ .append("&recordSchema=")
+ .append(request.getParameter("recordSchema"));
+ return sb.toString();
+ }
+
private boolean hasWebPage(String[] pathComponents) {
for ( int i = ( pathComponents.length - 1 ); i >= 0; i-- ) {
for ( int j = 0; j < classesWithPages.length; j++ ) {
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 2009-07-02 10:41:25 UTC (rev 158)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchController.java 2009-07-02 10:43:46 UTC (rev 159)
@@ -22,6 +22,9 @@
package org.cipres.treebase.web.controllers;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -50,6 +53,8 @@
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;
+import org.z3950.zing.cql.CQLNode;
+import org.z3950.zing.cql.CQLParseException;
/**
@@ -65,6 +70,8 @@
protected String formView;
private TaxonLabelService mTaxonLabelService;
+
+ protected abstract ModelAndView handleQueryRequest(HttpServletRequest request,HttpServletResponse response,BindException errors) throws CQLParseException, IOException, InstantiationException;
protected ModelAndView onSubmit(
HttpServletRequest request,
@@ -110,6 +117,33 @@
return selectResultsView(request);
}
+ protected ModelAndView searchResultsAsRDF (SearchResults<?> searchResults,HttpServletRequest request,CQLNode root, String schema, String original) throws UnsupportedEncodingException {
+ //${baseURL}
+ //${phyloWSPath}
+ //${normalizedCQLQuery}
+ //${searchResults}
+ //${domainAddress}
+ String phyloWSPath = "find/" + original;
+ request.getSession().setAttribute("searchResultsThawed", searchResults);
+ StringBuffer domainAddress = new StringBuffer("http://");
+ domainAddress
+ .append(request.getServerName())
+ .append(':')
+ .append(request.getServerPort());
+ StringBuffer baseURL = new StringBuffer(domainAddress);
+ baseURL.append("/treebase-web/phylows");
+ request.getSession().setAttribute("recordSchema", schema);
+ request.getSession().setAttribute("format", request.getParameter("format"));
+ request.getSession().setAttribute("baseURL", baseURL.toString());
+ request.getSession().setAttribute("domainAddress", domainAddress.toString());
+ request.getSession().setAttribute("phyloWSPath", phyloWSPath);
+ request.getSession().setAttribute("originalSection", original);
+ if ( null != root ) {
+ request.getSession().setAttribute("normalizedCQLQuery", URLEncoder.encode(root.toCQL(),"UTF-8"));
+ }
+ return new ModelAndView(new RedirectView("searchResultsAsRDF.html"));
+ }
+
protected <E extends TBPersistable> SearchResults<E> intersectSearchResults(
SearchResults<E> oldRes,
SearchResults<E> newRes,
@@ -380,6 +414,10 @@
protected ModelAndView showForm(HttpServletRequest request,
HttpServletResponse response, BindException bindException, Map model)
throws Exception {
+ String query = request.getParameter("query");
+ if ( query != null ) {
+ return this.handleQueryRequest(request, response, bindException);
+ }
String action = request.getParameter("action");
if (action != null && action.equals("discard") && request.getMethod().equals("GET")) {
discardSearchResults(request);
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 2009-07-02 10:41:25 UTC (rev 158)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/StudySearchController.java 2009-07-02 10:43:46 UTC (rev 159)
@@ -20,27 +20,36 @@
package org.cipres.treebase.web.controllers;
+import java.io.IOException;
import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.cipres.treebase.TreebaseIDString;
+import org.cipres.treebase.TreebaseUtil;
import org.cipres.treebase.TreebaseIDString.MalformedTreebaseIDString;
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.study.Study;
import org.cipres.treebase.domain.study.StudyService;
-import org.cipres.treebase.domain.taxon.TaxonLabel;
-import org.cipres.treebase.domain.taxon.TaxonVariant;
import org.cipres.treebase.web.Constants;
import org.cipres.treebase.web.util.RequestMessageSetter;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
+import org.z3950.zing.cql.CQLAndNode;
+import org.z3950.zing.cql.CQLBooleanNode;
+import org.z3950.zing.cql.CQLNode;
+import org.z3950.zing.cql.CQLNotNode;
+import org.z3950.zing.cql.CQLOrNode;
+import org.z3950.zing.cql.CQLParseException;
+import org.z3950.zing.cql.CQLParser;
+import org.z3950.zing.cql.CQLRelation;
+import org.z3950.zing.cql.CQLTermNode;
/**
* StudySearchController.java
@@ -99,13 +108,41 @@
clearMessages(request);
String formName = request.getParameter("formName");
+ String query = request.getParameter("query");
LOGGER.info("formName is '" + formName + "'");
+ if ( ! TreebaseUtil.isEmpty(query) ) {
+ /*
+ CQLParser parser = new CQLParser();
+ CQLNode root = parser.parse(query);
+ root = normalizeParseTree(root);
+ Set<Study> queryResults = doCQLQuery(root, new HashSet<Study>(),request, response, errors);
+ StudySearchResults tsr = new StudySearchResults(queryResults);
+ saveSearchResults(request, tsr);
+ if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
+ return new ModelAndView("search/studySearch", Constants.RESULT_SET, tsr);
+ }
+ else {
+ return this.searchResultsAsRDF(tsr, request, root);
+ }
+ */
+ return this.handleQueryRequest(request, response, errors);
+ }
+
if (formName.equals("searchKeyword")) {
SearchType searchType;
String buttonName = request.getParameter("searchButton");
-
+ String searchTerm = convertStars(request.getParameter("searchTerm"));
+ StudySearchResults oldRes;
+ {
+ SearchResults<?> sr = searchResults(request);
+ if (sr != null) {
+ oldRes = (StudySearchResults) sr.convertToStudies();
+ } else {
+ oldRes = new StudySearchResults (); // TODO: Convert existing search results to new type
+ }
+ }
if (buttonName.equals("authorKeyword")) {
searchType = SearchType.byAuthorName;
} else if (buttonName.equals("studyID")) {
@@ -123,84 +160,171 @@
} else {
throw new Error("Unknown search button name '" + buttonName + "'");
}
-
- return doSearch(request, response, searchType, errors);
+ Collection<Study> matches = doSearch(request, response, searchType, errors,searchTerm);
+ if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
+ SearchResults<Study> newRes = intersectSearchResults(oldRes, new StudySearchResults(matches),
+ new RequestMessageSetter(request), "No matching studies found");
+ saveSearchResults(request, newRes);
+ return new ModelAndView("search/studySearch", Constants.RESULT_SET, newRes);
+ }
+ else {
+ return this.searchResultsAsRDF(new StudySearchResults(matches), request, null,"study","study");
+ }
} else {
return super.onSubmit(request, response, command, errors);
}
}
- protected ModelAndView doSearch(
+ private Set<Study> doCQLQuery(
+ CQLNode node,
+ Set<Study> results,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ BindException errors
+ ) throws InstantiationException {
+ if ( node instanceof CQLBooleanNode ) {
+ Set<Study> resultsLeft = doCQLQuery(((CQLBooleanNode)node).left,results, request, response, errors);
+ Set<Study> resultsRight = doCQLQuery(((CQLBooleanNode)node).right,results, request, response, errors);
+ if ( node instanceof CQLNotNode ) {
+ Set<Study> resultsDifference = new HashSet<Study>();
+ for ( Study leftStudy : resultsLeft ) {
+ if ( ! resultsRight.contains(leftStudy) )
+ resultsDifference.add(leftStudy);
+ }
+ resultsLeft = resultsDifference;
+ }
+ else if ( node instanceof CQLOrNode ) {
+ resultsLeft.addAll(resultsRight);
+ }
+ else if ( node instanceof CQLAndNode ) {
+ Set<Study> resultsUnion = new HashSet<Study>();
+ for ( Study leftStudy : resultsLeft ) {
+ if ( resultsRight.contains(leftStudy) )
+ resultsUnion.add(leftStudy);
+ }
+ resultsLeft = resultsUnion;
+ }
+ results = resultsLeft;
+ }
+ else if ( node instanceof CQLTermNode ) {
+ CQLTermNode term = (CQLTermNode)node;
+ String index = term.getIndex();
+ if ( index.startsWith("tb.title") ) {
+ results.addAll(doSearch(request, response, SearchType.byTitle, errors, term.getTerm()));
+ } else if ( index.equals("tb.identifier.study") ) {
+ results.addAll(doSearch(request, response, SearchType.byID, errors, term.getTerm()));
+ } else if ( index.startsWith("dcterms.contributor") ) {
+ results.addAll(doSearch(request, response, SearchType.byAuthorName, errors, term.getTerm()));
+ } else if ( index.startsWith("dcterms.abstract") ) {
+ results.addAll(doSearch(request, response, SearchType.inAbstract, errors, term.getTerm()));
+ } else if ( index.startsWith("dcterms.subject") ) {
+ results.addAll(doSearch(request, response, SearchType.byKeyword, errors, term.getTerm()));
+ } else if ( index.startsWith("dcterms.bibliographicCitation") ) {
+ results.addAll(doSearch(request, response, SearchType.inCitation, errors, term.getTerm()));
+ } else if ( index.equals("tb.identifier.study.tb1") ) {
+ results.addAll(doSearch(request, response, SearchType.byLegacyID, errors, term.getTerm()));
+ } else {
+ // issue warnings
+ addMessage(request, "Unsupported index: " + index);
+ }
+ }
+ logger.debug(node);
+ return results;
+ }
+
+ private CQLNode normalizeParseTree(CQLNode node) {
+ if ( node instanceof CQLBooleanNode ) {
+ ((CQLBooleanNode)node).left = normalizeParseTree(((CQLBooleanNode)node).left);
+ ((CQLBooleanNode)node).right = normalizeParseTree(((CQLBooleanNode)node).right);
+ return node;
+ }
+ else if ( node instanceof CQLTermNode ) {
+ String index = ((CQLTermNode)node).getIndex();
+ String term = ((CQLTermNode)node).getTerm();
+ CQLRelation relation = ((CQLTermNode)node).getRelation();
+ index = index.replaceAll("dcterms.title", "tb.title.study");
+ index = index.replaceAll("dcterms.identifier", "tb.identifier.study");
+ return new CQLTermNode(index,relation,term);
+ }
+ logger.debug(node);
+ return node;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Collection<Study> doSearch(
HttpServletRequest request,
HttpServletResponse response,
SearchType searchType,
- BindException errors) throws InstantiationException {
+ BindException errors,
+ String searchTerm) throws InstantiationException {
- String searchTerm = convertStars(request.getParameter("searchTerm"));
+// String searchTerm = convertStars(request.getParameter("searchTerm"));
String keywordSearchTerm = "%" + searchTerm + "%";
- StudySearchResults oldRes;
-
- {
- SearchResults<?> sr = searchResults(request);
- if (sr != null) {
- oldRes = (StudySearchResults) sr.convertToStudies();
- } else {
- oldRes = new StudySearchResults (); // TODO: Convert existing search results to new type
- }
- }
-
- LOGGER.info("doSearch old results contained " + oldRes.size() + " item(s)");
+// StudySearchResults oldRes;
+//
+// {
+// SearchResults<?> sr = searchResults(request);
+// if (sr != null) {
+// oldRes = (StudySearchResults) sr.convertToStudies();
+// } else {
+// oldRes = new StudySearchResults (); // TODO: Convert existing search results to new type
+// }
+// }
+//
+// LOGGER.info("doSearch old results contained " + oldRes.size() + " item(s)");
Collection<Study> matches;
StudyService studyService = getSearchService().getStudyService();
switch (searchType) {
- case byID:
- matches = (Collection<Study>) doSearchByIDString(request, studyService, Study.class, searchTerm);
- break;
- case byLegacyID:
- {
- TreebaseIDString legacyID = null;
- boolean malformed = false;
- try {
- legacyID = new TreebaseIDString(searchTerm, Study.class);
- } catch (MalformedTreebaseIDString e) {
- malformed = true;
+ case byID:
+ matches = (Collection<Study>) doSearchByIDString(request, studyService, Study.class, searchTerm);
+ break;
+ case byLegacyID:
+ {
+ TreebaseIDString legacyID = null;
+ boolean malformed = false;
+ try {
+ legacyID = new TreebaseIDString(searchTerm, Study.class);
+ } catch (MalformedTreebaseIDString e) {
+ malformed = true;
+ }
+ if (malformed || legacyID.getTBClass() != Study.class) {
+ addMessage(request, "Legacy ID number '" + searchTerm + "' is not valid; try S#### or just ####");
+ matches = null;
+ break;
+ }
+ matches = (Collection<Study>) studyService.findByTBStudyID("S" + legacyID.getId().toString());
+ break;
}
- if (malformed || legacyID.getTBClass() != Study.class) {
- addMessage(request, "Legacy ID number '" + searchTerm + "' is not valid; try S#### or just ####");
- matches = null;
+ case inAbstract:
+ matches = studyService.findByAbstract(keywordSearchTerm);
break;
- }
- matches = (Collection<Study>) studyService.findByTBStudyID("S" + legacyID.getId().toString());
- break;
+ case inCitation:
+ matches = studyService.findByCitation(keywordSearchTerm);
+ break;
+ case byAuthorName:
+ matches = studyService.findByAuthor(searchTerm);
+ break;
+ case byTitle:
+ matches = studyService.findByTitle(keywordSearchTerm);
+ break;
+ case byKeyword:
+ matches = studyService.findByKeyword(keywordSearchTerm);
+ break;
+ default:
+ throw new Error ("Unknown search type '" + searchType + "'");
}
- case inAbstract:
- matches = studyService.findByAbstract(keywordSearchTerm);
- break;
- case inCitation:
- matches = studyService.findByCitation(keywordSearchTerm);
- break;
- case byAuthorName:
- matches = studyService.findByAuthor(searchTerm);
- break;
- case byTitle:
- matches = studyService.findByTitle(keywordSearchTerm);
- break;
- case byKeyword:
- matches = studyService.findByKeyword(keywordSearchTerm);
- break;
- default:
- throw new Error ("Unknown search type '" + searchType + "'");
- }
- SearchResults<Study> newRes = intersectSearchResults(oldRes, new StudySearchResults(matches),
- new RequestMessageSetter(request), "No matching studies found");
-
- saveSearchResults(request, newRes);
-
- return new ModelAndView("search/studySearch", Constants.RESULT_SET, newRes);
+ return matches;
+// SearchResults<Study> newRes = intersectSearchResults(oldRes, new StudySearchResults(matches),
+// new RequestMessageSetter(request), "No matching studies found");
+//
+// saveSearchResults(request, newRes);
+//
+// return new ModelAndView("search/studySearch", Constants.RESULT_SET, newRes);
}
+ /*
private void validateTaxonSet(HttpServletRequest request,
HttpServletResponse response, String searchTerm,
BindException errors) {
@@ -256,6 +380,7 @@
private String titleCase(String s) {
return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
}
+ */
@Override
SearchResultsType currentSearchType() {
@@ -266,4 +391,38 @@
public String getDefaultViewURL() {
return "studySearch.html";
}
+
+ @Override
+ protected ModelAndView handleQueryRequest(HttpServletRequest request,
+ HttpServletResponse response, BindException errors)
+ throws CQLParseException, IOException, InstantiationException {
+ String query = request.getParameter("query");
+ CQLParser parser = new CQLParser();
+ CQLNode root = parser.parse(query);
+ root = normalizeParseTree(root);
+ Set<Study> queryResults = doCQLQuery(root, new HashSet<Study>(),request, response, errors);
+ StudySearchResults tsr = new StudySearchResults(queryResults);
+ saveSearchResults(request, tsr);
+ if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
+ return new ModelAndView("search/studySearch", Constants.RESULT_SET, tsr);
+ }
+ else {
+ SearchResults<?> res = tsr;
+ String schema = null;
+ if ( ! TreebaseUtil.isEmpty(request.getParameter("recordSchema")) ) {
+ schema = request.getParameter("recordSchema");
+ if ( schema.equals("tree") ) {
+ res = tsr.convertToTrees();
+ }
+ else if ( schema.equals("matrix") ) {
+ res = tsr.convertToMatrices();
+ }
+ else if ( schema.equals("taxon") ) {
+ res = tsr.convertToTaxa();
+ }
+ }
+ this.saveSearchResults(request, res);
+ return this.searchResultsAsRDF(res, request, root, schema, "study");
+ }
+ }
}
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 2009-07-02 10:41:25 UTC (rev 158)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TaxonSearchController.java 2009-07-02 10:43:46 UTC (rev 159)
@@ -1,17 +1,20 @@
package org.cipres.treebase.web.controllers;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.cipres.treebase.TreebaseIDString;
+import org.cipres.treebase.TreebaseUtil;
import org.cipres.treebase.TreebaseIDString.MalformedTreebaseIDString;
+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.SearchService;
import org.cipres.treebase.domain.search.TaxonSearchResults;
@@ -19,16 +22,29 @@
import org.cipres.treebase.domain.taxon.TaxonHome;
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.TaxonVariant;
import org.cipres.treebase.web.model.SearchCommand;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
+import org.z3950.zing.cql.CQLAndNode;
+import org.z3950.zing.cql.CQLBooleanNode;
+import org.z3950.zing.cql.CQLNode;
+import org.z3950.zing.cql.CQLNotNode;
+import org.z3950.zing.cql.CQLOrNode;
+import org.z3950.zing.cql.CQLParseException;
+import org.z3950.zing.cql.CQLParser;
+import org.z3950.zing.cql.CQLRelation;
+import org.z3950.zing.cql.CQLTermNode;
public class TaxonSearchController extends SearchController {
- static final Logger LOGGER = Logger.getLogger(TreeSearchController.class);
+ static final Logger LOGGER = Logger.getLogger(TaxonSearchController.class);
private TaxonHome mTaxonHome;
private TaxonLabelHome mTaxonLabelHome;
+ private enum SearchIndex { LABEL, ID };
+ private enum SearchTable { TAXON, TAXONLABEL, TAXONVARIANT };
+ private enum NamingAuthority { TREEBASE, UBIO, NCBI };
@Override
protected ModelAndView onSubmit(HttpServletRequest request,
@@ -36,10 +52,56 @@
throws Exception {
clearMessages(request);
String formName = request.getParameter("formName");
+ String query = request.getParameter("query");
+ if ( ! TreebaseUtil.isEmpty(query) ) {
+ /*
+ CQLParser parser = new CQLParser();
+ CQLNode root = parser.parse(query);
+ root = normalizeParseTree(root);
+ 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") ) {
+ return samePage(request);
+ }
+ else {
+ return this.searchResultsAsRDF(tsr, request, root);
+ }
+ */
+ return this.handleQueryRequest(request, response, errors);
+ }
if (formName.equals("searchByTaxonLabel")) {
SearchCommand newSearchCommand = (SearchCommand)searchCommand;
- ModelAndView modelAndView = doTaxonSearch(request, response, newSearchCommand, errors);
- return modelAndView;
+ String searchOn = request.getParameter("searchOn");
+ String searchTerm = convertStars(request.getParameter("searchTerm"));
+ String[] searchTerms = searchTerm.split("\\r\\n");
+ Collection<Taxon> taxa = new HashSet<Taxon>();
+ for ( int i = 0; i < searchTerms.length; i++ ) {
+ if ( searchOn.equals("TextSearch") ) {
+ taxa.addAll(doTaxonSearch(request, newSearchCommand, searchTerms[i], SearchIndex.LABEL, null));
+ }
+ else if ( searchOn.equals("Identifiers") ) {
+ String objectIdentifier = request.getParameter("objectIdentifier");
+ if ( objectIdentifier.equals("TreeBASE") ) {
+ taxa.addAll(doTaxonSearch(request,newSearchCommand,searchTerms[i],SearchIndex.ID,NamingAuthority.TREEBASE));
+ }
+ else if ( objectIdentifier.equals("NCBI") ) {
+ taxa.addAll(doTaxonSearch(request,newSearchCommand,searchTerms[i],SearchIndex.ID,NamingAuthority.NCBI));
+ }
+ else if ( objectIdentifier.equals("uBio") ) {
+ taxa.addAll(doTaxonSearch(request,newSearchCommand,searchTerms[i],SearchIndex.ID,NamingAuthority.UBIO));
+ }
+ }
+ }
+ TaxonSearchResults tsr = new TaxonSearchResults(taxa);
+ saveSearchResults(request, tsr);
+ if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
+ return samePage(request);
+ }
+ else {
+ return this.searchResultsAsRDF(tsr, request, null,"taxon","taxon");
+ }
+
} else if (formName.equals("taxonResultsAction")) {
return modifySearchResults(request, response, errors);
} else {
@@ -47,13 +109,99 @@
}
}
+ private CQLNode normalizeParseTree(CQLNode node) {
+ if ( node instanceof CQLBooleanNode ) {
+ ((CQLBooleanNode)node).left = normalizeParseTree(((CQLBooleanNode)node).left);
+ ((CQLBooleanNode)node).right = normalizeParseTree(((CQLBooleanNode)node).right);
+ return node;
+ }
+ else if ( node instanceof CQLTermNode ) {
+ String index = ((CQLTermNode)node).getIndex();
+ String term = ((CQLTermNode)node).getTerm();
+ CQLRelation relation = ((CQLTermNode)node).getRelation();
+ index = index.replaceAll("dcterms.title", "tb.title.taxon");
+ index = index.replaceAll("dcterms.identifier", "tb.identifier.taxon");
+ return new CQLTermNode(index,relation,term);
+ }
+ logger.debug(node);
+ return node;
+ }
+
+ private Set<Taxon> doCQLQuery(CQLNode node, Set<Taxon> results, HttpServletRequest request) {
+ if ( node instanceof CQLBooleanNode ) {
+ Set<Taxon> resultsLeft = doCQLQuery(((CQLBooleanNode)node).left,results, request);
+ Set<Taxon> resultsRight = doCQLQuery(((CQLBooleanNode)node).right,results, request);
+ if ( node instanceof CQLNotNode ) {
+ for ( Taxon rightTaxon : resultsRight ) {
+ if ( resultsLeft.contains(rightTaxon) ) {
+ resultsLeft.remove(rightTaxon);
+ }
+ }
+ }
+ else if ( node instanceof CQLOrNode ) {
+ resultsLeft.addAll(resultsRight);
+ }
+ else if ( node instanceof CQLAndNode ) {
+ Set<Taxon> resultsUnion = new HashSet<Taxon>();
+ for ( Taxon leftTaxon : resultsLeft ) {
+ if ( resultsRight.contains(leftTaxon) ) {
+ resultsUnion.add(leftTaxon);
+ }
+ }
+ resultsLeft = resultsUnion;
+ }
+ results = resultsLeft;
+ }
+ else if ( node instanceof CQLTermNode ) {
+ CQLTermNode term = (CQLTermNode)node;
+ String index = term.getIndex();
+ if ( index.startsWith("tb.title") ) {
+ boolean exactMatch = term.getRelation().getBase().equals("==");
+ SearchTable searchTable = null;
+ if ( index.endsWith("taxonLabel") ) {
+ searchTable = SearchTable.TAXONLABEL;
+ }
+ else if ( index.endsWith("taxonVariant") ) {
+ searchTable = SearchTable.TAXONVARIANT;
+ }
+ else if ( index.endsWith("taxon") ) {
+ searchTable = SearchTable.TAXON;
+ }
+ boolean caseSensitive = true;
+ if ( ! term.getRelation().getModifiers().isEmpty() ) {
+ caseSensitive = ! term.getRelation().getModifiers().firstElement().getType().equalsIgnoreCase("ignoreCase");
+ }
+ results.addAll(doTextSearch(term.getTerm(), caseSensitive, exactMatch, searchTable));
+ }
+ else if ( index.startsWith("tb.identifier") ) {
+ NamingAuthority namingAuthority = null;
+ if ( index.endsWith("ncbi") ) {
+ namingAuthority = NamingAuthority.NCBI;
+ }
+ else if ( index.endsWith("ubio") ) {
+ namingAuthority = NamingAuthority.UBIO;
+ }
+ else {
+ namingAuthority = NamingAuthority.TREEBASE;
+ }
+ results.addAll(doIdentifierSearch(request, term.getTerm(), namingAuthority));
+ } else {
+ // issue warnings
+ addMessage(request, "Unsupported index: " + index);
+ }
+
+ }
+ logger.debug(node);
+ return results;
+ }
+
private ModelAndView modifySearchResults(HttpServletRequest request,
HttpServletResponse response, BindException errors) throws InstantiationException {
TaxonSearchResults results = searchResults(request).convertToTaxa();
String buttonName = request.getParameter("taxonResultsaction");
if (buttonName.equals("addCheckedToResults")) {
- Map<String,String> parameterMap = request.getParameterMap();
+// Map<String,String> parameterMap = request.getParameterMap();
Collection<Taxon> newTaxa = new HashSet<Taxon> ();
for (String taxonIdString : request.getParameterValues("selection")) {
Taxon tx;
@@ -72,36 +220,40 @@
return samePage(request);
}
- protected ModelAndView doTaxonSearch(HttpServletRequest request,
- HttpServletResponse response,
- SearchCommand searchCommand, BindException errors) throws Exception {
- String searchTerm = convertStars(request.getParameter("searchTerm"));
- String[] searchTerms = searchTerm.split("\\r\\n");
- String searchOn = request.getParameter("searchOn");
- //Collection<TaxonVariant> tvs = new ArrayList<TaxonVariant>();
+ protected Collection<Taxon> doTaxonSearch(HttpServletRequest request,
+ SearchCommand searchCommand, String searchTerm, SearchIndex searchIndex, NamingAuthority namingAuthority) throws Exception {
+
Collection<Taxon> taxa = new HashSet<Taxon> ();
- if ( searchOn.equals("TextSearch") ) {
- taxa = doTextSearch(request,searchTerms);
+ switch(searchIndex) {
+ case LABEL:
+ String[] stringModifiers = request.getParameterValues("stringModifier");
+ boolean caseSensitive = false;
+ boolean exactMatch = false;
+ if ( stringModifiers != null ) {
+ for ( int i = 0; i < stringModifiers.length; i++ ) {
+ if ( stringModifiers[i].equals("caseSensitive") ) {
+ caseSensitive = true;
+ }
+ if ( stringModifiers[i].equals("exactMatch") ) {
+ exactMatch = true;
+ }
+ }
+ }
+ for ( SearchTable searchTable : createSearchTableEnum(request) ) {
+ taxa.addAll(doTextSearch(searchTerm, caseSensitive, exactMatch, searchTable));
+ }
+ break;
+ case ID:
+ taxa.addAll(doIdentifierSearch(request,searchTerm, namingAuthority));
+ break;
}
- else if ( searchOn.equals("Identifiers") ) {
- taxa = doIdentifierSearch(request,searchTerms);
- }
- /*
- tvs = getTaxonLabelService().findTaxonVariantByFullName(searchTerm);
- LOGGER.debug("Found " + tvs.size() + " tvs");
- for (TaxonVariant tv : tvs) {
- if (tv.getTaxon() != null) taxa.add(tv.getTaxon());
- }
- */
-
getTaxonLabelService().resurrectAll(taxa);
LOGGER.debug("Found " + taxa.size() + " taxa");
-
- TaxonSearchResults tsr = new TaxonSearchResults(taxa);
- //saveTempSearchResults(request, tsr);
- saveSearchResults(request, tsr);
- return samePage(request);
+ return taxa;
+// TaxonSearchResults tsr = new TaxonSearchResults(taxa);
+// saveSearchResults(request, tsr);
+// return samePage(request);
}
/**
@@ -110,44 +262,60 @@
* @param request
* @param results
*/
- private Collection<Taxon> doIdentifierSearch(HttpServletRequest request,String[] identifiers) {
- String objectIdentifier = request.getParameter("objectIdentifier");
+ private Collection<Taxon> doIdentifierSearch(HttpServletRequest request, String identifier, NamingAuthority namingAuthority) {
Collection<Taxon> taxaFound = new ArrayList<Taxon>();
- if ( objectIdentifier.equals("TreeBASE") ) {
- LOGGER.debug("Going to search for TreeBASE IDs");
- for ( int i = 0; i < identifiers.length; i++ ) {
+ switch(namingAuthority) {
+ case TREEBASE :
+ LOGGER.debug("Going to search for TreeBASE IDs");
TreebaseIDString idstr;
try {
- idstr = new TreebaseIDString(identifiers[i], Taxon.class, true);
+ idstr = new TreebaseIDString(identifier, Taxon.class, true);
+ Taxon match = getTaxonHome().findPersistedObjectByID(idstr.getTBClass(), idstr.getId());
+ if ( match != null ) {
+ taxaFound.add(match);
+ }
} catch (MalformedTreebaseIDString e) {
- addMessage(request, "Ignoring malformed taxon ID string '" + identifiers[i] + "'; try 'Tx####' or just a number");
- continue;
+ addMessage(request, "Ignoring malformed taxon ID string '" + identifier + "'; try 'Tx####' or just a number");
}
- Taxon match = getTaxonHome().findPersistedObjectByID(idstr.getTBClass(), idstr.getId());
+ break;
+ case NCBI :
+ LOGGER.debug("Going to search for NCBI taxon ids");
+ Taxon match = getTaxonHome().findByNcbiTaxId(Integer.parseInt(identifier));
if ( match != null ) {
taxaFound.add(match);
}
- }
+ break;
+ case UBIO :
+ LOGGER.debug("Going to search for uBio nameBankIDs");
+ Taxon match1 = getTaxonHome().findByUBIOTaxId(Long.parseLong(identifier));
+ if ( match1 != null ) {
+ taxaFound.add(match1);
+ }
+ break;
}
- else if ( objectIdentifier.equals("NCBI") ) {
- LOGGER.debug("Going to search for NCBI taxon ids");
- for ( int i = 0; i < identifiers.length; i++ ) {
- Taxon match = getTaxonHome().findByNcbiTaxId(Integer.parseInt(identifiers[i]));
- if ( match != null ) {
- taxaFound.add(match);
- }
+ return taxaFound;
+ }
+
+ /**
+ *
+ * @param request
+ * @return
+ */
+ private Set<SearchTable> createSearchTableEnum(HttpServletRequest request) {
+ Set<SearchTable> results = new HashSet<SearchTable>();
+ String[] stringProperties = request.getParameterValues("stringProperty");
+ for ( int i = 0; i < stringProperties.length; i++ ) {
+ if ( stringProperties[i].equals("taxonLabel") ) {
+ results.add(SearchTable.TAXONLABEL);
}
- }
- else if ( objectIdentifier.equals("uBio") ) {
- LOGGER.debug("Going to search for uBio nameBankIDs");
- for ( int i = 0; i < identifiers.length; i++ ) {
- Taxon match = getTaxonHome().findByUBIOTaxId(Long.parseLong(identifiers[i]));
- if ( match != null ) {
- taxaFound.add(match);
- }
+ else if ( stringProperties[i].equals("taxonVariant") ) {
+ results.add(SearchTable.TAXONVARIANT);
+ }
+ else if ( stringProperties[i].equals("taxon") ) {
+ results.add(SearchTable.TAXON);
}
}
- return taxaFound;
+ return results;
}
/**
@@ -156,88 +324,50 @@
* @param request
* @param results
*/
- private Collection<Taxon> doTextSearch(HttpServletRequest request, String[] stringPatterns) {
+ private Collection<Taxon> doTextSearch(String pattern, boolean caseSensitive, boolean exactMatch, SearchTable searchTable) {
LOGGER.debug("Going to search for strings");
+ LOGGER.debug("Case sensitive? " + caseSensitive);
+ LOGGER.debug("Exact match? " + exactMatch);
+ TaxonLabelService tls = getTaxonLabelService();
Collection<Taxon> taxaFound = new ArrayList<Taxon>();
- String[] stringProperties = request.getParameterValues("stringProperty");
- String[] stringModifiers = request.getParameterValues("stringModifier");
- boolean caseSensitive = false;
- boolean exactMatch = false;
- if ( stringModifiers != null ) {
- for ( int i = 0; i < stringModifiers.length; i++ ) {
- if ( stringModifiers[i].equals("caseSensitive") ) {
- caseSensitive = true;
+ switch(searchTable) {
+ case TAXONLABEL :
+ LOGGER.debug("Will search taxon labels");
+ Collection<TaxonLabel> labelsFound = exactMatch
+ ? tls.findByExactString(pattern)
+ : tls.findBySubstring(pattern, caseSensitive);
+ for ( TaxonLabel label : labelsFound ) {
+ if ( label.getTaxonVariant() != null && label.getTaxonVariant().getTaxon() != null ) {
+ taxaFound.add(label.getTaxonVariant().getTaxon());
+ }
}
- if ( stringModifiers[i].equals("exactMatch") ) {
- exactMatch = true;
- }
- }
- }
- LOGGER.debug("Case sensitive? " + caseSensitive);
- LOGGER.debug("Exact match? " + exactMatch);
- if ( stringProperties != null ) {
- for ( int i = 0; i < stringProperties.length; i++ ) {
- for ( int j = 0; j < stringPatterns.length; j++ ) {
- if ( stringProperties[i].equals("taxonLabel") ) {
- LOGGER.debug("Will search taxon labels");
- Collection<TaxonLabel> labelsFound = new ArrayList<TaxonLabel>();
- if ( exactMatch ) {
- labelsFound = getTaxonLabelService().findByExactString(stringPatterns[j]);
- }
- else {
- labelsFound = getTaxonLabelService().findBySubstring(stringPatterns[j], caseSensitive);
- }
- Iterator<TaxonLabel> labelsIterator = labelsFound.iterator();
- while ( labelsIterator.hasNext() ) {
- TaxonLabel label = labelsIterator.next();
- TaxonVariant variant = label.getTaxonVariant();
- if ( variant != null ) {
- Taxon taxon = variant.getTaxon();
- if ( taxon != null ) {
- taxaFound.add(taxon);
- }
- }
- }
+ break;
+ case TAXONVARIANT :
+ LOGGER.debug("Will search taxon variants");
+ Collection<TaxonVariant> variantsFound = exactMatch
+ ? tls.findTaxonVariantByFullName(pattern)
+ : tls.findTaxonVariantWithSubstring(pattern, caseSensitive);
+ for ( TaxonVariant variant : variantsFound ) {
+ if ( variant.getTaxon() != null ) {
+ taxaFound.add(variant.getTaxon());
}
- if ( stringProperties[i].equals("taxonVariant") ) {
- LOGGER.debug("Will search taxon variants");
- Collection<TaxonVariant> variantsFound = new ArrayList<TaxonVariant>();
- if ( exactMatch ) {
- variantsFound = getTaxonLabelService().findTaxonVariantByFullName(stringPatterns[j]);
- }
- else {
- variantsFound = getTaxonLabelService().findTaxonVariantWithSubstring(stringPatterns[j], caseSensitive);
- }
- Iterator<TaxonVariant> variantsIterator = variantsFound.iterator();
- while ( variantsIterator.hasNext() ) {
- TaxonVariant variant = variantsIterator.next();
- Taxon taxon = variant.getTaxon();
- if ( taxon != null ) {
- taxaFound.add(taxon);
- }
- }
- }
- if ( stringProperties[i].equals("taxon") ) {
- LOGGER.debug("Will search taxa");
- Collection<Taxon> tmpTaxaFound = new ArrayList<Taxon>();
- if ( exactMatch ) {
- tmpTaxaFound = getTaxonLabelService().findTaxaByName(stringPatterns[j]);
- }
- else {
- tmpTaxaFound = getTaxonLabelService().findTaxaBySubstring(stringPatterns[j], caseSensitive);
- }
- taxaFound.addAll(tmpTaxaFound);
- }
}
- }
+ break;
+ case TAXON :
+ LOGGER.debug("Will search taxa");
+ Collection<Taxon> tmpTaxaFound = exactMatch
+ ? tls.findTaxaByName(pattern)
+ : tls.findTaxaBySubstring(pattern, caseSensitive);
+ taxaFound.addAll(tmpTaxaFound);
+ break;
}
return taxaFound;
}
- private void saveTempSearchResults(HttpServletRequest request,
- TaxonSearchResults taxonSearchResults) {
- request.getSession().setAttribute("taxonSearchResults", taxonSearchResults);
- }
+// private void saveTempSearchResults(HttpServletRequest request,
+// TaxonSearchResults taxonSearchResults) {
+// request.getSession().setAttribute("taxonSearchResults", taxonSearchResults);
+// }
public void setSearchService(SearchService searchService) {
this.searchService = searchService;
@@ -268,4 +398,38 @@
public void setTaxonLabelHome(TaxonLabelHome taxonLabelHome) {
mTaxonLabelHome = taxonLabelHome;
}
+
+ @Override
+ protected ModelAndView handleQueryRequest(HttpServletRequest request,
+ HttpServletResponse response, BindException errors)
+ throws CQLParseException, IOException, InstantiationException {
+ String query = request.getParameter("query");
+ CQLParser parser = new CQLParser();
+ CQLNode root = parser.parse(query);
+ root = normalizeParseTree(root);
+ 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") ) {
+ return samePage(request);
+ }
+ else {
+ SearchResults<?> res = tsr;
+ String schema = null;
+ if ( ! TreebaseUtil.isEmpty(request.getParameter("recordSchema")) ) {
+ schema = request.getParameter("recordSchema");
+ if ( schema.equals("tree" ) ) {
+ res = tsr.convertToTrees();
+ }
+ else if ( schema.equals("matrix") ) {
+ res = tsr.convertToMatrices();
+ }
+ else if ( schema.equals("study") ) {
+ res = tsr.convertToStudies();
+ }
+ }
+ this.saveSearchResults(request, res);
+ return this.searchResultsAsRDF(res, request, root,schema,"taxon");
+ }
+ }
}
Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TreeSearchController.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TreeSearchController.java 2009-07-02 10:41:25 UTC (rev 158)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TreeSearchController.java 2009-07-02 10:43:46 UTC (rev 159)
@@ -20,25 +20,35 @@
package org.cipres.treebase.web.controllers;
-import java.util.ArrayList;
+import java.io.IOException;
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
+import org.cipres.treebase.TreebaseUtil;
import org.cipres.treebase.RangeExpression.MalformedRangeExpression;
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.TreeSearchResults;
-import org.cipres.treebase.domain.study.Study;
import org.cipres.treebase.domain.tree.PhyloTree;
import org.cipres.treebase.domain.tree.PhyloTreeService;
import org.cipres.treebase.web.Constants;
import org.cipres.treebase.web.util.RequestMessageSetter;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
+import org.z3950.zing.cql.CQLAndNode;
+import org.z3950.zing.cql.CQLBooleanNode;
+import org.z3950.zing.cql.CQLNode;
+import org.z3950.zing.cql.CQLNotNode;
+import org.z3950.zing.cql.CQLOrNode;
+import org.z3950.zing.cql.CQLParseException;
+import org.z3950.zing.cql.CQLParser;
+import org.z3950.zing.cql.CQLRelation;
+import org.z3950.zing.cql.CQLTermNode;
/**
* TreeSearchController.java
@@ -73,50 +83,161 @@
clearMessages(request);
String formName = request.getParameter("formName");
+ String query = request.getParameter("query");
LOGGER.info("formName is '" + formName + "'");
-
+ if ( ! TreebaseUtil.isEmpty(query) ) {
+ /*
+ CQLParser parser = new CQLParser();
+ CQLNode root = parser.parse(query);
+ root = normalizeParseTree(root);
+ Set<PhyloTree> queryResults = doCQLQuery(root, new HashSet<PhyloTree>(),request, response, errors);
+ TreeSearchResults tsr = new TreeSearchResults(queryResults);
+ saveSearchResults(request, tsr);
+ if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
+ return new ModelAndView("search/treeSearch", Constants.RESULT_SET, tsr);
+ }
+ else {
+ return this.searchResultsAsRDF(tsr, request, root);
+ }
+ */
+ return this.handleQueryRequest(request, response, errors);
+ }
+
if (formName.equals("treeSimple")) {
String buttonName = request.getParameter("searchButton");
-
+ String searchTerm = convertStars(request.getParameter("searchTerm"));
+ Collection<PhyloTree> matches = null;
+ TreeSearchResults oldRes;
+ {
+ SearchResults<?> sr = searchResults(request);
+ if (sr != null) {
+ oldRes = (TreeSearchResults) sr.convertToTrees();
+ } else {
+ oldRes = new TreeSearchResults (); // TODO: Convert existing search results to new type
+ }
+ }
if (buttonName.equals("treeID")) {
- return doSearch(request, response, SearchType.byID, errors);
+ matches = doSearch(request, response, SearchType.byID, errors, searchTerm);
} else if (buttonName.equals("treeTitle")) {
- return doSearch(request, response, SearchType.byTitle, errors);
+ matches = doSearch(request, response, SearchType.byTitle, errors, searchTerm);
} else if (buttonName.equals("treeType")) {
- return doSearch(request, response, SearchType.byType, errors);
+ matches = doSearch(request, response, SearchType.byType, errors, searchTerm);
} else if (buttonName.equals("treeKind")) {
- return doSearch(request, response, SearchType.byKind, errors);
+ matches = doSearch(request, response, SearchType.byKind, errors, searchTerm);
} else if (buttonName.equals("treeQuality")) {
- return doSearch(request, response, SearchType.byQuality, errors);
+ matches = doSearch(request, response, SearchType.byQuality, errors, searchTerm);
} else if (buttonName.equals("treeNTAX")) {
- return doSearch(request, response, SearchType.byNTAX, errors);
+ matches = doSearch(request, response, SearchType.byNTAX, errors, searchTerm);
} else {
throw new Error("Unknown search button name '" + buttonName + "'");
}
+ SearchResults<PhyloTree> newRes = intersectSearchResults(oldRes, new TreeSearchResults(matches),
+ new RequestMessageSetter(request), "No matching trees found");
+ saveSearchResults(request, newRes);
+ if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
+ return new ModelAndView("search/treeSearch", Constants.RESULT_SET, newRes);
+ }
+ else {
+ return this.searchResultsAsRDF(newRes, request, null,"tree","tree");
+ }
} else {
return super.onSubmit(request, response, command, errors);
}
}
- private ModelAndView doSearch(
+ private Set<PhyloTree> doCQLQuery(
+ CQLNode node,
+ Set<PhyloTree> results,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ BindException errors
+ ) throws InstantiationException {
+ if ( node instanceof CQLBooleanNode ) {
+ Set<PhyloTree> resultsLeft = doCQLQuery(((CQLBooleanNode)node).left,results, request, response, erro...
[truncated message content] |
|
From: <rv...@us...> - 2009-07-02 10:42:05
|
Revision: 158
http://treebase.svn.sourceforge.net/treebase/?rev=158&view=rev
Author: rvos
Date: 2009-07-02 10:41:25 +0000 (Thu, 02 Jul 2009)
Log Message:
-----------
Sketch for an RDF triple object and a semantically annotated persisted object
Added Paths:
-----------
trunk/treebase-web/src/main/java/org/cipres/treebase/web/model/PersistedObjectCommand.java
trunk/treebase-web/src/main/java/org/cipres/treebase/web/model/TreebaseTriple.java
Added: trunk/treebase-web/src/main/java/org/cipres/treebase/web/model/PersistedObjectCommand.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/model/PersistedObjectCommand.java (rev 0)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/model/PersistedObjectCommand.java 2009-07-02 10:41:25 UTC (rev 158)
@@ -0,0 +1,47 @@
+package org.cipres.treebase.web.model;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.cipres.treebase.domain.AbstractPersistedObject;
+import org.cipres.treebase.domain.TBPersistable;
+
+/*
+ * XXX this is work in progress, not functional right now
+ */
+public class PersistedObjectCommand extends AbstractPersistedObject {
+ private static final long serialVersionUID = 1L;
+ private TBPersistable mTBPersistable;
+ private Set<TreebaseTriple> mTreebaseTripleList;
+
+ public PersistedObjectCommand(TBPersistable tbPersistable) {
+ mTBPersistable = tbPersistable;
+ mTreebaseTripleList = new HashSet<TreebaseTriple>();
+ Method[] methods = tbPersistable.getClass().getDeclaredMethods();
+ for ( int i = 0; i < methods.length; i++ ) {
+ String methodName = methods[i].getName();
+ if ( methodName.equals("getLabel") || methodName.equals("getTitle") ) {
+ setDcTitle(methods[i]);
+ }
+ else if ( methodName.equals("getDescription") ) {
+ setDcDescription(methods[i]);
+ }
+ }
+ }
+
+ private void setDcTitle(Method method) {
+
+ }
+
+ private void setDcDescription(Method method) {
+
+ }
+
+ public List<TreebaseTriple> getTreebaseTripleList () {
+ return null;
+ }
+
+}
Added: trunk/treebase-web/src/main/java/org/cipres/treebase/web/model/TreebaseTriple.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/model/TreebaseTriple.java (rev 0)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/model/TreebaseTriple.java 2009-07-02 10:41:25 UTC (rev 158)
@@ -0,0 +1,32 @@
+package org.cipres.treebase.web.model;
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+/*
+ * XXX this is work in progress, not functional right now
+ */
+public class TreebaseTriple {
+ private URI mSubject;
+ private QName mPredicate;
+ private URI mObject;
+
+ public TreebaseTriple (URI subject,QName predicate,URI object) {
+ mSubject = subject;
+ mPredicate = predicate;
+ mObject = object;
+ }
+
+ public URI getSubject() {
+ return mSubject;
+ }
+
+ public QName getPredicate() {
+ return mPredicate;
+ }
+
+ public URI getObject() {
+ return mObject;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-07-02 10:38:55
|
Revision: 156
http://treebase.svn.sourceforge.net/treebase/?rev=156&view=rev
Author: rvos
Date: 2009-07-02 10:38:23 +0000 (Thu, 02 Jul 2009)
Log Message:
-----------
Adding documentation page for URL API
Added Paths:
-----------
trunk/treebase-web/src/main/webapp/help/urlAPI.jsp
Added: trunk/treebase-web/src/main/webapp/help/urlAPI.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/help/urlAPI.jsp (rev 0)
+++ trunk/treebase-web/src/main/webapp/help/urlAPI.jsp 2009-07-02 10:38:23 UTC (rev 156)
@@ -0,0 +1,110 @@
+<%@ include file="/common/taglibs.jsp"%>
+
+<title>URL API</title>
+<content tag="heading">URL API</content>
+<body id="submissions"/>
+<p>
+ The TreeBASE2 website provides users with simple ways to navigate the underlying data
+ programmatically. This page describes the stateless web service interface and URL architecture
+ that can be used to search the web site and obtain data in a variety of formats with rich semantics.
+</p>
+<h3>PhyloWS support</h3>
+<p>
+ The site structure described here is designed to be compliant with the emerging
+ <a href="http://evoinfo.nescent.org/PhyloWS">PhyloWS</a> standard. One of the tenets of the
+ standard is that URLs contain a <strong>/phylows/</strong> delimiter below which the standard
+ recommends a <a href="https://www.nescent.org/wg_evoinfo/PhyloWS/REST">simple API</a> to derefence
+ phylogenetic data by their accession numbers. In the examples below, the url fragments come
+ immediately below the <strong>/phylows/</strong> delimiter (everything between the
+ <strong>http://</strong> and <strong>phylows</strong> is considered
+ subject to change, likely to be stabilized using <a href="http://purl.org">purl</a> addresses).
+</p>
+<h3>Site sections</h3>
+<p>The data on the TreeBASE2 website are organized in four subsections:</p>
+<ul>
+ <li><strong>taxon/</strong> <em>operational taxonomic units, taxonomic mappings and outlinks</em></li>
+ <li><strong>matrix/</strong> <em>character state matrices, morphological character definitions</em></li>
+ <li><strong>tree/</strong> <em>contains trees and tree nodes</em></li>
+ <li><strong>study/</strong> <em>full submission records, including citation and analysis records</em></li>
+</ul>
+<p>
+ Within those four sections, every item in the TreeBASE2 database can be de-referenced by appending
+ the item's full identifier to the right section name. For example, <strong>tree/TB2:Tr2227</strong>
+ represents a tree (and returns a simple RDF file to describe the tree). For some classes of objects,
+ these short addresses can be passed a <strong>format</strong>
+ parameter to specify in which data format to represent the object:
+ <a href="/treebase-web/phylows/study/TB2:S1787?format=html">study/TB2:S1787?format=html</a>.
+ Identifiers that match any of the following expressions can be represented as <strong>nexml</strong>,
+ <strong>nexus</strong>, <strong>rdf</strong> or <strong>html</strong> (i.e. in a web page):
+</p>
+<ul>
+ <li><strong>matrix/TB2:M[0-9]+</strong> <em>character state matrix</em></li>
+ <li><strong>tree/TB2:Tr[0-9]+</strong> <em>phylogenetic tree</em></li>
+ <li><strong>study/TB2:S[0-9]+</strong> <em>study record</em></li>
+</ul>
+<h3>NeXML support</h3>
+<p>
+ The <strong>nexml</strong> and the <strong>rdf</strong> download options both use output
+ generated by the java support libraries available from the
+ <a href="http://nexml.org/nexml/java">nexml website</a>. The website uses the nexml annotation
+ feature extensively to transmit all the metadata stored by the database. Nexml annotations
+ are <a href="http://www.w3.org/TR/xhtml-rdfa-primer/">RDFa</a> compliant element structures
+ that use <a href="http://www.w3.org/TR/curie/">CURIE</a> strings to identify metadata properties,
+ and @content attributes to store the property value. For example, this (simplified) annotation:
+ <strong>
+ <meta content="uBio:2538170" property="tb:identifier.ubio"/>
+ </strong>
+ means that the element that encloses it has a special kind of identifier attached to it, namely
+ one that TreeBASE recognizes as originating in <a href="/treebase-web/phylows/taxon/uBio:2538170">uBio</a>.
+</p>
+<p>
+ The salient part is
+ the CURIE string predicate <strong>tb:identifier.ubio</strong>, which is one of a
+ <a href="http://spreadsheets.google.com/pub?key=rL--O7pyhR8FcnnG5-ofAlw">long list</a> of
+ proposed predicates that are written in TreeBASE's NeXML output and can be used as
+ <a href="http://www.loc.gov/standards/sru/specs/cql.html">CQL</a> search predicates. The predicates
+ proposed (and now experimentally transmitted) are intended to be subclasses of predicates
+ from commonly used vocabularies. For example, <strong>tb:identifier.ubio</strong> inherits from
+ <a href="http://dublincore.org/documents/dcmi-terms/#terms-identifier">dcterms:identifier</a> and
+ so any of the latter's semantics apply to the former, which is refined to indicate that the
+ value is a uBio namebank ID.
+</p>
+<h3>Searching</h3>
+<p>
+ The TreeBASE website can be searched using a subset of constructs from the
+ <a href="http://www.loc.gov/standards/sru/specs/cql.html">CQL</a> specification. Specifically,
+ the predicates
+ <a href="http://spreadsheets.google.com/pub?key=rL--O7pyhR8FcnnG5-ofAlw">listed here with
+ an asterisk</a> can be used in statements in the site section they apply to, such that, for example
+ a taxon can be retrieved by its ncbi ID like so:
+ <div style="background-color:;padding:10px">
+ <strong>taxon/find?query=tb:identifier.ncbi=<em><ncbi taxon id></em></strong>
+ </div>
+ or by its name like so:
+ <div style="background-color:;padding:10px">
+ <strong>taxon/find?query=tb:title.taxon=<em><name></em></strong>
+ </div>
+ or using an exact match
+ (<strong>==</strong>) or a case-insensitive one (<strong>=/ignoreCase</strong>). These statements
+ can be combined with boolean <strong>and</strong>, <strong>or</strong> and <strong>not</strong>.
+ For example:
+ <div style="background-color:;padding:10px">
+ <strong>study/find?query=dcterms.contributor=Huelsenbeck or dcterms.contributor=Ronquist</strong>
+ </div>
+ Finally, searching can be modified to project the results from one section info those of another. The
+ effect is roughly the same as switching between tabs in the search section: if the results are a
+ list of tree and you click on the matrix search tab, the trees are converted to the set of matrices
+ on which the trees are based. This behaviour can be used by specifying the
+ <strong>recordSchema=<section></strong> argument, i.e.:
+ <div style="background-color:;padding:10px">
+ <strong>taxon/find?query=dcterms.title=="Homo sapiens"&recordSchema=tree</strong>
+ </div>
+ returns all the trees that have <em>Homo sapiens</em> in them.
+ By default, all these queries return a web page, but with a <strong>format=rss1</strong> argument
+ the search results are listed in an RDF compatible RSS1.0 file, i.e.:
+ <div style="background-color:;padding:10px">
+ <strong>taxon/find?query=tb:title.taxon=<em><name></em>&format=rss1</strong>
+ </div>
+ The returned results in RSS1.0 use the short urls of the form <strong><section>/<id></strong>, whose
+ returned resource descriptions (like <a href="/treebase-web/phylows/tree/TB2:Tr2227">
+ this</a> one) need to be scanned to discover suitable serialization formats.
\ 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: <mjd...@us...> - 2009-07-01 21:01:14
|
Revision: 155
http://treebase.svn.sourceforge.net/treebase/?rev=155&view=rev
Author: mjdominus
Date: 2009-07-01 21:00:18 +0000 (Wed, 01 Jul 2009)
Log Message:
-----------
bug fix
Modified Paths:
--------------
trunk/treebase-core/src/main/perl/dump/sqldump
Modified: trunk/treebase-core/src/main/perl/dump/sqldump
===================================================================
--- trunk/treebase-core/src/main/perl/dump/sqldump 2009-07-01 20:56:13 UTC (rev 154)
+++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-07-01 21:00:18 UTC (rev 155)
@@ -178,7 +178,8 @@
my $percent = int(0.5 + $count / $total_records * 100);
print STDERR "\r$percent%" if $percent ne $old_percent;
$old_percent = $percent;
- last if defined($nrecs) && ++$rows_printed >= $nrecs;
+ ++$rows_printed;
+ last if defined($nrecs) && $rows_printed >= $nrecs;
}
}
@@ -186,7 +187,8 @@
else {
while ( $row = $sth->fetchrow_arrayref ) {
$dumper->rec(@$row);
- last if defined($nrecs) && ++$rows_printed >= $nrecs;
+ ++$rows_printed;
+ last if defined($nrecs) && $rows_printed >= $nrecs;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mjd...@us...> - 2009-07-01 20:56:34
|
Revision: 154
http://treebase.svn.sourceforge.net/treebase/?rev=154&view=rev
Author: mjdominus
Date: 2009-07-01 20:56:13 +0000 (Wed, 01 Jul 2009)
Log Message:
-----------
when table is empty, write a comment instead of an empty file
Modified Paths:
--------------
trunk/treebase-core/src/main/perl/dump/sqldump
trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm
Modified: trunk/treebase-core/src/main/perl/dump/sqldump
===================================================================
--- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-28 11:56:30 UTC (rev 153)
+++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-07-01 20:56:13 UTC (rev 154)
@@ -164,6 +164,7 @@
$sth->execute();
my $row;
+ my $rows_printed = 0;
# if --progress is provided, print out progress counter
if ($with_progress_meter) {
@@ -177,7 +178,7 @@
my $percent = int(0.5 + $count / $total_records * 100);
print STDERR "\r$percent%" if $percent ne $old_percent;
$old_percent = $percent;
- last if defined($nrecs) && (--$nrecs == 0);
+ last if defined($nrecs) && ++$rows_printed >= $nrecs;
}
}
@@ -185,10 +186,14 @@
else {
while ( $row = $sth->fetchrow_arrayref ) {
$dumper->rec(@$row);
- last if defined($nrecs) && (--$nrecs == 0);
+ last if defined($nrecs) && ++$rows_printed >= $nrecs;
}
}
+ if ($rows_printed == 0) {
+ $dumper->print("-- empty table\n");
+ }
+
# finish the statement handler
$sth->finish();
Modified: trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm
===================================================================
--- trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-06-28 11:56:30 UTC (rev 153)
+++ trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-07-01 20:56:13 UTC (rev 154)
@@ -33,6 +33,12 @@
return;
}
+# Print some text literally
+sub print {
+ my $self = shift;
+ return print {$self->{'OUT'}} @_;
+}
+
# Format data into an insert statement and return (or write) the result
sub rec {
my $self = shift;
@@ -56,7 +62,6 @@
return $create;
}
-# XXX UNFINISHED !!!!
sub quote_data {
my $self = shift;
my @d = @_;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 11:56:32
|
Revision: 153
http://treebase.svn.sourceforge.net/treebase/?rev=153&view=rev
Author: rvos
Date: 2009-06-28 11:56:30 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Changed redirect response code to SEE OTHER (303)
Modified Paths:
--------------
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java
Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java 2009-06-28 11:49:36 UTC (rev 152)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java 2009-06-28 11:56:30 UTC (rev 153)
@@ -103,7 +103,7 @@
res.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
}
if ( ! TreebaseUtil.isEmpty(url) ) {
- res.setStatus(HttpServletResponse.SC_FOUND);
+ res.setStatus(HttpServletResponse.SC_SEE_OTHER);
res.setHeader("Location", url);
}
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 11:49:39
|
Revision: 152
http://treebase.svn.sourceforge.net/treebase/?rev=152&view=rev
Author: rvos
Date: 2009-06-28 11:49:36 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Made redirect URLs absolute
Modified Paths:
--------------
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java
trunk/treebase-web/src/main/webapp/WEB-INF/pages/anyObjectAsRDF.jsp
Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java 2009-06-28 11:09:50 UTC (rev 151)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java 2009-06-28 11:49:36 UTC (rev 152)
@@ -60,6 +60,7 @@
throws Exception {
res.setContentType("text/plain");
String url = null;
+ String domain = "http://" + req.getServerName() + ":" + req.getServerPort();
try {
String pathInfo = req.getPathInfo();
if ( TreebaseUtil.isEmpty(pathInfo) ) {
@@ -81,17 +82,17 @@
TreebaseIDString tbID = namespacedGUID.getTreebaseIDString();
if ( hasWebPage(pathComponents) ) {
if ( TreebaseUtil.isEmpty(req.getParameter(format)) ) {
- url = "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
+ url = domain + "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
}
else if ( req.getParameter(format).equals("html") ) {
- url = createUrl(tbID.getTypePrefix(),tbID.getId());
+ url = domain + createUrl(tbID.getTypePrefix(),tbID.getId());
}
else {
- url = createDownloadUrl(tbID.getTypePrefix(),tbID.getId(),req.getParameter(format));
+ url = domain + createDownloadUrl(tbID.getTypePrefix(),tbID.getId(),req.getParameter(format));
}
}
else {
- url = "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
+ url = domain + "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
}
}
} catch ( MalformedTreebaseIDString e ) {
Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/anyObjectAsRDF.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/WEB-INF/pages/anyObjectAsRDF.jsp 2009-06-28 11:09:50 UTC (rev 151)
+++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/anyObjectAsRDF.jsp 2009-06-28 11:49:36 UTC (rev 152)
@@ -7,7 +7,7 @@
xmlns="http://purl.org/rss/1.0/">
<channel rdf:about="${baseURL}/${phyloWSPath}">
<title>${phyloWSPath}</title>
- <link>${baseURL}/${phyloWSPath}</link>
+ <link>${baseURL}</link>
<description>Serializations for ${phyloWSPath}</description>
<image rdf:resource="${domainAddress}<fmt:message key="icons.treebase.16px"/>"/>
<items>
@@ -21,7 +21,7 @@
</channel>
<image rdf:about="${domainAddress}<fmt:message key="icons.treebase.16px"/>">
<title>${phyloWSPath}</title>
- <link>${baseURL}/${phyloWSPath}</link>
+ <link>${baseURL}</link>
<url>${domainAddress}<fmt:message key="icons.treebase.16px"/></url>
</image>
<c:if test="${hasWebPage}">
@@ -29,7 +29,7 @@
<title>Web page</title>
<link>${baseURL}/${phyloWSPath}?format=html</link>
<description>A human-readable version of the resource</description>
- <!--dcterms:format>text/html</dcterms:format-->
+ <dc:format>text/html</dc:format>
<dc:language>EN-US</dc:language>
</item>
</c:if>
@@ -38,7 +38,7 @@
<title>NeXML file</title>
<link>${baseURL}/${phyloWSPath}?format=nexml</link>
<description>A NeXML serialization of the resource</description>
- <!--dcterms:format>application/xml</dcterms:format-->
+ <dc:format>application/xml</dc:format>
</item>
</c:if>
<c:if test="${hasNexus}">
@@ -46,7 +46,7 @@
<title>Nexus file</title>
<link>${baseURL}/${phyloWSPath}?format=nexus</link>
<description>A Nexus serialization of the resource</description>
- <!--dcterms:format>text/plain</dcterms:format-->
+ <dc:format>text/plain</dc:format>
</item>
</c:if>
<c:if test="${hasRdf}">
@@ -54,7 +54,7 @@
<title>RDF file</title>
<link>${baseURL}/${phyloWSPath}?format=rdf</link>
<description>An RDF/XML serialization of the resource</description>
- <!--dcterms:format>application/rdf+xml</dcterms:format-->
+ <dc:format>application/rdf+xml</dc:format>
</item>
</c:if>
</rdf:RDF>
\ 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: <rv...@us...> - 2009-06-28 11:09:51
|
Revision: 151
http://treebase.svn.sourceforge.net/treebase/?rev=151&view=rev
Author: rvos
Date: 2009-06-28 11:09:50 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Adding 16px treebase logo
Added Paths:
-----------
trunk/treebase-web/src/main/webapp/images/logo16px.png
Added: trunk/treebase-web/src/main/webapp/images/logo16px.png
===================================================================
(Binary files differ)
Property changes on: trunk/treebase-web/src/main/webapp/images/logo16px.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:35:21
|
Revision: 150
http://treebase.svn.sourceforge.net/treebase/?rev=150&view=rev
Author: rvos
Date: 2009-06-28 10:35:18 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Now emits RSS1.0
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/WEB-INF/pages/anyObjectAsRDF.jsp
Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/anyObjectAsRDF.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/WEB-INF/pages/anyObjectAsRDF.jsp 2009-06-28 10:33:46 UTC (rev 149)
+++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/anyObjectAsRDF.jsp 2009-06-28 10:35:18 UTC (rev 150)
@@ -1,35 +1,60 @@
<%@ include file="/common/taglibs.jsp"%>
-<% response.setContentType("application/rdf+xml"); %>
+<% response.setContentType("application/rss+xml"); %>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/"
- xmlns:dc="http://purl.org/dc/elements/1.1/">
- <rdf:Description rdf:about="${baseURL}/${namespacedGUID}">
- <dc:identifier>${namespacedGUID}</dc:identifier>
- <c:if test="${hasWebPage}"><dc:relation rdf:resource="${baseURL}/${namespacedGUID}.html"/></c:if>
- <c:if test="${hasNeXML}"><dc:relation rdf:resource="${baseURL}/${namespacedGUID}.xml"/></c:if>
- <c:if test="${hasNexus}"><dc:relation rdf:resource="${baseURL}/${namespacedGUID}.nex"/></c:if>
- <c:if test="${hasRdf}"><dc:relation rdf:resource="${baseURL}/${namespacedGUID}.rdf"/></c:if>
- </rdf:Description><c:if test="${hasWebPage}">
- <rdf:Description rdf:about="${baseURL}/${namespacedGUID}.html">
- <dcterms:format>text/html</dcterms:format>
- <dc:language>EN-US</dc:language>
- <dc:description>A Web page</dc:description>
- </rdf:Description></c:if><c:if test="${hasNeXML}">
- <rdf:Description rdf:about="${baseURL}/${namespacedGUID}.xml">
- <dcterms:format>application/xml</dcterms:format>
- <dc:description>A NeXML serialization</dc:description>
- </rdf:Description></c:if><c:if test="${hasNexus}">
- <rdf:Description rdf:about="${baseURL}/${namespacedGUID}.nex">
- <dcterms:format>text/plain</dcterms:format>
- <dc:description>A Nexus serialization</dc:description>
- </rdf:Description></c:if><c:if test="${hasRdf}">
- <rdf:Description rdf:about="${baseURL}/${namespacedGUID}.rdf">
- <dcterms:format>application/rdf+xml</dcterms:format>
- <dc:description>RDF/XML metadata about the resource</dc:description>
- </rdf:Description></c:if><%--c:if test="${hasJSON}">
- <rdf:Description rdf:about="${baseURL}/${namespacedGUID}.js">
- <dcterms:format>text/javascript</dcterms:format>
- <dc:description>A JSON mapping of a NeXML serialization</dc:description>
- </rdf:Description></c:if--%>
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns="http://purl.org/rss/1.0/">
+ <channel rdf:about="${baseURL}/${phyloWSPath}">
+ <title>${phyloWSPath}</title>
+ <link>${baseURL}/${phyloWSPath}</link>
+ <description>Serializations for ${phyloWSPath}</description>
+ <image rdf:resource="${domainAddress}<fmt:message key="icons.treebase.16px"/>"/>
+ <items>
+ <rdf:Seq>
+ <c:if test="${hasWebPage}"><rdf:li rdf:resource="${baseURL}/${phyloWSPath}?format=html"/></c:if>
+ <c:if test="${hasNeXML}"><rdf:li rdf:resource="${baseURL}/${phyloWSPath}?format=nexml"/></c:if>
+ <c:if test="${hasNexus}"><rdf:li rdf:resource="${baseURL}/${phyloWSPath}?format=nexus"/></c:if>
+ <c:if test="${hasRdf}"><rdf:li rdf:resource="${baseURL}/${phyloWSPath}?format=rdf"/></c:if>
+ </rdf:Seq>
+ </items>
+ </channel>
+ <image rdf:about="${domainAddress}<fmt:message key="icons.treebase.16px"/>">
+ <title>${phyloWSPath}</title>
+ <link>${baseURL}/${phyloWSPath}</link>
+ <url>${domainAddress}<fmt:message key="icons.treebase.16px"/></url>
+ </image>
+ <c:if test="${hasWebPage}">
+ <item rdf:about="${baseURL}/${phyloWSPath}?format=html">
+ <title>Web page</title>
+ <link>${baseURL}/${phyloWSPath}?format=html</link>
+ <description>A human-readable version of the resource</description>
+ <!--dcterms:format>text/html</dcterms:format-->
+ <dc:language>EN-US</dc:language>
+ </item>
+ </c:if>
+ <c:if test="${hasNeXML}">
+ <item rdf:about="${baseURL}/${phyloWSPath}?format=nexml">
+ <title>NeXML file</title>
+ <link>${baseURL}/${phyloWSPath}?format=nexml</link>
+ <description>A NeXML serialization of the resource</description>
+ <!--dcterms:format>application/xml</dcterms:format-->
+ </item>
+ </c:if>
+ <c:if test="${hasNexus}">
+ <item rdf:about="${baseURL}/${phyloWSPath}?format=nexus">
+ <title>Nexus file</title>
+ <link>${baseURL}/${phyloWSPath}?format=nexus</link>
+ <description>A Nexus serialization of the resource</description>
+ <!--dcterms:format>text/plain</dcterms:format-->
+ </item>
+ </c:if>
+ <c:if test="${hasRdf}">
+ <item rdf:about="${baseURL}/${phyloWSPath}?format=rdf">
+ <title>RDF file</title>
+ <link>${baseURL}/${phyloWSPath}?format=rdf</link>
+ <description>An RDF/XML serialization of the resource</description>
+ <!--dcterms:format>application/rdf+xml</dcterms:format-->
+ </item>
+ </c:if>
</rdf:RDF>
\ 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: <rv...@us...> - 2009-06-28 10:33:47
|
Revision: 149
http://treebase.svn.sourceforge.net/treebase/?rev=149&view=rev
Author: rvos
Date: 2009-06-28 10:33:46 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
s/PhyloWS/phylows/g
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml
Modified: trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml
===================================================================
--- trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml 2009-06-28 10:32:54 UTC (rev 148)
+++ trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml 2009-06-28 10:33:46 UTC (rev 149)
@@ -841,7 +841,7 @@
<property name="alwaysUseFullPath" value="true"/>
<property name="mappings">
<props>
- <prop key="/PhyloWS/**">phyloWSController</prop>
+ <prop key="/phylows/**">phyloWSController</prop>
<prop key="/home.html">filenameController</prop>
<prop key="/login.html">filenameController</prop>
<prop key="/user/viewXML.html">filenameController</prop>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:32:55
|
Revision: 148
http://treebase.svn.sourceforge.net/treebase/?rev=148&view=rev
Author: rvos
Date: 2009-06-28 10:32:54 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
s/PhyloWS/phylows/g
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/WEB-INF/web.xml
Modified: trunk/treebase-web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/treebase-web/src/main/webapp/WEB-INF/web.xml 2009-06-28 10:30:44 UTC (rev 147)
+++ trunk/treebase-web/src/main/webapp/WEB-INF/web.xml 2009-06-28 10:32:54 UTC (rev 148)
@@ -159,7 +159,7 @@
</servlet-mapping>
<servlet-mapping>
<servlet-name>treebase</servlet-name>
- <url-pattern>/PhyloWS/*</url-pattern>
+ <url-pattern>/phylows/*</url-pattern>
</servlet-mapping>
<!-- ========================================================== -->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:30:45
|
Revision: 147
http://treebase.svn.sourceforge.net/treebase/?rev=147&view=rev
Author: rvos
Date: 2009-06-28 10:30:44 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Now uses foo?format=bar instead of foo.bar
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/summary.jsp
Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/summary.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/summary.jsp 2009-06-28 10:28:10 UTC (rev 146)
+++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/summary.jsp 2009-06-28 10:30:44 UTC (rev 147)
@@ -10,7 +10,7 @@
<body id="s-study"/>
<c:set var="serverName" scope="request" value="<%= request.getServerName() %>"/>
<c:set var="portNumber" scope="request" value="<%= request.getServerPort() %>"/>
-<c:set var="baseLink" scope="request" value='http://${serverName}:${portNumber}/treebase-web/PhyloWS/${study.namespacedGUID}'/>
+<c:set var="baseLink" scope="request" value='http://${serverName}:${portNumber}/treebase-web/phylows/${study.phyloWSPath}'/>
<c:set var="currentSection" scope="request" value="Citation"/>
<c:set var="headerPrefix" scope="request" value="${currentSection} for"/>
<jsp:include page="nav.jsp"/>
@@ -89,7 +89,7 @@
</a>
</li>
<li>Other versions:
- <a href="${baseLink}.nex">
+ <a href="${baseLink}?format=nexus">
<img
class="iconButton"
src="<fmt:message key="icons.download.reconstructed"/>"
@@ -97,7 +97,7 @@
alt="<fmt:message key="download.reconstructedfile"/>"/>
Nexus
</a>
- <a href="${baseLink}.xml">
+ <a href="${baseLink}?format=nexml">
<img
class="iconButton"
src="<fmt:message key="icons.xml"/>"
@@ -105,7 +105,7 @@
alt="<fmt:message key="download.nexml"/>"/>
NeXML
</a>
- <a href="${baseLink}.rdf">
+ <a href="${baseLink}?format=rdf">
<img
class="iconButton"
src="<fmt:message key="icons.rdf"/>"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:28:11
|
Revision: 146
http://treebase.svn.sourceforge.net/treebase/?rev=146&view=rev
Author: rvos
Date: 2009-06-28 10:28:10 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Now uses foo?format=bar instead of foo.bar
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/trees.jsp
Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/trees.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/trees.jsp 2009-06-28 10:26:49 UTC (rev 145)
+++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/trees.jsp 2009-06-28 10:28:10 UTC (rev 146)
@@ -54,12 +54,14 @@
<a href="${taxaURL}">View Taxa</a>
</display:column>
+ <c:set var="baseURL" scope="request" value="/phylows/${tree.phyloWSPath}"/>
+
<display:column
sortable="false"
class="iconColumn"
headerClass="iconColumn">
- <c:url value="/PhyloWS/${tree.namespacedGUID}.xml" var="newTreeURL"/>
- <a href="${newTreeURL}">
+ <c:url var="url" value="${baseURL}"><c:param name="format">nexml</c:param></c:url>
+ <a href="${url}">
<img
class="iconButton"
src="<fmt:message key="icons.xml"/>"
@@ -72,8 +74,8 @@
sortable="false"
class="iconColumn"
headerClass="iconColumn">
- <c:url value="/PhyloWS/${tree.namespacedGUID}.rdf" var="newTreeURL"/>
- <a href="${newTreeURL}">
+ <c:url var="url" value="${baseURL}"><c:param name="format">rdf</c:param></c:url>
+ <a href="${url}">
<img
class="iconButton"
src="<fmt:message key="icons.rdf"/>"
@@ -86,8 +88,8 @@
sortable="false"
class="iconColumn"
headerClass="iconColumn">
- <c:url value="/PhyloWS/${tree.namespacedGUID}.nex" var="newTreeURL"/>
- <a href="${newTreeURL}">
+ <c:url var="url" value="${baseURL}"><c:param name="format">nexus</c:param></c:url>
+ <a href="${url}">
<img
class="iconButton"
src="<fmt:message key="icons.download.reconstructed"/>"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:26:51
|
Revision: 145
http://treebase.svn.sourceforge.net/treebase/?rev=145&view=rev
Author: rvos
Date: 2009-06-28 10:26:49 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Refactored to remove hardcoded /PhyloWS/ strings.
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/matrices.jsp
Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/matrices.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/matrices.jsp 2009-06-28 10:23:41 UTC (rev 144)
+++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/matrices.jsp 2009-06-28 10:26:49 UTC (rev 145)
@@ -5,6 +5,11 @@
<c:set var="currentSection" scope="request" value="Matrices"/>
<c:set var="headerPrefix" scope="request" value="${currentSection} for "/>
+
+<c:set var="serverName" scope="request" value="<%= request.getServerName() %>"/>
+<c:set var="portNumber" scope="request" value="<%= request.getServerPort() %>"/>
+<c:set var="baseURL" scope="request" value='http://${serverName}:${portNumber}/treebase-web/phylows/'/>
+
<jsp:include page="nav.jsp"/>
<c:url var="studyURL" value="summary.html">
@@ -21,11 +26,8 @@
cellpadding="3">
<display:column title="ID">
- <c:url value="matrix.html" var="matrixURL">
- <c:param name="id">${study.id}</c:param>
- <c:param name="matrixid">${matrix.id}</c:param>
- </c:url>
- <a href="${matrixURL}">M${matrix.id }</a>
+ <c:url var="url" value="${baseURL}${matrix.phyloWSPath}"><c:param name="format">html</c:param></c:url>
+ <a href="${url}">${matrix.treebaseIDString}</a>
</display:column>
<display:column
@@ -69,8 +71,8 @@
sortable="false"
class="iconColumn"
headerClass="iconColumn">
- <c:url value="/PhyloWS/${matrix.namespacedGUID}.xml" var="newMatrixURL"/>
- <a href="${newMatrixURL}">
+ <c:url var="url" value="${baseURL}${matrix.phyloWSPath}"><c:param name="format">nexml</c:param></c:url>
+ <a href="${url}">
<img
class="iconButton"
src="<fmt:message key="icons.xml"/>"
@@ -83,8 +85,8 @@
sortable="false"
class="iconColumn"
headerClass="iconColumn">
- <c:url value="/PhyloWS/${matrix.namespacedGUID}.rdf" var="newMatrixURL"/>
- <a href="${newMatrixURL}">
+ <c:url var="url" value="${baseURL}${matrix.phyloWSPath}"><c:param name="format">rdf</c:param></c:url>
+ <a href="${url}">
<img
class="iconButton"
src="<fmt:message key="icons.rdf"/>"
@@ -97,8 +99,8 @@
sortable="false"
class="iconColumn"
headerClass="iconColumn">
- <c:url value="/PhyloWS/${matrix.namespacedGUID}.nex" var="newMatrixURL"/>
- <a href="${newMatrixURL}">
+ <c:url var="url" value="${baseURL}${matrix.phyloWSPath}"><c:param name="format">nexus</c:param></c:url>
+ <a href="${url}">
<img
class="iconButton"
src="<fmt:message key="icons.download.reconstructed"/>"
@@ -128,7 +130,7 @@
sortable="false"
class="iconColumn"
headerClass="iconColumn">
- <c:url var="url" value="/PhyloWS/${matrix.namespacedGUID}.html"/>
+ <c:url var="url" value="${baseURL}${matrix.phyloWSPath}"><c:param name="format">html</c:param></c:url>
<a href="${url}">
<img
class="iconButton"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:23:49
|
Revision: 144
http://treebase.svn.sourceforge.net/treebase/?rev=144&view=rev
Author: rvos
Date: 2009-06-28 10:23:41 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Adding icon path variable for treebase 16px icon
Modified Paths:
--------------
trunk/treebase-web/src/main/resources/ApplicationResources.properties
Modified: trunk/treebase-web/src/main/resources/ApplicationResources.properties
===================================================================
--- trunk/treebase-web/src/main/resources/ApplicationResources.properties 2009-06-28 10:18:51 UTC (rev 143)
+++ trunk/treebase-web/src/main/resources/ApplicationResources.properties 2009-06-28 10:23:41 UTC (rev 144)
@@ -472,6 +472,7 @@
icons.rdf=/treebase-web/images/icons/page_white_code_red.png
icons.json=/treebase-web/images/icons/script.png
icons.permalink=/treebase-web/images/icons/link.png
+icons.treebase.16px=/treebase-web/images/logo16px.png
#-- help system --
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:19:51
|
Revision: 143
http://treebase.svn.sourceforge.net/treebase/?rev=143&view=rev
Author: rvos
Date: 2009-06-28 10:18:51 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Now uses PhyloWSPath object to manage whatever url fragments come between /phylows/ and NamespacedGUID
Modified Paths:
--------------
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AnyObjectAsRDFController.java
Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AnyObjectAsRDFController.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AnyObjectAsRDFController.java 2009-06-28 10:17:15 UTC (rev 142)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AnyObjectAsRDFController.java 2009-06-28 10:18:51 UTC (rev 143)
@@ -7,6 +7,7 @@
import javax.servlet.http.HttpServletResponse;
import org.cipres.treebase.NamespacedGUID;
+import org.cipres.treebase.PhyloWSPath;
import org.cipres.treebase.TreebaseIDString;
import org.cipres.treebase.domain.matrix.Matrix;
import org.cipres.treebase.domain.study.Study;
@@ -24,6 +25,7 @@
HttpServletResponse response) throws Exception {
NamespacedGUID namespacedGUID = new NamespacedGUID(request.getParameter("namespacedGUID"));
TreebaseIDString treebaseIDString = null;
+ PhyloWSPath phyloWSPath = null;
request.setAttribute("hasWebPage", false);
request.setAttribute("hasNexus", false);
request.setAttribute("hasNeXML", false);
@@ -45,18 +47,22 @@
request.setAttribute("hasNeXML", true);
request.setAttribute("hasRdf", true);
}
+ phyloWSPath = new PhyloWSPath(theClass.getPackage(),namespacedGUID);
}
}
}
request.getSession().setAttribute("namespacedGUID", namespacedGUID.toString());
// <c:set var="baseURL" value="http://localhost:8080/treebase-web/PhyloWS"/>
- StringBuffer url = new StringBuffer("http://");
- url
+ StringBuffer domainAddress = new StringBuffer("http://");
+ domainAddress
.append(request.getServerName())
.append(':')
- .append(request.getServerPort())
- .append("/treebase-web/PhyloWS");
- request.getSession().setAttribute("baseURL", url.toString());
+ .append(request.getServerPort());
+ StringBuffer baseURL = new StringBuffer(domainAddress);
+ baseURL.append("/treebase-web/phylows");
+ request.getSession().setAttribute("baseURL", baseURL.toString());
+ request.getSession().setAttribute("domainAddress", domainAddress.toString());
+ request.getSession().setAttribute("phyloWSPath", phyloWSPath);
return new ModelAndView("anyObjectAsRDF");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:18:04
|
Revision: 142
http://treebase.svn.sourceforge.net/treebase/?rev=142&view=rev
Author: rvos
Date: 2009-06-28 10:17:15 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Added redirect for uBio and NCBI namespaced GUIDs
Modified Paths:
--------------
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java
Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java 2009-06-28 10:15:53 UTC (rev 141)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java 2009-06-28 10:17:15 UTC (rev 142)
@@ -18,10 +18,14 @@
import org.cipres.treebase.domain.tree.PhyloTreeService;
public class PhyloWSController implements Controller {
+ private static String ncbiBaseUrl = "http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=";
+ private static String uBioBaseUrl = "http://www.ubio.org/browser/details.php?namebankID=";
private static final long serialVersionUID = 1L;
private MatrixService mMatrixService;
private PhyloTreeService mPhyloTreeService;
private StudyService mStudyService;
+ private static String format = "format";
+ private static String[] classesWithPages = { "tree", "study", "matrix" };
private String createUrl(String prefix, Long objectId) throws Exception {
String url = "";
@@ -62,26 +66,33 @@
throw new InvalidRequestException(
"Invalid request '"
+ pathInfo
- + "', should be /${NamespacedGUID}");
+ + "', should be /${class}/${NamespacedGUID}");
}
String[] pathComponents = pathInfo.split("/");
- if ( pathComponents.length != 2 ) {
- throw new InvalidRequestException(
- "Invalid request '"
- + pathInfo
- + "', should be /${NamespacedGUID}");
+ String rawNamespacedGUID = pathComponents[pathComponents.length-1];
+ if ( rawNamespacedGUID.startsWith("uBio:") ) {
+ url = uBioBaseUrl + rawNamespacedGUID.substring("uBio:".length());
}
- String[] idComponents = pathComponents[1].split("\\.");
- NamespacedGUID namespacedGUID = new NamespacedGUID(idComponents[0]);
- TreebaseIDString tbID = namespacedGUID.getTreebaseIDString();
- if ( idComponents.length >= 2 && idComponents[1].equals("html") ) {
- url = createUrl(tbID.getTypePrefix(),tbID.getId());
- }
- else if ( idComponents.length >= 2 ) {
- url = createDownloadUrl(tbID.getTypePrefix(),tbID.getId(),idComponents[1]);
- }
+ else if ( rawNamespacedGUID.startsWith("NCBI:") ) {
+ url = ncbiBaseUrl + rawNamespacedGUID.substring("NCBI:".length());
+ }
else {
- url = "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
+ NamespacedGUID namespacedGUID = new NamespacedGUID(rawNamespacedGUID);
+ TreebaseIDString tbID = namespacedGUID.getTreebaseIDString();
+ if ( hasWebPage(pathComponents) ) {
+ if ( TreebaseUtil.isEmpty(req.getParameter(format)) ) {
+ url = "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
+ }
+ else if ( req.getParameter(format).equals("html") ) {
+ url = createUrl(tbID.getTypePrefix(),tbID.getId());
+ }
+ else {
+ url = createDownloadUrl(tbID.getTypePrefix(),tbID.getId(),req.getParameter(format));
+ }
+ }
+ else {
+ url = "/treebase-web/search/study/anyObjectAsRDF.html?namespacedGUID=" + namespacedGUID.toString();
+ }
}
} catch ( MalformedTreebaseIDString e ) {
res.sendError(HttpServletResponse.SC_BAD_REQUEST, "Bad ID string: " + e.getMessage());
@@ -91,11 +102,22 @@
res.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
}
if ( ! TreebaseUtil.isEmpty(url) ) {
- res.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
+ res.setStatus(HttpServletResponse.SC_FOUND);
res.setHeader("Location", url);
}
return null;
}
+
+ private boolean hasWebPage(String[] pathComponents) {
+ for ( int i = ( pathComponents.length - 1 ); i >= 0; i-- ) {
+ for ( int j = 0; j < classesWithPages.length; j++ ) {
+ if ( pathComponents[i].equals(classesWithPages[j]) ) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
private String createDownloadUrl(String prefix, Long objectId, String format) throws Exception {
if ( format.equals("xml") ) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:16:55
|
Revision: 141
http://treebase.svn.sourceforge.net/treebase/?rev=141&view=rev
Author: rvos
Date: 2009-06-28 10:15:53 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
$baseURI =~ s/PhyloWS/phylows/;
Modified Paths:
--------------
trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AbstractDownloadController.java
Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AbstractDownloadController.java
===================================================================
--- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AbstractDownloadController.java 2009-06-28 10:14:15 UTC (rev 140)
+++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AbstractDownloadController.java 2009-06-28 10:15:53 UTC (rev 141)
@@ -29,7 +29,7 @@
.append(request.getServerName())
.append(':')
.append(request.getServerPort())
- .append("/treebase-web/PhyloWS/");
+ .append("/treebase-web/phylows/");
properties.setProperty("nexml.uri.base", baseURI.toString());
return properties;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:15:15
|
Revision: 140
http://treebase.svn.sourceforge.net/treebase/?rev=140&view=rev
Author: rvos
Date: 2009-06-28 10:14:15 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Added required method stubs (due to changed TBPersistable interface)
Modified Paths:
--------------
trunk/treebase-core/src/test/java/org/cipres/treebase/TBMockObject.java
Modified: trunk/treebase-core/src/test/java/org/cipres/treebase/TBMockObject.java
===================================================================
--- trunk/treebase-core/src/test/java/org/cipres/treebase/TBMockObject.java 2009-06-28 10:13:26 UTC (rev 139)
+++ trunk/treebase-core/src/test/java/org/cipres/treebase/TBMockObject.java 2009-06-28 10:14:15 UTC (rev 140)
@@ -60,4 +60,19 @@
return getId().hashCode();
}
+ public NamespacedGUID getNamespacedGUID() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TreebaseIDString getTreebaseIDString() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public PhyloWSPath getPhyloWSPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:14:27
|
Revision: 139
http://treebase.svn.sourceforge.net/treebase/?rev=139&view=rev
Author: rvos
Date: 2009-06-28 10:13:26 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Adding PhyloWSPath, a class that abstracts away the exact structure of whatever comes between the /phylows/ url fragment and the TB2:${id} fragment.
Added Paths:
-----------
trunk/treebase-core/src/main/java/org/cipres/treebase/PhyloWSPath.java
Added: trunk/treebase-core/src/main/java/org/cipres/treebase/PhyloWSPath.java
===================================================================
--- trunk/treebase-core/src/main/java/org/cipres/treebase/PhyloWSPath.java (rev 0)
+++ trunk/treebase-core/src/main/java/org/cipres/treebase/PhyloWSPath.java 2009-06-28 10:13:26 UTC (rev 139)
@@ -0,0 +1,48 @@
+package org.cipres.treebase;
+
+import org.cipres.treebase.domain.TBPersistable;
+
+public class PhyloWSPath {
+ private NamespacedGUID mNamespacedGUID;
+ private Package mPackage;
+
+ public StringBuilder getPath(StringBuilder sb) {
+ String[] packagePathFragments = mPackage.getName().split("\\.");
+ return sb
+ // i.e. admin, matrix, study, taxon or tree
+ .append(packagePathFragments[packagePathFragments.length-1])
+ .append('/');
+ }
+
+ public String getPath() {
+ return getPath(new StringBuilder()).toString();
+ }
+
+ /**
+ *
+ */
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ return getPath(sb).append(mNamespacedGUID.toString()).toString();
+ }
+
+ /**
+ *
+ * @param tbPersistable
+ */
+ public PhyloWSPath(TBPersistable tbPersistable) {
+ mNamespacedGUID = tbPersistable.getNamespacedGUID();
+ mPackage = tbPersistable.getClass().getPackage();
+ }
+
+ /**
+ *
+ * @param pPackage
+ * @param namespacedGUID
+ */
+ public PhyloWSPath(Package pPackage, NamespacedGUID namespacedGUID) {
+ mPackage = pPackage;
+ mNamespacedGUID = namespacedGUID;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:14:11
|
Revision: 137
http://treebase.svn.sourceforge.net/treebase/?rev=137&view=rev
Author: rvos
Date: 2009-06-28 10:11:30 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Implemented interface methods
Modified Paths:
--------------
trunk/treebase-core/src/main/java/org/cipres/treebase/domain/AbstractPersistedObject.java
Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/AbstractPersistedObject.java
===================================================================
--- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/AbstractPersistedObject.java 2009-06-28 10:11:14 UTC (rev 136)
+++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/AbstractPersistedObject.java 2009-06-28 10:11:30 UTC (rev 137)
@@ -32,6 +32,7 @@
import javax.persistence.Version;
import org.cipres.treebase.NamespacedGUID;
+import org.cipres.treebase.PhyloWSPath;
import org.cipres.treebase.TreebaseIDString;
/**
@@ -111,5 +112,10 @@
public NamespacedGUID getNamespacedGUID () {
return getTreebaseIDString().getNamespacedGUID();
}
+
+ @Transient
+ public PhyloWSPath getPhyloWSPath() {
+ return new PhyloWSPath(this);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:13:13
|
Revision: 138
http://treebase.svn.sourceforge.net/treebase/?rev=138&view=rev
Author: rvos
Date: 2009-06-28 10:12:13 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
xml:base attribute now correctly copied from input nexml document to output rdf document.
Modified Paths:
--------------
trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceRDFa.java
Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceRDFa.java
===================================================================
--- trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceRDFa.java 2009-06-28 10:11:30 UTC (rev 137)
+++ trunk/treebase-core/src/main/java/org/cipres/treebase/service/nexus/NexusServiceRDFa.java 2009-06-28 10:12:13 UTC (rev 138)
@@ -12,11 +12,14 @@
import org.cipres.treebase.domain.nexus.nexml.NexmlDocumentConverter;
import org.cipres.treebase.domain.study.Study;
import org.dom4j.DocumentException;
+import org.dom4j.QName;
import org.dom4j.io.DocumentResult;
import org.dom4j.io.DocumentSource;
import org.dom4j.io.SAXReader;
+import org.jdom.Namespace;
import org.nexml.model.Document;
import org.nexml.model.DocumentFactory;
+
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
@@ -95,6 +98,9 @@
e.printStackTrace();
}
org.dom4j.Document transformedDoc = result.getDocument();
+ QName qName = QName.get("base", "xml", "http://www.w3.org/XML/1998/namespace");
+ String sourceBase = jDomDocument.getRootElement().attributeValue(qName);
+ transformedDoc.getRootElement().setAttributeValue(qName, sourceBase);
return transformedDoc.asXML();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:11:46
|
Revision: 136
http://treebase.svn.sourceforge.net/treebase/?rev=136&view=rev
Author: rvos
Date: 2009-06-28 10:11:14 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Added interface methods
Modified Paths:
--------------
trunk/treebase-core/src/main/java/org/cipres/treebase/domain/TBPersistable.java
Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/TBPersistable.java
===================================================================
--- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/TBPersistable.java 2009-06-28 10:10:36 UTC (rev 135)
+++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/TBPersistable.java 2009-06-28 10:11:14 UTC (rev 136)
@@ -22,6 +22,12 @@
package org.cipres.treebase.domain;
+import javax.persistence.Transient;
+
+import org.cipres.treebase.NamespacedGUID;
+import org.cipres.treebase.PhyloWSPath;
+import org.cipres.treebase.TreebaseIDString;
+
/**
* A tagging interface for all persisted treebase objects.
*
@@ -54,5 +60,11 @@
* @return
*/
public Long getId();
+
+ public TreebaseIDString getTreebaseIDString ();
+
+ public NamespacedGUID getNamespacedGUID ();
+
+ public PhyloWSPath getPhyloWSPath ();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2009-06-28 10:11:36
|
Revision: 135
http://treebase.svn.sourceforge.net/treebase/?rev=135&view=rev
Author: rvos
Date: 2009-06-28 10:10:36 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
Now attaches uBio and NCBI identifiers as dc:relation annotations
Modified Paths:
--------------
trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUConverter.java
Modified: 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/NexmlOTUConverter.java 2009-06-28 10:09:22 UTC (rev 134)
+++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlOTUConverter.java 2009-06-28 10:10:36 UTC (rev 135)
@@ -1,5 +1,7 @@
package org.cipres.treebase.domain.nexus.nexml;
+import java.net.URI;
+
import org.cipres.treebase.domain.study.Study;
import org.cipres.treebase.domain.taxon.TaxonLabel;
import org.cipres.treebase.domain.taxon.TaxonLabelHome;
@@ -80,12 +82,16 @@
}
attachTreeBaseID(xmlOTU,taxonLabel,TaxonLabel.class);
if ( null != taxonLabel.getNcbiTaxID() ) {
- attachAnnotation("dc:identifier", "NCBI:" + taxonLabel.getNcbiTaxID(), mDCURI, xmlOTU);
+ StringBuilder urlString = new StringBuilder(getDocument().getBaseURI().toString());
+ taxonLabel.getPhyloWSPath().getPath(urlString).append("NCBI:").append(taxonLabel.getNcbiTaxID());
+ xmlOTU.addAnnotationValue("dc:relation", mDCURI, URI.create(urlString.toString()));
}
TaxonVariant tv = taxonLabel.getTaxonVariant();
if ( null != tv ) {
if ( null != tv.getNamebankID() ) {
- attachAnnotation("dc:identifier", "uBio:" + tv.getNamebankID(), mDCURI, xmlOTU);
+ StringBuilder urlString = new StringBuilder(getDocument().getBaseURI().toString());
+ taxonLabel.getPhyloWSPath().getPath(urlString).append("uBio:").append(tv.getNamebankID());
+ xmlOTU.addAnnotationValue("dc:relation", mDCURI, URI.create(urlString.toString()));
}
}
return xmlOTU;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|