~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to backend/wbpublic/grtdb/editor_user_role.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License as
 
6
 * published by the Free Software Foundation; version 2 of the
 
7
 * License.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
12
 * GNU General Public License for more details.
 
13
 * 
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
17
 * 02110-1301  USA
 
18
 */
 
19
#ifndef _EDITOR_USER_ROLE_H_
 
20
#define _EDITOR_USER_ROLE_H_
 
21
 
 
22
#include "wb_config.h"
 
23
 
 
24
#include "grtdb/editor_dbobject.h"
 
25
#include "role_tree_model.h"
 
26
 
 
27
#include "grts/structs.db.h"
 
28
 
 
29
#include "wbpublic_public_interface.h"
 
30
 
 
31
#define UserRoleEditorBE_VERSION 1
 
32
 
 
33
 
 
34
namespace bec {
 
35
 
 
36
  class RoleEditorBE;
 
37
 
 
38
  class WBPUBLICBACKEND_PUBLIC_FUNC RolePrivilegeListBE : public ListModel
 
39
  {
 
40
  public:
 
41
    enum Columns {
 
42
      Name,
 
43
      Enabled
 
44
    };
 
45
 
 
46
    RolePrivilegeListBE(RoleEditorBE *owner);
 
47
 
 
48
    virtual void refresh();
 
49
 
 
50
    virtual int count();
 
51
 
 
52
    void remove_all();
 
53
 
 
54
    virtual bool set_field(const NodeId &node, int column, int value);
 
55
 
 
56
  protected:
 
57
    RoleEditorBE *_owner;
 
58
    db_RolePrivilegeRef _role_privilege;
 
59
    grt::StringListRef _privileges;
 
60
 
 
61
    virtual bool get_field_grt(const NodeId &node, int column, grt::ValueRef &value);
 
62
  };
 
63
 
 
64
  //!
 
65
  //! Wraps in ListModel way operations with db_Role::privileges()
 
66
  //! Role is obtained from RoleEditorBE owner. 
 
67
  //!
 
68
  class WBPUBLICBACKEND_PUBLIC_FUNC RoleObjectListBE : public ListModel
 
69
  {
 
70
  public:
 
71
    enum Columns {
 
72
      Name
 
73
    };
 
74
 
 
75
    RoleObjectListBE(RoleEditorBE *owner);
 
76
 
 
77
    void set_selected_node(const NodeId &node);
 
78
    db_RolePrivilegeRef get_selected_object_info();
 
79
 
 
80
    virtual int count();
 
81
    virtual void refresh() {};
 
82
 
 
83
    virtual MenuItemList get_popup_items_for_nodes(const std::vector<NodeId> &nodes);
 
84
    virtual bool activate_popup_item_for_nodes(const std::string &name, const std::vector<NodeId> &nodes);
 
85
 
 
86
  protected:
 
87
    RoleEditorBE *_owner;
 
88
    NodeId _selection;
 
89
 
 
90
    virtual IconId get_field_icon(const NodeId &node, int column, IconSize size);
 
91
    virtual bool get_field_grt(const NodeId &node, int column, grt::ValueRef &value);
 
92
  };
 
93
  
 
94
  //!
 
95
  //! Represents Roles, their objects and assigned privileges.
 
96
  //! The set of classes: RoleEditorBE, RoleObjectListBE and RolePrivilegeListBE
 
97
  //! works using RoleEditorBE::_role field.
 
98
  class WBPUBLICBACKEND_PUBLIC_FUNC RoleEditorBE : public BaseEditor 
 
99
  {
 
100
  protected:
 
101
    db_RoleRef _role;                      //!< Selected role
 
102
    db_mgmt_RdbmsRef _rdbms;
 
103
    RoleTreeBE _tree;                      //!< List of roles in a schema
 
104
    RolePrivilegeListBE _privilege_list;   //!< Serves as a source of role's objects privileges for the UIs
 
105
    RoleObjectListBE _object_list;         //!< Serves as a source of role's objects for the UI.
 
106
 
 
107
  public:
 
108
    RoleEditorBE(GRTManager *grtm, const db_RoleRef &role, const db_mgmt_RdbmsRef &rdbms);
 
109
 
 
110
    db_RoleRef get_role() { return _role; }
 
111
    virtual GrtObjectRef get_object() { return get_role(); }
 
112
 
 
113
    const db_mgmt_RdbmsRef& get_rdbms() { return _rdbms; }
 
114
 
 
115
    void set_name(const std::string &name);
 
116
    std::string get_name();
 
117
 
 
118
    void set_parent_role(const std::string &name);
 
119
    std::string get_parent_role();
 
120
    std::vector<std::string> get_role_list();
 
121
 
 
122
    RoleTreeBE* get_role_tree() { return &_tree; }
 
123
 
 
124
    RolePrivilegeListBE *get_privilege_list() { return &_privilege_list; }
 
125
    RoleObjectListBE *get_object_list() { return &_object_list; }
 
126
 
 
127
    bool add_dropped_objectdata(const std::string &data);
 
128
    
 
129
    bool add_object(db_DatabaseObjectRef object);
 
130
    void remove_object(const bec::NodeId& object_node_id);
 
131
  };
 
132
};
 
133
 
 
134
 
 
135
#endif /* _EDITOR_USER_ROLE_H_ */