You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

results.jsp 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <%--
  2. ~ Licensed to the Apache Software Foundation (ASF) under one
  3. ~ or more contributor license agreements. See the NOTICE file
  4. ~ distributed with this work for additional information
  5. ~ regarding copyright ownership. The ASF licenses this file
  6. ~ to you under the Apache License, Version 2.0 (the
  7. ~ "License"); you may not use this file except in compliance
  8. ~ with the License. You may obtain a copy of the License at
  9. ~
  10. ~ http://www.apache.org/licenses/LICENSE-2.0
  11. ~
  12. ~ Unless required by applicable law or agreed to in writing,
  13. ~ software distributed under the License is distributed on an
  14. ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. ~ KIND, either express or implied. See the License for the
  16. ~ specific language governing permissions and limitations
  17. ~ under the License.
  18. --%>
  19. <%@ taglib uri="/struts-tags" prefix="s" %>
  20. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  21. <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
  22. <%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
  23. <html>
  24. <head>
  25. <title>Search Results</title>
  26. <s:head/>
  27. </head>
  28. <body>
  29. <c:if test="${fromFilterSearch == true}">
  30. <h1>Advanced Search</h1>
  31. </c:if>
  32. <c:if test="${fromFilterSearch == false}">
  33. <h1>Search</h1>
  34. </c:if>
  35. <c:url var="imgNextPageUrl" value="/images/icon_next_page.gif"/>
  36. <c:url var="imgPrevPageUrl" value="/images/icon_prev_page.gif"/>
  37. <c:url var="imgPrevPageDisabledUrl" value="/images/icon_prev_page_disabled.gif"/>
  38. <c:url var="imgNextPageDisabledUrl" value="/images/icon_next_page_disabled.gif"/>
  39. <div id="contentArea">
  40. <div id="searchBox">
  41. <c:if test="${fromFilterSearch == true}">
  42. <s:form method="get" action="filteredSearch" validate="true">
  43. <s:textfield label="Row Count" size="50" name="rowCount"/>
  44. <s:textfield label="Group Id" size="50" name="groupId"/>
  45. <s:textfield label="Artifact Id" size="50" name="artifactId"/>
  46. <s:textfield label="Version" size="50" name="version"/>
  47. <s:textfield label="Class / Package" size="50" name="className"/>
  48. <s:select name="repositoryId" label="Repository ID" list="managedRepositoryList"/>
  49. <s:hidden name="completeQueryString" value="${completeQueryString}"/>
  50. <s:hidden name="fromFilterSearch" value="${fromFilterSearch}"/>
  51. <s:submit label="Go!"/>
  52. </s:form>
  53. <s:url id="indexUrl" action="index"/>
  54. <s:a href="%{indexUrl}">
  55. Quick Search Page
  56. </s:a>
  57. <script type="text/javascript">
  58. document.getElementById("filteredSearch_groupId").focus();
  59. </script>
  60. </c:if>
  61. <c:if test="${fromFilterSearch == false}">
  62. <s:form method="get" action="quickSearch" validate="true">
  63. <s:textfield label="Search for" size="50" name="q"/>
  64. <s:checkbox label="Search within results" name="searchResultsOnly"/>
  65. <s:hidden name="completeQueryString" value="${completeQueryString}"/>
  66. <s:submit label="Go!"/>
  67. </s:form>
  68. <script type="text/javascript">
  69. document.getElementById("quickSearch_q").focus();
  70. </script>
  71. </c:if>
  72. <p>
  73. <s:actionerror/>
  74. </p>
  75. </div>
  76. <h1>Results</h1>
  77. <div id="resultsBox">
  78. <c:choose>
  79. <%-- search was made from the indices --%>
  80. <c:when test="${databaseResults == null}">
  81. <c:set var="hitsNum">${fn:length(results.hits) + (currentPage * results.limits.pageSize)}</c:set>
  82. <c:choose>
  83. <c:when test="${results.totalHits > results.limits.pageSize}">
  84. <p>Hits: ${(hitsNum - results.limits.pageSize) + 1} to ${hitsNum} of ${results.totalHits}</p>
  85. </c:when>
  86. <c:otherwise>
  87. <p>Hits: 1 to ${hitsNum} of ${results.totalHits}</p>
  88. </c:otherwise>
  89. </c:choose>
  90. <c:choose>
  91. <c:when test="${empty results.hits}">
  92. <p>No results</p>
  93. </c:when>
  94. <c:otherwise>
  95. <%-- Pagination start --%>
  96. <p>
  97. <%-- Prev & Next icons --%>
  98. <c:if test="${fromFilterSearch == false}">
  99. <c:set var="prevPageUrl">
  100. <s:url action="quickSearch" namespace="/">
  101. <s:param name="q" value="%{'${q}'}"/>
  102. <s:param name="currentPage" value="%{'${currentPage - 1}'}"/>
  103. </s:url>
  104. </c:set>
  105. <c:set var="nextPageUrl">
  106. <s:url action="quickSearch" namespace="/">
  107. <s:param name="q" value="%{'${q}'}"/>
  108. <s:param name="currentPage" value="%{'${currentPage + 1}'}"/>
  109. </s:url>
  110. </c:set>
  111. </c:if>
  112. <c:if test="${fromFilterSearch == true}">
  113. <c:set var="prevPageUrl">
  114. <s:url action="filteredSearch" namespace="/">
  115. <%-- <s:param name="q" value="%{'${q}'}"/> --%>
  116. <s:param name="rowCount" value="%{'${rowCount}'}"/>
  117. <s:param name="groupId" value="%{'${groupId}'}"/>
  118. <s:param name="artifactId" value="%{'${artifactId}'}"/>
  119. <s:param name="version" value="%{'${version}'}"/>
  120. <s:param name="className" value="%{'${className}'}"/>
  121. <s:param name="repositoryId" value="%{'${repositoryId}'}"/>
  122. <s:param name="filterSearch" value="%{'${filterSearch}'}"/>
  123. <s:param name="fromResultsPage" value="true"/>
  124. <s:param name="currentPage" value="%{'${currentPage - 1}'}"/>
  125. <s:param name="searchResultsOnly" value="%{'${searchResultsOnly}'}"/>
  126. <s:param name="completeQueryString" value="%{'${completeQueryString}'}"/>
  127. </s:url>
  128. </c:set>
  129. <c:set var="nextPageUrl">
  130. <s:url action="filteredSearch" namespace="/">
  131. <%-- <s:param name="q" value="%{'${q}'}"/> --%>
  132. <s:param name="rowCount" value="%{'${rowCount}'}"/>
  133. <s:param name="groupId" value="%{'${groupId}'}"/>
  134. <s:param name="artifactId" value="%{'${artifactId}'}"/>
  135. <s:param name="version" value="%{'${version}'}"/>
  136. <s:param name="className" value="%{'${className}'}"/>
  137. <s:param name="repositoryId" value="%{'${repositoryId}'}"/>
  138. <s:param name="filterSearch" value="%{'${filterSearch}'}"/>
  139. <s:param name="fromResultsPage" value="true"/>
  140. <s:param name="currentPage" value="%{'${currentPage + 1}'}"/>
  141. <s:param name="searchResultsOnly" value="%{'${searchResultsOnly}'}"/>
  142. <s:param name="completeQueryString" value="%{'${completeQueryString}'}"/>
  143. </s:url>
  144. </c:set>
  145. </c:if>
  146. <c:choose>
  147. <c:when test="${currentPage == 0}">
  148. <img src="${imgPrevPageDisabledUrl}"/>
  149. </c:when>
  150. <c:otherwise>
  151. <a href="${prevPageUrl}">
  152. <img src="${imgPrevPageUrl}"/>
  153. </a>
  154. </c:otherwise>
  155. </c:choose>
  156. <%-- Google-style pagination --%>
  157. <c:choose>
  158. <c:when test="${totalPages > 11}">
  159. <c:choose>
  160. <c:when test="${(currentPage - 5) < 0}">
  161. <c:set var="beginVal">0</c:set>
  162. <c:set var="endVal">10</c:set>
  163. </c:when>
  164. <c:when test="${(currentPage + 5) > (totalPages - 1)}">
  165. <c:set var="beginVal">${(totalPages -1) - 10}</c:set>
  166. <c:set var="endVal">${totalPages - 1}</c:set>
  167. </c:when>
  168. <c:otherwise>
  169. <c:set var="beginVal">${currentPage - 5}</c:set>
  170. <c:set var="endVal">${currentPage + 5}</c:set>
  171. </c:otherwise>
  172. </c:choose>
  173. </c:when>
  174. <c:otherwise>
  175. <c:set var="beginVal">0</c:set>
  176. <c:set var="endVal">${totalPages - 1}</c:set>
  177. </c:otherwise>
  178. </c:choose>
  179. <c:forEach var="i" begin="${beginVal}" end="${endVal}">
  180. <c:if test="${fromFilterSearch == false}">
  181. <c:choose>
  182. <c:when test="${i != currentPage}">
  183. <c:set var="specificPageUrl">
  184. <s:url action="quickSearch" namespace="/">
  185. <s:param name="q" value="%{'${q}'}"/>
  186. <s:param name="currentPage" value="%{'${i}'}"/>
  187. <s:param name="searchResultsOnly" value="%{'${searchResultsOnly}'}"/>
  188. <s:param name="completeQueryString" value="%{'${completeQueryString}'}"/>
  189. </s:url>
  190. </c:set>
  191. <a href="${specificPageUrl}">${i + 1}</a>
  192. </c:when>
  193. <c:otherwise>
  194. <b>${i + 1}</b>
  195. </c:otherwise>
  196. </c:choose>
  197. </c:if>
  198. <c:if test="${fromFilterSearch == true}">
  199. <c:choose>
  200. <c:when test="${i != currentPage}">
  201. <c:set var="specificPageUrl">
  202. <s:url action="filteredSearch" namespace="/">
  203. <%-- <s:param name="q" value="%{'${q}'}"/> --%>
  204. <s:param name="rowCount" value="%{'${rowCount}'}"/>
  205. <s:param name="groupId" value="%{'${groupId}'}"/>
  206. <s:param name="artifactId" value="%{'${artifactId}'}"/>
  207. <s:param name="version" value="%{'${version}'}"/>
  208. <s:param name="className" value="%{'${className}'}"/>
  209. <s:param name="repositoryId" value="%{'${repositoryId}'}"/>
  210. <s:param name="filterSearch" value="%{'${filterSearch}'}"/>
  211. <s:param name="fromResultsPage" value="true"/>
  212. <s:param name="currentPage" value="%{'${i}'}"/>
  213. <s:param name="searchResultsOnly" value="%{'${searchResultsOnly}'}"/>
  214. <s:param name="completeQueryString" value="%{'${completeQueryString}'}"/>
  215. </s:url>
  216. </c:set>
  217. <a href="${specificPageUrl}">${i + 1}</a>
  218. </c:when>
  219. <c:otherwise>
  220. <b>${i + 1}</b>
  221. </c:otherwise>
  222. </c:choose>
  223. </c:if>
  224. </c:forEach>
  225. <c:choose>
  226. <c:when test="${currentPage == (totalPages - 1)}">
  227. <img src="${imgNextPageDisabledUrl}"/>
  228. </c:when>
  229. <c:otherwise>
  230. <a href="${nextPageUrl}">
  231. <img src="${imgNextPageUrl}"/>
  232. </a>
  233. </c:otherwise>
  234. </c:choose>
  235. </p>
  236. <%-- Pagination end --%>
  237. <c:forEach items="${results.hits}" var="record" varStatus="i">
  238. <c:choose>
  239. <c:when test="${not empty (record.groupId)}">
  240. <h3 class="artifact-title">
  241. <my:showArtifactTitle groupId="${record.groupId}" artifactId="${record.artifactId}"
  242. version="${record.version}"/>
  243. </h3>
  244. <p>
  245. <my:showArtifactLink groupId="${record.groupId}" artifactId="${record.artifactId}"
  246. version="${record.version}" versions="${record.versions}" repositoryId="${record.repositoryId}"/>
  247. </p>
  248. </c:when>
  249. <c:otherwise>
  250. <p>
  251. <c:url var="hiturl" value="/repository/${record.url}" />
  252. <a href="${hiturl}">${record.urlFilename}</a>
  253. </p>
  254. </c:otherwise>
  255. </c:choose>
  256. </c:forEach>
  257. </c:otherwise>
  258. </c:choose>
  259. </c:when>
  260. <%-- search was made from the database (find artifact)--%>
  261. <c:otherwise>
  262. <p>Hits: ${fn:length(databaseResults)}</p>
  263. <c:choose>
  264. <c:when test="${empty databaseResults}">
  265. <p>No results</p>
  266. </c:when>
  267. <c:otherwise>
  268. <c:forEach items="${databaseResults}" var="artifactModel" varStatus="i">
  269. <c:choose>
  270. <c:when test="${not empty (artifactModel.groupId)}">
  271. <h3 class="artifact-title">
  272. <my:showArtifactTitle groupId="${artifactModel.groupId}" artifactId="${artifactModel.artifactId}"
  273. version="${artifactModel.version}"/>
  274. </h3>
  275. <p>
  276. <my:showArtifactLink groupId="${artifactModel.groupId}" artifactId="${artifactModel.artifactId}"
  277. version="${artifactModel.version}" versions="${artifactModel.versions}"/>
  278. </p>
  279. </c:when>
  280. <c:otherwise>
  281. <p>
  282. <c:url var="hiturl" value="/repository/${artifactModel.repositoryId}" />
  283. <a href="${hiturl}">${artifactModel.repositoryId}</a>
  284. </p>
  285. </c:otherwise>
  286. </c:choose>
  287. </c:forEach>
  288. </c:otherwise>
  289. </c:choose>
  290. </c:otherwise>
  291. </c:choose>
  292. </div>
  293. </div>
  294. </body>
  295. </html>