Bow-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 617 discussions
01 Jun '10
Author: bbrossaud
Date: 2010-06-01 15:24:13 +0200 (Tue, 01 Jun 2010)
New Revision: 53
Url: http://chorem.org/repositories/revision/bow/53
Log:
retrieve tagCloud thanks to facets
Modified:
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/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-06-01 10:55:42 UTC (rev 52)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-06-01 13:24:13 UTC (rev 53)
@@ -5,16 +5,14 @@
package org.chorem.bow;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.nuiton.util.StringUtil;
+import org.nuiton.wikitty.FacetTopic;
/**
*
@@ -25,8 +23,7 @@
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
- // among all bookmarks
+ protected List<FacetTopic> tagCloud = new ArrayList<FacetTopic>(); // associate a tag with its frequency
protected List<String> tagsSearch = new ArrayList<String>(); // contains the tags taped in the search field
protected int tmax = -1;
protected int tmin = -1;
@@ -249,12 +246,28 @@
}
}
- public void createTagCloud() {
- tagCloud.clear();
- createTagClougByBookmarks();
+ public void createTagCloud(List<FacetTopic> cpy) {
+ setTagCloud(cpy);
+ deleteTagBySearch();
defineTValues();
}
+ public void setTagCloud(List<FacetTopic> cpy) {
+ if (cpy != null) {
+ tagCloud = new ArrayList<FacetTopic>(cpy);
+ }
+ }
+
+ public void deleteTagBySearch() {
+ List<FacetTopic> save = new ArrayList<FacetTopic>(tagCloud);
+ for (FacetTopic topic : save) {
+ String name = topic.getTopicName();
+ if (tagsSearch.contains(name)) {
+ tagCloud.remove(topic);
+ }
+ }
+ }
+
public void deleteBookmarkBySearch() {
List<Bookmark> bookmarksList = new ArrayList<Bookmark>(bookmarks);
for (Bookmark bookmark : bookmarksList) {
@@ -276,42 +289,11 @@
}
}
- public void createTagClougByBookmarks() {
- List<Bookmark> bookmarksList = new ArrayList<Bookmark>(bookmarks);
- for (Bookmark bookmark : bookmarksList) {
- addBookmarkTagsToTagCloud(bookmark);
- }
- }
-
-
- /* @param bookmark user bookmark
- * @return void
- */
- protected void addBookmarkTagsToTagCloud(Bookmark bookmark) {
- Set<String> tags = bookmark.getTags(); // bookmark tags
- if (tags != null && !tags.isEmpty()) {
- for (String tag : tags) {
- if (!tagsSearch.contains(tag)) { // the tags cloud mustn't contained the tags taped in the search field
- if (tagCloud.containsKey(tag)) { // check if it contains the tag
- Integer count = tagCloud.get(tag);
- ++count;
- tagCloud.put(tag, count);
- } else {
- tagCloud.put(tag, 1);
- }
- }
- }
- }
- }
-
protected void defineTValues() {
- Collection values = tagCloud.values();
- Iterator it = values.iterator();
tmax = -1; // correspond to the most tag frequency in the tag cloud
tmin = -1; // correspond to the less tag frequency in the tag cloud
- int value;
- while (it.hasNext()) {
- value = (Integer) it.next();
+ for (FacetTopic tag : tagCloud) {
+ int value = tag.getCount();
if (tmax < value) { // search the most tag frequancy
tmax = value;
}
@@ -386,7 +368,7 @@
return font;
}
- public Map<String, Integer> getTagsCloud() {
+ public List<FacetTopic> getTagsCloud() {
return tagCloud;
}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 10:55:42 UTC (rev 52)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 13:24:13 UTC (rev 53)
@@ -12,8 +12,10 @@
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
@@ -33,6 +35,8 @@
import org.htmlparser.util.SimpleNodeIterator;
import org.nuiton.util.ArgumentsParserException;
import org.nuiton.wikitty.Criteria;
+import org.nuiton.wikitty.FacetTopic;
+import org.nuiton.wikitty.PagedResult;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.search.Search;
@@ -235,8 +239,8 @@
WikittyProxy proxy = model.getProxy();
Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine);
criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
- List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, searchLine);
+ PagedResult result = proxy.findAllByCriteria(Bookmark.class, criteria);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine);
request.setAttribute("bookmarkActions", bookmarkActions);
request.setAttribute("token", token);
request.getRequestDispatcher("openSearchResult.jsp").forward(request, response);
@@ -302,18 +306,18 @@
Criteria baseCriteria = getBookmarkListCriteriaByUser(user, searchLine);
if (type != null && baseCriteria != null && !type.isEmpty()) {
WikittyProxy proxy = model.getProxy();
- List<Bookmark> bookList = null;
+ PagedResult result = null;
if (type.equals("name")) {
Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_DESCRIPTION);
- bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ result = proxy.findAllByCriteria(Bookmark.class, criteria);
} else if (type.equals("date")) {
Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_DATE);
- bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ result = proxy.findAllByCriteria(Bookmark.class, criteria);
} else if (type.equals("click")) {
Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_CLICK);
- bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ result = proxy.findAllByCriteria(Bookmark.class, criteria);
}
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, searchLine);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine);
request.setAttribute("bookmarkActions", bookmarkActions);
}
}
@@ -325,18 +329,18 @@
Criteria baseCriteria = getBookmarkListCriteriaByUser(user, searchLine);
if (type != null && baseCriteria != null && !type.isEmpty()) {
WikittyProxy proxy = model.getProxy();
- List<Bookmark> bookList = null;
+ PagedResult result = null;
if (type.equals("name")) {
Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_DESCRIPTION);
- bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ result = proxy.findAllByCriteria(Bookmark.class, criteria);
} else if (type.equals("date")) {
Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_DATE);
- bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ result = proxy.findAllByCriteria(Bookmark.class, criteria);
} else if (type.equals("click")) {
Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
- bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ result = proxy.findAllByCriteria(Bookmark.class, criteria);
}
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, searchLine);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine);
request.setAttribute("bookmarkActions", bookmarkActions);
}
}
@@ -507,29 +511,29 @@
WikittyProxy proxy = model.getProxy();
Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine);
criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
- List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, searchLine);
+ PagedResult result = proxy.findAllByCriteria(Bookmark.class, criteria); // select all bookmarks by user
+ BookmarkActions bookmarkActions = createBookmarkActions(request, result, searchLine);
request.setAttribute("bookmarkActions", bookmarkActions);
}
- protected BookmarkActions createBookmarkActions(HttpServletRequest request, List<Bookmark> bookList, String searchLine) {
+ protected BookmarkActions createBookmarkActions(HttpServletRequest request, PagedResult result, String searchLine) {
String fullText = request.getParameter("fullTextLine");
BookmarkActions bookmarkActions = new BookmarkActions();
+ List<Bookmark> bookList = result.getAll();
if (bookList != null) {
bookmarkActions.setBookmarks(bookList);
}
if (fullText != null && !fullText.isEmpty()) {
bookmarkActions.fullText(fullText);
- bookmarkActions.createTagClougByBookmarks();
- bookmarkActions.defineTValues();
} else {
if (searchLine != null && searchLine.isEmpty()) {
bookmarkActions.emptySearchline();
} else {
bookmarkActions.addTags(searchLine); // add the new tags
}
- bookmarkActions.createTagCloud(); // create the tags cloud with the new informations
}
+ List<FacetTopic> topics = result.getTopic(Bookmark.FQ_FIELD_TAGS);
+ bookmarkActions.createTagCloud(topics);
return bookmarkActions;
}
@@ -647,11 +651,11 @@
Criteria criteria = getBookmarkListCriteriaByUser(user, null);
if (criteria != null) {
Criteria sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
- List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, sortCriteria).getAll(); // select all bookmarks by user
+ PagedResult result = proxy.findAllByCriteria(Bookmark.class, sortCriteria); // select all bookmarks by user
sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_DATE).setEndIndex(10);
List<Bookmark> lastBookmarks = proxy.findAllByCriteria(Bookmark.class, sortCriteria).getAll();
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, null);
- bookList = bookmarkActions.getBookmarks();
+ BookmarkActions bookmarkActions = createBookmarkActions(request, result, null);
+ List<Bookmark> bookList = bookmarkActions.getBookmarks();
if (bookList.size() > 10) {
bookList = bookmarkActions.getBookmarks().subList(0, 10);
bookmarkActions.setBookmarks(bookList);
@@ -767,9 +771,9 @@
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, null);
+ Criteria criteria = getBookmarkListCriteriaByUser(user, null);
+ PagedResult result = proxy.findAllByCriteria(Bookmark.class, criteria);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, result, null);
request.setAttribute("bookmarkActions", bookmarkActions);
}
@@ -793,10 +797,11 @@
if (searchLine != null && !searchLine.isEmpty()) {
String[] words = searchLine.split("\\s+"); // put the tags in an array
List<String> tags = new ArrayList<String>(Arrays.asList(words));
- log.debug(tags.size());
- criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).eq(Bookmark.FQ_FIELD_TAGS, tags).criteria();
+ criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).
+ eq(Bookmark.FQ_FIELD_TAGS, tags).criteria().addFacetField(Bookmark.FQ_FIELD_TAGS);
} else {
- criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria();
+ criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).
+ criteria().addFacetField(Bookmark.FQ_FIELD_TAGS);
}
}
return criteria;
Modified: trunk/src/main/webapp/home.jsp
===================================================================
--- trunk/src/main/webapp/home.jsp 2010-06-01 10:55:42 UTC (rev 52)
+++ trunk/src/main/webapp/home.jsp 2010-06-01 13:24:13 UTC (rev 53)
@@ -9,6 +9,7 @@
<%@page import="java.util.ArrayList" %>
<%@page import="java.util.List" %>
<%@page import="org.chorem.bow.TokenActions" %>
+<%@page import="org.nuiton.wikitty.FacetTopic" %>
<%
TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
@@ -227,13 +228,13 @@
<div class="menu">
<div class="tagCloud">
<% if (bookmarkActions != null) {
- Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
- Set<String> tags = tagsCloud.keySet();
- for (String tag : tags) {
- int value = tagsCloud.get(tag);
+ List<FacetTopic> tagCloud = bookmarkActions.getTagsCloud();
+ for (FacetTopic tag : tagCloud) {
+ int value = tag.getCount();
+ String tagName = tag.getTopicName();
int font = bookmarkActions.getFont(value);
%>
- <a href="bow?action=search&addTag=<%=tag%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
+ <a href="bow?action=search&addTag=<%=tagName%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tagName%></a>
<%
}
}
Modified: trunk/src/main/webapp/search.jsp
===================================================================
--- trunk/src/main/webapp/search.jsp 2010-06-01 10:55:42 UTC (rev 52)
+++ trunk/src/main/webapp/search.jsp 2010-06-01 13:24:13 UTC (rev 53)
@@ -9,6 +9,7 @@
<%@page import="java.util.ArrayList" %>
<%@page import="java.util.List" %>
<%@page import="org.chorem.bow.TokenActions" %>
+<%@page import="org.nuiton.wikitty.FacetTopic" %>
<%
TokenActions tokenActions = (TokenActions) session.getAttribute("tokenActions");
@@ -161,13 +162,13 @@
<div class="menu">
<div class="tagCloud">
<% if (bookmarkActions != null) {
- Map<String, Integer> tagsCloud = bookmarkActions.getTagsCloud();
- Set<String> tags = tagsCloud.keySet();
- for (String tag : tags) {
- int value = tagsCloud.get(tag);
+ List<FacetTopic> tagCloud = bookmarkActions.getTagsCloud();
+ for (FacetTopic tag : tagCloud) {
+ int value = tag.getCount();
+ String tagName = tag.getTopicName();
int font = bookmarkActions.getFont(value);
%>
- <a href="bow?action=search&addTag=<%=tag%>&searchLine=<%=searchLine%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tag%></a>
+ <a href="bow?action=search&addTag=<%=tagName%>&searchLine=<%=searchLine%>" title="<%=value%> results" class="tag" style="font-size: <%=font%>px;"><%=tagName%></a>
<%
}
}
1
0
Author: bpoussin
Date: 2010-06-01 12:55:42 +0200 (Tue, 01 Jun 2010)
New Revision: 52
Url: http://chorem.org/repositories/revision/bow/52
Log:
suppression d'imports non utilises
Modified:
trunk/src/main/java/org/chorem/bow/AliasServlet.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified: trunk/src/main/java/org/chorem/bow/AliasServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/AliasServlet.java 2010-06-01 10:54:42 UTC (rev 51)
+++ trunk/src/main/java/org/chorem/bow/AliasServlet.java 2010-06-01 10:55:42 UTC (rev 52)
@@ -9,7 +9,6 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
import org.nuiton.wikitty.Criteria;
import org.nuiton.wikitty.WikittyProxy;
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 10:54:42 UTC (rev 51)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 10:55:42 UTC (rev 52)
@@ -31,7 +31,6 @@
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;
import org.htmlparser.util.SimpleNodeIterator;
-import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
import org.nuiton.wikitty.Criteria;
import org.nuiton.wikitty.WikittyProxy;
1
0
Author: bpoussin
Date: 2010-06-01 12:54:42 +0200 (Tue, 01 Jun 2010)
New Revision: 51
Url: http://chorem.org/repositories/revision/bow/51
Log:
modification de la configuration (creation d'une vrai classe de config, multi-thread enable)
Added:
trunk/src/main/java/org/chorem/bow/BowConfig.java
Modified:
trunk/src/main/java/org/chorem/bow/AliasServlet.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified: trunk/src/main/java/org/chorem/bow/AliasServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/AliasServlet.java 2010-06-01 10:02:53 UTC (rev 50)
+++ trunk/src/main/java/org/chorem/bow/AliasServlet.java 2010-06-01 10:54:42 UTC (rev 51)
@@ -25,10 +25,8 @@
protected String bowUrl = "";
public AliasServlet() throws ArgumentsParserException {
- ApplicationConfig config = new ApplicationConfig();
- config.setConfigFileName("bow.properties");
- config.parse(new String[]{});
- bowUrl = config.getOption("bow.url");
+ BowConfig config = BowConfig.getInstance();
+ bowUrl = config.getBowUrl();
}
@Override
Added: trunk/src/main/java/org/chorem/bow/BowConfig.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BowConfig.java (rev 0)
+++ trunk/src/main/java/org/chorem/bow/BowConfig.java 2010-06-01 10:54:42 UTC (rev 51)
@@ -0,0 +1,140 @@
+/* *##%
+ * Copyright (c) 2010 poussin. All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *##%*/
+
+package org.chorem.bow;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.io.File;
+import org.apache.commons.lang.UnhandledException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ApplicationConfig;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class BowConfig extends ApplicationConfig {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(BowConfig.class);
+
+ /** Singleton instance. */
+ protected static BowConfig instance = null;
+
+ public BowConfig() {
+ super();
+
+ // set default option (included configuration file name : important)
+ for (Option o : Option.values()) {
+ if (o.defaultValue != null) {
+ setDefaultOption(o.key, o.defaultValue);
+ }
+ }
+ }
+
+ public static synchronized BowConfig getInstance() {
+ if (instance == null) {
+ try {
+ instance = new BowConfig();
+ instance.parse(new String[]{});
+ instance.setDataDirInSystemProps();
+ } catch (Exception e) {
+ throw new UnhandledException(e);
+ }
+ }
+ return instance;
+ }
+
+ /**
+ * Get version as string.
+ *
+ * @return version
+ */
+ public String getVersion() {
+ return getOption(Option.APPLICATION_VERSION.key);
+ }
+
+ /**
+ * Get bow url as string.
+ *
+ * @return url
+ */
+ public String getBowUrl() {
+ return getOption(Option.BOW_URL.key);
+ }
+
+ public File getDataDirAsFile() {
+ File option = getOptionAsFile(Option.DATA_DIR.key);
+ return option;
+ }
+
+ /**
+ * Set {@code solr} and {@code jms} system configuration.
+ *
+ * This is the "only" way to configure embedded solr.
+ */
+ protected void setDataDirInSystemProps() {
+ String value = System.getProperty(Option.DATA_DIR.key, null);
+ if (value == null) {
+ value = getOption(Option.DATA_DIR.key);
+ if (log.isInfoEnabled()) {
+ log.info("Setting system property " + Option.DATA_DIR.key + " : " + value);
+ }
+ System.setProperty(Option.DATA_DIR.key, value);
+ env.put(Option.DATA_DIR.key, value);
+ }
+ }
+
+ /**
+ * Vradi option definition.
+ */
+ public static enum Option {
+
+ CONFIG_FILE(CONFIG_FILE_NAME, _("bow.config.configFileName.description"),
+ "bow.properties", String.class, false, false),
+ APPLICATION_VERSION("application.version", _("bow.config.application.version.description"),
+ null, String.class, true, true),
+ BOW_URL("bow.url", _("bow.config.bow.url.description"),
+ null, String.class, false, false),
+ DATA_DIR("solr.data.dir", _("bow.config.data.dir.description"),
+ System.getProperty("user.home") + "/.bow/solr", String.class, false, false);
+
+ public final String key;
+ public final String description;
+ public final String defaultValue;
+ public final Class<?> type;
+ public final boolean isTransient;
+ public final boolean isFinal;
+
+ private Option(String key, String description, String defaultValue,
+ Class<?> type, boolean isTransient, boolean isFinal) {
+ this.key = key;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.type = type;
+ this.isFinal = isFinal;
+ this.isTransient = isTransient;
+ }
+ }
+
+}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 10:02:53 UTC (rev 50)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 10:54:42 UTC (rev 51)
@@ -49,11 +49,9 @@
protected String url = "";
public ControllerServlet() throws ArgumentsParserException, Exception {
- ApplicationConfig config = new ApplicationConfig();
- config.setConfigFileName("bow.properties");
- config.parse(new String[]{});
- version = config.getOption("application.version");
- url = config.getOption("bow.url");
+ BowConfig config = BowConfig.getInstance();
+ version = config.getVersion();
+ url = config.getBowUrl();
if (url == null) {
throw new Exception("No bow.url=\"SERVER URL\" in bow.properties");
}
1
0
Author: bbrossaud
Date: 2010-06-01 12:02:53 +0200 (Tue, 01 Jun 2010)
New Revision: 50
Url: http://chorem.org/repositories/revision/bow/50
Log:
retrieve bookmarks by research thanks to criteria
Modified:
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-06-01 09:02:01 UTC (rev 49)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-06-01 10:02:53 UTC (rev 50)
@@ -251,7 +251,6 @@
public void createTagCloud() {
tagCloud.clear();
- //deleteBookmarkBySearch();
createTagClougByBookmarks();
defineTValues();
}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 09:02:01 UTC (rev 49)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 10:02:53 UTC (rev 50)
@@ -239,7 +239,7 @@
Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine);
criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, searchLine);
request.setAttribute("bookmarkActions", bookmarkActions);
request.setAttribute("token", token);
request.getRequestDispatcher("openSearchResult.jsp").forward(request, response);
@@ -301,7 +301,7 @@
protected void actionOrderAsc(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
String type = request.getParameter("type");
- String searchLine = request.getParameter("searchline");
+ String searchLine = request.getParameter("searchLine");
Criteria baseCriteria = getBookmarkListCriteriaByUser(user, searchLine);
if (type != null && baseCriteria != null && !type.isEmpty()) {
WikittyProxy proxy = model.getProxy();
@@ -316,14 +316,14 @@
Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_CLICK);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
}
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, searchLine);
request.setAttribute("bookmarkActions", bookmarkActions);
}
}
protected void actionOrderDesc(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
- String searchLine = request.getParameter("searchline");
+ String searchLine = request.getParameter("searchLine");
String type = request.getParameter("type");
Criteria baseCriteria = getBookmarkListCriteriaByUser(user, searchLine);
if (type != null && baseCriteria != null && !type.isEmpty()) {
@@ -339,7 +339,7 @@
Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
}
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, searchLine);
request.setAttribute("bookmarkActions", bookmarkActions);
}
}
@@ -499,17 +499,24 @@
protected void actionSearch(HttpServletRequest request, User user)
throws IOException, ServletException {
String searchLine = request.getParameter("searchLine");
+ String tag = request.getParameter("addTag");
+ if (tag != null && !tag.isEmpty()) {
+ if (searchLine == null || searchLine.isEmpty()) {
+ searchLine = tag;
+ } else {
+ searchLine += " " + tag;
+ }
+ }
WikittyProxy proxy = model.getProxy();
Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine);
criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, searchLine);
request.setAttribute("bookmarkActions", bookmarkActions);
}
- protected BookmarkActions createBookmarkActions(HttpServletRequest request, List<Bookmark> bookList) {
+ protected BookmarkActions createBookmarkActions(HttpServletRequest request, List<Bookmark> bookList, String searchLine) {
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);
@@ -523,10 +530,6 @@
bookmarkActions.emptySearchline();
} 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
}
@@ -650,7 +653,7 @@
List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, sortCriteria).getAll(); // select all bookmarks by user
sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_DATE).setEndIndex(10);
List<Bookmark> lastBookmarks = proxy.findAllByCriteria(Bookmark.class, sortCriteria).getAll();
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, null);
bookList = bookmarkActions.getBookmarks();
if (bookList.size() > 10) {
bookList = bookmarkActions.getBookmarks().subList(0, 10);
@@ -769,7 +772,7 @@
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);
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList, null);
request.setAttribute("bookmarkActions", bookmarkActions);
}
@@ -787,16 +790,16 @@
}
}
- protected Criteria getBookmarkListCriteriaByUser(User user, String searchline) {
+ protected Criteria getBookmarkListCriteriaByUser(User user, String searchLine) {
Criteria criteria = null;
if (user != null) {
- if (searchline != null && !searchline.isEmpty()) {
- String[] words = searchline.split("\\s+"); // put the tags in an array
+ if (searchLine != null && !searchLine.isEmpty()) {
+ String[] words = searchLine.split("\\s+"); // put the tags in an array
List<String> tags = new ArrayList<String>(Arrays.asList(words));
- criteria = Search.query().eq(User.FQ_FIELD_EMAIL, user.getEmail()).
- contains(Bookmark.FQ_FIELD_TAGS, tags).criteria();
+ log.debug(tags.size());
+ criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).eq(Bookmark.FQ_FIELD_TAGS, tags).criteria();
} else {
- criteria = Search.query().eq(User.FQ_FIELD_EMAIL, user.getEmail()).criteria();
+ criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria();
}
}
return criteria;
1
0
Author: bbrossaud
Date: 2010-06-01 11:02:01 +0200 (Tue, 01 Jun 2010)
New Revision: 49
Url: http://chorem.org/repositories/revision/bow/49
Log:
fullText works now
Modified:
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-06-01 07:59:09 UTC (rev 48)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-06-01 09:02:01 UTC (rev 49)
@@ -154,11 +154,11 @@
String[] tagsTab = tags.split("\\s+"); // put the tags in an array
for (int i = 0; i < tagsTab.length; ++i) {
Set<String> tagList = bookmark.getTags();
- if (tagList != null) {
+ if (tagList != null && tagsTab[i] != null) {
if (!tagList.contains(tagsTab[i]) && !tagsTab[i].isEmpty()) {
bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
}
- } else {
+ } else if (!tagsTab[i].isEmpty()){
bookmark.addTags(tagsTab[i]);
}
}
@@ -168,14 +168,7 @@
public static void addTagsToBookmark(List<String> tagList, Bookmark bookmark) {
if (tagList != null && !tagList.isEmpty()) {
for (String tag : tagList) {
- Set<String> bookmarTags = bookmark.getTags();
- if (bookmarTags != null) {
- if (!bookmarTags.contains(tag) && !tag.isEmpty()) {
- bookmark.addTags(tag); // Added tag for each rank (one tag by rank)
- }
- } else if (!tag.isEmpty()) {
- bookmark.addTags(tag);
- }
+ addTagsToBookmark(tag, bookmark);
}
}
}
@@ -258,7 +251,7 @@
public void createTagCloud() {
tagCloud.clear();
- deleteBookmarkBySearch();
+ //deleteBookmarkBySearch();
createTagClougByBookmarks();
defineTValues();
}
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 07:59:09 UTC (rev 48)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 09:02:01 UTC (rev 49)
@@ -236,8 +236,8 @@
response.sendRedirect(searchLine);
} else {
WikittyProxy proxy = model.getProxy();
- Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortDescending(Bookmark.FQ_FIELD_CLICK);
+ Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine);
+ criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
request.setAttribute("bookmarkActions", bookmarkActions);
@@ -301,23 +301,19 @@
protected void actionOrderAsc(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
String type = request.getParameter("type");
- if (type != null && !type.isEmpty()) {
+ String searchLine = request.getParameter("searchline");
+ Criteria baseCriteria = getBookmarkListCriteriaByUser(user, searchLine);
+ if (type != null && baseCriteria != null && !type.isEmpty()) {
WikittyProxy proxy = model.getProxy();
List<Bookmark> bookList = null;
if (type.equals("name")) {
- Criteria criteria = Search.query().
- eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortAscending(Bookmark.FQ_FIELD_DESCRIPTION);
+ Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_DESCRIPTION);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
} else if (type.equals("date")) {
- Criteria criteria = Search.query().
- eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortAscending(Bookmark.FQ_FIELD_DATE);
+ Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_DATE);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
} else if (type.equals("click")) {
- Criteria criteria = Search.query().
- eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortAscending(Bookmark.FQ_FIELD_CLICK);
+ Criteria criteria = baseCriteria.addSortAscending(Bookmark.FQ_FIELD_CLICK);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
}
BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
@@ -327,24 +323,20 @@
protected void actionOrderDesc(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
+ String searchLine = request.getParameter("searchline");
String type = request.getParameter("type");
- if (type != null && !type.isEmpty()) {
+ Criteria baseCriteria = getBookmarkListCriteriaByUser(user, searchLine);
+ if (type != null && baseCriteria != null && !type.isEmpty()) {
WikittyProxy proxy = model.getProxy();
List<Bookmark> bookList = null;
if (type.equals("name")) {
- Criteria criteria = Search.query().
- eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortDescending(Bookmark.FQ_FIELD_DESCRIPTION);
+ Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_DESCRIPTION);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
} else if (type.equals("date")) {
- Criteria criteria = Search.query().
- eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortDescending(Bookmark.FQ_FIELD_DATE);
+ Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_DATE);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
} else if (type.equals("click")) {
- Criteria criteria = Search.query().
- eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortDescending(Bookmark.FQ_FIELD_CLICK);
+ Criteria criteria = baseCriteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
}
BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
@@ -506,9 +498,10 @@
*/
protected void actionSearch(HttpServletRequest request, User user)
throws IOException, ServletException {
+ String searchLine = request.getParameter("searchLine");
WikittyProxy proxy = model.getProxy();
- Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortDescending(Bookmark.FQ_FIELD_CLICK);
+ Criteria criteria = getBookmarkListCriteriaByUser(user, searchLine);
+ criteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user
BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
request.setAttribute("bookmarkActions", bookmarkActions);
@@ -522,7 +515,6 @@
bookmarkActions.setBookmarks(bookList);
}
if (fullText != null && !fullText.isEmpty()) {
- log.debug("toto");
bookmarkActions.fullText(fullText);
bookmarkActions.createTagClougByBookmarks();
bookmarkActions.defineTValues();
@@ -652,22 +644,23 @@
protected void actionHome(HttpServletRequest request, User user) {
WikittyProxy proxy = model.getProxy();
- Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortDescending(Bookmark.FQ_FIELD_CLICK);
- List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user
- criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortDescending(Bookmark.FQ_FIELD_DATE).setEndIndex(10);
- List<Bookmark> lastBookmarks = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
- bookList = bookmarkActions.getBookmarks();
- if (bookList.size() > 10) {
- bookList = bookmarkActions.getBookmarks().subList(0, 10);
- bookmarkActions.setBookmarks(bookList);
+ Criteria criteria = getBookmarkListCriteriaByUser(user, null);
+ if (criteria != null) {
+ Criteria sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_CLICK);
+ List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, sortCriteria).getAll(); // select all bookmarks by user
+ sortCriteria = criteria.addSortDescending(Bookmark.FQ_FIELD_DATE).setEndIndex(10);
+ List<Bookmark> lastBookmarks = proxy.findAllByCriteria(Bookmark.class, sortCriteria).getAll();
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ bookList = bookmarkActions.getBookmarks();
+ if (bookList.size() > 10) {
+ bookList = bookmarkActions.getBookmarks().subList(0, 10);
+ bookmarkActions.setBookmarks(bookList);
+ }
+ if (lastBookmarks != null) {
+ bookmarkActions.setLastBookmarks(lastBookmarks);
+ }
+ request.setAttribute("bookmarkActions", bookmarkActions);
}
- if (lastBookmarks != null) {
- bookmarkActions.setLastBookmarks(lastBookmarks);
- }
- request.setAttribute("bookmarkActions", bookmarkActions);
}
protected void actionImportBookmarks(HttpServletRequest request, HttpServletResponse response, User user)
@@ -793,4 +786,19 @@
response.sendRedirect("bow?action=home");
}
}
+
+ protected Criteria getBookmarkListCriteriaByUser(User user, String searchline) {
+ Criteria criteria = null;
+ if (user != null) {
+ if (searchline != null && !searchline.isEmpty()) {
+ String[] words = searchline.split("\\s+"); // put the tags in an array
+ List<String> tags = new ArrayList<String>(Arrays.asList(words));
+ criteria = Search.query().eq(User.FQ_FIELD_EMAIL, user.getEmail()).
+ contains(Bookmark.FQ_FIELD_TAGS, tags).criteria();
+ } else {
+ criteria = Search.query().eq(User.FQ_FIELD_EMAIL, user.getEmail()).criteria();
+ }
+ }
+ return criteria;
+ }
}
1
0
Author: bbrossaud
Date: 2010-06-01 09:59:09 +0200 (Tue, 01 Jun 2010)
New Revision: 48
Url: http://chorem.org/repositories/revision/bow/48
Log:
fullText works now
Modified:
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-31 16:04:07 UTC (rev 47)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-06-01 07:59:09 UTC (rev 48)
@@ -238,8 +238,13 @@
Set<String> tags = bookmark.getTags();
String name = bookmark.getDescription();
for (String word : fullText) {
- if (tags != null && tags.contains(word)) {
- delete = false;
+ if (tags != null) {
+ for (String tag : tags) {
+ if (tag.contains(word)) {
+ delete = false;
+ break;
+ }
+ }
}
if (name.contains(word)) {
delete = false;
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 16:04:07 UTC (rev 47)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-06-01 07:59:09 UTC (rev 48)
@@ -366,16 +366,7 @@
proxy.store(bookmark);
}
}
- 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");
- }
+ redirectToTheGoodPage(request, response);
}
protected void actionRemoveBookmark(HttpServletRequest request, HttpServletResponse response, User user)
@@ -388,16 +379,7 @@
proxy.delete(bookmarkId);
}
}
- 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");
- }
+ redirectToTheGoodPage(request, response);
}
protected void actionDeleteTag(HttpServletRequest request, HttpServletResponse response, User user)
@@ -414,16 +396,7 @@
}
}
}
- 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");
- }
+ redirectToTheGoodPage(request, response);
}
@@ -454,16 +427,7 @@
tokenActions.setPermanentToken("");
}
}
- 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");
- }
+ redirectToTheGoodPage(request, response);
}
/* @param request servlet request
@@ -473,12 +437,7 @@
protected void actionAddUrl(HttpServletRequest request, HttpServletResponse response, User user)
throws IOException, ServletException {
addUrl(request, user);
- String searchLine = request.getParameter("searchLine");
- if (searchLine != null) {
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
- } else {
- response.sendRedirect("bow?action=home");
- }
+ redirectToTheGoodPage(request, response);
}
protected void addUrl(HttpServletRequest request, User user) {
@@ -552,10 +511,6 @@
addSortDescending(Bookmark.FQ_FIELD_CLICK);
List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll(); // select all bookmarks by user
BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
- String searchLine = bookmarkActions.getSearchLine();
- if (searchLine.isEmpty()) {
- bookmarkActions.emptySearchline();
- }
request.setAttribute("bookmarkActions", bookmarkActions);
}
@@ -572,10 +527,14 @@
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);
+ if (searchLine != null && searchLine.isEmpty()) {
+ bookmarkActions.emptySearchline();
+ } 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
}
@@ -737,12 +696,7 @@
}
}
}
- String searchLine = request.getParameter("searchLine");
- if (searchLine != null) {
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
- } else {
- response.sendRedirect("bow?action=home");
- }
+ redirectToTheGoodPage(request, response);
}
protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks, List<String> tagList)
@@ -815,12 +769,7 @@
}
}
}
- String searchLine = request.getParameter("searchLine");
- if (searchLine != null) {
- response.sendRedirect("bow?action=search&searchLine=" + searchLine);
- } else {
- response.sendRedirect("bow?action=home");
- }
+ redirectToTheGoodPage(request, response);
}
protected void actionFullText(HttpServletRequest request, User user) {
@@ -828,7 +777,20 @@
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);
}
+
+ protected void redirectToTheGoodPage(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
+ 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");
+ }
+ }
}
1
0
r47 - in trunk: . src/main/java/org/chorem/bow src/main/webapp
by bbrossaud@users.chorem.org 31 May '10
by bbrossaud@users.chorem.org 31 May '10
31 May '10
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">
1
0
Author: bbrossaud
Date: 2010-05-31 15:58:55 +0200 (Mon, 31 May 2010)
New Revision: 46
Url: http://chorem.org/repositories/revision/bow/46
Log:
remove bugs on opensearch
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 13:54:19 UTC (rev 45)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 13:58:55 UTC (rev 46)
@@ -207,7 +207,6 @@
log.debug("Going to actionOpenSearchResult");
}
this.actionOpenSearchResult(request, response, user, token);
- request.getRequestDispatcher("openSearchResult.jsp").forward(request, response);
} else {
if (user != null) {
request.getRequestDispatcher("error.jsp").forward(request, response);
1
0
Author: bbrossaud
Date: 2010-05-31 15:54:19 +0200 (Mon, 31 May 2010)
New Revision: 45
Url: http://chorem.org/repositories/revision/bow/45
Log:
the opensearch now suggest the url if there are less than 5 bookmarks
Modified:
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
trunk/src/main/java/org/chorem/bow/OpenSearchActions.java
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 10:21:08 UTC (rev 44)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 13:54:19 UTC (rev 45)
@@ -12,7 +12,6 @@
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
@@ -182,7 +181,6 @@
log.debug("Going to actionOrderDesc");
}
this.actionOrderDesc(request, response, user);
- request.getRequestDispatcher("openSearchResult.jsp").forward(request, response);
} else if (action.equals("addClick") && user != null) {
if (log.isDebugEnabled()) {
log.debug("Going to actionAddClic");
@@ -228,13 +226,19 @@
protected void actionOpenSearchResult(HttpServletRequest request, HttpServletResponse response, User user, String token)
throws IOException, ServletException {
- WikittyProxy proxy = model.getProxy();
- Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
- addSortDescending(Bookmark.FQ_FIELD_CLICK);
- List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
- BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
- request.setAttribute("bookmarkActions", bookmarkActions);
- request.setAttribute("token", token);
+ String searchLine = request.getParameter("searchLine");
+ if (searchLine != null && searchLine.matches("^http://[^ ]*") && !searchLine.contains(" ")) {
+ response.sendRedirect(searchLine);
+ } else {
+ WikittyProxy proxy = model.getProxy();
+ Criteria criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria().
+ addSortDescending(Bookmark.FQ_FIELD_CLICK);
+ List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ BookmarkActions bookmarkActions = createBookmarkActions(request, bookList);
+ request.setAttribute("bookmarkActions", bookmarkActions);
+ request.setAttribute("token", token);
+ request.getRequestDispatcher("openSearchResult.jsp").forward(request, response);
+ }
}
protected void actionOpenSearchSuggestion(HttpServletRequest request, HttpServletResponse response, User user)
@@ -244,16 +248,23 @@
if (search != null) {
OpenSearchActions openSearchActions = new OpenSearchActions();
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();
- openSearchActions.setBookmarkList(bookList);
String[] words = search.split("\\s+");
List<String> searchLine = new ArrayList<String>(Arrays.asList(words));
if (search.charAt(search.length() - 1) == ' ') {
searchLine.add("");
}
+ Criteria criteria = null;
+ if (searchLine.size() > 1) {
+ List<String> cpy = new ArrayList<String>(searchLine);
+ cpy.remove(cpy.size() - 1);
+ criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).
+ contains(Bookmark.FQ_FIELD_TAGS, cpy).criteria();
+ } else {
+ criteria = Search.query().eq(Bookmark.FQ_FIELD_EMAIL, user.getEmail()).criteria();
+ }
+ List<Bookmark> bookList = proxy.findAllByCriteria(Bookmark.class, criteria).getAll();
+ openSearchActions.setBookmarkList(bookList);
openSearchActions.findSuggestions(searchLine);
- log.debug("result={" + openSearchActions.getJsonResult() + "}");
request.setAttribute("openSearchAction", openSearchActions);
}
}
@@ -276,8 +287,8 @@
++click;
bookmark.setClick(click);
proxy.store(bookmark);
- String url = bookmark.getLink();
- response.sendRedirect(url);
+ String link = bookmark.getLink();
+ response.sendRedirect(link);
}
}
}
@@ -445,15 +456,15 @@
}
protected void addUrl(HttpServletRequest request, User user) {
- String url = request.getParameter("url"); // url of the website
+ String link = request.getParameter("url"); // url of the website
String name = request.getParameter("name");
Bookmark bookmark = null;
if (name != null) {
String tags = request.getParameter("tags"); // tags
- bookmark = BookmarkActions.createBookmark(url, name, tags, user, null);
+ bookmark = BookmarkActions.createBookmark(link, name, tags, user, null);
} else {
String nameAndTags = request.getParameter("nameAndTags");
- bookmark = BookmarkActions.createBookmark(url, nameAndTags, user);
+ bookmark = BookmarkActions.createBookmark(link, nameAndTags, user);
}
if (bookmark != null) {
WikittyProxy proxy = model.getProxy();
@@ -520,7 +531,6 @@
bookmarkActions.emptySearchline();
}
request.setAttribute("bookmarkActions", bookmarkActions);
-
}
protected BookmarkActions createBookmarkActions(HttpServletRequest request, List<Bookmark> bookList) {
Modified: trunk/src/main/java/org/chorem/bow/OpenSearchActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/OpenSearchActions.java 2010-05-31 10:21:08 UTC (rev 44)
+++ trunk/src/main/java/org/chorem/bow/OpenSearchActions.java 2010-05-31 13:54:19 UTC (rev 45)
@@ -26,28 +26,20 @@
public void findSuggestions(List<String> searchLine) {
int size = searchLine.size();
search = searchLine.toArray(new String[size]);
- if (!bookmarkList.isEmpty()) {
- int i;
- for (i = 0; i < (search.length - 1); ++i) {
- List<Bookmark> newList = new ArrayList<Bookmark>(bookmarkList);
- for (Bookmark bookmark : newList) {
- if (!bookmarkHasTag(bookmark, search[i])) {
- bookmarkList.remove(bookmark);
- }
- }
- }
- fieldSuggestionList(search[i], searchLine);
- }
+ fieldSuggestionList(search[size - 1], searchLine);
}
protected void fieldSuggestionList(String word, List<String> searchLine) {
if (bookmarkList != null) {
Map<String, Integer> map = new HashMap<String, Integer>();
- for (Bookmark bookmark : bookmarkList) {
+ List<Bookmark> save = new ArrayList<Bookmark>(bookmarkList);
+ for (Bookmark bookmark : save) {
Set<String> tagList = bookmark.getTags();
+ boolean contain = false;
if (tagList != null) {
for (String tag : tagList) {
if (tag.indexOf(word) == 0 && !searchLine.contains(tag)) {
+ contain = true;
if (map.containsKey(tag)) {
Integer count = map.get(tag);
++count;
@@ -58,6 +50,9 @@
}
}
}
+ if (contain == false) {
+ bookmarkList.remove(bookmark);
+ }
}
Set<String> keys = map.keySet();
for (String key : keys) {
@@ -114,6 +109,11 @@
str += ",";
}
}
+ if (bookmarkList.size() <= 5 && suggestions.size() > 0) {
+ for (Bookmark bookmark : bookmarkList) {
+ str += ",\"" + bookmark.getLink() + "\"";
+ }
+ }
str += "]";
return str;
}
1
0
Author: bbrossaud
Date: 2010-05-31 12:21:08 +0200 (Mon, 31 May 2010)
New Revision: 44
Url: http://chorem.org/repositories/revision/bow/44
Log:
addition tag works if bookmard doesn't have tag, importation adds the folder name as a tag to the bookmark tagList
Modified:
trunk/TODO.txt
trunk/src/main/java/org/chorem/bow/BookmarkActions.java
trunk/src/main/java/org/chorem/bow/ControllerServlet.java
Modified: trunk/TODO.txt
===================================================================
--- trunk/TODO.txt 2010-05-28 15:09:08 UTC (rev 43)
+++ trunk/TODO.txt 2010-05-31 10:21:08 UTC (rev 44)
@@ -9,4 +9,21 @@
-> le && pour le nuage de tag (11 mai) OK
-> gestion des sessions (14 mai) OK
-> javascript ==> (11 mai) OK
--> Mise en forme (28 mai)
\ No newline at end of file
+-> Mise en forme (28 mai)
+
+
+===> corriger ajout de tag quand vide
+
+===> ajout des tags par repertoire
+
+===> seeks.fr + champs pour recherche
+
+===> champ recherche fulltext
+
+===> class bokkmarkFile = Id proprietaire, list<userID> writer, list<userId> reader;
+
+===> class bookmark = idBookmarkFile a la place de UserID;
+
+===> dans class user = String SearchEngine;
+
+===> openSearch ==> proposer des url
Modified: trunk/src/main/java/org/chorem/bow/BookmarkActions.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-28 15:09:08 UTC (rev 43)
+++ trunk/src/main/java/org/chorem/bow/BookmarkActions.java 2010-05-31 10:21:08 UTC (rev 44)
@@ -30,6 +30,14 @@
protected int tmax = -1;
protected int tmin = -1;
+ public static Bookmark createBookmarkFromHtml(String html, String name, User user) {
+ String link = getUrlFromHtml(html);
+ String tags = getTagsFromHtml(html);
+ Date date = getDateFromHtml(html);
+ Bookmark bookmark = createBookmark(link, name, tags, user, date);
+ return bookmark;
+ }
+
public static Date getDateFromHtml(String html) {
Date date = null;
if (html != null) {
@@ -140,17 +148,37 @@
}
public static void addTagsToBookmark(String tags, Bookmark bookmark) {
- if (tags != null) {
+ if (tags != null && !tags.isEmpty()) {
tags = tags.trim();
String[] tagsTab = tags.split("\\s+"); // put the tags in an array
for (int i = 0; i < tagsTab.length; ++i) {
- if (!tagsTab[i].isEmpty()) {
- bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
+ Set<String> tagList = bookmark.getTags();
+ if (tagList != null) {
+ if (!tagList.contains(tagsTab[i]) && !tagsTab[i].isEmpty()) {
+ bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
+ }
+ } else {
+ bookmark.addTags(tagsTab[i]);
}
}
}
}
+ public static void addTagsToBookmark(List<String> tagList, Bookmark bookmark) {
+ if (tagList != null && !tagList.isEmpty()) {
+ for (String tag : tagList) {
+ Set<String> bookmarTags = bookmark.getTags();
+ if (bookmarTags != null) {
+ if (!bookmarTags.contains(tag) && !tag.isEmpty()) {
+ bookmark.addTags(tag); // Added tag for each rank (one tag by rank)
+ }
+ } else if (!tag.isEmpty()) {
+ bookmark.addTags(tag);
+ }
+ }
+ }
+ }
+
public static Bookmark createBookmark(String url, String name, String tags, User user, Date date) {
Bookmark bookmark = (Bookmark) new BookmarkImpl();
if (name != null) {
@@ -190,21 +218,6 @@
}
}
- public static void updateBookmarkTags(Bookmark bookmark, String tags) {
- if (tags != null && !tags.isEmpty()) {
- tags = tags.trim();
- String[] tagsTab = tags.split("\\s+"); // put the tags in an array
- for (int i = 0; i < tagsTab.length; ++i) {
- Set<String> tagList = bookmark.getTags();
- if (tagList != null) {
- if (!tagList.contains(tagsTab[i]) && !tagsTab[i].isEmpty()) {
- bookmark.addTags(tagsTab[i]); // Added tag for each rank (one tag by rank)
- }
- }
- }
- }
- }
-
public static String getBookmarkTagsString(Bookmark bookmark) {
if (bookmark != null) {
Set<String> tags = bookmark.getTags();
Modified: trunk/src/main/java/org/chorem/bow/ControllerServlet.java
===================================================================
--- trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-28 15:09:08 UTC (rev 43)
+++ trunk/src/main/java/org/chorem/bow/ControllerServlet.java 2010-05-31 10:21:08 UTC (rev 44)
@@ -221,7 +221,8 @@
request.getRequestDispatcher("login.jsp").forward(request, response);
}
} catch (Exception eee) {
- request.getRequestDispatcher("error.jsp").forward(request, response);
+ throw new ServletException("msg", eee);
+ // request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
@@ -345,7 +346,7 @@
Bookmark bookmark = proxy.restore(Bookmark.class, bookmarkId);
if (bookmark != null) {
BookmarkActions.updateBookmarkName(bookmark, name);
- BookmarkActions.updateBookmarkTags(bookmark, tags);
+ BookmarkActions.addTagsToBookmark(tags, bookmark);
proxy.store(bookmark);
}
}
@@ -687,7 +688,7 @@
Parser parser = new Parser(content);
NodeList list = parser.parse(null);
List<Bookmark> bookmarks = new ArrayList<Bookmark>();
- parseHtmlToBookmarks(list, user, bookmarks);
+ parseHtmlToBookmarks(list, user, bookmarks, new ArrayList<String>());
proxy.store(bookmarks);
}
}
@@ -695,28 +696,39 @@
response.sendRedirect("bow?action=home");
}
- protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks)
+ protected void parseHtmlToBookmarks(NodeList list, User user, List<Bookmark> bookmarks, List<String> tagList)
throws ParserException {
if (list != null) {
+ boolean isFolder = false;
SimpleNodeIterator it = list.elements();
while (it.hasMoreNodes()) {
Node node = it.nextNode();
String plainText = node.toPlainTextString();
String text = node.getText();
- if (text != null && text.contains("A HREF")) {
- String url = BookmarkActions.getUrlFromHtml(text);
- String tags = BookmarkActions.getTagsFromHtml(text);
- Date date = BookmarkActions.getDateFromHtml(text);
- Bookmark bookmark = BookmarkActions.createBookmark(url, plainText, tags, user, date);
+ if (text != null && text.startsWith("H3")) {
+ log.debug(text);
+ if (plainText != null && !plainText.isEmpty()) {
+ tagList.add(plainText);
+ isFolder = true;
+ }
+ } else if (text != null && text.startsWith("A HREF")) {
+ Bookmark bookmark = BookmarkActions.createBookmarkFromHtml(text, plainText, user);
+ BookmarkActions.addTagsToBookmark(tagList, bookmark);
if (bookmark != null) {
bookmarks.add(bookmark);
}
}
NodeList children = node.getChildren();
if (children != null) {
- parseHtmlToBookmarks(children, user, bookmarks);
+ parseHtmlToBookmarks(children, user, bookmarks, tagList);
}
}
+ if (isFolder == true) {
+ int index = tagList.size() - 1;
+ if (index > -1) {
+ tagList.remove(index);
+ }
+ }
}
}
1
0