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.csw.common.requests;
025:
026: import java.util.ArrayList;
027: import org.fao.geonet.csw.common.Csw;
028: import org.fao.geonet.csw.common.Csw.ElementSetName;
029: import org.jdom.Element;
030:
031: //=============================================================================
032:
033: /** Params:
034: * - elementSetName (0..1) Can be 'brief', 'summary', 'full'. Default is 'summary'
035: * - id (1..n)
036: */
037:
038: public class GetRecordByIdRequest extends CatalogRequest {
039: private ElementSetName setName;
040:
041: private ArrayList<String> alIds = new ArrayList<String>();
042:
043: //---------------------------------------------------------------------------
044: //---
045: //--- Constructor
046: //---
047: //---------------------------------------------------------------------------
048:
049: public GetRecordByIdRequest() {
050: }
051:
052: //---------------------------------------------------------------------------
053: //---
054: //--- API methods
055: //---
056: //---------------------------------------------------------------------------
057:
058: public void setElementSetName(ElementSetName name) {
059: setName = name;
060: }
061:
062: //---------------------------------------------------------------------------
063:
064: public void addId(String id) {
065: alIds.add(id);
066: }
067:
068: //---------------------------------------------------------------------------
069:
070: public void clearIds() {
071: alIds.clear();
072: }
073:
074: //---------------------------------------------------------------------------
075: //---
076: //--- Protected methods
077: //---
078: //---------------------------------------------------------------------------
079:
080: protected String getRequestName() {
081: return "GetRecordById";
082: }
083:
084: //---------------------------------------------------------------------------
085:
086: protected void setupGetParams() {
087: addParam("request", getRequestName());
088: addParam("service", Csw.SERVICE);
089: addParam("version", Csw.CSW_VERSION);
090:
091: if (setName != null)
092: addParam("elementSetName", setName);
093:
094: fill("id", alIds);
095: }
096:
097: //---------------------------------------------------------------------------
098:
099: protected Element getPostParams() {
100: Element params = new Element(getRequestName(),
101: Csw.NAMESPACE_CSW);
102:
103: //--- 'service' and 'version' are common mandatory attributes
104: params.setAttribute("service", Csw.SERVICE);
105: params.setAttribute("version", Csw.CSW_VERSION);
106:
107: fill(params, "Id", alIds);
108:
109: if (setName != null) {
110: Element elem = new Element("ElementSetName",
111: Csw.NAMESPACE_CSW);
112: elem.setText(setName.toString());
113:
114: params.addContent(elem);
115: }
116:
117: return params;
118: }
119: }
120:
121: //=============================================================================
|