[15425] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * z3950explain.cpp --
|
---|
| 4 | * Copyright (C) 2000 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 "z3950explain.h"
|
---|
| 27 |
|
---|
| 28 | void getExplainInfo(bend_search_rr *rr, FilterResponse_t &response, comerror_t &err)
|
---|
| 29 | {
|
---|
| 30 | text_t GSQuery = ZQueryToGSQuery(rr);
|
---|
| 31 | char *GSQuery_char = GSQuery.getcstr();
|
---|
| 32 |
|
---|
| 33 | int i;
|
---|
| 34 | if (strstr(GSQuery_char, "TargetInfo") != NULL) {
|
---|
| 35 | // should be one only
|
---|
| 36 | // real-life example:
|
---|
| 37 | /*
|
---|
| 38 | 62
|
---|
| 39 | explain-category targetInfo
|
---|
| 40 | date-of-info Sep 22, 1999
|
---|
| 41 | language eng
|
---|
| 42 | */
|
---|
| 43 | ResultDocInfo_t docinfo;
|
---|
| 44 | docinfo.metadata["explain-category"].values.push_back("TargetInfo");
|
---|
| 45 | docinfo.metadata["name"].values.push_back("Greenstone");
|
---|
| 46 | docinfo.metadata["namedResultSets"].values.push_back("false");
|
---|
| 47 | docinfo.metadata["multipleDBsearch"].values.push_back("true");
|
---|
| 48 | docinfo.metadata["language"].values.push_back("eng");
|
---|
| 49 | response.docInfo.push_back(docinfo);
|
---|
| 50 | response.numDocs++;
|
---|
| 51 | }
|
---|
| 52 | if (strstr(GSQuery_char, "DatabaseInfo") != NULL) {
|
---|
| 53 | // should be one per collection
|
---|
| 54 | // real-life example:
|
---|
| 55 | /*
|
---|
| 56 | 3
|
---|
| 57 | dbnum 0
|
---|
| 58 | explain-category DatabaseInfo
|
---|
| 59 | database-name.1 0
|
---|
| 60 | title Z39.50 EXPLAIN DB
|
---|
| 61 | database-name.2 ir-explain-1
|
---|
| 62 | date-of-info Sep 22, 1999
|
---|
| 63 | language eng
|
---|
| 64 | dbpath /usr/wald/z39.50root/explain
|
---|
| 65 | dbname explain
|
---|
| 66 | */
|
---|
| 67 | ResultDocInfo_t docinfo;
|
---|
| 68 | docinfo.metadata["explain-category"].values.push_back("DatabaseInfo");
|
---|
| 69 | docinfo.metadata["database-name"].values.push_back("IR-Explain-1");
|
---|
| 70 | docinfo.metadata["title"].values.push_back("Z39.50 EXPLAIN DB");
|
---|
| 71 | docinfo.metadata["language"].values.push_back("eng");
|
---|
| 72 | docinfo.metadata["dbname"].values.push_back("explain");
|
---|
| 73 | response.docInfo.push_back(docinfo);
|
---|
| 74 | response.numDocs++;
|
---|
| 75 | // now get the info for each collection
|
---|
| 76 | text_tarray collectlist;
|
---|
| 77 | Protocol->get_collection_list(collectlist, err, cerr);
|
---|
| 78 | text_tarray::iterator COLHERE = collectlist.begin();
|
---|
| 79 | text_tarray::iterator COLEND = collectlist.end();
|
---|
| 80 | while (COLHERE != COLEND) {
|
---|
| 81 | // don't include information for non-active collections
|
---|
| 82 | bool collection_active;
|
---|
| 83 | Protocol->ping(*COLHERE, collection_active, err, cerr);
|
---|
| 84 | if (collection_active != true) {
|
---|
| 85 | COLHERE++;
|
---|
| 86 | continue;
|
---|
| 87 | }
|
---|
| 88 | ColInfoResponse_t collectinfo;
|
---|
| 89 | Protocol->get_collectinfo(*COLHERE, collectinfo, err, cerr);
|
---|
| 90 | docinfo.clear();
|
---|
| 91 | docinfo.metadata["name"].values.push_back(collectinfo.shortInfo.name);
|
---|
| 92 | docinfo.metadata["host"].values.push_back(collectinfo.shortInfo.host);
|
---|
| 93 | if (collectinfo.isPublic) {
|
---|
| 94 | docinfo.metadata["isPublic"].values.push_back("true");
|
---|
| 95 | } else {
|
---|
| 96 | docinfo.metadata["isPublic"].values.push_back("false");
|
---|
| 97 | }
|
---|
| 98 | if (collectinfo.isBeta) {
|
---|
| 99 | docinfo.metadata["isBeta"].values.push_back("true");
|
---|
| 100 | } else {
|
---|
| 101 | docinfo.metadata["isBeta"].values.push_back("false");
|
---|
| 102 | }
|
---|
| 103 | if (collectinfo.useBook == true) {
|
---|
| 104 | docinfo.metadata["useBook"].values.push_back("true");
|
---|
| 105 | } else {
|
---|
| 106 | docinfo.metadata["useBook"].values.push_back("false");
|
---|
| 107 | }
|
---|
| 108 | docinfo.metadata["buildDate"].values.push_back(collectinfo.buildDate);
|
---|
| 109 | text_tarray::iterator TEXTT_HERE = collectinfo.ccsCols.begin();
|
---|
| 110 | text_tarray::iterator TEXTT_END = collectinfo.ccsCols.end();
|
---|
| 111 | for (i = 1; TEXTT_HERE != TEXTT_END; i++, TEXTT_HERE++) {
|
---|
| 112 | text_t tmp = "ccsCols.";
|
---|
| 113 | tmp.appendint(i);
|
---|
| 114 | docinfo.metadata[tmp].values.push_back(*TEXTT_HERE);
|
---|
| 115 | }
|
---|
| 116 | TEXTT_HERE = collectinfo.languages.begin();
|
---|
| 117 | TEXTT_END = collectinfo.languages.end();
|
---|
| 118 | for (i = 1; TEXTT_HERE != TEXTT_END; i++, TEXTT_HERE++) {
|
---|
| 119 | text_t tmp = "languages.";
|
---|
| 120 | tmp.appendint(i);
|
---|
| 121 | docinfo.metadata[tmp].values.push_back(*TEXTT_HERE);
|
---|
| 122 | }
|
---|
| 123 | docinfo.metadata["numDocs"].values.push_back(collectinfo.numDocs);
|
---|
| 124 | docinfo.metadata["numSections"].values.push_back(collectinfo.numSections);
|
---|
| 125 | docinfo.metadata["numWords"].values.push_back(collectinfo.numWords);
|
---|
| 126 | docinfo.metadata["numBytes"].values.push_back(collectinfo.numBytes);
|
---|
| 127 |
|
---|
| 128 | collectionmeta_map::iterator COLLMETA_MAP_HERE = collectinfo.collectionmeta.begin();
|
---|
| 129 | collectionmeta_map::iterator COLLMETA_MAP_END = collectinfo.collectionmeta.end();
|
---|
| 130 | for (i = 1; COLLMETA_MAP_HERE != COLLMETA_MAP_END; i++, COLLMETA_MAP_HERE++) {
|
---|
| 131 | text_t tmp = "collectionmeta.";
|
---|
| 132 | tmp.appendint(i);
|
---|
| 133 | text_t tmp2 = COLLMETA_MAP_HERE->first;
|
---|
| 134 | tmp2.appendcstr(" -> ");
|
---|
| 135 | tmp2.append(COLLMETA_MAP_HERE->second[g_EmptyText]);
|
---|
| 136 | docinfo.metadata[tmp].values.push_back(tmp2);
|
---|
| 137 | }
|
---|
| 138 | text_tmap::iterator TEXTT_MAP_HERE;
|
---|
| 139 | text_tmap::iterator TEXTT_MAP_END;
|
---|
| 140 | // uncomment if you want to include this in the explain record,
|
---|
| 141 | // it's a bit messy to include by default
|
---|
| 142 | /*
|
---|
| 143 | TEXTT_MAP_HERE = collectinfo.format.begin();
|
---|
| 144 | TEXTT_MAP_END = collectinfo.format.end();
|
---|
| 145 | for (i = 1; TEXTT_MAP_HERE != TEXTT_MAP_END; i++, TEXTT_MAP_HERE++) {
|
---|
| 146 | text_t tmp = "format.";
|
---|
| 147 | tmp.appendint(i);
|
---|
| 148 | text_t tmp2 = TEXTT_MAP_HERE->first;
|
---|
| 149 | tmp2.appendcstr(" -> ");
|
---|
| 150 | tmp2.append(TEXTT_MAP_HERE->second);
|
---|
| 151 | docinfo.metadata[tmp].values.push_back(tmp2);
|
---|
| 152 | }
|
---|
| 153 | */
|
---|
| 154 | TEXTT_MAP_HERE = collectinfo.building.begin();
|
---|
| 155 | TEXTT_MAP_END = collectinfo.building.end();
|
---|
| 156 | for (i = 1; TEXTT_MAP_HERE != TEXTT_MAP_END; i++, TEXTT_MAP_HERE++) {
|
---|
| 157 | text_t tmp = "building.";
|
---|
| 158 | tmp.appendint(i);
|
---|
| 159 | text_t tmp2 = TEXTT_MAP_HERE->first;
|
---|
| 160 | tmp2.appendcstr(" -> ");
|
---|
| 161 | tmp2.append(TEXTT_MAP_HERE->second);
|
---|
| 162 | docinfo.metadata[tmp].values.push_back(tmp2);
|
---|
| 163 | }
|
---|
| 164 | docinfo.metadata["receptionist"].values.push_back(collectinfo.receptionist);
|
---|
| 165 | docinfo.metadata["buildType"].values.push_back(collectinfo.buildType);
|
---|
| 166 | response.docInfo.push_back(docinfo);
|
---|
| 167 | response.numDocs++;
|
---|
| 168 | COLHERE++;
|
---|
| 169 | }
|
---|
| 170 | }
|
---|
| 171 | if (strstr(GSQuery_char, "SchemaInfo") != NULL) {
|
---|
| 172 | // should be one per collection
|
---|
| 173 | // real-life example:
|
---|
| 174 | /*
|
---|
| 175 | 10
|
---|
| 176 | dbnum 1
|
---|
| 177 | explain-category schemaInfo
|
---|
| 178 | database-name.1 1
|
---|
| 179 | database-name.2 books
|
---|
| 180 | database-name.3 default
|
---|
| 181 | database-name.4 cat
|
---|
| 182 | date-of-info Sep 22, 1999
|
---|
| 183 | language eng
|
---|
| 184 | schema.1 1.2.840.10003.13.1000.3.1
|
---|
| 185 | dbpath /usr/wald/z39.50root/books
|
---|
| 186 | dbname books
|
---|
| 187 | */
|
---|
| 188 | }
|
---|
| 189 | if (strstr(GSQuery_char, "AttributeSetInfo") != NULL) {
|
---|
| 190 | // should be one per collection
|
---|
| 191 | // real-life example:
|
---|
| 192 | /*
|
---|
| 193 | 9
|
---|
| 194 | dbnum 1
|
---|
| 195 | explain-category AttributeSetInfo
|
---|
| 196 | database-name.1 1
|
---|
| 197 | database-name.2 books
|
---|
| 198 | database-name.3 default
|
---|
| 199 | database-name.4 cat
|
---|
| 200 | date-of-info Sep 22, 1999
|
---|
| 201 | language eng
|
---|
| 202 | attribute-set.1 1.2.840.10003.13.1000.3.1
|
---|
| 203 | dbpath /usr/wald/z39.50root/books
|
---|
| 204 | dbname books
|
---|
| 205 | */
|
---|
| 206 | }
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 |
|
---|