r77 - in trunk: vradi-services/src/main/java/org/chorem/vradi/services vradi-web/src/main/java/org/chorem/vradi/actions vradi-web/src/main/resources vradi-web/src/main/webapp/WEB-INF/jsp
Author: sletellier Date: 2011-05-31 14:44:10 +0200 (Tue, 31 May 2011) New Revision: 77 Url: http://chorem.org/repositories/revision/vradi/77 Log: First implementation of thesaurus on web Added: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/ThesaurusAction.java Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SearchAction.java trunk/vradi-web/src/main/resources/struts.xml trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java 2011-05-30 17:11:34 UTC (rev 76) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java 2011-05-31 12:44:10 UTC (rev 77) @@ -27,7 +27,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.vradi.VradiServiceConfiguration; import org.chorem.vradi.VradiServiceConfigurationHelper; import org.chorem.vradi.beans.FormPagedResult; import org.chorem.vradi.beans.QueryBean; @@ -402,6 +401,7 @@ * @param extension the form type to update * @return the form type up to date */ + @Override public WikittyExtension updateFormType(WikittyExtension extension, String templateName) throws VradiException { return formTypeManager.updateFormType(extension, templateName); Modified: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SearchAction.java =================================================================== --- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SearchAction.java 2011-05-30 17:11:34 UTC (rev 76) +++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/SearchAction.java 2011-05-31 12:44:10 UTC (rev 77) @@ -92,7 +92,8 @@ // Activate or not query for user, if it's the first one, user and client will // be created to add request. It will be automaticly added to email binding. VradiUser user = getUser(); - if (!StringUtils.isEmpty(switchUserQueryActivation)) { + boolean doSwithUserQueryActivation = !StringUtils.isEmpty(switchUserQueryActivation); + if (doSwithUserQueryActivation) { queryActive = getVradiSession().getDataService().switchUserQueryActivation(user, queryName, query); } FormPaginatedList paginatedList = new FormPaginatedList(getProxy()); @@ -115,7 +116,9 @@ } // Save request played - if (!StringUtils.isEmpty(saveRequest) && !StringUtils.isEmpty(queryName)) { + if ((!StringUtils.isEmpty(saveRequest) || + doSwithUserQueryActivation) && + !StringUtils.isEmpty(queryName)) { user = getVradiSession().getDataService().saveQuery(user, queryName, query); Added: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/ThesaurusAction.java =================================================================== --- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/ThesaurusAction.java (rev 0) +++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/ThesaurusAction.java 2011-05-31 12:44:10 UTC (rev 77) @@ -0,0 +1,68 @@ +package org.chorem.vradi.actions; + +import com.jgeppert.struts2.jquery.tree.result.TreeNode; +import com.opensymphony.xwork2.ActionSupport; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.services.VradiException; + +import java.util.ArrayList; +import java.util.List; + +/** + * Action used to display thesaurus + * + * @author sletellier + */ +public class ThesaurusAction extends VradiBaseAction { + + private static final long serialVersionUID = -2886756982077980790L; + private List<TreeNode> nodes = new ArrayList<TreeNode>(); + private String id = null; + + public String execute() { + + if (id.equals("0")) { + List<RootThesaurus> rootThesaurus; + try { + rootThesaurus = getVradiSession().getDataService().getRootThesaurus(); + } catch (VradiException eee) { + log.error("Failed to load rootThesaurus : ", eee); + return ERROR; + } + for (RootThesaurus root : rootThesaurus) { + TreeNode node = new TreeNode(); + node.setId(root.getWikittyId()); + node.setTitle(root.getName()); + nodes.add(node); + } + } else { + List<Thesaurus> thesaurus; + try { + thesaurus = getVradiSession().getDataService().getChildrenThesaurus(id); + } catch (VradiException eee) { + log.error("Failed to load children of thesaurus : " + id, eee); + return ERROR; + } + for (Thesaurus child : thesaurus) { + TreeNode node = new TreeNode(); + node.setId(child.getWikittyId()); + node.setTitle(child.getName()); + nodes.add(node); + } + } + return SUCCESS; + } + + public String getJSON() { + return execute(); + } + + public List<TreeNode> getNodes() { + return nodes; + } + + public void setId(String id) { + this.id = id; + } +} Modified: trunk/vradi-web/src/main/resources/struts.xml =================================================================== --- trunk/vradi-web/src/main/resources/struts.xml 2011-05-30 17:11:34 UTC (rev 76) +++ trunk/vradi-web/src/main/resources/struts.xml 2011-05-31 12:44:10 UTC (rev 77) @@ -109,12 +109,15 @@ </action> <!-- - | Activate or not user request + | Thesaurus +--> - <!--action name="switchUserQueryActivation" class="org.chorem.vradi.actions.SearchAction" method="switchUserQueryActivation"> - <result type="redirect">search.action</result> - </action--> + <action name="thesaurus" class="org.chorem.vradi.actions.ThesaurusAction"> + <result name="success" type="json"> + <param name="root">nodes</param> + </result> + </action> + <!-- | Affiche la liste des notes attachees a un formulaire | Permet de creer une nouvelle note Modified: trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp =================================================================== --- trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp 2011-05-30 17:11:34 UTC (rev 76) +++ trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp 2011-05-31 12:44:10 UTC (rev 77) @@ -5,6 +5,8 @@ <%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <%@taglib prefix="displaytag" uri="http://displaytag.sf.net"%> +<%@taglib prefix="sj" uri="/struts-jquery-tags" %> +<%@taglib prefix="sjt" uri="/struts-jquery-tree-tags" %> <html> <head> @@ -12,8 +14,26 @@ <link href="${css}" rel="stylesheet" type="text/css" /> <title><s:text name="vradi.search.title" /></title> <s:head /> + <sj:head/> + <script type="text/javascript"> + $.subscribe('treeClicked', function(event, data) { + var item = event.originalEvent.data.rslt.obj; + var parent = item.parent(); + while (!parent && parent != -1) { + parent = parent.parent(); + } + $('#searchArea')[0].innerHTML += parent.text().trim() + }); + </script> </head> <body> + <s:url id="thesaurusDataUrl" action="thesaurus"/> + <sjt:tree + id="thesaurus" + href="%{thesaurusDataUrl}" + onClickTopics="treeClicked" + /> + <s:form id="searchForm" action="search" method="post" theme="simple"> <s:select id="lastQueries" name="lastQueries"
participants (1)
-
sletellier@users.chorem.org