30
wxString pgTextSearchConfiguration::GetTranslatedMessage(int kindOfMessage) const
32
wxString message = wxEmptyString;
34
switch (kindOfMessage)
36
case RETRIEVINGDETAILS:
37
message = _("Retrieving details on FTS configuration");
38
message += wxT(" ") + GetName();
40
case REFRESHINGDETAILS:
41
message = _("Refreshing FTS configuration");
42
message += wxT(" ") + GetName();
44
case DROPINCLUDINGDEPS:
45
message = wxString::Format(_("Are you sure you wish to drop FTS configuration \"%s\" including all objects that depend on it?"),
46
GetFullIdentifier().c_str());
48
case DROPEXCLUDINGDEPS:
49
message = wxString::Format(_("Are you sure you wish to drop FTS configuration \"%s\"?"),
50
GetFullIdentifier().c_str());
52
case DROPCASCADETITLE:
53
message = _("Drop FTS configuration cascaded?");
56
message = _("Drop FTS configuration?");
58
case PROPERTIESREPORT:
59
message = _("FTS configuration properties report");
60
message += wxT(" - ") + GetName();
63
message = _("FTS configuration properties");
66
message = _("FTS configuration DDL report");
67
message += wxT(" - ") + GetName();
70
message = _("FTS configuration DDL");
72
case DEPENDENCIESREPORT:
73
message = _("FTS configuration dependencies report");
74
message += wxT(" - ") + GetName();
77
message = _("FTS configuration dependencies");
79
case DEPENDENTSREPORT:
80
message = _("FTS configuration dependents report");
81
message += wxT(" - ") + GetName();
84
message = _("FTS configuration dependents");
30
91
bool pgTextSearchConfiguration::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
32
wxString sql = wxT("DROP TEXT SEARCH CONFIGURATION ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + this->GetIdentifier();
35
sql += wxT(" CASCADE");
37
return GetDatabase()->ExecuteVoid(sql);
93
wxString sql = wxT("DROP TEXT SEARCH CONFIGURATION ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + this->GetIdentifier();
96
sql += wxT(" CASCADE");
98
return GetDatabase()->ExecuteVoid(sql);
41
102
wxString pgTextSearchConfiguration::GetSql(ctlTree *browser)
45
sql = wxT("-- Text Search Configuration: ") + GetFullIdentifier() + wxT("\n\n")
46
+ wxT("-- DROP TEXT SEARCH CONFIGURATION ") + GetFullIdentifier() + wxT("\n\n")
47
+ wxT("CREATE TEXT SEARCH CONFIGURATION ") + GetFullIdentifier() + wxT(" (")
48
+ wxT("\n PARSER = ") + qtTypeIdent(GetParser())
51
for (size_t i=0 ; i < tokens.GetCount() ; i++)
52
sql += wxT("ALTER TEXT SEARCH CONFIGURATION ") + GetQuotedFullIdentifier()
53
+ wxT(" ADD MAPPING FOR ") + tokens.Item(i).BeforeFirst('/')
54
+ wxT(" WITH ") + tokens.Item(i).AfterFirst('/')
57
if (!GetComment().IsNull())
58
sql += wxT("COMMENT ON TEXT SEARCH CONFIGURATION ") + GetFullIdentifier()
59
+ wxT(" IS ") + qtDbString(GetComment()) + wxT(";\n");
106
sql = wxT("-- Text Search Configuration: ") + GetFullIdentifier() + wxT("\n\n")
107
+ wxT("-- DROP TEXT SEARCH CONFIGURATION ") + GetFullIdentifier() + wxT("\n\n")
108
+ wxT("CREATE TEXT SEARCH CONFIGURATION ") + GetFullIdentifier() + wxT(" (")
109
+ wxT("\n PARSER = ") + qtTypeIdent(GetParser())
112
for (size_t i = 0 ; i < tokens.GetCount() ; i++)
113
sql += wxT("ALTER TEXT SEARCH CONFIGURATION ") + GetQuotedFullIdentifier()
114
+ wxT(" ADD MAPPING FOR ") + tokens.Item(i).BeforeFirst('/')
115
+ wxT(" WITH ") + tokens.Item(i).AfterFirst('/')
118
if (!GetComment().IsNull())
119
sql += wxT("COMMENT ON TEXT SEARCH CONFIGURATION ") + GetFullIdentifier()
120
+ wxT(" IS ") + qtDbString(GetComment()) + wxT(";\n");
66
127
void pgTextSearchConfiguration::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
70
CreateListColumns(properties);
131
CreateListColumns(properties);
72
properties->AppendItem(_("Name"), GetName());
73
properties->AppendItem(_("OID"), GetOid());
74
properties->AppendItem(_("Owner"), GetOwner());
75
properties->AppendItem(_("Parser"), GetParser());
76
properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
133
properties->AppendItem(_("Name"), GetName());
134
properties->AppendItem(_("OID"), GetOid());
135
properties->AppendItem(_("Owner"), GetOwner());
136
properties->AppendItem(_("Parser"), GetParser());
137
properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
82
143
pgObject *pgTextSearchConfiguration::Refresh(ctlTree *browser, const wxTreeItemId item)
85
pgCollection *coll=browser->GetParentCollection(item);
87
config = textSearchConfigurationFactory.CreateObjects(coll, 0, wxT("\n AND cfg.oid=") + GetOidStr());
145
pgObject *config = 0;
146
pgCollection *coll = browser->GetParentCollection(item);
148
config = textSearchConfigurationFactory.CreateObjects(coll, 0, wxT("\n AND cfg.oid=") + GetOidStr());
154
wxString pgTextSearchConfigurationCollection::GetTranslatedMessage(int kindOfMessage) const
156
wxString message = wxEmptyString;
158
switch (kindOfMessage)
160
case RETRIEVINGDETAILS:
161
message = _("Retrieving details on FTS configurations");
163
case REFRESHINGDETAILS:
164
message = _("Refreshing FTS configurations");
166
case OBJECTSLISTREPORT:
167
message = _("FTS configurations list report");
94
175
//////////////////////////////////////////////////////
97
178
pgObject *pgTextSearchConfigurationFactory::CreateObjects(pgCollection *collection, ctlTree *browser, const wxString &restriction)
99
pgTextSearchConfiguration *config=0;
180
pgTextSearchConfiguration *config = 0;
101
182
pgSet *configurations;
102
183
configurations = collection->GetDatabase()->ExecuteSet(
103
wxT("SELECT cfg.oid, cfg.cfgname, pg_get_userbyid(cfg.cfgowner) as cfgowner, cfg.cfgparser, parser.prsname as parsername, description\n")
104
wxT(" FROM pg_ts_config cfg\n")
105
wxT(" LEFT OUTER JOIN pg_ts_parser parser ON parser.oid=cfg.cfgparser\n")
106
wxT(" LEFT OUTER JOIN pg_description des ON des.objoid=cfg.oid\n")
107
wxT(" WHERE cfg.cfgnamespace = ") + collection->GetSchema()->GetOidStr()
108
+ restriction + wxT("\n")
109
wxT(" ORDER BY cfg.cfgname"));
113
while (!configurations->Eof())
115
config = new pgTextSearchConfiguration(collection->GetSchema(), configurations->GetVal(wxT("cfgname")));
116
config->iSetOid(configurations->GetOid(wxT("oid")));
117
config->iSetOwner(configurations->GetVal(wxT("cfgowner")));
118
config->iSetComment(configurations->GetVal(wxT("description")));
119
config->iSetParser(configurations->GetVal(wxT("parsername")));
120
config->iSetParserOid(configurations->GetOid(wxT("cfgparser")));
123
maps = collection->GetDatabase()->ExecuteSet(
125
wxT(" (SELECT t.alias FROM pg_catalog.ts_token_type(cfgparser) AS t")
126
wxT(" WHERE t.tokid = maptokentype) AS tokenalias,\n")
128
wxT("FROM pg_ts_config_map\n")
129
wxT(" LEFT OUTER JOIN pg_ts_config ON mapcfg=pg_ts_config.oid\n")
130
wxT(" LEFT OUTER JOIN pg_ts_dict ON mapdict=pg_ts_dict.oid\n")
131
wxT("WHERE mapcfg=") + config->GetOidStr() + wxT("\n")
132
wxT("ORDER BY 1, mapseqno"));
139
if (tokenToAdd.Length() > 0 &&
140
!tokenToAdd.BeforeFirst('/').IsSameAs(maps->GetVal(wxT("tokenalias")), false))
142
config->GetTokens().Add(tokenToAdd);
143
tokenToAdd = wxT("");
146
if (tokenToAdd.Length() == 0)
147
tokenToAdd = maps->GetVal(wxT("tokenalias")) + wxT("/") + maps->GetVal(wxT("dictname"));
149
tokenToAdd += wxT(",") + maps->GetVal(wxT("dictname"));
154
if (tokenToAdd.Length() > 0 &&
155
!tokenToAdd.BeforeFirst('/').IsSameAs(maps->GetVal(wxT("tokenalias")), false))
157
config->GetTokens().Add(tokenToAdd);
158
tokenToAdd = wxT("");
166
browser->AppendObject(collection, config);
167
configurations->MoveNext();
184
wxT("SELECT cfg.oid, cfg.cfgname, pg_get_userbyid(cfg.cfgowner) as cfgowner, cfg.cfgparser, parser.prsname as parsername, description\n")
185
wxT(" FROM pg_ts_config cfg\n")
186
wxT(" LEFT OUTER JOIN pg_ts_parser parser ON parser.oid=cfg.cfgparser\n")
187
wxT(" LEFT OUTER JOIN pg_description des ON des.objoid=cfg.oid\n")
188
wxT(" WHERE cfg.cfgnamespace = ") + collection->GetSchema()->GetOidStr()
189
+ restriction + wxT("\n")
190
wxT(" ORDER BY cfg.cfgname"));
194
while (!configurations->Eof())
196
config = new pgTextSearchConfiguration(collection->GetSchema(), configurations->GetVal(wxT("cfgname")));
197
config->iSetOid(configurations->GetOid(wxT("oid")));
198
config->iSetOwner(configurations->GetVal(wxT("cfgowner")));
199
config->iSetComment(configurations->GetVal(wxT("description")));
200
config->iSetParser(configurations->GetVal(wxT("parsername")));
201
config->iSetParserOid(configurations->GetOid(wxT("cfgparser")));
204
maps = collection->GetDatabase()->ExecuteSet(
206
wxT(" (SELECT t.alias FROM pg_catalog.ts_token_type(cfgparser) AS t")
207
wxT(" WHERE t.tokid = maptokentype) AS tokenalias,\n")
209
wxT("FROM pg_ts_config_map\n")
210
wxT(" LEFT OUTER JOIN pg_ts_config ON mapcfg=pg_ts_config.oid\n")
211
wxT(" LEFT OUTER JOIN pg_ts_dict ON mapdict=pg_ts_dict.oid\n")
212
wxT("WHERE mapcfg=") + config->GetOidStr() + wxT("\n")
213
wxT("ORDER BY 1, mapseqno"));
220
if (tokenToAdd.Length() > 0 &&
221
!tokenToAdd.BeforeFirst('/').IsSameAs(maps->GetVal(wxT("tokenalias")), false))
223
config->GetTokens().Add(tokenToAdd);
224
tokenToAdd = wxT("");
227
if (tokenToAdd.Length() == 0)
228
tokenToAdd = maps->GetVal(wxT("tokenalias")) + wxT("/") + maps->GetVal(wxT("dictname"));
230
tokenToAdd += wxT(",") + maps->GetVal(wxT("dictname"));
235
if (tokenToAdd.Length() > 0 &&
236
!tokenToAdd.BeforeFirst('/').IsSameAs(maps->GetVal(wxT("tokenalias")), false))
238
config->GetTokens().Add(tokenToAdd);
239
tokenToAdd = wxT("");
247
browser->AppendObject(collection, config);
248
configurations->MoveNext();
173
254
delete configurations;
179
#include "images/configuration.xpm"
180
#include "images/configurations.xpm"
260
#include "images/configuration.pngc"
261
#include "images/configurations.pngc"
182
pgTextSearchConfigurationFactory::pgTextSearchConfigurationFactory()
183
: pgSchemaObjFactory(__("FTS Configuration"), __("New FTS Configuration..."), __("Create a new FTS Configuration."), configuration_xpm)
263
pgTextSearchConfigurationFactory::pgTextSearchConfigurationFactory()
264
: pgSchemaObjFactory(__("FTS Configuration"), __("New FTS Configuration..."), __("Create a new FTS Configuration."), configuration_png_img)
188
269
pgTextSearchConfigurationFactory textSearchConfigurationFactory;
189
static pgaCollectionFactory cf(&textSearchConfigurationFactory, __("FTS Configurations"), configurations_xpm);
270
static pgaCollectionFactory cf(&textSearchConfigurationFactory, __("FTS Configurations"), configurations_png_img);