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...> - 2010-03-12 23:26:33
|
Revision: 560 http://treebase.svn.sourceforge.net/treebase/?rev=560&view=rev Author: rvos Date: 2010-03-12 23:26:27 +0000 (Fri, 12 Mar 2010) Log Message: ----------- Removed unused code. Modified Paths: -------------- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchResultsAsRDFController.java Modified: 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 2010-03-12 23:25:12 UTC (rev 559) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchResultsAsRDFController.java 2010-03-12 23:26:27 UTC (rev 560) @@ -32,27 +32,10 @@ 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("searchResultsThawed", searchResults); 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("baseURL", TreebaseUtil.getPurlDomain()); request.getSession().setAttribute("phyloWSPath", phyloWSPath); if ( null != request.getParameter("query") ) { String query = request.getParameter("query"); @@ -64,52 +47,6 @@ } } 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. |