source: trunk/gsdl/src/recpt/comtypes.cpp@ 1253

Last change on this file since 1253 was 1253, checked in by sjboddie, 24 years ago

added new numsections field to collection info and made the statusaction
recognize it

  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 KB
Line 
1/**********************************************************************
2 *
3 * comtypes.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * $Id: comtypes.cpp 1253 2000-06-29 00:22:59Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.23 2000/06/29 00:22:58 sjboddie
31 added new numsections field to collection info and made the statusaction
32 recognize it
33
34 Revision 1.22 1999/12/13 02:24:33 davidb
35 Data fields for cross collection searching (CCS)
36
37 Support for multiple meta-data entries for same document/section.
38
39 Revision 1.21 1999/11/01 22:00:50 sjboddie
40 added assignment operator for FilterResponse_t
41
42 Revision 1.20 1999/10/14 23:02:34 sjboddie
43 fixed bug in new parent metadata stuff
44
45 Revision 1.19 1999/10/10 07:49:35 sjboddie
46 - metadata now returns map rather than array
47 - redesigned browsing support (although it's not finished
48 so won't currently work ;-)
49
50 Revision 1.18 1999/09/07 04:56:54 sjboddie
51 added GPL notice
52
53 Revision 1.17 1999/09/02 00:25:26 rjmcnab
54 changes to get compiling on AIX
55
56 Revision 1.16 1999/08/13 04:19:05 sjboddie
57 added name attribute to metadata
58
59 Revision 1.15 1999/08/03 03:31:43 sjboddie
60 added ability to set receptionist from configuration files
61
62 Revision 1.14 1999/07/16 03:41:29 sjboddie
63 changed isApprox
64
65 Revision 1.13 1999/07/08 20:46:45 rjmcnab
66 Added the result number to the ResultDocInfo_t
67
68 Revision 1.12 1999/07/07 06:11:33 rjmcnab
69 Slight change for multiple phrase matching.
70
71 Revision 1.11 1999/07/01 22:47:49 sjboddie
72 added format option to collection info
73
74 Revision 1.10 1999/06/29 22:05:01 rjmcnab
75 Added a couple of fields to ResultDocInfo_t to handle a special
76 version of mg.
77
78 Revision 1.9 1999/06/16 02:01:22 sjboddie
79 Few changes to get getParents filter option to return metadata of parents
80 as well as current OID
81
82 Revision 1.8 1999/05/10 03:40:33 sjboddie
83 lots of changes - slowly getting document action sorted out
84
85 Revision 1.7 1999/04/21 05:23:14 sjboddie
86
87 Changed the way metadata is returned
88
89 Revision 1.6 1999/04/06 22:20:34 rjmcnab
90 Got browsefilter working.
91
92 Revision 1.5 1999/03/31 23:44:47 rjmcnab
93 Altered the protocol so that the metadata is part of the filter.
94
95 Revision 1.4 1999/03/11 00:11:19 rjmcnab
96 Added a function to get a string version of comerror_t
97
98 Revision 1.3 1999/03/09 21:00:47 rjmcnab
99 Reorganised the statusaction, added more functions to comtypes.
100
101 Revision 1.2 1999/03/04 21:19:15 rjmcnab
102
103 Added clear() functions to all the data types.
104
105 Revision 1.1 1999/02/21 22:35:25 rjmcnab
106
107 Initial revision.
108
109 */
110
111
112#include "comtypes.h"
113
114
115text_t get_comerror_string (comerror_t err) {
116 if (err == noError) return "no error";
117 else if (err == authenticationFailure) return "authentication failure";
118 else if (err == protocolError) return "protocol error";
119 else if (err == configurationError) return "configuration error";
120 else if (err == systemProblem) return "system problem";
121
122 return "unknown problem";
123}
124
125
126void ShortColInfo_t::clear() {
127 name.clear();
128 host.clear();
129 port = 0;
130}
131
132void ColInfoResponse_t::clear () {
133 shortInfo.clear();
134 isPublic=false;
135 isBeta=false;
136 languages.erase(languages.begin(), languages.end());
137 ccsCols.erase(ccsCols.begin(), ccsCols.end());
138 buildDate=0;
139 numDocs=0;
140 numSections=0;
141 numWords=0;
142 numBytes=0;
143 format.erase(format.begin(), format.end());
144 building.erase(format.begin(), format.end());
145 receptionist.clear();
146}
147
148void InfoFiltersResponse_t::clear () {
149 filterNames.erase(filterNames.begin(), filterNames.end());
150}
151
152
153void InfoFilterOptionsRequest_t::clear () {
154 filterName.clear();
155}
156
157
158void FilterOption_t::clear () {
159 name.clear();
160 type = booleant;
161 repeatable = onePerQuery;
162 defaultValue.clear();
163 validValues.erase(validValues.begin(), validValues.end());
164}
165
166void FilterOption_t::check_defaultValue () {
167 text_tarray::iterator here, end;
168
169 // how the default is interpreted depends on the option type
170 switch (type) {
171 case booleant:
172 case enumeratedt: // has to be one of the validValues
173 here = validValues.begin ();
174 end = validValues.end ();
175 while (here != end) {
176 if (*here == defaultValue) return;
177 here++;
178 }
179
180 break;
181
182 case integert: // has to be in the validValues range
183 if ((validValues.size() >= 2) &&
184 (validValues[0].getint() <= defaultValue.getint()) &&
185 (validValues[1].getint() >= defaultValue.getint()))
186 return;
187 break;
188
189 case stringt: // any value is valid
190 return;
191 }
192
193 // did not find the defaultValue
194 if (validValues.empty()) defaultValue.clear();
195 else defaultValue = validValues[0];
196}
197
198
199bool operator==(const FilterOption_t &x, const FilterOption_t &y) {
200 return ((x.name == y.name) &&
201 (x.type == y.type) &&
202 (x.repeatable == y.repeatable) &&
203 (x.defaultValue == y.defaultValue) &&
204 (x.validValues == y.validValues));
205}
206
207bool operator<(const FilterOption_t &x, const FilterOption_t &y) {
208 return ((x.name < y.name) ||
209 ((x.name == y.name) &&
210 ((x.type < y.type) ||
211 ((x.type == y.type) &&
212 ((x.repeatable < y.repeatable) ||
213 ((x.repeatable == y.repeatable) &&
214 ((x.defaultValue < y.defaultValue) ||
215 ((x.defaultValue == y.defaultValue) &&
216 (x.validValues < y.validValues)))))))));
217}
218
219
220
221void InfoFilterOptionsResponse_t::clear () {
222 filterOptions.erase(filterOptions.begin(), filterOptions.end());
223}
224
225
226void OptionValue_t::clear () {
227 name.clear();
228 value.clear();
229}
230
231
232void FilterRequest_t::clear () {
233 filterName.clear();
234 filterOptions.erase(filterOptions.begin(), filterOptions.end());
235 docSet.erase(docSet.begin(), docSet.end());
236 filterResultOptions = 0;
237 requestParams.clear();
238 refParams.clear();
239 fields.erase(fields.begin(), fields.end());
240 getParents = false;
241}
242
243
244void TermInfo_t::clear () {
245 term.clear();
246 freq = 0;
247 matchTerms.erase (matchTerms.begin(), matchTerms.end());
248}
249
250
251void MetadataInfo_t::clear () {
252 params.clear();
253 isRef = false;
254 values.erase(values.begin(), values.end());
255 if (parent != NULL) {
256 delete parent;
257 parent = NULL;
258 }
259}
260
261MetadataInfo_t::MetadataInfo_t () {parent=NULL;clear();}
262
263// copy constructor
264MetadataInfo_t::MetadataInfo_t (const MetadataInfo_t &x) {
265 params = x.params;
266 isRef = x.isRef;
267 values = x.values;
268 if (x.parent == NULL) parent = NULL;
269 else {
270 parent = new MetadataInfo_t ();
271 *parent = *(x.parent);
272 }
273}
274
275MetadataInfo_t::~MetadataInfo_t () {
276 if (parent != NULL) {
277 delete parent;
278 parent = NULL;
279 }
280}
281
282MetadataInfo_t &MetadataInfo_t::operator=(const MetadataInfo_t &x) {
283 if (&x != this) {
284 params = x.params;
285 isRef = x.isRef;
286 values = x.values;
287 if (x.parent == NULL) parent = NULL;
288 else {
289 parent = new MetadataInfo_t ();
290 *parent = *(x.parent);
291 }
292 }
293 return *this;
294}
295
296void ResultDocInfo_t::clear () {
297 OID.clear ();
298 ranking = 0;
299 result_num = 0;
300 num_terms_matched = 0;
301 num_phrase_match = 0;
302 docFreq.erase(docFreq.begin(), docFreq.end());
303 metadata.erase(metadata.begin(), metadata.end());
304 classifier_metadata_type.erase(classifier_metadata_type.begin(),
305 classifier_metadata_type.end());
306 classifier_metadata_offset = 0;
307
308}
309
310ResultDocInfo_t &ResultDocInfo_t::operator=(const ResultDocInfo_t &x) {
311 OID = x.OID;
312 ranking = x.ranking;
313 result_num = x.result_num;
314 num_terms_matched = x.num_terms_matched;
315 num_phrase_match = x.num_phrase_match;
316 docFreq = x.docFreq;
317 metadata = x.metadata;
318 return *this;
319}
320
321void FilterResponse_t::clear () {
322 numDocs = 0;
323 isApprox = Exact;
324 termInfo.erase (termInfo.begin(), termInfo.end());
325 docInfo.erase (docInfo.begin(), docInfo.end());
326}
327
328FilterResponse_t &FilterResponse_t::operator=(const FilterResponse_t &x) {
329 numDocs = x.numDocs;
330 isApprox = x.isApprox;
331 termInfo = x.termInfo;
332 docInfo = x.docInfo;
333 return *this;
334}
335
336void DocumentRequest_t::clear () {
337 OID.clear();
338 docType.clear();
339 docFormat.clear();
340}
341
342void DocumentResponse_t::clear () {
343 doc.clear();
344}
345
346
347
Note: See TracBrowser for help on using the repository browser.