/* * MGPPGDBMServices.java * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org * * 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 2 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, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package org.greenstone.gsdl3.service; import org.greenstone.mgpp.*; import org.greenstone.gdbm.*; import org.greenstone.gsdl3.util.*; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.Text; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import java.util.HashMap; import java.util.Vector; import java.util.Set; import java.util.Map; import java.util.Iterator; /** * A ServicesImpl class for MGPP+GDBM * * @author Katherine Don * @version $Revision: 3492 $ * @see ServicesImpl */ public class MGPPGDBMServices extends ServicesImpl { private MGPPWrapper mgpp_src_=null; private GDBMWrapper gdbm_src_=null; private String default_index_=null; private String default_level_=null; public MGPPGDBMServices() { mgpp_src_ = new MGPPWrapper(); gdbm_src_ = new GDBMWrapper(); } /** configure this service */ public boolean configure(Element info) { System.out.println("configuring MGPPGDBMServices"); // get the default index from Element def = (Element)GSXML.getChildByTagName(info, "defaultIndex"); if (def !=null) { default_index_ = def.getAttribute("name"); } if (default_index_==null||default_index_.equals("")) { System.err.println("Error: default index not specified!"); return false; } System.out.println("default index="+default_index_); // get the default level out of def = (Element)GSXML.getChildByTagName(info, "defaultLevel"); if (def !=null) { default_level_ = def.getAttribute("name"); } if (default_level_==null||default_level_.equals("")) { System.err.println("Error: default level not specified!"); return false; } // the default level is also the level which gdbm is expecting mgpp_src_.setReturnLevel(default_level_); System.out.println("default level="+default_level_); // set up which services are available for this collection Element e = null; // these entries should reflect the build config file - some services may not be available depending on how the collection was built. // set up short_service_info_ - for now just has name and type e = doc_.createElement("service"); e.setAttribute("type", "query"); e.setAttribute("name", "TextQuery"); short_service_info_.appendChild(e); e = doc_.createElement("service"); e.setAttribute("type", "query"); e.setAttribute("name", "FieldQuery"); short_service_info_.appendChild(e); e = doc_.createElement("service"); e.setAttribute("type", "query"); e.setAttribute("name", "ResourceRetrieve"); short_service_info_.appendChild(e); e = doc_.createElement("service"); e.setAttribute("type", "query"); e.setAttribute("name", "MetadataRetrieve"); short_service_info_.appendChild(e); // set up service_info_map_ - for now, just has the same elements as above // should have full details about each service incl params lists etc. // do the text query one - for now a static list. later use buildcfg.xml values to dynamically change this e = doc_.createElement("service"); e.setAttribute("type", "query"); e.setAttribute("name", "TextQuery"); Element paramList = doc_.createElement("paramList"); Element param; // first do index and level params // the index info - read from config file Element index_list = (Element)GSXML.getChildByTagName(info, "indexList"); NodeList indexes = index_list.getElementsByTagName("index"); int len = indexes.getLength(); if (len > 1) { // add level param to list String [] inds = new String[len]; for (int i=0; i 1) { // add level param to list String [] levs = new String[len]; for (int i=0; i