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 133
|
/*
* Copyright (c) 2007, 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 _EDITOR_USER_ROLE_H_
#define _EDITOR_USER_ROLE_H_
#include "grtdb/editor_dbobject.h"
#include "role_tree_model.h"
#include "grts/structs.db.h"
#include "wbpublic_public_interface.h"
namespace bec {
class RoleEditorBE;
class WBPUBLICBACKEND_PUBLIC_FUNC RolePrivilegeListBE : public ListModel
{
public:
enum Columns {
Name,
Enabled
};
RolePrivilegeListBE(RoleEditorBE *owner);
virtual void refresh();
virtual size_t count();
void add_all();
void remove_all();
virtual bool set_field(const NodeId &node, ColumnId column, ssize_t value);
protected:
RoleEditorBE *_owner;
db_RolePrivilegeRef _role_privilege;
grt::StringListRef _privileges;
virtual bool get_field_grt(const NodeId &node, ColumnId column, grt::ValueRef &value);
};
//!
//! Wraps in ListModel way operations with db_Role::privileges()
//! Role is obtained from RoleEditorBE owner.
//!
class WBPUBLICBACKEND_PUBLIC_FUNC RoleObjectListBE : public ListModel
{
public:
enum Columns {
Name
};
RoleObjectListBE(RoleEditorBE *owner);
void set_selected_node(const NodeId &node);
db_RolePrivilegeRef get_selected_object_info();
virtual size_t count();
virtual void refresh() {};
virtual MenuItemList get_popup_items_for_nodes(const std::vector<NodeId> &nodes);
virtual bool activate_popup_item_for_nodes(const std::string &name, const std::vector<NodeId> &nodes);
protected:
RoleEditorBE *_owner;
NodeId _selection;
virtual IconId get_field_icon(const NodeId &node, ColumnId column, IconSize size);
virtual bool get_field_grt(const NodeId &node, ColumnId column, grt::ValueRef &value);
};
//!
//! Represents Roles, their objects and assigned privileges.
//! The set of classes: RoleEditorBE, RoleObjectListBE and RolePrivilegeListBE
//! works using RoleEditorBE::_role field.
class WBPUBLICBACKEND_PUBLIC_FUNC RoleEditorBE : public BaseEditor
{
protected:
db_RoleRef _role; //!< Selected role
db_mgmt_RdbmsRef _rdbms;
RoleTreeBE _tree; //!< List of roles in a schema
RolePrivilegeListBE _privilege_list; //!< Serves as a source of role's objects privileges for the UIs
RoleObjectListBE _object_list; //!< Serves as a source of role's objects for the UI.
public:
RoleEditorBE(GRTManager *grtm, const db_RoleRef &role, const db_mgmt_RdbmsRef &rdbms);
db_RoleRef get_role() { return _role; }
const db_mgmt_RdbmsRef& get_rdbms() { return _rdbms; }
virtual std::string get_title();
void set_name(const std::string &name);
std::string get_name();
void set_parent_role(const std::string &name);
std::string get_parent_role();
std::vector<std::string> get_role_list();
RoleTreeBE* get_role_tree() { return &_tree; }
RolePrivilegeListBE *get_privilege_list() { return &_privilege_list; }
RoleObjectListBE *get_object_list() { return &_object_list; }
bool add_dropped_objectdata(const std::string &data);
bool add_object(const std::string &type, const std::string &name);
bool add_object(db_DatabaseObjectRef object);
void remove_object(const bec::NodeId& object_node_id);
};
};
#endif /* _EDITOR_USER_ROLE_H_ */
|