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

Last change on this file since 919 was 823, checked in by davidb, 24 years ago

Data fields for cross collection searching (CCS)

Support for multiple meta-data entries for same document/section.

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