Changeset 226
- Timestamp:
- 1999-04-07T10:20:35+12:00 (25 years ago)
- Location:
- trunk/gsdl/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/colservr/collectserver.cpp
r220 r226 1 1 2 /********************************************************************** 2 3 * … … 12 13 /* 13 14 $Log$ 15 Revision 1.6 1999/04/06 22:20:29 rjmcnab 16 Got browsefilter working. 17 14 18 Revision 1.5 1999/03/31 23:44:44 rjmcnab 15 19 Altered the protocol so that the metadata is part of the filter. … … 48 52 // it contains. The configuration should take place just before initialisation. 49 53 void collectserver::configure (const text_t &key, const text_tarray &cfgline) { 50 if (key == "indexmap") { 51 configinfo.indexmap.importmap (cfgline); 52 53 // update the list of indexes in the filter information 54 text_tarray options; 55 configinfo.indexmap.gettoarray (options); 56 update_enumfiltopt ("Index", options); 57 58 } else if (key == "subcollectionmap") { 59 configinfo.subcollectionmap.importmap (cfgline); 60 61 // update the list of subcollections in the filter information 62 text_tarray options; 63 configinfo.subcollectionmap.gettoarray (options); 64 update_enumfiltopt ("Subcollection", options); 65 66 } else if (key == "languagemap") { 67 configinfo.languagemap.importmap (cfgline); 68 69 // update the list of languages in the filter information 70 text_tarray options; 71 configinfo.languagemap.gettoarray (options); 72 update_enumfiltopt ("Language", options); 73 74 } else if (cfgline.size() >= 1) { 54 if (cfgline.size() >= 1) { 75 55 const text_t &value = cfgline[0]; 76 56 if (key == "gsdlhome") configinfo.gsdlhome = value; … … 92 72 else if (key == "numwords") collectinfo.numWords = value.getint(); 93 73 else if (key == "numbytes") collectinfo.numBytes = value.getint(); 94 95 else if ((key == "filteroptdefault") && (cfgline.size() == 2)) { 96 // set this default for each type of filter 97 // FilterDescript_tmap::iterator filteropthere = filterinfo.filterOptions.begin(); 98 // FilterDescript_tmap::iterator filteroptend = filterinfo.filterOptions.end(); 99 100 // while (filteropthere != filteroptend) { 101 // // see if this filter has an option with this name 102 // FilterOption_tmap &fotm = (*filteropthere).second.filterOptions; 103 // if (fotm.find(cfgline[0]) != fotm.end()) { 104 // (*(fotm.find(cfgline[0]))).second.defaultValue = cfgline[1]; 105 // } 106 107 // filteropthere++; 108 // } 109 } 74 } 75 76 // configure the filters 77 filtermapclass::iterator filter_here = filters.begin(); 78 filtermapclass::iterator filter_end = filters.end(); 79 while (filter_here != filter_end) { 80 assert ((*filter_here).second.f != NULL); 81 if ((*filter_here).second.f != NULL) 82 (*filter_here).second.f->configure(key, cfgline); 83 84 filter_here++; 85 } 86 87 // configure the sources 88 sourcelistclass::iterator source_here = sources.begin(); 89 sourcelistclass::iterator source_end = sources.end(); 90 while (source_here != source_end) { 91 assert ((*source_here).s != NULL); 92 if ((*source_here).s != NULL) 93 (*source_here).s->configure(key, cfgline); 94 95 source_here++; 110 96 } 111 97 } … … 118 104 119 105 120 bool collectserver::init (ostream &/*logout*/) { 106 bool collectserver::init (ostream &logout) { 107 // init the filters 108 filtermapclass::iterator filter_here = filters.begin(); 109 filtermapclass::iterator filter_end = filters.end(); 110 while (filter_here != filter_end) { 111 assert ((*filter_here).second.f != NULL); 112 if (((*filter_here).second.f != NULL) && 113 !(*filter_here).second.f->init(logout)) return false; 114 115 filter_here++; 116 } 117 118 // init the sources 119 sourcelistclass::iterator source_here = sources.begin(); 120 sourcelistclass::iterator source_end = sources.end(); 121 while (source_here != source_end) { 122 assert ((*source_here).s != NULL); 123 if (((*source_here).s != NULL) && 124 !(*source_here).s->init(logout)) return false; 125 126 source_here++; 127 } 128 121 129 return true; 122 130 } … … 129 137 } 130 138 131 void collectserver::get_filterinfo (InfoFiltersResponse_t & /*response*/,139 void collectserver::get_filterinfo (InfoFiltersResponse_t &response, 132 140 comerror_t &err, ostream &/*logout*/) { 133 err = protocolError; 134 } 135 136 void collectserver::get_filteroptions (const InfoFilterOptionsRequest_t &/*request*/, 141 response.clear (); 142 143 // get a list of filter names 144 filtermapclass::iterator filter_here = filters.begin(); 145 filtermapclass::iterator filter_end = filters.end(); 146 while (filter_here != filter_end) { 147 response.filterNames.insert ((*filter_here).first); 148 filter_here++; 149 } 150 151 err = noError; 152 } 153 154 void collectserver::get_filteroptions (const InfoFilterOptionsRequest_t &request, 137 155 InfoFilterOptionsResponse_t &response, 138 comerror_t &err, ostream &/*logout*/) { 139 response = filterinfo; 140 err = noError; 156 comerror_t &err, ostream &logout) { 157 outconvertclass text_t2ascii; 158 159 filterclass *thisfilter = filters.getfilter(request.filterName); 160 if (thisfilter != NULL) { 161 thisfilter->get_filteroptions (response, err, logout); 162 } else { 163 response.clear (); 164 err = protocolError; 165 logout << text_t2ascii << "Protocol Error: filter options requested for non-existent\n" 166 << "filter \"" << request.filterName << "\".\n\n"; 167 } 141 168 } 142 169 143 170 void collectserver::filter (const FilterRequest_t &request, 144 171 FilterResponse_t &response, 145 comerror_t &err, ostream &/*logout*/) { 172 comerror_t &err, ostream &logout) { 173 outconvertclass text_t2ascii; 174 146 175 response.clear(); 147 176 148 if (request.filterName == "QueryFilter") { 149 // return documents 150 response.numDocs = 2; 151 response.isApprox = false; 152 153 // fill in the term info 154 TermInfo_t terminfo; 155 terminfo.term = "the"; 156 terminfo.freq = 2; 157 terminfo.matchTerms.push_back ("the"); 158 terminfo.matchTerms.push_back ("The"); 159 response.termInfo.push_back (terminfo); 160 161 // fill in the document info 162 ResultDocInfo_t resultdoc; 163 resultdoc.OID = "HASH1234"; 164 resultdoc.ranking = 8000; 165 resultdoc.docFreq.push_back (10); 166 response.docInfo.push_back (resultdoc); 167 168 resultdoc.clear(); 169 resultdoc.OID = "HASH2345"; 170 resultdoc.ranking = 5000; 171 resultdoc.docFreq.push_back (5); 172 response.docInfo.push_back (resultdoc); 173 174 } else if (request.filterName == "BrowseFilter") { 175 // return documents 176 response.numDocs = 2; 177 response.isApprox = false; 178 179 // fill in the document info 180 ResultDocInfo_t resultdoc; 181 resultdoc.OID = "HASH2345"; 182 response.docInfo.push_back (resultdoc); 183 184 resultdoc.clear(); 185 resultdoc.OID = "HASH3456"; 186 response.docInfo.push_back (resultdoc); 177 filterclass *thisfilter = filters.getfilter(request.filterName); 178 if (thisfilter != NULL) { 179 // filter the data 180 thisfilter->filter (request, response, err, logout); 181 182 // fill in the metadata for each of the OIDs (if it is requested) 183 if (request.filterResultOptions & FRmetadata) { 184 ResultDocInfo_tarray::iterator resultdoc_here = response.docInfo.begin(); 185 ResultDocInfo_tarray::iterator resultdoc_end = response.docInfo.end(); 186 while (resultdoc_here != resultdoc_end) { 187 // try each of the sources in turn 188 sourcelistclass::iterator source_here = sources.begin(); 189 sourcelistclass::iterator source_end = sources.end(); 190 while (source_here != source_end) { 191 assert ((*source_here).s != NULL); 192 if (((*source_here).s != NULL) && 193 ((*source_here).s->get_metadata(request.requestParams, request.refParams, 194 request.fields, (*resultdoc_here).OID, 195 (*resultdoc_here).metadata, err, logout))) { 196 if (err != noError) return; 197 break; 198 } 199 200 source_here++; 201 } 202 203 resultdoc_here++; 204 } 205 } 187 206 188 207 } else { 208 response.clear (); 189 209 err = protocolError; 190 return; 191 } 192 210 logout << text_t2ascii << "Protocol Error: filter options requested for non-existent\n" 211 << "filter \"" << request.filterName << "\".\n\n"; 212 } 213 193 214 err = noError; 194 215 } 195 216 196 217 197 void collectserver::update_enumfiltopt (text_t /*optionname*/,198 const text_tarray &/*options*/) {199 // update this option for each of the filters200 // FilterDescript_tmap::iterator filteropthere = filterinfo.filterOptions.begin();201 // FilterDescript_tmap::iterator filteroptend = filterinfo.filterOptions.end();202 203 // while (filteropthere != filteroptend) {204 // // see if this filter has an option with this name205 // FilterOption_tmap &fotm = (*filteropthere).second.filterOptions;206 // FilterOption_tmap::iterator fotm_iterator = fotm.find(optionname);207 // if (fotm_iterator != fotm.end()) {208 // // set the valid values to be the options209 // (*fotm_iterator).second.validValues = options;210 211 // // make sure the default is a valid value212 // (*fotm_iterator).second.check_defaultValue();213 // }214 215 // filteropthere++;216 // }217 }218 218 219 219 -
trunk/gsdl/src/colservr/collectserver.h
r220 r226 17 17 #include "text_t.h" 18 18 #include "comtypes.h" 19 #include "maptools.h" 19 #include "filter.h" 20 #include "source.h" 20 21 21 22 #if defined(GSDL_USE_OBJECTSPACE) … … 40 41 text_t collection; 41 42 text_t collectdir; 42 stringmap indexmap;43 stringmap subcollectionmap;44 stringmap languagemap;45 43 }; 46 44 … … 50 48 colservrconf configinfo; 51 49 ColInfoResponse_t collectinfo; 52 InfoFilterOptionsResponse_t filterinfo; 50 51 filtermapclass filters; 52 sourcelistclass sources; 53 53 54 54 public: 55 55 collectserver (); 56 56 virtual ~collectserver (); 57 58 // add_filter makes another filter available to the collection server 59 // the filter remains the property of the calling code and that 60 // code should destroy the filter after the collection server has been 61 // destroyed. 62 void add_filter (filterclass *thefilter) {filters.addfilter(thefilter);} 63 filtermapclass *get_filtermap_ptr () {return &filters;} 64 65 // add_source makes another source available to the collection server 66 // the source remains the property of the calling code and that 67 // code should destroy the source after the collection server has been 68 // destroyed. 69 void add_source (sourceclass *thesource) {sources.addsource(thesource);} 70 sourcelistclass *get_sourcelist_ptr () {return &sources;} 57 71 58 72 // configure should be called for each line in the … … 83 97 FilterResponse_t &response, 84 98 comerror_t &err, ostream &logout); 85 86 protected:87 void update_enumfiltopt (text_t optionname, const text_tarray &options);88 99 }; 89 100 -
trunk/gsdl/src/colservr/filter.cpp
r220 r226 12 12 /* 13 13 $Log$ 14 Revision 1.3 1999/04/06 22:20:30 rjmcnab 15 Got browsefilter working. 16 14 17 Revision 1.2 1999/03/31 23:44:46 rjmcnab 15 18 Altered the protocol so that the metadata is part of the filter. … … 22 25 23 26 #include "filter.h" 27 #include "fileutil.h" 24 28 #include <assert.h> 25 29 … … 34 38 35 39 // configure should be called once for each configuration line 36 // default does nothing 37 void filterclass::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) { 40 // default configures the default filter options 41 void filterclass::configure (const text_t &key, const text_tarray &cfgline) { 42 if (cfgline.size() >= 1) { 43 const text_t &value = cfgline[0]; 44 45 if (key == "collection") collection = value; 46 else if (key == "collectdir") collectdir = value; 47 else if (key == "gsdlhome") gsdlhome = value; 48 else if ((key == "filteroptdefault") && (cfgline.size() == 2)) { 49 // see if this filter has an option with this name 50 FilterOption_tmap::iterator thisfilteroption = 51 filterOptions.find(cfgline[0]); 52 if (thisfilteroption != filterOptions.end()) 53 (*thisfilteroption).second.defaultValue = cfgline[1]; 54 } 55 } 38 56 } 39 57 40 58 // init should be called after all the configuration is done but 41 59 // before any other methods are called 42 // default does nothing60 // default checks all the filter option defaults 43 61 bool filterclass::init (ostream &/*logout*/) { 62 // check all the filter defaults 63 FilterOption_tmap::iterator filteroption_here = filterOptions.begin(); 64 FilterOption_tmap::iterator filteroption_end = filterOptions.end(); 65 while (filteroption_here != filteroption_end) { 66 (*filteroption_here).second.check_defaultValue (); 67 68 filteroption_here++; 69 } 70 71 // get the collection directory name 72 if (collectdir.empty()) { 73 collectdir = filename_cat (gsdlhome, "collect", collection); 74 } 75 44 76 return true; 45 77 } … … 51 83 } 52 84 85 // returns the current filter options 86 void filterclass::get_filteroptions (InfoFilterOptionsResponse_t &response, 87 comerror_t &err, ostream &/*logout*/) { 88 response.clear(); 89 response.filterOptions = filterOptions; 90 err = noError; 91 } 92 53 93 // default returns nothing 54 void filterclass::get_filteroptions (InfoFilterOptionsResponse_t &response) { 55 response.clear(); 56 } 57 58 // default returns nothing 59 void filterclass::filter (const FilterRequest_t &/*request*/, 94 void filterclass::filter (const FilterRequest_t &request, 60 95 FilterResponse_t &response, 61 96 comerror_t &err, ostream &/*logout*/) { 97 ResultDocInfo_t resultdoc; 98 62 99 response.clear(); 100 101 if ((request.filterResultOptions & FROID) || 102 (request.filterResultOptions & FRmetadata)) { 103 // copy the OIDs from the request to the response 104 text_tset::const_iterator here = request.docSet.begin(); 105 text_tset::const_iterator end = request.docSet.end(); 106 while (here != end) { 107 resultdoc.OID = (*here); 108 response.docInfo.push_back(resultdoc); 109 110 here++; 111 } 112 } 113 114 response.numDocs = response.docInfo.size(); 115 response.isApprox = false; 63 116 err = noError; 64 117 } … … 94 147 } 95 148 149 150 151 152 // some useful functions for dealing with document sets 153 154 // returns -1 if t1 is a child of t2 155 // returns 0 if t1 and t2 are not parent-child related 156 // returns 1 if t1 is a parent of t2 157 int child_compare (const text_t &t1, const text_t &t2) { 158 text_t::const_iterator t1_here = t1.begin(); 159 text_t::const_iterator t1_end = t1.end(); 160 text_t::const_iterator t2_here = t2.begin(); 161 text_t::const_iterator t2_end = t2.end(); 162 163 while ((t1_here != t1_end) && (t2_here != t2_end)) { 164 if (*t1_here != *t2_here) return 0; // unrelated 165 t1_here++; 166 t2_here++; 167 } 168 169 if ((t1_here == t1_end) && (t2_here == t2_end)) return 0; // equal 170 if (t1_here != t1_end) { 171 if (*t1_here == '.') return -1; // t1 is child 172 else return 0; // unrelated 173 } 174 175 if (t2_here != t2_end) { 176 if (*t2_here == '.') return 1; // t2 is child 177 else return 0; // unrelated 178 } 179 180 return 0; // shouldn't get here... 181 } 182 183 // intersect places the result in set1 184 void intersect (text_tset &set1, const text_tset &set2) { 185 text_tset resultset; 186 int childcomp = 0; 187 188 text_tset::const_iterator set1_here = set1.begin(); 189 text_tset::const_iterator set1_end = set1.end(); 190 text_tset::const_iterator set2_here = set2.begin(); 191 text_tset::const_iterator set2_end = set2.end(); 192 while ((set1_here != set1_end) && (set2_here != set2_end)) { 193 if (*set1_here == *set2_here) { 194 // equal 195 resultset.insert (*set1_here); 196 set1_here++; 197 set2_here++; 198 199 } else if ((childcomp=child_compare(*set1_here, *set2_here)) != 0) { 200 if (childcomp < 0) { 201 // set1_here is child 202 resultset.insert (*set1_here); 203 set1_here++; 204 } else { 205 // set2_here is child 206 resultset.insert (*set2_here); 207 set2_here++; 208 } 209 210 } else if (*set1_here < *set2_here) { 211 // set1 is less 212 set1_here++; 213 214 } else { 215 // set2 is less 216 set2_here++; 217 } 218 } 219 220 set1 = resultset; 221 } -
trunk/gsdl/src/colservr/filter.h
r220 r226 20 20 21 21 class filterclass { 22 protected: 23 text_t gsdlhome; 24 text_t collection; 25 text_t collectdir; 26 27 FilterOption_tmap filterOptions; 28 22 29 public: 23 30 filterclass (); … … 25 32 26 33 // configure should be called once for each configuration line 34 // default configures the default filter options 27 35 virtual void configure (const text_t &key, const text_tarray &cfgline); 28 36 29 37 // init should be called after all the configuration is done but 30 38 // before any other methods are called 39 // default checks all the filter option defaults 31 40 virtual bool init (ostream &logout); 32 41 … … 34 43 virtual text_t get_filter_name (); 35 44 36 virtual void get_filteroptions (InfoFilterOptionsResponse_t &response); 45 // returns the current filter options 46 virtual void get_filteroptions (InfoFilterOptionsResponse_t &response, 47 comerror_t &err, ostream &logout); 37 48 38 49 virtual void filter (const FilterRequest_t &request, … … 96 107 97 108 109 110 // some useful functions for dealing with document sets 111 112 // intersect places the result in set1 113 void intersect (text_tset &set1, const text_tset &set2); 114 98 115 #endif -
trunk/gsdl/src/colservr/infodbclass.cpp
r216 r226 12 12 /* 13 13 $Log$ 14 Revision 1.2 1999/04/06 22:20:31 rjmcnab 15 Got browsefilter working. 16 14 17 Revision 1.1 1999/03/30 05:10:07 rjmcnab 15 18 Initial revision. … … 58 61 59 62 60 // returns 0 if failed, 1if opened61 intgdbmclass::opendatabase (const text_t &filename) {63 // returns true if opened 64 bool gdbmclass::opendatabase (const text_t &filename) { 62 65 text_t data_location; 63 66 int block_size = 0; 64 67 65 68 if (gdbmfile != NULL) { 66 if (openfile == filename) return 1;69 if (openfile == filename) return true; 67 70 else closedatabase (); 68 71 } … … 90 93 } 91 94 92 // returns 0 on success, -1 on failure93 intgdbmclass::getinfo (text_t key, infodbclass &info) {95 // returns true on success 96 bool gdbmclass::getinfo (text_t key, infodbclass &info) { 94 97 text_t data; 95 96 if (!getkeydata (key, data)) return -1;98 99 if (!getkeydata (key, data)) return false; 97 100 text_t::iterator here = data.begin (); 98 101 text_t::iterator end = data.end (); 99 102 100 103 text_t ikey, ivalue; 101 104 info.clear (); // reset info 102 105 103 106 while (getinfoline(here, end, ikey, ivalue)) { 104 107 info[ikey] = ivalue; 105 108 } 106 109 107 return 0;110 return true; 108 111 } 109 112 110 int gdbmclass::exists (text_t key) { 113 // returns true if exists 114 bool gdbmclass::exists (text_t key) { 111 115 text_t data; 112 116 return getkeydata (key, data); 113 117 } 114 118 115 int gdbmclass::getkeydata (text_t key, text_t &data) { 119 // returns true on success 120 bool gdbmclass::getkeydata (text_t key, text_t &data) { 116 121 datum key_data; 117 122 datum return_data; 118 123 119 if (gdbmfile == NULL) return 0;120 124 if (gdbmfile == NULL) return false; 125 121 126 // get a utf-8 encoded c string of the unicode key 122 127 key_data.dptr = (to_utf8(key)).getcstr(); 123 128 if (key_data.dptr == NULL) { 124 129 if (logout != NULL) (*logout) << "gdbmclass: out of memory\n"; 125 return 0;130 return false; 126 131 } 127 132 key_data.dsize = strlen (key_data.dptr); 128 133 129 134 // fetch the result 130 135 return_data = gdbm_fetch (gdbmfile, key_data); 131 136 delete key_data.dptr; 132 133 if (return_data.dptr == NULL) return 0;137 138 if (return_data.dptr == NULL) return false; 134 139 135 140 data.setcarr (return_data.dptr, return_data.dsize); … … 137 142 data = to_uni(data); // convert to unicode 138 143 139 return 1;144 return true; 140 145 } 141 146 142 int gdbmclass::getinfoline (text_t::iterator &here, text_t::iterator end, 143 text_t &key, text_t &value) { 147 // returns true on success 148 bool gdbmclass::getinfoline (text_t::iterator &here, text_t::iterator end, 149 text_t &key, text_t &value) { 144 150 key.clear(); 145 151 value.clear(); … … 149 155 150 156 // get the '<' 151 if (here == end || *here != '<') return 0;157 if (here == end || *here != '<') return false; 152 158 here++; 153 159 … … 159 165 160 166 // get the '>' 161 if (here == end || *here != '>') return 0;167 if (here == end || *here != '>') return false; 162 168 here++; 163 169 … … 181 187 } 182 188 183 return 1;189 return true; 184 190 } 185 191 -
trunk/gsdl/src/colservr/infodbclass.h
r216 r226 83 83 ~gdbmclass() {}; 84 84 85 // returns 0 if failed, 1if opened86 intopendatabase (const text_t &filename);85 // returns true if opened 86 bool opendatabase (const text_t &filename); 87 87 void closedatabase (); 88 88 89 // returns 0 on success, -1 on failure90 intgetinfo (text_t key, infodbclass &info);89 // returns true on success 90 bool getinfo (text_t key, infodbclass &info); 91 91 void setlogout (ostream *thelogout) {logout = thelogout;} 92 int exists (text_t key); 92 93 // returns true if exists 94 bool exists (text_t key); 93 95 94 96 protected: … … 97 99 ostream *logout; 98 100 99 int getkeydata (text_t key, text_t &data); 100 int getinfoline (text_t::iterator &here, text_t::iterator end, 101 // returns true on success 102 bool getkeydata (text_t key, text_t &data); 103 104 // returns true on success 105 bool getinfoline (text_t::iterator &here, text_t::iterator end, 101 106 text_t &key, text_t &value); 102 107 }; -
trunk/gsdl/src/colservr/mgsearch.h
r138 r226 25 25 // appear within the index directory) and real indexes (indexes as they 26 26 // appear within the collect.cfg file) and mappings between them. 27 28 // all these functions can go when we don't need src/library any more 29 27 30 void getdirindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap, 28 31 const text_tarray &languagemap, const text_t &dirindex, … … 45 48 bool isdoclevelindex (const text_t &realindex); 46 49 text_t getdoclevelindex (const text_tarray &indexmap); 50 51 47 52 48 53 class mgsearchclass { -
trunk/gsdl/src/colservr/source.cpp
r219 r226 12 12 /* 13 13 $Log$ 14 Revision 1.2 1999/04/06 22:20:32 rjmcnab 15 Got browsefilter working. 16 14 17 Revision 1.1 1999/03/31 23:43:40 rjmcnab 15 18 Initial revision … … 42 45 } 43 46 44 // default does nothing 45 //void sourceclass::get_metadata (const MetadataRequest_t &/*request*/, 46 // MetadataResponse_t &response, 47 // comerror_t &err, ostream &/*logout*/) { 48 // response.clear(); 49 // err = noError; 50 //} 47 // get_metadata fills out the metadata if possible, if it is not responsable 48 // for the given OID then it will return false. 49 bool sourceclass::get_metadata (const text_t &/*requestParams*/, const text_t &/*refParams*/, 50 const text_tarray &/*fields*/, const text_t &/*OID*/, 51 MetadataInfo_tarray &metadata, 52 comerror_t &err, ostream &/*logout*/) { 53 metadata.erase(metadata.begin(), metadata.end()); 54 err = noError; 55 56 return false; 57 } 51 58 52 59 … … 55 62 // should not be deleted until it is removed from this list. 56 63 void sourcelistclass::addsource (sourceclass *thesource) { 57 // can't add a protocolthat doesn't exist64 // can't add a source that doesn't exist 58 65 assert (thesource != NULL); 59 66 if (thesource == NULL) return; -
trunk/gsdl/src/colservr/source.h
r219 r226 30 30 // before any other methods are called 31 31 virtual bool init (ostream &logout); 32 /* // needs some work 33 virtual void get_metadata (const MetadataRequest_t &request, 34 MetadataResponse_t &response, 32 33 // get_metadata fills out the metadata if possible, if it is not responsable 34 // for the given OID then it will return false. 35 virtual bool get_metadata (const text_t &requestParams, const text_t &refParams, 36 const text_tarray &fields, const text_t &OID, 37 MetadataInfo_tarray &metadata, 35 38 comerror_t &err, ostream &logout); 36 */37 39 }; 38 40 -
trunk/gsdl/src/recpt/Makefile
r220 r226 42 42 43 43 COLSERVRHEADERS = infodbclass.h mgq.h mgsearch.h querycache.h queryinfo.h \ 44 collectserver.h colservrconfig.h maptools.h filter.h source.h 44 collectserver.h colservrconfig.h maptools.h filter.h \ 45 source.h browsefilter.h queryfilter.h 45 46 46 47 LIBRARYHEADERS = $(COLSERVRHEADERS) \ … … 58 59 59 60 COLSERVRSOURCES = infodbclass.cpp mgq.c mgsearch.cpp querycache.cpp queryinfo.cpp \ 60 collectserver.cpp colservrconfig.cpp maptools.cpp filter.cpp source.cpp 61 collectserver.cpp colservrconfig.cpp maptools.cpp filter.cpp \ 62 source.cpp browsefilter.cpp queryfilter.cpp 61 63 62 64 LIBRARYSOURCES = $(COLSERVRSOURCES) \ … … 74 76 75 77 COLSERVROBJECTS = infodbclass.o mgq.o mgsearch.o querycache.o queryinfo.o \ 76 collectserver.o colservrconfig.o maptools.o filter.o source.o 78 collectserver.o colservrconfig.o maptools.o filter.o \ 79 source.o browsefilter.o queryfilter.o 77 80 78 81 LIBRARYOBJECTS = $(COLSERVROBJECTS) \ … … 212 215 queryinfo.o: ../../lib/text_t.h 213 216 collectserver.o: collectserver.h ../../lib/gsdlconf.h ../../lib/site.h 214 collectserver.o: ../../lib/text_t.h comtypes.h maptools.h217 collectserver.o: ../../lib/text_t.h comtypes.h filter.h source.h 215 218 colservrconfig.o: colservrconfig.h ../../lib/gsdlconf.h ../../lib/site.h 216 colservrconfig.o: ../../lib/text_t.h collectserver.h comtypes.h maptools.h217 colservrconfig.o: ../../lib/fileutil.h ../../lib/cfgread.h219 colservrconfig.o: ../../lib/text_t.h collectserver.h comtypes.h filter.h 220 colservrconfig.o: source.h ../../lib/fileutil.h ../../lib/cfgread.h 218 221 maptools.o: maptools.h ../../lib/gsdlconf.h ../../lib/site.h 219 222 maptools.o: ../../lib/text_t.h 220 223 filter.o: filter.h ../../lib/gsdlconf.h ../../lib/site.h ../../lib/text_t.h 221 filter.o: comtypes.h 224 filter.o: comtypes.h ../../lib/fileutil.h 222 225 source.o: source.h ../../lib/gsdlconf.h ../../lib/site.h ../../lib/text_t.h 223 226 source.o: comtypes.h 227 browsefilter.o: browsefilter.h ../../lib/gsdlconf.h ../../lib/site.h 228 browsefilter.o: ../../lib/text_t.h comtypes.h filter.h infodbclass.h 229 browsefilter.o: ../../lib/fileutil.h 230 queryfilter.o: queryfilter.h ../../lib/gsdlconf.h ../../lib/site.h 231 queryfilter.o: ../../lib/text_t.h comtypes.h filter.h infodbclass.h 232 queryfilter.o: maptools.h ../../lib/fileutil.h 224 233 nullproto.o: nullproto.h ../../lib/gsdlconf.h ../../lib/site.h 225 nullproto.o: collectserver.h ../../lib/text_t.h comtypes.h maptools.h234 nullproto.o: collectserver.h ../../lib/text_t.h comtypes.h filter.h source.h 226 235 nullproto.o: recptproto.h colservrconfig.h 227 236 librarymain.o: receptionist.h ../../lib/gsdlconf.h ../../lib/site.h 228 237 librarymain.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h action.h 229 238 librarymain.o: recptproto.h comtypes.h converter.h ../../lib/gsdlunicode.h 230 librarymain.o: cgiwrapper.h nullproto.h collectserver.h maptools.h 239 librarymain.o: cgiwrapper.h nullproto.h collectserver.h filter.h source.h 240 librarymain.o: browsefilter.h infodbclass.h queryfilter.h maptools.h -
trunk/gsdl/src/recpt/comtypes.cpp
r220 r226 12 12 /* 13 13 $Log$ 14 Revision 1.6 1999/04/06 22:20:34 rjmcnab 15 Got browsefilter working. 16 14 17 Revision 1.5 1999/03/31 23:44:47 rjmcnab 15 18 Altered the protocol so that the metadata is part of the filter. … … 39 42 else if (err == authenticationFailure) return "authentication failure"; 40 43 else if (err == protocolError) return "protocol error"; 44 else if (err == configurationError) return "configuration error"; 41 45 else if (err == systemProblem) return "system problem"; 42 46 … … 94 98 95 99 void FilterOption_t::check_defaultValue () { 96 if (validValues.empty()) { 97 // nothing to check against 98 defaultValue.clear(); 99 return; 100 text_tarray::iterator here, end; 101 102 // how the default is interpreted depends on the option type 103 switch (type) { 104 case booleant: 105 case enumeratedt: // has to be one of the validValues 106 here = validValues.begin (); 107 end = validValues.end (); 108 while (here != end) { 109 if (*here == defaultValue) return; 110 here++; 111 } 112 113 break; 114 115 case integert: // has to be in the validValues range 116 if ((validValues.size() >= 2) && 117 (validValues[0].getint() <= defaultValue.getint()) && 118 (validValues[1].getint() >= defaultValue.getint())) 119 return; 120 break; 121 122 case stringt: // any value is valid 123 return; 100 124 } 101 125 102 text_tarray::iterator here = validValues.begin (); 103 text_tarray::iterator end = validValues.end (); 104 while (here != end) { 105 if (*here == defaultValue) { 106 // found the default value in the list of valid values 107 // now there is nothing more to do 108 return; 109 } 110 111 here++; 112 } 113 114 // did not find the defaultValue, set it to be the 115 // first option in the list 116 defaultValue = validValues[0]; 126 // did not find the defaultValue 127 if (validValues.empty()) defaultValue.clear(); 128 else defaultValue = validValues[0]; 117 129 } 118 130 -
trunk/gsdl/src/recpt/comtypes.h
r220 r226 32 32 33 33 34 enum comerror_t {noError, authenticationFailure, protocolError, systemProblem}; 34 enum comerror_t {noError, authenticationFailure, protocolError, 35 configurationError, systemProblem}; 35 36 text_t get_comerror_string (comerror_t err); 36 37 … … 203 204 text_t filterName; 204 205 OptionValue_tarray filterOptions; 205 text_t array docSet; // contains ""if not used206 text_tset docSet; // empty if not used 206 207 int filterResultOptions; // use the FR* defines above 207 208 -
trunk/gsdl/src/recpt/librarymain.cpp
r189 r226 12 12 /* 13 13 $Log$ 14 Revision 1.3 1999/04/06 22:20:35 rjmcnab 15 Got browsefilter working. 16 14 17 Revision 1.2 1999/03/05 03:53:54 sjboddie 15 18 … … 27 30 #include "nullproto.h" 28 31 #include "collectserver.h" 32 #include "filter.h" 33 #include "browsefilter.h" 34 #include "queryfilter.h" 35 #include "infodbclass.h" 36 #include "mgsearch.h" 29 37 #include <assert.h> 30 38 … … 35 43 // add a collection server for each collection ... (not implemented yet) 36 44 collectserver cserver; 45 gdbmclass gdbmhandler; 46 mgsearchclass mgsearch; 47 48 // add a null filter 49 filterclass filter; 50 cserver.add_filter (&filter); 51 52 // add a browse filter 53 browsefilterclass browsefilter; 54 browsefilter.set_gdbmptr (&gdbmhandler); 55 cserver.add_filter (&browsefilter); 56 57 // add a query filter 58 queryfilterclass queryfilter; 59 queryfilter.set_gdbmptr (&gdbmhandler); 60 queryfilter.set_mgsearchptr (&mgsearch); 61 cserver.add_filter (&queryfilter); 62 63 // inform collection server and everything it contains about its 64 // collection name 37 65 cserver.configure ("collection", "gberg"); 66 38 67 nproto.add_collectserver (&cserver); 39 68 … … 41 70 recpt.add_protocol (&nproto); 42 71 43 cgiwrapper (recpt, " gberg");72 cgiwrapper (recpt, "cnrub"); 44 73 return 0; 45 74 } -
trunk/gsdl/src/recpt/statusaction.cpp
r220 r226 12 12 /* 13 13 $Log$ 14 Revision 1.12 1999/04/06 22:20:35 rjmcnab 15 Got browsefilter working. 16 14 17 Revision 1.11 1999/03/31 23:44:49 rjmcnab 15 18 Altered the protocol so that the metadata is part of the filter. … … 470 473 } 471 474 472 /* textout << outconvert << "<hr>\n" 473 << "<h3>Metadata options</h3>\n";474 475 MetadataInfoResponse_t metainfo;476 rproto->get_ metadataoptions (arg_c, metainfo, err, logout);475 476 InfoFiltersResponse_t filterinfo; 477 InfoFilterOptionsRequest_t filteroptions_request; 478 InfoFilterOptionsResponse_t filteroptions; 479 rproto->get_filterinfo (arg_c, filterinfo, err, logout); 477 480 if (err == noError) { 478 textout << outconvert 479 << "<table>\n" 480 << "<tr><th>supported fields</th><td>"; 481 text_tset::iterator sup_here = metainfo.supportedFields.begin(); 482 text_tset::iterator sup_end = metainfo.supportedFields.end(); 483 bool sup_first = true; 484 while (sup_here != sup_end) { 485 if (!sup_first) textout << outconvert << ", "; 486 sup_first = false; 487 textout << outconvert << "\"" << *sup_here << "\""; 488 sup_here++; 489 } 490 textout << outconvert << "</td></tr>\n" 491 492 << "<tr><th>supported languages</th><td>"; 493 sup_here = metainfo.supportedLanguages.begin(); 494 sup_end = metainfo.supportedLanguages.end(); 495 sup_first = true; 496 while (sup_here != sup_end) { 497 if (!sup_first) textout << outconvert << ", "; 498 sup_first = false; 499 textout << outconvert << "\"" << *sup_here << "\""; 500 sup_here++; 501 } 502 textout << outconvert << "</td></tr>\n" 503 << "</table>\n"; 504 505 } else { 506 textout << outconvert << "Error (" << get_comerror_string (err) 507 << ") while getting metadata information\n"; 508 } 509 */ 510 textout << outconvert << "<hr>\n"; 511 /* // this needs some work 512 InfoFilterOptionsResponse_t filterinfo; 513 rproto->get_filteroptions (arg_c, filterinfo, err, logout); 514 if (err == noError) { 515 FilterDescript_tmap::iterator filter_here = 516 filterinfo.filterOptions.begin(); 517 FilterDescript_tmap::iterator filter_end = 518 filterinfo.filterOptions.end(); 519 while (filter_here != filter_end) { 481 text_tset::iterator filternames_here = filterinfo.filterNames.begin(); 482 text_tset::iterator filternames_end = filterinfo.filterNames.end(); 483 while (filternames_here != filternames_end) { 520 484 textout << outconvert 521 << "<h3>Filter options for \"" << (*filter_here).first << "\"</h3>\n" 485 << "<hr>\n" 486 << "<h3>Filter options for \"" << (*filternames_here) << "\"</h3>\n" 522 487 << "<table>\n" 523 488 << "<tr><th>option name</th><th>type</th><th>repeatable</th>" 524 489 << "<th>default value</th><th>valid values</th></tr>\n"; 525 490 526 FilterOption_tmap::iterator filteropt_here = 527 (*filter_here).second.filterOptions.begin(); 528 FilterOption_tmap::iterator filteropt_end = 529 (*filter_here).second.filterOptions.end(); 530 while (filteropt_here != filteropt_end) { 491 filteroptions_request.clear(); 492 filteroptions_request.filterName = *filternames_here; 493 rproto->get_filteroptions (arg_c, filteroptions_request, 494 filteroptions, err, logout); 495 if (err == noError) { 496 FilterOption_tmap::iterator filteropt_here = 497 filteroptions.filterOptions.begin(); 498 FilterOption_tmap::iterator filteropt_end = 499 filteroptions.filterOptions.end(); 500 while (filteropt_here != filteropt_end) { 501 textout << outconvert 502 << "<tr><td>\"" 503 << (*filteropt_here).second.name 504 << "\"</td>\n" 505 506 << "<td>"; 507 text_t type_string; 508 switch ((*filteropt_here).second.type) { 509 case FilterOption_t::booleant: type_string = "boolean"; break; 510 case FilterOption_t::integert: type_string = "integer"; break; 511 case FilterOption_t::enumeratedt: type_string = "enumerated"; break; 512 case FilterOption_t::stringt: type_string = "string"; break; 513 } 514 textout << outconvert 515 << type_string 516 << "</td>\n" 517 518 << "<td>"; 519 text_t repeat_string; 520 switch ((*filteropt_here).second.repeatable) { 521 case FilterOption_t::onePerQuery: repeat_string = "one per query"; break; 522 case FilterOption_t::onePerTerm: repeat_string = "one per term"; break; 523 case FilterOption_t::nPerTerm: repeat_string = "n per term"; break; 524 } 525 textout << outconvert 526 << repeat_string 527 << "</td>\n" 528 529 << "<td>\"" 530 << (*filteropt_here).second.defaultValue 531 << "\"</td>\n" 532 533 << "<td>"; 534 535 text_tarray::iterator valid_here = 536 (*filteropt_here).second.validValues.begin(); 537 text_tarray::iterator valid_end = 538 (*filteropt_here).second.validValues.end(); 539 bool valid_first = true; 540 while (valid_here != valid_end) { 541 if (!valid_first) textout << outconvert << ", "; 542 valid_first = false; 543 textout << outconvert << "\"" << *valid_here << "\""; 544 valid_here++; 545 } 546 textout << outconvert 547 << "</td></tr>\n"; 548 549 filteropt_here++; 550 } 551 531 552 textout << outconvert 532 << "<tr><td>\"" 533 << (*filteropt_here).second.name 534 << "\"</td>\n" 535 536 << "<td>"; 537 text_t type_string; 538 switch ((*filteropt_here).second.type) { 539 case FilterOption_t::booleant: type_string = "boolean"; break; 540 case FilterOption_t::integert: type_string = "integer"; break; 541 case FilterOption_t::enumeratedt: type_string = "enumerated"; break; 542 case FilterOption_t::stringt: type_string = "string"; break; 543 } 544 textout << outconvert 545 << type_string 546 << "</td>\n" 547 548 << "<td>"; 549 text_t repeat_string; 550 switch ((*filteropt_here).second.repeatable) { 551 case FilterOption_t::onePerQuery: repeat_string = "one per query"; break; 552 case FilterOption_t::onePerTerm: repeat_string = "one per term"; break; 553 case FilterOption_t::nPerTerm: repeat_string = "n per term"; break; 554 } 555 textout << outconvert 556 << repeat_string 557 << "</td>\n" 558 559 << "<td>\"" 560 << (*filteropt_here).second.defaultValue 561 << "\"</td>\n" 562 563 << "<td>"; 564 565 text_tarray::iterator valid_here = 566 (*filteropt_here).second.validValues.begin(); 567 text_tarray::iterator valid_end = 568 (*filteropt_here).second.validValues.end(); 569 bool valid_first = true; 570 while (valid_here != valid_end) { 571 if (!valid_first) textout << outconvert << ", "; 572 valid_first = false; 573 textout << outconvert << "\"" << *valid_here << "\""; 574 valid_here++; 575 } 576 textout << outconvert 577 << "</td></tr>\n"; 578 579 filteropt_here++; 553 << "</table>\n"; 554 555 } else { 556 textout << outconvert << "Error (" << get_comerror_string (err) 557 << ") while getting filter option information\n"; 580 558 } 581 559 582 textout << outconvert 583 << "</table>\n"; 584 585 filter_here++; 560 filternames_here++; 586 561 } 587 562 588 563 } else { 589 564 textout << outconvert << "Error (" << get_comerror_string (err) 590 << ") while getting filter option information\n"; 591 } 592 */ 565 << ") while getting filter information\n"; 566 } 593 567 } 594 568
Note:
See TracChangeset
for help on using the changeset viewer.