source: main/trunk/greenstone2/runtime-src/src/colservr/source.h@ 31387

Last change on this file since 31387 was 31387, checked in by ak19, 7 years ago

Round 1 of commits for getting OAI deletion policy to work with GS2 (server end). The perl code writing out the OAI db and the GS3 server code implementing the deletion policy had already been completed earlier (end 2016).

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1/**********************************************************************
2 *
3 * source.h --
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
27#ifndef SOURCE_H
28#define SOURCE_H
29
30#include "gsdlconf.h"
31#include "text_t.h"
32#include "dbclass.h"
33#include "search.h"
34#include "comtypes.h"
35#include "maptools.h"
36
37
38class sourceclass {
39protected:
40 text_t classname;
41
42 text_t gsdlhome;
43 text_t collecthome;
44 text_t dbhome;
45 text_t collection;
46 text_t collectdir;
47
48 stringmap indexmap;
49 stringmap subcollectionmap;
50 stringmap languagemap;
51
52 text_t defaultindex;
53 text_t defaultsubcollection;
54 text_t defaultlanguage;
55
56 text_t indexstem;
57
58 text_t parentOID;
59 infodbclass parentinfo;
60 text_tarray parentcontents;
61
62 text_t db_filename;
63 dbclass *db_ptr;
64 text_t oaidb_filename;
65 dbclass *oaidb_ptr;
66
67 searchclass *textsearchptr;
68
69public:
70 sourceclass ();
71 virtual ~sourceclass ();
72
73 // the DB ptrs remain the responsibility of the calling code
74 // but as the db_ptr is deleted by this source object, the oaidb_ptr will be deleted by this object too
75 void set_db_ptr (dbclass *db_ptr_arg) { db_ptr = db_ptr_arg; }
76 void set_oaidb_ptr (dbclass *oaidb_ptr_arg) { oaidb_ptr = oaidb_ptr_arg; }
77
78 // the textsearchptr remains the responsibility of the calling code
79 void set_textsearchptr (searchclass *textsearchptr_arg) { textsearchptr = textsearchptr_arg; }
80
81 // configure should be called once for each configuration line
82 virtual void configure (const text_t &key, const text_tarray &cfgline);
83
84 // init should be called after all the configuration is done but
85 // before any other methods are called
86 virtual bool init (ostream &logout);
87
88 // translate_OID translates OIDs using ".pr", ."fc" etc.
89 virtual bool translate_OID (const text_t &OIDin, text_t &OIDout,
90 comerror_t &err, ostream &logout);
91
92 // get_metadata fills out the metadata if possible.
93 // If it is not responsible for the given OID then it will return false.
94 virtual bool get_metadata (const text_t &requestParams, const text_t &refParams,
95 bool getParents, const text_tset &fields,
96 const text_t &OID, MetadataInfo_tmap &metadata,
97 comerror_t &err, ostream &logout, bool append);
98
99 // get_oai_metadata fills out the metadata from the oai_db if possible
100 // if it is not responsible for the given OID then it will return false.
101 virtual bool get_oai_metadata (const text_t &requestParams, const text_t &refParams,
102 bool getParents, const text_tset &fields,
103 const text_t &OID, text_t &deleted_status,
104 MetadataInfo_tmap &metadata, comerror_t &err, ostream &logout);
105
106 virtual bool get_document (const text_t &OID, text_t &doc,
107 comerror_t &err, ostream &logout);
108
109 virtual bool is_searchable(bool &issearchable, comerror_t &err, ostream &logout);
110
111 protected:
112 text_t resolve_db_filename(const text_t& idx,
113 const text_t& file_ext);
114 text_t resolve_oaidb_filename(const text_t& file_ext);
115 text_t getcollectionpath();
116
117};
118
119
120// The sourceptr class does not 'own' the source. The
121// source should be deleted by the code which created it.
122class sourceptr {
123public:
124 sourceclass *s;
125
126 sourceptr () {s=NULL;}
127 ~sourceptr () {}
128};
129
130bool operator==(const sourceptr &x, const sourceptr &y);
131bool operator<(const sourceptr &x, const sourceptr &y);
132
133typedef vector<sourceptr> sourceptrlist;
134
135// contains a list of sources
136class sourcelistclass {
137protected:
138 sourceptrlist sourceptrs;
139
140public:
141 // type support for sourcelistclass
142 typedef sourceptrlist::iterator iterator;
143 typedef sourceptrlist::const_iterator const_iterator;
144 typedef sourceptrlist::reference reference;
145 typedef sourceptrlist::const_reference const_reference;
146 typedef sourceptrlist::size_type size_type;
147
148 typedef sourceptrlist::difference_type difference_type;
149 typedef sourceptrlist::const_reverse_iterator const_reverse_iterator;
150 typedef sourceptrlist::reverse_iterator reverse_iterator;
151
152 // basic container support
153 iterator begin () {return sourceptrs.begin();}
154 const_iterator begin () const {return sourceptrs.begin();}
155 iterator end () {return sourceptrs.end();}
156 const_iterator end () const {return sourceptrs.end();}
157
158 void erase(iterator pos) {sourceptrs.erase(pos);}
159 void erase(iterator first, iterator last) {sourceptrs.erase(first, last);}
160 sourcelistclass &operator=(const sourcelistclass &x)
161 {sourceptrs=x.sourceptrs;return *this;}
162
163 bool empty () const {return sourceptrs.empty();}
164 size_type size() const {return sourceptrs.size();}
165
166
167 // added functionality
168 void clear () {sourceptrs.erase(sourceptrs.begin(),sourceptrs.end());}
169
170 // thesource remains the property of the calling code but
171 // should not be deleted until it is removed from this list.
172 void addsource (sourceclass *thesource);
173};
174
175
176
177#endif
Note: See TracBrowser for help on using the repository browser.