From: <hs...@us...> - 2011-05-03 19:21:31
|
Revision: 826 http://treebase.svn.sourceforge.net/treebase/?rev=826&view=rev Author: hshyket Date: 2011-05-03 19:21:24 +0000 (Tue, 03 May 2011) Log Message: ----------- Fixing issue where Specimen Labels for Latitude and Longitude were not displaying properly. Also adding in Google Maps link to table with row segment data. Adding in functionality to download all row segment metadata if any row segment data exists. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/taxon/SpecimenLabel.java trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/matrix.jsp trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/rowSegments.jsp trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml Added Paths: ----------- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/DownloadRowSegmentDataController.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/taxon/SpecimenLabel.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/taxon/SpecimenLabel.java 2011-05-01 00:57:43 UTC (rev 825) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/taxon/SpecimenLabel.java 2011-05-03 19:21:24 UTC (rev 826) @@ -217,7 +217,7 @@ @Transient public String getLongitudeString() { if (mLongitude == null) return ""; - else return abs(mLongitude) + mLongitude < 0 ? "S" : "N"; + else return abs(mLongitude) + (mLongitude < 0 ? "S" : "N"); } /** @@ -245,7 +245,7 @@ @Transient public String getLatitudeString() { if (mLatitude == null) return ""; - else return abs(mLatitude) + mLatitude < 0 ? "W" : "E"; + else return abs(mLatitude) + (mLatitude < 0 ? "W" : "E"); } /** Added: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/DownloadRowSegmentDataController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/DownloadRowSegmentDataController.java (rev 0) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/DownloadRowSegmentDataController.java 2011-05-03 19:21:24 UTC (rev 826) @@ -0,0 +1,104 @@ + + + +package org.cipres.treebase.web.controllers; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.Controller; + +import org.cipres.treebase.TreebaseUtil; +import org.cipres.treebase.domain.matrix.RowSegmentService; +import org.cipres.treebase.web.util.WebUtil; + + +/** + * + * @author Madhu + * + * Created on May 15, 2008 + * + * For exporting the tab delimited row segment data for a particular matrix. + * + */ +public class DownloadRowSegmentDataController implements Controller { + + private RowSegmentService mRowSegmentService; + + /** + * @return the rowSegmentService + */ + public RowSegmentService getRowSegmentService() { + return mRowSegmentService; + } + + /** + * @param pRowSegmentService the rowSegmentService to set + */ + public void setRowSegmentService(RowSegmentService pRowSegmentService) { + mRowSegmentService = pRowSegmentService; + } + + public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) + throws Exception { + + Map<String,String []> param = request.getParameterMap(); + + + //String matrixId = (String) request.getSession().getAttribute("MATRIX_ID"); + String matrixId = param.get("matrixid")[0]; + String data = null; + if (!TreebaseUtil.isEmpty(matrixId)) { + data = getRowSegmentService().generateRowSegmentTextTSV(Long.parseLong(matrixId)); + } + + String downloadDir = request.getSession().getServletContext().getRealPath( + TreebaseUtil.FILESEP + "RowSegmentDownload") + + TreebaseUtil.FILESEP + "temp_rowsegment"; + + String fileName = "RowSegmentData_" + matrixId + ".tsv"; + + File dirPath = new File(downloadDir); + if (!dirPath.exists()) { + dirPath.mkdirs(); + } + + String rowsegmentFile = downloadDir + TreebaseUtil.FILESEP + fileName; + + try { + + File file = new File(rowsegmentFile); + FileWriter out = new FileWriter(file); + + out.write(data); + + out.close(); + // File did not exist and was created + // } else { + // File already exists + // } + + } catch (IOException e) { + e.printStackTrace(); + } + + WebUtil.downloadFile(response, downloadDir, fileName); + + File rowFile = new File(rowsegmentFile); + + if (rowFile.exists()) { + rowFile.delete(); + } + + // TODO Auto-generated method stub + return null; + } + +} Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/matrix.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/matrix.jsp 2011-05-01 00:57:43 UTC (rev 825) +++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/matrix.jsp 2011-05-03 19:21:24 UTC (rev 826) @@ -10,9 +10,10 @@ </c:url> <c:url var="matricesURL" value="matrices.html"> <c:param name="id" value="${study.id}"/> +</c:url> +<c:url var="rowSegmentsTSV" value="rowSegmentsTSV.html"> + <c:param name="matrixid" value="${matrix.id}" /> </c:url> - - <title>Matrix ${matrix.id} of study ${study.id}</title> <body id="s-matrix"/> @@ -23,7 +24,19 @@ <c:if test="${ not empty matrix.description }"> <p><strong>Description</strong>: ${matrix.description}</p> -</c:if> +</c:if> + +<c:set var="rowSegmentCount" value="false" /> + +<c:forEach var="row" items="${matrix.rowsReadOnly}" varStatus="status"> + <c:if test="${fn:length(row.segmentsReadOnly) gt 0}"> + <c:set var="rowSegmentCount" value="true" /> + </c:if> +</c:forEach> + +<c:if test="${rowSegmentCount}"> + <a href="${rowSegmentsTSV}">Download all Row Segment Metadata</a> +</c:if> <h2>Rows</h2> Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/rowSegments.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/rowSegments.jsp 2011-05-01 00:57:43 UTC (rev 825) +++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/study/rowSegments.jsp 2011-05-03 19:21:24 UTC (rev 826) @@ -19,6 +19,7 @@ <c:param name="id" value="${study.id}" /> <c:param name="matrixid" value="${matrix.id}" /> </c:url> + <c:forEach var="row" items="${matrix.rowsReadOnly}" varStatus="status"> <c:if test="${row.id == matrixrow.id}"> <c:set var="rownum" value="${status.count}"/> @@ -61,7 +62,28 @@ sortable="true" style="text-align:left; font-family:Courier; width:20%;"> ${seg.specimenInfo} - </display:column> + </display:column> + + <display:column title="Google Map" + style="text-align:left; font-family:Courier; width:20%;"> + <c:if test="${not empty(seg.specimenLabel.latitude) && not empty(seg.specimenLabel.longitude)}"> + <c:url var="googleMapURL" value="http://www.google.com/maps"> + <c:param name="f" value="q" /> + <c:param name="source" value="s_q" /> + <c:param name="hl" value="en" /> + <c:param name="geocode" value="" /> + <c:param name="q" value="${seg.specimenLabel.latitude},${seg.specimenLabel.longitude}" /> + <c:param name="sll" value="${seg.specimenLabel.latitude},${seg.specimenLabel.longitude}" /> + <c:param name="aq" value="" /> + <c:param name="sspn" value="0.199959,0.445976" /> + <c:param name="ie" value="UTF8" /> + <c:param name="z" value="16" /> + </c:url> + <a href='<c:out value="${googleMapURL}"/>' target="_blank">View Map</a> + </c:if> + </display:column> + + <%-- <display:column title="Segment data" property="segmentData" sortable="false" Modified: trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml 2011-05-01 00:57:43 UTC (rev 825) +++ trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml 2011-05-03 19:21:24 UTC (rev 826) @@ -254,6 +254,10 @@ <property name="phyloTreeService"><ref bean="phyloTreeService"></ref></property> <property name="analysisService"><ref bean="analysisService"></ref></property> <property name="taxonLabelService"><ref bean="taxonLabelService"></ref></property> + </bean> + + <bean id="downloadRowSegmentDataController" class="org.cipres.treebase.web.controllers.DownloadRowSegmentDataController"> + <property name="rowSegmentService"><ref bean="rowSegmentService"></ref></property> </bean> <!-- MultiActionController to display sumbissions by different criteria --> @@ -1023,7 +1027,8 @@ <prop key="/search/study/matrix.html">searchSummaryController</prop> <prop key="/search/study/analysis.html">searchSummaryController</prop> <prop key="/search/study/taxa.html">searchSummaryController</prop> - <prop key="/search/study/rowSegments.html">searchSummaryController</prop> + <prop key="/search/study/rowSegments.html">searchSummaryController</prop> + <prop key="/search/study/rowSegmentsTSV.html">downloadRowSegmentDataController</prop> <prop key="/search/study/anyObjectAsRDF.rdf">anyObjectAsRDFController</prop> <prop key="/search/searchResultsAsRDF.rdf">searchResultsAsRDFController</prop> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |