Author: bbrossaud Date: 2010-05-31 18:04:07 +0200 (Mon, 31 May 2010) New Revision: 47 Url: http://chorem.org/repositories/revision/bow/47 Log: fulltext research seems to work Modified: trunk/TODO.txt trunk/src/main/java/org/chorem/bow/BookmarkActions.java trunk/src/main/java/org/chorem/bow/ControllerServlet.java trunk/src/main/webapp/home.jsp trunk/src/main/webapp/search.jsp Modified: trunk/TODO.txt =================================================================== --- trunk/TODO.txt 2010-05-31 13:58:55 UTC (rev 46) +++ trunk/TODO.txt 2010-05-31 16:04:07 UTC (rev 47) @@ -27,3 +27,5 @@ ===> dans class user = String SearchEngine; ===> openSearch ==> proposer des url + +===> facetisations Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java =================================================================== --- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-31 13:58:55 UTC (rev 46) +++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-31 16:04:07 UTC (rev 47) @@ -22,6 +22,7 @@ */ public class BookmarkActions { + protected String fullTextLine = ""; protected List<Bookmark> bookmarks = new ArrayList<Bookmark>(); // bookmarks which contain the search tags protected List<Bookmark> lastBookmarks = new ArrayList<Bookmark>(); protected Map<String, Integer> tagCloud = new HashMap<String, Integer>(); // associate a tag with its frequency @@ -228,7 +229,29 @@ return ""; } - public void createTagsCloud() { + public void fullText(String line) { + fullTextLine = line; + String[] fullText = line.split("\\s+"); + List<Bookmark> save = new ArrayList<Bookmark>(bookmarks); + for (Bookmark bookmark : save) { + boolean delete = true; + Set<String> tags = bookmark.getTags(); + String name = bookmark.getDescription(); + for (String word : fullText) { + if (tags != null && tags.contains(word)) { + delete = false; + } + if (name.contains(word)) { + delete = false; + } + } + if (delete == true) { + bookmarks.remove(bookmark); + } + } + } + + public void createTagCloud() { tagCloud.clear(); deleteBookmarkBySearch(); createTagClougByBookmarks(); @@ -389,4 +412,8 @@ public int getTmax() { return tmax; } + + public String getFullTextLine() { + return fullTextLine; + } } Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java =================================================================== --- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 13:58:55 UTC (rev 46) +++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 16:04:07 UTC (rev 47) @@ -207,6 +207,12 @@ log.debug("Going to actionOpenSearchResult"); } this.actionOpenSearchResult(request, response, user, token); + } else if (action.equals("fullText") && user != null) { + if (log.isDebugEnabled()) { + log.debug("Going to actionFullText"); + } + this.actionFullText(request, user); + request.getRequestDispatcher("search.jsp").forward(request, response); } else { if (user != null) { request.getRequestDispatcher("error.jsp").forward(request, response); @@ -361,8 +367,12 @@ } } String searchLine = request.getParameter("searchLine"); + String fullText = request.getParameter("fullTextLine"); + if (fullText == null) { + fullText = ""; + } if (searchLine != null) { - response.sendRedirect("bow?action=search&searchLine=" + searchLine); + response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText); } else { response.sendRedirect("bow?action=home"); } @@ -379,8 +389,12 @@ } } String searchLine = request.getParameter("searchLine"); + String fullText = request.getParameter("fullTextLine"); + if (fullText == null) { + fullText = ""; + } if (searchLine != null) { - response.sendRedirect("bow?action=search&searchLine=" + searchLine); + response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText); } else { response.sendRedirect("bow?action=home"); } @@ -401,8 +415,12 @@ } } String searchLine = request.getParameter("searchLine"); + String fullText = request.getParameter("fullTextLine"); + if (fullText == null) { + fullText = ""; + } if (searchLine != null) { - response.sendRedirect("bow?action=search&searchLine=" + searchLine); + response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText); } else { response.sendRedirect("bow?action=home"); } @@ -436,7 +454,16 @@ tokenActions.setPermanentToken(""); } } - response.sendRedirect("bow?action=home"); + String searchLine = request.getParameter("searchLine"); + String fullText = request.getParameter("fullTextLine"); + if (fullText == null) { + fullText = ""; + } + if (searchLine != null) { + response.sendRedirect("bow?action=search&searchLine=" + searchLine + "&fullTextLine=" + fullText); + } else { + response.sendRedirect("bow?action=home"); + } } /* @param request servlet request @@ -533,17 +560,25 @@ } protected BookmarkActions createBookmarkActions(HttpServletRequest request, List<Bookmark> bookList) { - String words = request.getParameter("searchLine"); // retrieve informations taping in the search field + String fullText = request.getParameter("fullTextLine"); + String searchLine = request.getParameter("searchLine"); // retrieve informations taping in the search field BookmarkActions bookmarkActions = new BookmarkActions(); if (bookList != null) { bookmarkActions.setBookmarks(bookList); } - bookmarkActions.addTags(words); // add the new tags - String tag = request.getParameter("addTag"); - if (tag != null && !tag.isEmpty()) { - bookmarkActions.addTag(tag); + if (fullText != null && !fullText.isEmpty()) { + log.debug("toto"); + bookmarkActions.fullText(fullText); + bookmarkActions.createTagClougByBookmarks(); + bookmarkActions.defineTValues(); + } else { + bookmarkActions.addTags(searchLine); // add the new tags + String tag = request.getParameter("addTag"); + if (tag != null && !tag.isEmpty()) { + bookmarkActions.addTag(tag); + } + bookmarkActions.createTagCloud(); // create the tags cloud with the new informations } - bookmarkActions.createTagsCloud(); // create the tags cloud with the new informations return bookmarkActions; } @@ -702,7 +737,12 @@ } } } - response.sendRedirect("bow?action=home"); + String searchLine = request.getParameter("searchLine"); + if (searchLine != null) { + response.sendRedirect("bow?action=search&searchLine=" + searchLine); + } else { + response.sendRedirect("bow?action=home"); + } } protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks, List<String> tagList) @@ -782,4 +822,13 @@ response.sendRedirect("bow?action=home"); } } + + protected void actionFullText(HttpServletRequest request, User user) { + WikittyProxy proxy = model.getProxy(); + Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria(); + List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); + BookmarkActions bookmarkActions = createBookmarkActions(request, bookList); + log.debug(bookmarkActions.getBookmarks().size()); + request.setAttribute("bookmarkActions", bookmarkActions); + } } Modified: trunk/src/main/webapp/home.jsp =================================================================== --- trunk/src/main/webapp/home.jsp 2010-05-31 13:58:55 UTC (rev 46) +++ trunk/src/main/webapp/home.jsp 2010-05-31 16:04:07 UTC (rev 47) @@ -245,7 +245,14 @@ </div> </div> <div class="menu"> - <form method="post" action="bow?action=importBookmarks" enctype="multipart/form-data"> + <form method="POST" action="bow?action=fullText" style="text-align: center;"> + Full text research + <input style="float: left" type="text" name="fullTextLine" size="15" value="<%=bookmarkActions.getFullTextLine()%>"/> + <input style="float: left;" type="submit" value="Find" /> + </form> + </div> + <div class="menu"> + <form method="POST" action="bow?action=importBookmarks" enctype="multipart/form-data"> Import Bookmarks <input type="file" name="upfile" /> <input type="submit" value="Import"/> Modified: trunk/src/main/webapp/search.jsp =================================================================== --- trunk/src/main/webapp/search.jsp 2010-05-31 13:58:55 UTC (rev 46) +++ trunk/src/main/webapp/search.jsp 2010-05-31 16:04:07 UTC (rev 47) @@ -17,6 +17,7 @@ String temporaryToken = tokenActions.getTemporaryToken(); String permanentToken = tokenActions.getPermanentToken(); String searchLine = bookmarkActions.getSearchLine(); + String fullText = bookmarkActions.getFullTextLine(); String url = (String) request.getAttribute("bowUrl"); String version = (String) request.getAttribute("version"); %> @@ -41,29 +42,29 @@ <th class="result remove">Remove</th> <th class="result date"> Date - <a style="text-decoration:none" href="bow?action=orderAsc&type=date&searchLine=<%=searchLine%>" > + <a style="text-decoration:none" href="bow?action=orderAsc&type=date&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>" > <IMG style="border:none" SRC="img/asc.png" ALT="order ASC" TITLE="Asc" /> </a> - <a style="text-decoration:none" href="bow?action=orderDesc&type=date&searchLine=<%=searchLine%>"> + <a style="text-decoration:none" href="bow?action=orderDesc&type=date&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" /> </a> </th> <th class="result name"> Name - <a style="text-decoration:none" href="bow?action=orderAsc&type=name&searchLine=<%=searchLine%>"> + <a style="text-decoration:none" href="bow?action=orderAsc&type=name&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> <IMG style="border:none" SRC="img/asc.png" ALT="order ASC" TITLE="Asc" /> </a> - <a style="text-decoration:none" href="bow?action=orderDesc&type=name&searchLine=<%=searchLine%>"> + <a style="text-decoration:none" href="bow?action=orderDesc&type=name&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" /> </a> </th> <th class ="result tags">Tags</th> <th class=" result click"> Click - <a style="text-decoration:none" href="bow?action=orderAsc&type=click&searchLine=<%=searchLine%>"> + <a style="text-decoration:none" href="bow?action=orderAsc&type=click&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> <IMG style="border:none" SRC="img/asc.png" ALT="order ASC" TITLE="Asc" /> </a> - <a style="text-decoration:none" href="bow?action=orderDesc&type=click&searchLine=<%=searchLine%>"> + <a style="text-decoration:none" href="bow?action=orderDesc&type=click&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> <IMG style="border:none" SRC="img/desc.png" ALT="order DESC" TITLE="Desc" /> </a> </th> @@ -74,7 +75,7 @@ %> <tr class="result"> <td class="result"> - <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>"> + <a style="border:none;" href="bow?action=removeBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> <IMG style="border:none;" SRC="img/remove.png" ALT="Remove bookmark" TITLE="Remove" /> </a> </td> @@ -89,11 +90,11 @@ %> <td class="result"> <a title ="<%=alias%>" href="bow?action=addClick&bookmarkId=<%=bookmark.getWikittyId()%>" target="_blank"><%=bookmark.getDescription()%></a> - <form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>" style="display: inline"> + <form method="POST" action="bow?action=addAlias&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>" style="display: inline"> <input type="text" name="alias" size="10" value="<%=bookmark.getAlias()%>" /> <input style="display: inline;" type="submit" value="Add alias" /> </form> - <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>"> + <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> <input type="text" name="name" size="35" value="<%=bookmark.getDescription()%>" /> <input type="image" src="img/edit.png" title="Edit"/> </form> @@ -105,7 +106,7 @@ for (String tag : tagList) { %> <div style="display: inline"> - <a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>&searchLine=<%=searchLine%>"> + <a style="text-decoration:none" href="bow?action=deleteTag&bookmarkId=<%=bookmark.getWikittyId()%>&deleteTag=<%=tag%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> <IMG style="border:none" SRC="img/delete.png" ALT="Delete tag" TITLE="Delete" /> </a> <%=tag%> @@ -114,7 +115,7 @@ } } %> - <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>"> + <form method="POST" action="bow?action=editBookmark&bookmarkId=<%=bookmark.getWikittyId()%>&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> <input type="text" name="tags" size="35" value="<%=BookmarkActions.getBookmarkTagsString(bookmark)%>" /> <input type="image" src="img/edit.png" title="Edit"/> </form> @@ -142,10 +143,11 @@ <li><a href="bow?action=home">Home</a></li> <li><a href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='<%=url%>bow?action=addUrl&token=<%=temporaryToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">Temporary token</a></li> <li><a href="javascript:var%20url=location.href;var%20nameAndTags=prompt('Entrez%20le%20nom%20du%20lien%20et%20la%20liste%20des%20tags%20sous%20la%20forme:%20name|tag1%20tag2%20tag3',%20document.title+'|');var%20link='<%=url%>bow?action=addUrl&token=<%=permanentToken%>&url='+encodeURIComponent(url)+'&nameAndTags='+encodeURIComponent(nameAndTags);var%20script=document.createElement('script');script.src=link;script.type='text/javascript';document.body.appendChild(script);void(0);">Current permanent token</a></li> + <li><a href="bow?action=generateToken&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">Regenerate permanent token</a></li> </ul> </div> <div class="menu"> - <form method="POST" action="bow?action=addUrl&searchLine=<%=searchLine%>"> + <form method="POST" action="bow?action=addUrl&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>"> URL<br /> <input type="text" name="url" size="20" value="URL" /><br /> Name<br /> @@ -175,6 +177,22 @@ <input style="float: left" type="submit" value="Find" /> </form> </div> + <div class="menu"> + <form method="POST" action="bow?action=fullText" style="text-align: center;"> + Full text research + <input style="float: left" type="text" name="fullTextLine" size="15" value="<%=bookmarkActions.getFullTextLine()%>" /> + <input style="float: left;" type="submit" value="Find" /> + </form> + </div> + <div class="menu"> + <form method="post" action="bow?action=importBookmarks&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>" enctype="multipart/form-data"> + Import Bookmarks + <input type="file" name="upfile" /> + <input type="submit" value="Import"/> + </form> + <br /> + <a href="bow?action=exportBookmarks&searchLine=<%=searchLine%>&fullTextLine=<%=fullText%>">Export bookmarks</a> + </div> </div> </div> <div class="Index" id="footer">
participants (1)
-
bbrossaudï¼ users.chorem.org