source: main/trunk/greenstone2/runtime-src/src/recpt/basequeryaction.h@ 25234

Last change on this file since 25234 was 22045, checked in by davidb, 14 years ago

Introduction of sql-query action. This has been achived be creating a base call for query-action (sharing common functionality for fulltext query action and sql query action).

File size: 4.4 KB
Line 
1/**********************************************************************
2 *
3 * basequeryaction.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 BASEQUERYACTION_H
28#define BASEQUERYACTION_H
29
30#include "gsdlconf.h"
31#include "action.h"
32#include "receptionist.h"
33
34struct colinfo_t {
35 void clear();
36 colinfo_t () {clear();}
37
38 format_t *formatlistptr;
39 browserclass *browserptr;
40};
41
42struct QueryResult_t {
43 void clear ();
44 QueryResult_t () {clear();}
45
46 ResultDocInfo_t doc;
47 text_t collection;
48};
49
50struct gteqQueryResult_t
51{
52 bool operator()(const QueryResult_t &t1, const QueryResult_t &t2) const
53 { return t1.doc.ranking >= t2.doc.ranking; }
54};
55
56typedef set<QueryResult_t, gteqQueryResult_t> QueryResult_tset;
57
58
59class basequeryaction : public action {
60
61protected:
62
63 receptionist *recpt;
64
65 virtual text_t query_filter_name ()=0;
66
67 virtual void get_formatted_query_string (text_t &formattedstring,
68 bool segment,
69 cgiargsclass &args,
70 displayclass &disp, ostream &logout)=0;
71
72 virtual void define_single_query_macros (cgiargsclass &args,
73 displayclass &disp,
74 const FilterResponse_t &response);
75
76 virtual void define_query_macros (cgiargsclass &args, displayclass &disp,
77 int numDocs, isapprox isApprox);
78
79 virtual void define_history_macros (displayclass &disp, cgiargsclass &args,
80 recptprotolistclass *protos,
81 ostream &logout);
82
83 virtual void set_queryfilter_options (FilterRequest_t &request,
84 const text_t &querystring,
85 cgiargsclass &args)=0;
86
87
88 virtual void define_form_macros (displayclass &disp, cgiargsclass &args,
89 recptprotolistclass *protos,
90 ostream &logout) = 0;
91
92
93 virtual void set_option_macro (const text_t &macroname, text_t current_value,
94 bool display_single, bool add_js_update,
95 const FilterOption_t &option,
96 displayclass &disp);
97
98 void set_option_macro (const text_t &macroname,
99 text_t current_value,
100 bool display_single,
101 bool add_js_update,
102 const FilterOption_t &option_domain,
103 const FilterOption_t &option_range,
104 displayclass &disp);
105
106 bool search_single_collection (cgiargsclass& args, const text_t& collection,
107 recptprotolistclass* protos,
108 browsermapclass* browsers,
109 displayclass& disp,
110 outconvertclass &outconvert,
111 ostream &textout, ostream &logout);
112
113 virtual bool save_search_history(cgiargsclass &args, int numdocs,
114 isapprox isApprox)=0;
115
116public:
117 basequeryaction ();
118 virtual ~basequeryaction () {}
119
120 void set_receptionist (receptionist *therecpt) {recpt=therecpt;}
121
122 void configure (const text_t &key, const text_tarray &cfgline);
123 bool init (ostream &logout);
124
125 virtual text_t get_action_name ()=0;
126
127 virtual bool check_cgiargs (cgiargsinfoclass &argsinfo, cgiargsclass &args,
128 recptprotolistclass *protos, ostream &logout);
129
130 void get_cgihead_info (cgiargsclass &args, recptprotolistclass *protos,
131 response_t &response, text_t &response_data,
132 ostream &logout);
133
134 virtual void define_internal_macros (displayclass &disp, cgiargsclass &args,
135 recptprotolistclass *protos, ostream &logout);
136
137 virtual void define_external_macros (displayclass &disp, cgiargsclass &args,
138 recptprotolistclass *protos, ostream &logout)=0;
139
140 virtual bool do_action (cgiargsclass &args, recptprotolistclass *protos,
141 browsermapclass *browsers, displayclass &disp,
142 outconvertclass &outconvert, ostream &textout,
143 ostream &logout)=0;
144
145};
146
147#endif
Note: See TracBrowser for help on using the repository browser.