File: db_mysql_sql_export.h

package info (click to toggle)
mysql-workbench 6.3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 113,932 kB
  • ctags: 87,814
  • sloc: ansic: 955,521; cpp: 427,465; python: 59,728; yacc: 59,129; xml: 54,204; sql: 7,091; objc: 965; makefile: 638; sh: 613; java: 237; perl: 30; ruby: 6; php: 1
file content (132 lines) | stat: -rw-r--r-- 5,192 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* 
 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 of the
 * License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#ifndef _DB_MYSQL_SQL_EXPORT_H_
#define _DB_MYSQL_SQL_EXPORT_H_

#include "db_mysql_public_interface.h"
#include "grt/grt_manager.h"
#include "grts/structs.db.mysql.h"
#include "grt/grt_string_list_model.h"
#include "db_mysql_validation_page.h"

class WBPLUGINDBMYSQLBE_PUBLIC_FUNC DbMySQLSQLExport : public DbMySQLValidationPage
{
  //bec::GRTManager *_manager;
  db_mysql_CatalogRef _catalog;

  // options
  bool _gen_drops;
  bool _gen_schema_drops;
  bool _gen_warnings;
  bool _gen_create_index;
  bool _no_users_just_privileges;
  bool _no_view_placeholders;
  bool _gen_inserts;
  bool _no_FK_for_inserts;
  bool _triggers_after_inserts;
  std::string _output_filename;
  std::string _output_header;
  bool _tables_are_selected, _triggers_are_selected,
      _routines_are_selected, _views_are_selected, 
      _users_are_selected;
  bool _omit_schemata;
  bool _generate_use;
  bool _skip_foreign_keys;
  bool _skip_fk_indexes;
  bool _case_sensitive;
  bool _gen_doc_props;
  bool _gen_attached_scripts;

  boost::shared_ptr<bec::GrtStringListModel> _users_model;
  boost::shared_ptr<bec::GrtStringListModel> _users_exc_model;
  boost::shared_ptr<bec::GrtStringListModel> _tables_model;
  boost::shared_ptr<bec::GrtStringListModel> _tables_exc_model;
  boost::shared_ptr<bec::GrtStringListModel> _views_model;
  boost::shared_ptr<bec::GrtStringListModel> _views_exc_model;
  boost::shared_ptr<bec::GrtStringListModel> _routines_model;
  boost::shared_ptr<bec::GrtStringListModel> _routines_exc_model;
  boost::shared_ptr<bec::GrtStringListModel> _triggers_model;
  boost::shared_ptr<bec::GrtStringListModel> _triggers_exc_model;

  std::map<std::string,GrtNamedObjectRef> _users_map;
  std::map<std::string,GrtNamedObjectRef> _tables_map;
  std::map<std::string,GrtNamedObjectRef> _views_map;
  std::map<std::string,GrtNamedObjectRef> _routines_map;
  std::map<std::string,GrtNamedObjectRef> _triggers_map;
  grt::DictRef _db_options;

  std::string get_q_name(const char *part1, const char *part2)
  {
    return std::string(part1).append(".").append(part2);
  }

  db_mysql_CatalogRef filter_catalog();

protected:
  virtual db_mysql_CatalogRef get_model_catalog();
  virtual grt::DictRef get_options_as_dict(grt::GRT*);
  //bec::MessageListBE messages_list;
public:

  DbMySQLSQLExport(bec::GRTManager *grtm, db_mysql_CatalogRef catalog = db_mysql_CatalogRef());

  //bec::GRTManager *get_grt_manager() const { return _manager; }
  db_mysql_CatalogRef get_catalog() const { return _catalog; }

  std::string get_output_filename() const { return _output_filename; }
  
  void set_option(const std::string& name, bool value);
  void set_option(const std::string& name, const std::string& value);
  void set_db_options_for_version(const GrtVersionRef &version);
  void set_db_options(grt::DictRef &db_options);

  void start_export(bool wait_finish);
  //void run_validation();

  void export_finished(grt::ValueRef res);
  grt::ValueRef export_task(grt::GRT*, grt::StringRef);

  typedef boost::function<int ()> Task_finish_cb;
  void task_finish_cb(Task_finish_cb cb) { _task_finish_cb= cb; }

  void setup_grt_string_list_models_from_catalog(bec::GrtStringListModel **users_model, 
                                                 bec::GrtStringListModel **users_exc_model,
                                                 bec::GrtStringListModel **tables_model, 
                                                 bec::GrtStringListModel **tables_exc_model,
                                                 bec::GrtStringListModel **views_model, 
                                                 bec::GrtStringListModel **views_exc_model, 
                                                 bec::GrtStringListModel **routines_model, 
                                                 bec::GrtStringListModel **routines_exc_model, 
                                                 bec::GrtStringListModel **triggers_model,
                                                 bec::GrtStringListModel **triggers_exc_model);

  std::string export_sql_script() { return _export_sql_script; }

private:
  //Validation_finished_cb _validation_finished_cb;
  //Validation_step_finished_cb _validation_step_finished_cb;
  Task_finish_cb _task_finish_cb;
  std::string _export_sql_script;
};


grt::StringListRef convert_string_vector_to_grt_list(grt::GRT *grt, const std::vector<std::string>& v);

#endif // _DB_MYSQL_SQL_EXPORT_H_