Changeset 249
- Timestamp:
- 1999-04-30T14:00:48+12:00 (25 years ago)
- Location:
- trunk/gsdl/src/colservr
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/colservr/browsefilter.cpp
r238 r249 12 12 /* 13 13 $Log$ 14 Revision 1.3 1999/04/30 02:00:45 sjboddie 15 lots of stuff to do with getting documentaction working 16 14 17 Revision 1.2 1999/04/19 23:56:05 rjmcnab 15 18 Finished the gdbm metadata stuff … … 151 154 // replace " with the parent node name and split the contains string 152 155 // into the result set 153 text_t setresultset;156 text_tarray resultset; 154 157 text_t tmptext; 155 158 text_t &contains = info["contains"]; … … 159 162 if (*contains_here == '"') tmptext += parentnode; 160 163 else if (*contains_here == ';') { 161 if (!tmptext.empty()) resultset. insert(tmptext);164 if (!tmptext.empty()) resultset.push_back (tmptext); 162 165 tmptext.clear(); 163 166 } else tmptext.push_back(*contains_here); … … 166 169 } 167 170 // insert the last result in the set 168 if (!tmptext.empty()) resultset. insert(tmptext);171 if (!tmptext.empty()) resultset.push_back (tmptext); 169 172 170 173 // do an intersection with the input set … … 177 180 int resultnum = 1; 178 181 ResultDocInfo_t resultdoc; 179 text_t set::iterator result_here = resultset.begin();180 text_t set::iterator result_end = resultset.end();182 text_tarray::iterator result_here = resultset.begin(); 183 text_tarray::iterator result_end = resultset.end(); 181 184 182 185 while (result_here != result_end) { -
trunk/gsdl/src/colservr/collectserver.cpp
r226 r249 13 13 /* 14 14 $Log$ 15 Revision 1.7 1999/04/30 02:00:45 sjboddie 16 lots of stuff to do with getting documentaction working 17 15 18 Revision 1.6 1999/04/06 22:20:29 rjmcnab 16 19 Got browsefilter working. … … 38 41 39 42 #include "collectserver.h" 43 #include "infodbclass.h" 44 #include "OIDtools.h" 40 45 #include <assert.h> 41 46 … … 168 173 } 169 174 170 void collectserver::filter ( constFilterRequest_t &request,175 void collectserver::filter (FilterRequest_t &request, 171 176 FilterResponse_t &response, 172 177 comerror_t &err, ostream &logout) { 173 178 outconvertclass text_t2ascii; 179 180 // translate any ".fc", ".pr" etc. stuff in the docSet 181 text_t translatedOID; 182 text_tset translatedOIDs; 183 text_tset::iterator doc_here = request.docSet.begin(); 184 text_tset::iterator doc_end = request.docSet.end(); 185 while (doc_here != doc_end) { 186 if (needs_translating (*doc_here)) { 187 sourcelistclass::iterator source_here = sources.begin(); 188 sourcelistclass::iterator source_end = sources.end(); 189 while (source_here != source_end) { 190 assert ((*source_here).s != NULL); 191 if (((*source_here).s != NULL) && 192 ((*source_here).s->translate_OID (*doc_here, translatedOID, err, logout))) { 193 if (err != noError) return; 194 break; 195 } 196 source_here++; 197 } 198 translatedOIDs.insert (translatedOID); 199 } else { 200 translatedOIDs.insert (*doc_here); 201 } 202 doc_here ++; 203 } 204 request.docSet = translatedOIDs; 174 205 175 206 response.clear(); -
trunk/gsdl/src/colservr/collectserver.h
r226 r249 94 94 comerror_t &err, ostream &logout); 95 95 96 virtual void filter ( constFilterRequest_t &request,96 virtual void filter (FilterRequest_t &request, 97 97 FilterResponse_t &response, 98 98 comerror_t &err, ostream &logout); -
trunk/gsdl/src/colservr/filter.cpp
r235 r249 12 12 /* 13 13 $Log$ 14 Revision 1.5 1999/04/30 02:00:46 sjboddie 15 lots of stuff to do with getting documentaction working 16 14 17 Revision 1.4 1999/04/12 03:45:02 rjmcnab 15 18 Finished the query filter. … … 224 227 } 225 228 229 void intersect (text_tarray &set1, const text_tset &set2) { 230 text_tarray resultset; 231 232 text_tarray::const_iterator set1_here = set1.begin(); 233 text_tarray::const_iterator set1_end = set1.end(); 234 235 while (set1_here != set1_end) { 236 if (in_set (set2, *set1_here)) 237 resultset.push_back (*set1_here); 238 set1_here ++; 239 } 240 set1 = resultset; 241 } 242 226 243 227 244 // tests to see if el is in set -
trunk/gsdl/src/colservr/filter.h
r235 r249 112 112 // intersect places the result in set1 113 113 void intersect (text_tset &set1, const text_tset &set2); 114 void intersect (text_tarray &set1, const text_tset &set2); 114 115 115 116 // tests to see if el is in set -
trunk/gsdl/src/colservr/infodbclass.cpp
r226 r249 12 12 /* 13 13 $Log$ 14 Revision 1.3 1999/04/30 02:00:46 sjboddie 15 lots of stuff to do with getting documentaction working 16 14 17 Revision 1.2 1999/04/06 22:20:31 rjmcnab 15 18 Got browsefilter working. … … 25 28 #include "gsdlunicode.h" 26 29 #include "fileutil.h" 27 30 #include "OIDtools.h" 28 31 29 32 // constructors … … 91 94 gdbmfile = NULL; 92 95 openfile.clear(); 96 } 97 98 // replaces the .fc, .lc, .pr, .ns and .ps syntax (first child, 99 // last child, parent, next sibling, previous sibling) 100 // it expects child, parent, etc. to exist if syntax has been used 101 // so you should test before using 102 text_t gdbmclass::translate_OID (const text_t &inOID, infodbclass &info) { 103 104 if (inOID.empty() || inOID.size() < 4) return inOID; 105 if (findchar (inOID.begin(), inOID.end(), '.') == inOID.end()) return inOID; 106 107 text_t OID = inOID; 108 text_tarray tailarray; 109 text_t tail = substr (OID.end()-3, OID.end()); 110 while (tail == ".fc" || tail == ".lc" || tail == ".pr" || 111 tail == ".ns" || tail == ".ps") { 112 tailarray.push_back(tail); 113 OID.erase (OID.end()-3, OID.end()); 114 tail = substr (OID.end()-3, OID.end()); 115 } 116 117 if (!tailarray.size()) return inOID; 118 text_tarray::const_iterator begin = tailarray.begin(); 119 text_tarray::const_iterator here = tailarray.end() - 1; 120 121 while (here >= begin) { 122 123 if (*here == ".fc") 124 get_first_child (OID, info); 125 else if (*here == ".lc") 126 get_last_child (OID, info); 127 else if (*here == ".pr") 128 OID = get_parent (OID); 129 else if (*here == ".ns") 130 get_next_sibling (OID, info); 131 else if (*here == ".ps") 132 get_previous_sibling (OID, info); 133 134 here --; 135 } 136 return OID; 137 } 138 139 void gdbmclass::get_first_child (text_t &OID, infodbclass &info) { 140 141 text_t firstchild; 142 if (getinfo (OID, info)) { 143 text_t &contains = info["contains"]; 144 if (!contains.empty()) { 145 text_t parent = OID; 146 getdelimitstr (contains.begin(), contains.end(), ';', firstchild); 147 if (firstchild.empty()) OID = contains; 148 else OID = firstchild; 149 if (*(OID.begin()) == '"') translate_parent (OID, parent); 150 } 151 } 152 } 153 154 void gdbmclass::get_last_child (text_t &OID, infodbclass &info) { 155 156 text_tarray children; 157 if (getinfo (OID, info)) { 158 text_t &contains = info["contains"]; 159 if (!contains.empty()) { 160 text_t parent = OID; 161 splitchar (contains.begin(), contains.end(), ';', children); 162 OID = children.back(); 163 if (*(OID.begin()) == '"') translate_parent (OID, parent); 164 } 165 } 166 } 167 168 void gdbmclass::get_next_sibling (text_t &OID, infodbclass &info) { 169 170 text_tarray siblings; 171 text_t parent = get_parent (OID); 172 173 if (getinfo (parent, info)) { 174 text_t &contains = info["contains"]; 175 if (!contains.empty()) { 176 splitchar (contains.begin(), contains.end(), ';', siblings); 177 text_tarray::const_iterator here = siblings.begin(); 178 text_tarray::const_iterator end = siblings.end(); 179 text_t shrunk_OID = OID; 180 shrink_parent (shrunk_OID); 181 while (here != end) { 182 if (*here == shrunk_OID && (here+1 != end)) { 183 OID = *(here+1); 184 if (*(OID.begin()) == '"') translate_parent (OID, parent); 185 break; 186 } 187 here ++; 188 } 189 } 190 } 191 } 192 193 void gdbmclass::get_previous_sibling (text_t &OID, infodbclass &info) { 194 195 text_tarray siblings; 196 text_t parent = get_parent (OID); 197 198 if (getinfo (parent, info)) { 199 text_t &contains = info["contains"]; 200 if (!contains.empty()) { 201 splitchar (contains.begin(), contains.end(), ';', siblings); 202 text_tarray::const_iterator here = siblings.begin(); 203 text_tarray::const_iterator end = siblings.end(); 204 text_t shrunk_OID = OID; 205 shrink_parent (shrunk_OID); 206 while (here != end) { 207 if (*here == shrunk_OID && (here != siblings.begin())) { 208 OID = *(here-1); 209 if (*(OID.begin()) == '"') translate_parent (OID, parent); 210 break; 211 } 212 here ++; 213 } 214 } 215 } 93 216 } 94 217 -
trunk/gsdl/src/colservr/infodbclass.h
r226 r249 87 87 void closedatabase (); 88 88 89 // replaces the .c, .p, .n, .l syntax (child, parent, next, previous) 90 // it expects child, parent, etc. to exist if syntax has been used 91 // so you should test before using 92 text_t translate_OID (const text_t &OID, infodbclass &info); 93 89 94 // returns true on success 90 95 bool getinfo (text_t key, infodbclass &info); … … 98 103 GDBM_FILE gdbmfile; 99 104 ostream *logout; 100 105 106 void get_first_child (text_t &OID, infodbclass &info); 107 void get_last_child (text_t &OID, infodbclass &info); 108 void get_next_sibling (text_t &OID, infodbclass &info); 109 void get_previous_sibling (text_t &OID, infodbclass &info); 110 101 111 // returns true on success 102 112 bool getkeydata (text_t key, text_t &data); -
trunk/gsdl/src/colservr/mggdbmsource.cpp
r243 r249 12 12 /* 13 13 $Log$ 14 Revision 1.7 1999/04/30 02:00:47 sjboddie 15 lots of stuff to do with getting documentaction working 16 14 17 Revision 1.6 1999/04/21 22:40:44 sjboddie 15 18 made another change to the one I just committed. if requested metadata doesn't … … 38 41 #include "mggdbmsource.h" 39 42 #include "fileutil.h" 40 43 #include "OIDtools.h" 41 44 42 45 … … 86 89 } 87 90 88 bool mggdbmsourceclass::get_metadata (const text_t &/*requestParams*/, const text_t &/*refParams*/, 89 const text_tarray &fields, const text_t &OID, 90 MetadataInfo_tarray &metadata, 91 comerror_t &err, ostream &logout) { 91 bool mggdbmsourceclass::translate_OID (const text_t &OIDin, text_t &OIDout, 92 comerror_t &err, ostream &logout) { 93 92 94 outconvertclass text_t2ascii; 93 94 metadata.erase(metadata.begin(), metadata.end());95 95 96 96 err = noError; … … 115 115 } 116 116 117 infodbclass info; 118 OIDout = gdbmptr->translate_OID (OIDin, info); 119 return true; 120 } 121 122 bool mggdbmsourceclass::get_metadata (const text_t &/*requestParams*/, const text_t &/*refParams*/, 123 const text_tarray &fields, const text_t &OID, 124 MetadataInfo_tarray &metadata, 125 comerror_t &err, ostream &logout) { 126 outconvertclass text_t2ascii; 127 128 metadata.erase(metadata.begin(), metadata.end()); 129 130 err = noError; 131 if (gdbmptr == NULL) { 132 // most likely a configuration problem 133 logout << text_t2ascii 134 << "configuration error: mggdbmsource contains a null gdbmclass\n\n"; 135 err = configurationError; 136 return true; 137 } 138 139 // open the database 140 gdbmptr->setlogout(&logout); 141 if (!gdbmptr->opendatabase (gdbm_filename)) { 142 // most likely a system problem (we have already checked that the 143 // gdbm database exists) 144 logout << text_t2ascii 145 << "system problem: open on gdbm database \"" 146 << gdbm_filename << "\" failed\n\n"; 147 err = systemProblem; 148 return true; 149 } 150 117 151 // get the metadata 118 152 infodbclass info; … … 126 160 127 161 // collect together the metadata 162 bool donenextprevtest = false; 163 bool hasnext, hasprevious; 128 164 MetadataInfo_t this_metadata; 129 165 text_t *pos_metadata; … … 134 170 this_metadata.isRef = false; 135 171 pos_metadata = info.getinfo(*fields_here); 136 if (pos_metadata != NULL && *fields_here != "contains") 172 173 if ((*fields_here == "hasnext" || *fields_here == "hasprevious")) { 174 175 // collect metadata 176 if (!donenextprevtest) { 177 donenextprevtest = true; 178 179 // cache parent contents array 180 text_t thisparent = get_parent (OID); 181 if (thisparent != parentOID) { 182 parentOID = thisparent; 183 parentcontents.erase(parentcontents.begin(), parentcontents.end()); 184 if (gdbmptr->getinfo(parentOID, parentinfo)) { 185 text_t &parentinfocontains = parentinfo["contains"]; 186 if (!parentinfocontains.empty()) 187 splitchar (parentinfocontains.begin(), parentinfocontains.end(), ';', parentcontents); 188 } 189 } 190 191 // do tests 192 text_tarray::const_iterator parentcontents_here = parentcontents.begin(); 193 text_tarray::const_iterator parentcontents_end = parentcontents.end(); 194 text_t shrunk_OID = OID; 195 shrink_parent (shrunk_OID); 196 while (parentcontents_here != parentcontents_end) { 197 if (*parentcontents_here == shrunk_OID) { 198 if (parentcontents_here == parentcontents.begin()) hasprevious = false; 199 else hasprevious = true; 200 201 parentcontents_here++; 202 203 if (parentcontents_here == parentcontents.end()) hasnext = false; 204 else hasnext = true; 205 206 break; 207 } 208 209 parentcontents_here ++; 210 } 211 } 212 213 // fill in metadata 214 if ((*fields_here == "hasnext" && hasnext) || 215 (*fields_here == "hasprevious" && hasprevious)) 216 this_metadata.values.push_back("1"); 217 else 218 this_metadata.values.push_back("0"); 219 220 } 221 else if (pos_metadata != NULL && *fields_here != "contains") 137 222 this_metadata.values.push_back(*pos_metadata); 138 223 else -
trunk/gsdl/src/colservr/mggdbmsource.h
r236 r249 29 29 text_t collectdir; 30 30 31 text_t parentOID; 32 infodbclass parentinfo; 33 text_tarray parentcontents; 34 31 35 text_t gdbm_filename; 32 36 gdbmclass *gdbmptr; … … 46 50 void configure (const text_t &key, const text_tarray &cfgline); 47 51 bool init (ostream &logout); 52 bool translate_OID (const text_t &OIDin, text_t &OIDout, 53 comerror_t &err, ostream &logout); 48 54 bool get_metadata (const text_t &requestParams, const text_t &refParams, 49 55 const text_tarray &fields, const text_t &OID, -
trunk/gsdl/src/colservr/source.cpp
r226 r249 12 12 /* 13 13 $Log$ 14 Revision 1.3 1999/04/30 02:00:48 sjboddie 15 lots of stuff to do with getting documentaction working 16 14 17 Revision 1.2 1999/04/06 22:20:32 rjmcnab 15 18 Got browsefilter working. … … 45 48 } 46 49 50 51 // translate_OID translates OIDs using ".pr", ."fc" etc. 52 bool sourceclass::translate_OID (const text_t &/*OIDin*/, text_t &/*OIDout*/, 53 comerror_t &err, ostream &/*logout*/) { 54 err = noError; 55 56 return false; 57 } 58 59 47 60 // get_metadata fills out the metadata if possible, if it is not responsable 48 61 // for the given OID then it will return false. -
trunk/gsdl/src/colservr/source.h
r226 r249 30 30 // before any other methods are called 31 31 virtual bool init (ostream &logout); 32 33 // translate_OID translates OIDs using ".pr", ."fc" etc. 34 virtual bool translate_OID (const text_t &OIDin, text_t &OIDout, 35 comerror_t &err, ostream &logout); 32 36 33 37 // get_metadata fills out the metadata if possible, if it is not responsable
Note:
See TracChangeset
for help on using the changeset viewer.