001: //=============================================================================
002: //=== Copyright (C) 2001-2007 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
019: //===
020: //=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
021: //=== Rome - Italy. email: geonetwork@osgeo.org
022: //==============================================================================
023:
024: package org.fao.geonet.kernel.harvest.harvester.z3950;
025:
026: import jeeves.exceptions.BadInputEx;
027: import jeeves.utils.Util;
028: import org.fao.geonet.kernel.DataManager;
029: import org.fao.geonet.kernel.harvest.harvester.AbstractParams;
030: import org.jdom.Element;
031:
032: //=============================================================================
033:
034: public class Z3950Params extends AbstractParams {
035: //--------------------------------------------------------------------------
036: //---
037: //--- Constructor
038: //---
039: //--------------------------------------------------------------------------
040:
041: public Z3950Params(DataManager dm) {
042: super (dm);
043: }
044:
045: //---------------------------------------------------------------------------
046: //---
047: //--- Create : called when a new entry must be added. Reads values from the
048: //--- provided entry, providing default values
049: //---
050: //---------------------------------------------------------------------------
051:
052: public void create(Element node) throws BadInputEx {
053: super .create(node);
054:
055: Element site = node.getChild("site");
056: // Element searches = node.getChild("searches");
057: //
058: // capabUrl = Util.getParam(site, "capabilitiesUrl", "");
059: icon = Util.getParam(site, "icon", "default.gif");
060: //
061: // addSearches(searches);
062: }
063:
064: //---------------------------------------------------------------------------
065: //---
066: //--- Update : called when an entry has changed and variables must be updated
067: //---
068: //---------------------------------------------------------------------------
069:
070: public void update(Element node) throws BadInputEx {
071: super .update(node);
072:
073: Element site = node.getChild("site");
074: // Element searches = node.getChild("searches");
075: //
076: // capabUrl = Util.getParam(site, "capabilitiesUrl", capabUrl);
077: icon = Util.getParam(site, "icon", icon);
078: //
079: // //--- if some search queries are given, we drop the previous ones and
080: // //--- set these new ones
081: //
082: // if (searches != null)
083: // addSearches(searches);
084: }
085:
086: //---------------------------------------------------------------------------
087: //---
088: //--- Other API methods
089: //---
090: //---------------------------------------------------------------------------
091:
092: // public Iterable<Search> getSearches() { return alSearches; }
093:
094: //---------------------------------------------------------------------------
095:
096: public Z3950Params copy() {
097: Z3950Params copy = new Z3950Params(dm);
098: copyTo(copy);
099:
100: // copy.capabUrl = capabUrl;
101: copy.icon = icon;
102: //
103: // for (Search s : alSearches)
104: // copy.alSearches.add(s.copy());
105:
106: return copy;
107: }
108:
109: //---------------------------------------------------------------------------
110: //---
111: //--- Private methods
112: //---
113: //---------------------------------------------------------------------------
114:
115: // private void addSearches(Element searches)
116: // {
117: // alSearches.clear();
118: //
119: // if (searches == null)
120: // return;
121: //
122: // Iterator searchList = searches.getChildren("search").iterator();
123: //
124: // while (searchList.hasNext())
125: // {
126: // Element search = (Element) searchList.next();
127: //
128: // Search s = new Search();
129: //
130: // s.freeText = Util.getParam(search, "freeText", "").trim();
131: // s.title = Util.getParam(search, "title", "").trim();
132: // s.abstrac = Util.getParam(search, "abstract", "").trim();
133: // s.subject = Util.getParam(search, "subject", "").trim();
134: //
135: // alSearches.add(s);
136: // }
137: // }
138:
139: //---------------------------------------------------------------------------
140: //---
141: //--- Variables
142: //---
143: //---------------------------------------------------------------------------
144:
145: // public String capabUrl;
146: public String icon;
147: //
148: // private ArrayList<Search> alSearches = new ArrayList<Search>();
149: }
150:
151: //=============================================================================
152:
153: //class Search
154: //{
155: // //---------------------------------------------------------------------------
156: // //---
157: // //--- API methods
158: // //---
159: // //---------------------------------------------------------------------------
160: //
161: // public Search copy()
162: // {
163: // Search s = new Search();
164: //
165: // s.freeText = freeText;
166: // s.title = title;
167: // s.abstrac = abstrac;
168: // s.subject = subject;
169: //
170: // return s;
171: // }
172: //
173: // //---------------------------------------------------------------------------
174: // //---
175: // //--- Variables
176: // //---
177: // //---------------------------------------------------------------------------
178: //
179: // public String freeText;
180: // public String title;
181: // public String abstrac;
182: // public String subject;
183: //}
184:
185: //=============================================================================
|