2
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
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
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.
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
19
#ifndef _EDITOR_USER_ROLE_H_
20
#define _EDITOR_USER_ROLE_H_
22
#include "wb_config.h"
24
#include "grtdb/editor_dbobject.h"
25
#include "role_tree_model.h"
27
#include "grts/structs.db.h"
29
#include "wbpublic_public_interface.h"
31
#define UserRoleEditorBE_VERSION 1
38
class WBPUBLICBACKEND_PUBLIC_FUNC RolePrivilegeListBE : public ListModel
46
RolePrivilegeListBE(RoleEditorBE *owner);
48
virtual void refresh();
54
virtual bool set_field(const NodeId &node, int column, int value);
58
db_RolePrivilegeRef _role_privilege;
59
grt::StringListRef _privileges;
61
virtual bool get_field_grt(const NodeId &node, int column, grt::ValueRef &value);
65
//! Wraps in ListModel way operations with db_Role::privileges()
66
//! Role is obtained from RoleEditorBE owner.
68
class WBPUBLICBACKEND_PUBLIC_FUNC RoleObjectListBE : public ListModel
75
RoleObjectListBE(RoleEditorBE *owner);
77
void set_selected_node(const NodeId &node);
78
db_RolePrivilegeRef get_selected_object_info();
81
virtual void refresh() {};
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);
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);
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
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.
108
RoleEditorBE(GRTManager *grtm, const db_RoleRef &role, const db_mgmt_RdbmsRef &rdbms);
110
db_RoleRef get_role() { return _role; }
111
virtual GrtObjectRef get_object() { return get_role(); }
113
const db_mgmt_RdbmsRef& get_rdbms() { return _rdbms; }
115
void set_name(const std::string &name);
116
std::string get_name();
118
void set_parent_role(const std::string &name);
119
std::string get_parent_role();
120
std::vector<std::string> get_role_list();
122
RoleTreeBE* get_role_tree() { return &_tree; }
124
RolePrivilegeListBE *get_privilege_list() { return &_privilege_list; }
125
RoleObjectListBE *get_object_list() { return &_object_list; }
127
bool add_dropped_objectdata(const std::string &data);
129
bool add_object(db_DatabaseObjectRef object);
130
void remove_object(const bec::NodeId& object_node_id);
135
#endif /* _EDITOR_USER_ROLE_H_ */