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

Last change on this file since 10789 was 10789, checked in by kjdon, 19 years ago

added an option 'supercollectionoptions uniform_search_results_formatting' so that search results formatting all comes from the collection you are in rather than the each individual collection

  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 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 *********************************************************************/
25
26#include "comtypes.h"
27
28
29text_t get_comerror_string (comerror_t err) {
30 if (err == noError) return "no error";
31 else if (err == authenticationFailure) return "authentication failure";
32 else if (err == protocolError) return "protocol error";
33 else if (err == configurationError) return "configuration error";
34 else if (err == systemProblem) return "system problem";
35 else if (err == syntaxError) return "query syntax error";
36 return "unknown problem";
37}
38
39
40void ShortColInfo_t::clear() {
41 name.clear();
42 host.clear();
43 port = 0;
44}
45
46/*
47 isPublic now defaults to true most values are default
48 similar to a constructor in a class to make some initializations
49*/
50
51void ColInfoResponse_t::clear () {
52 shortInfo.clear();
53 isPublic=true;
54 isBeta=false;
55 isSegmented=false;
56 languages.erase(languages.begin(), languages.end());
57 ccsCols.erase(ccsCols.begin(), ccsCols.end());
58 ccsOptions = 0;
59 buildDate=0;
60 buildType.clear();
61 searchTypes.erase(searchTypes.begin(), searchTypes.end());
62 numDocs=0;
63 numSections=0;
64 numWords=0;
65 numBytes=0;
66 format.erase(format.begin(), format.end());
67 building.erase(format.begin(), format.end());
68 httpdomain.clear();
69 httpprefix.clear();
70 receptionist.clear();
71
72 // Setting some authentication parameters use with
73 // various parts of the code.
74
75 authenticate.clear(); // turned off by default, individual collection authentication
76 auth_group.clear(); // turned off by default, authentication by groups method
77 public_documents.clear(); // turned off by default, allow access to these documents <list>
78 private_documents.clear(); // turned off by default, disallow access to these documents <list>
79
80}
81
82text_t ColInfoResponse_t::get_collectionmeta(text_t name, text_t lang) {
83 text_t value = collectionmeta[name][lang];
84 if (value.empty()) {
85 value = collectionmeta[name][g_EmptyText];
86 }
87 return value;
88
89}
90
91void InfoFiltersResponse_t::clear () {
92 filterNames.erase(filterNames.begin(), filterNames.end());
93}
94
95
96void InfoFilterOptionsRequest_t::clear () {
97 filterName.clear();
98}
99
100
101void FilterOption_t::clear () {
102 name.clear();
103 type = booleant;
104 repeatable = onePerQuery;
105 defaultValue.clear();
106 validValues.erase(validValues.begin(), validValues.end());
107}
108
109void FilterOption_t::check_defaultValue () {
110 text_tarray::iterator here, end;
111
112 // how the default is interpreted depends on the option type
113 switch (type) {
114 case booleant:
115 case enumeratedt: // has to be one of the validValues
116 here = validValues.begin ();
117 end = validValues.end ();
118 while (here != end) {
119 if (*here == defaultValue) return;
120 ++here;
121 }
122
123 break;
124
125 case integert: // has to be in the validValues range
126 if ((validValues.size() >= 2) &&
127 (validValues[0].getint() <= defaultValue.getint()) &&
128 (validValues[1].getint() >= defaultValue.getint()))
129 return;
130 break;
131
132 case stringt: // any value is valid
133 return;
134 }
135
136 // did not find the defaultValue
137 if (validValues.empty()) defaultValue.clear();
138 else defaultValue = validValues[0];
139}
140
141
142bool operator==(const FilterOption_t &x, const FilterOption_t &y) {
143 return ((x.name == y.name) &&
144 (x.type == y.type) &&
145 (x.repeatable == y.repeatable) &&
146 (x.defaultValue == y.defaultValue) &&
147 (x.validValues == y.validValues));
148}
149
150bool operator<(const FilterOption_t &x, const FilterOption_t &y) {
151 return ((x.name < y.name) ||
152 ((x.name == y.name) &&
153 ((x.type < y.type) ||
154 ((x.type == y.type) &&
155 ((x.repeatable < y.repeatable) ||
156 ((x.repeatable == y.repeatable) &&
157 ((x.defaultValue < y.defaultValue) ||
158 ((x.defaultValue == y.defaultValue) &&
159 (x.validValues < y.validValues)))))))));
160}
161
162
163
164void InfoFilterOptionsResponse_t::clear () {
165 filterOptions.erase(filterOptions.begin(), filterOptions.end());
166}
167
168
169void OptionValue_t::clear () {
170 name.clear();
171 value.clear();
172}
173
174
175void FilterRequest_t::clear () {
176 filterName.clear();
177 filterLang.clear();
178 filterOptions.erase(filterOptions.begin(), filterOptions.end());
179 docSet.erase(docSet.begin(), docSet.end());
180 filterResultOptions = 0;
181 requestParams.clear();
182 refParams.clear();
183 fields.erase(fields.begin(), fields.end());
184 getParents = false;
185}
186
187
188void TermInfo_t::clear () {
189 term.clear();
190 freq = 0;
191 matchTerms.erase (matchTerms.begin(), matchTerms.end());
192}
193
194
195void MetadataInfo_t::clear () {
196 params.clear();
197 isRef = false;
198 values.erase(values.begin(), values.end());
199 if (parent != NULL) {
200 delete parent;
201 parent = NULL;
202 }
203}
204
205MetadataInfo_t::MetadataInfo_t () {parent=NULL;clear();}
206
207// copy constructor
208MetadataInfo_t::MetadataInfo_t (const MetadataInfo_t &x) {
209 params = x.params;
210 isRef = x.isRef;
211 values = x.values;
212 if (x.parent == NULL) parent = NULL;
213 else {
214 parent = new MetadataInfo_t ();
215 *parent = *(x.parent);
216 }
217}
218
219MetadataInfo_t::~MetadataInfo_t () {
220 if (parent != NULL) {
221 delete parent;
222 parent = NULL;
223 }
224}
225
226MetadataInfo_t &MetadataInfo_t::operator=(const MetadataInfo_t &x) {
227 if (&x != this) {
228 params = x.params;
229 isRef = x.isRef;
230 values = x.values;
231 if (x.parent == NULL) parent = NULL;
232 else {
233 parent = new MetadataInfo_t ();
234 *parent = *(x.parent);
235 }
236 }
237 return *this;
238}
239
240void ResultDocInfo_t::clear () {
241 OID.clear ();
242 ranking = 0;
243 result_num = 0;
244 num_terms_matched = 0;
245 num_phrase_match = 0;
246 docFreq.erase(docFreq.begin(), docFreq.end());
247 metadata.erase(metadata.begin(), metadata.end());
248 classifier_metadata_type.erase(classifier_metadata_type.begin(),
249 classifier_metadata_type.end());
250 classifier_metadata_offset = 0;
251
252}
253
254ResultDocInfo_t &ResultDocInfo_t::operator=(const ResultDocInfo_t &x) {
255 OID = x.OID;
256 ranking = x.ranking;
257 result_num = x.result_num;
258 num_terms_matched = x.num_terms_matched;
259 num_phrase_match = x.num_phrase_match;
260 docFreq = x.docFreq;
261 metadata = x.metadata;
262 return *this;
263}
264
265void FilterResponse_t::clear () {
266 numDocs = 0;
267 isApprox = Exact;
268 termInfo.erase (termInfo.begin(), termInfo.end());
269 docInfo.erase (docInfo.begin(), docInfo.end());
270}
271
272FilterResponse_t &FilterResponse_t::operator=(const FilterResponse_t &x) {
273 numDocs = x.numDocs;
274 isApprox = x.isApprox;
275 termInfo = x.termInfo;
276 docInfo = x.docInfo;
277 return *this;
278}
279
280void DocumentRequest_t::clear () {
281 OID.clear();
282 docType.clear();
283 docFormat.clear();
284}
285
286void DocumentResponse_t::clear () {
287 doc.clear();
288}
Note: See TracBrowser for help on using the repository browser.