001: //=============================================================================
002: //=== Copyright (C) 2001-2005 Food and Agriculture Organization of the
003: //=== United Nations (FAO-UN), United Nations World Food Programme (WFP)
004: //=== and United Nations Environment Programme (UNEP)
005: //===
006: //=== This program is free software; you can redistribute it and/or modify
007: //=== it under the terms of the GNU General Public License as published by
008: //=== the Free Software Foundation; either version 2 of the License, or (at
009: //=== your option) any later version.
010: //===
011: //=== This program is distributed in the hope that it will be useful, but
012: //=== WITHOUT ANY WARRANTY; without even the implied warranty of
013: //=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: //=== General Public License for more details.
015: //===
016: //=== You should have received a copy of the GNU General Public License
017: //=== along with this program; if not, write to the Free Software
018: //=== Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: //===
020: //=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
021: //=== Rome - Italy. email: GeoNetwork@fao.org
022: //==============================================================================
023:
024: package org.fao.geonet.services.thesaurus;
025:
026: import java.util.Iterator;
027: import java.util.List;
028:
029: import jeeves.constants.Jeeves;
030: import jeeves.interfaces.Service;
031: import jeeves.server.ServiceConfig;
032: import jeeves.server.UserSession;
033: import jeeves.server.context.ServiceContext;
034: import jeeves.utils.Util;
035:
036: import org.fao.geonet.GeonetContext;
037: import org.fao.geonet.constants.Geonet;
038: import org.fao.geonet.kernel.Thesaurus;
039: import org.fao.geonet.kernel.ThesaurusManager;
040: import org.fao.geonet.kernel.KeywordBean;
041: import org.fao.geonet.kernel.search.KeywordsSearcher;
042: import org.jdom.Element;
043:
044: //=============================================================================
045:
046: /** For editing : removes a concept from a thesaurus. Access is restricted
047: */
048:
049: public class DeleteElement implements Service {
050: //--------------------------------------------------------------------------
051: //---
052: //--- Init
053: //---
054: //--------------------------------------------------------------------------
055:
056: public void init(String appPath, ServiceConfig params)
057: throws Exception {
058: }
059:
060: //--------------------------------------------------------------------------
061: //---
062: //--- Service
063: //---
064: //--------------------------------------------------------------------------
065:
066: public Element exec(Element params, ServiceContext context)
067: throws Exception {
068:
069: String sThesaurusName = Util.getParam(params, "pThesaurus");
070:
071: GeonetContext gc = (GeonetContext) context
072: .getHandlerContext(Geonet.CONTEXT_NAME);
073: UserSession session = context.getUserSession();
074:
075: KeywordsSearcher searcher = (KeywordsSearcher) session
076: .getProperty(Geonet.Session.SEARCH_KEYWORDS_RESULT);
077: List keywords = searcher.getSelectedKeywordsInList();
078: ThesaurusManager thesaurusMan = gc.getThesaurusManager();
079: Thesaurus thesaurus = thesaurusMan
080: .getThesaurusByName(sThesaurusName);
081:
082: Iterator iter = keywords.iterator();
083: while (iter.hasNext()) {
084: KeywordBean keyword = (KeywordBean) iter.next();
085: thesaurus.removeElement(keyword);
086: }
087:
088: Element elResp = new Element(Jeeves.Elem.RESPONSE);
089: // ajout des parametres necessaires pour le service thesaurus.edit
090: // elResp.addContent(new Element("pTypeSearch").setText("0"));
091: // elResp.addContent(new Element("pKeyword").setText("*"));
092: // elResp.addContent(new Element("pNewSearch").setText("true"));
093: // elResp.addContent(new Element("pThesauri").setText(sThesaurusName));
094: // elResp.addContent(new Element("pNbResPerPage").setText("10"));
095: // elResp.addContent(new Element("mode").setText("edit"));
096: return elResp;
097: }
098: }
099:
100: //=============================================================================
|