diff --git a/html-templates/USER.html b/html-templates/USER.html
new file mode 100644
index 00000000..34709b71
--- /dev/null
+++ b/html-templates/USER.html
@@ -0,0 +1,21 @@
+
+
+ User
+
+
+{%header:Summary%}
+
+
+{%object_name%}
+
{%object_description%} [edit]|
+
+
+User info[edit] |
+
+{%userinfo:source%} |
+
+
+
diff --git a/src/gui/MetadataItemPropertiesFrame.cpp b/src/gui/MetadataItemPropertiesFrame.cpp
index 4d0fde5e..5525aab9 100644
--- a/src/gui/MetadataItemPropertiesFrame.cpp
+++ b/src/gui/MetadataItemPropertiesFrame.cpp
@@ -399,9 +399,8 @@ wxIcon getMetadataItemIcon(NodeType type)
return wxArtProvider::GetIcon(ART_Function, wxART_OTHER, sz);
case ntGenerator:
return wxArtProvider::GetIcon(ART_Generator, wxART_OTHER, sz);
-// TODO: replace package art
case ntPackage:
- return wxArtProvider::GetIcon(ART_Procedure, wxART_OTHER, sz);
+ return wxArtProvider::GetIcon(ART_Package, wxART_OTHER, sz);
case ntProcedure:
return wxArtProvider::GetIcon(ART_Procedure, wxART_OTHER, sz);
case ntServer:
@@ -414,6 +413,8 @@ wxIcon getMetadataItemIcon(NodeType type)
return wxArtProvider::GetIcon(ART_Trigger, wxART_OTHER, sz);
case ntView:
return wxArtProvider::GetIcon(ART_View, wxART_OTHER, sz);
+ case ntUser:
+ return wxArtProvider::GetIcon(ART_User, wxART_OTHER, sz);
default:
break;
}
diff --git a/src/metadata/MetadataItemDescriptionVisitor.cpp b/src/metadata/MetadataItemDescriptionVisitor.cpp
index 006d2f97..aef11f78 100644
--- a/src/metadata/MetadataItemDescriptionVisitor.cpp
+++ b/src/metadata/MetadataItemDescriptionVisitor.cpp
@@ -49,6 +49,7 @@
#include "metadata/relation.h"
#include "metadata/role.h"
#include "metadata/trigger.h"
+#include "metadata/user.h"
// class LoadDescriptionVisitor
@@ -221,6 +222,13 @@ void LoadDescriptionVisitor::visitTrigger(Trigger& trigger)
"where RDB$TRIGGER_NAME = ?");
}
+void LoadDescriptionVisitor::visitUser(User& user)
+{
+ loadDescription(&user,
+ "select SEC$DESCRIPTION from SEC$USERS "
+ "where SEC$USER_NAME = ?");
+}
+
// class SaveDescriptionVisitor
SaveDescriptionVisitor::SaveDescriptionVisitor(wxString description)
: MetadataItemVisitor(), descriptionM(description)
@@ -429,3 +437,8 @@ void SaveDescriptionVisitor::visitTrigger(Trigger& trigger)
"where RDB$TRIGGER_NAME = ?");
}
+void SaveDescriptionVisitor::visitUser(User& user)
+{
+ saveDescription(&user, "comment on trigger %s is '%s'");
+}
+
diff --git a/src/metadata/MetadataItemDescriptionVisitor.h b/src/metadata/MetadataItemDescriptionVisitor.h
index 0049fa90..dbb4fbfe 100644
--- a/src/metadata/MetadataItemDescriptionVisitor.h
+++ b/src/metadata/MetadataItemDescriptionVisitor.h
@@ -53,6 +53,7 @@ class LoadDescriptionVisitor : public MetadataItemVisitor
virtual void visitRelation(Relation& relation);
virtual void visitRole(Role& role);
virtual void visitTrigger(Trigger& trigger);
+ virtual void visitUser(User& user);
bool descriptionAvailable() const;
wxString getDescription() const;
@@ -82,6 +83,7 @@ class SaveDescriptionVisitor : public MetadataItemVisitor
virtual void visitRelation(Relation& relation);
virtual void visitRole(Role& role);
virtual void visitTrigger(Trigger& trigger);
+ virtual void visitUser(User& user);
};
#endif // FR_DESCRIPTIONVISITOR_H
diff --git a/src/metadata/MetadataTemplateCmdHandler.cpp b/src/metadata/MetadataTemplateCmdHandler.cpp
index 162a5b57..c158031c 100644
--- a/src/metadata/MetadataTemplateCmdHandler.cpp
+++ b/src/metadata/MetadataTemplateCmdHandler.cpp
@@ -966,6 +966,9 @@ void MetadataTemplateCmdHandler::handleTemplateCmd(TemplateProcessor *tp,
processedText << u->getUserId();
else if (cmdParams[0] == "unix_group")
processedText << u->getGroupId();
+ else if (cmdParams[0] == "source")
+ processedText += tp->escapeChars(u->getSource(), false);
+
}
// {%sql_security%}
// If the current object is a data base, procedure, relation,
@@ -1001,11 +1004,11 @@ void MetadataTemplateCmdHandler::handleTemplateCmd(TemplateProcessor *tp,
}
else if ((cmdName == "collationinfo") && (cmdParams.Count() >= 1))
{
- Collation* p = dynamic_cast(object);
- if (!p)
+ Collation* c = dynamic_cast(object);
+ if (!c)
return;
if (cmdParams[0] == "source")
- processedText += tp->escapeChars(p->getSource(), false);
+ processedText += tp->escapeChars(c->getSource(), false);
}
diff --git a/src/metadata/User.cpp b/src/metadata/User.cpp
index 6c7c2d63..70b2bb7b 100644
--- a/src/metadata/User.cpp
+++ b/src/metadata/User.cpp
@@ -30,11 +30,19 @@
#include "wx/wx.h"
#endif
+#include
+
+#include "core/FRError.h"
#include "core/StringUtils.h"
+#include "engine/MetadataLoader.h"
#include "metadata/MetadataItemVisitor.h"
#include "metadata/server.h"
#include "metadata/User.h"
+void User::loadProperties()
+{
+}
+
User::User(ServerPtr server)
: MetadataItem(ntUnknown, server.get()), serverM(server)
{
@@ -96,6 +104,21 @@ uint32_t User::getGroupId() const
return groupidM;
}
+IBPP::User& User::getUserIBPP() const
+{
+ IBPP::User usr;
+
+ usr.username = wx2std(usernameM);
+ usr.password = wx2std(passwordM);
+ usr.firstname = wx2std(firstnameM);
+ usr.lastname = wx2std(lastnameM);
+ usr.middlename = wx2std(middlenameM);
+ usr.userid = useridM;
+ usr.groupid = groupidM;
+
+ return usr;
+}
+
void User::setUsername(const wxString& value)
{
if (usernameM != value)
@@ -159,15 +182,23 @@ void User::setGroupId(uint32_t value)
}
}
+void User::setUserIBPP(const IBPP::User& usr)
+{
+ setUsername(usr.username);
+ setUsername(usr.username);
+ setPassword(usr.password);
+ setFirstName(usr.firstname);
+ setMiddleName(usr.middlename);
+ setLastName(usr.lastname);
+ setUserId(usr.userid);
+ setGroupId(usr.groupid);
+
+ notifyObservers();
+}
+
void User::assignTo(IBPP::User& dest) const
{
- dest.username = wx2std(usernameM);
- dest.password = wx2std(passwordM);
- dest.firstname = wx2std(firstnameM);
- dest.lastname = wx2std(lastnameM);
- dest.middlename = wx2std(middlenameM);
- dest.userid = useridM;
- dest.groupid = groupidM;
+ dest = getUserIBPP();
}
void User::acceptVisitor(MetadataItemVisitor* visitor)
@@ -175,12 +206,28 @@ void User::acceptVisitor(MetadataItemVisitor* visitor)
visitor->visitUser(*this);
}
+const wxString User::getTypeName() const
+{
+ return "USER";
+}
+
+wxString User::getSource()
+{
+ ensurePropertiesLoaded();
+ wxString sql = "FIRSTNAME '" + getFirstName() + "' \n" +
+ "MIDDLENAME '" + getMiddleName() + "' \n"
+ "LASTNAME '" + getLastName() + "' \n"
+ "USING PLUGIN "+" \n"
+
+ ;
+ return sql;
+}
+
bool User::isSystem() const
{
return usernameM == "SYSDBA";
}
-
void Users::loadChildren()
{
load(0);
@@ -199,7 +246,7 @@ void Users::acceptVisitor(MetadataItemVisitor* visitor)
void Users::load(ProgressIndicator* progressIndicator)
{
- DatabasePtr db = getDatabase();
+ /*DatabasePtr db = getDatabase();
if (db->getInfo().getODSVersionIsHigherOrEqualTo(12, 0)) {
wxString stmt = "select sec$user_name from sec$users a order by 1 ";
setItems(db->loadIdentifiers(stmt, progressIndicator));
@@ -217,7 +264,7 @@ void Users::load(ProgressIndicator* progressIndicator)
}
}
- }
+ }*/
}
const wxString Users::getTypeName() const
@@ -225,6 +272,7 @@ const wxString Users::getTypeName() const
return "USERS_COLLECTION";
}
+
Users20::Users20(DatabasePtr database)
:Users(database)
{
@@ -243,6 +291,9 @@ void Users20::load(ProgressIndicator* progressIndicator)
{
insert(it->username);
}
+ notifyObservers();
+ setChildrenLoaded(true);
+
}
}
@@ -256,6 +307,112 @@ Users30::Users30(DatabasePtr database)
void Users30::load(ProgressIndicator* progressIndicator)
{
DatabasePtr db = getDatabase();
- wxString stmt = "select sec$user_name from sec$users a order by 1 ";
+ wxString stmt = "select sec$user_name from sec$users order by 1 ";
setItems(db->loadIdentifiers(stmt, progressIndicator));
}
+
+void User20::loadProperties()
+{
+ setPropertiesLoaded(false);
+
+ DatabasePtr db = getDatabase();
+ IBPP::Service svc;
+ if (db->getServer()->getService(svc, NULL, true)) {
+ IBPP::User usr;
+ usr.username = getName_();
+ svc->GetUser(usr);
+ setUserIBPP(usr);
+ }
+
+ setPropertiesLoaded(true);
+ notifyObservers();
+}
+
+User20::User20(ServerPtr server)
+ : User(server)
+{
+}
+
+User20::User20(ServerPtr server, const IBPP::User& src)
+ :User(server, src)
+{
+}
+
+User20::User20(DatabasePtr database, const wxString& name)
+ :User(database, name)
+{
+}
+
+void User30::loadProperties()
+{
+
+ DatabasePtr db = getDatabase();
+
+ MetadataLoader* loader = db->getMetadataLoader();
+ MetadataLoaderTransaction tr(loader);
+ wxMBConv* converter = db->getCharsetConverter();
+
+ IBPP::Statement& st1 = loader->getStatement(
+ "select sec$user_name, "
+ "sec$first_name, "
+ "sec$middle_name, "
+ "sec$last_name, "
+ "sec$active, "
+ "sec$admin, "
+ "sec$description, "
+ "sec$plugin "
+ "from sec$users "
+ "where sec$user_name = ? "
+ );
+ st1->Set(1, wx2std(getName_(), converter));
+ st1->Execute();
+ if (!st1->Fetch())
+ throw FRError(_("User not found: ") + getName_());
+
+ setPropertiesLoaded(false);
+ std::string lstr;
+
+
+ if (st1->IsNull(2))
+ lstr = "";
+ else
+ st1->Get(2, lstr);
+ setFirstName(lstr);
+
+ if (st1->IsNull(3))
+ lstr = "";
+ else
+ st1->Get(3, lstr);
+ setMiddleName(lstr);
+
+ if (st1->IsNull(4))
+ lstr = "";
+ else
+ st1->Get(4, lstr);
+ setLastName(lstr);
+
+ if (st1->IsNull(4))
+ lstr = "";
+ else
+ st1->Get(4, lstr);
+ setLastName(lstr);
+
+ setPropertiesLoaded(true);
+ notifyObservers();
+}
+
+User30::User30(ServerPtr server)
+ : User(server)
+{
+}
+
+User30::User30(ServerPtr server, const IBPP::User& src)
+ :User(server, src)
+{
+}
+
+User30::User30(DatabasePtr database, const wxString& name)
+ :User(database, name)
+{
+}
+
diff --git a/src/metadata/User.h b/src/metadata/User.h
index 74590f72..00966817 100644
--- a/src/metadata/User.h
+++ b/src/metadata/User.h
@@ -42,6 +42,8 @@ class User: public MetadataItem
wxString lastnameM;
uint32_t useridM;
uint32_t groupidM;
+protected:
+ virtual void loadProperties();
public:
User(ServerPtr server);
User(ServerPtr server, const IBPP::User& src);
@@ -58,6 +60,7 @@ class User: public MetadataItem
wxString getLastName() const;
uint32_t getUserId() const;
uint32_t getGroupId() const;
+ IBPP::User& getUserIBPP() const;
void setUsername(const wxString& value);
void setPassword(const wxString& value);
@@ -66,14 +69,39 @@ class User: public MetadataItem
void setLastName(const wxString& value);
void setUserId(uint32_t value);
void setGroupId(uint32_t value);
+ void setUserIBPP(const IBPP::User& usr);
void assignTo(IBPP::User& dest) const;
virtual void acceptVisitor(MetadataItemVisitor* visitor);
+ virtual const wxString getTypeName() const;
+ virtual wxString getSource();
+
+
+};
+class User20: public User
+{
+protected:
+ virtual void loadProperties();
+public:
+ User20(ServerPtr server);
+ User20(ServerPtr server, const IBPP::User& src);
+ User20(DatabasePtr database, const wxString& name);
};
-//template
+class User30 : public User
+{
+protected:
+ virtual void loadProperties();
+public:
+ User30(ServerPtr server);
+ User30(ServerPtr server, const IBPP::User& src);
+ User30(DatabasePtr database, const wxString& name);
+
+};
+
+
class Users : public MetadataCollection
{
protected:
@@ -81,24 +109,36 @@ class Users : public MetadataCollection
public:
Users(DatabasePtr database);
+
virtual void acceptVisitor(MetadataItemVisitor* visitor);
- void load(ProgressIndicator* progressIndicator);
+ virtual void load(ProgressIndicator* progressIndicator);
virtual const wxString getTypeName() const;
};
-class Users20 : public Users//
+class Users20 : public Users
{
public:
Users20(DatabasePtr database);
- void load(ProgressIndicator* progressIndicator);
+ virtual void load(ProgressIndicator* progressIndicator);
+
+ virtual ItemType newItem(const wxString & name) {
+ ItemType item(new User20(getDatabase(), name));
+ return item;
+ }
+
};
-class Users30 : public Users//
+class Users30 : public Users
{
public:
Users30(DatabasePtr database);
- void load(ProgressIndicator* progressIndicator);
+ virtual void load(ProgressIndicator* progressIndicator);
+
+ virtual ItemType newItem(const wxString& name) {
+ ItemType item(new User30(getDatabase(), name));
+ return item;
+ }
};
diff --git a/src/metadata/collection.h b/src/metadata/collection.h
index 3042e4c7..50bc747e 100644
--- a/src/metadata/collection.h
+++ b/src/metadata/collection.h
@@ -117,13 +117,18 @@ class MetadataCollection : public MetadataCollectionBase
}
public:
+ virtual ItemType newItem(const wxString& name) {
+ ItemType item(new T(getDatabase(), name));
+ return item;
+ }
+
// inserts new item into list at correct position to preserve alphabetical
// order of item names, and returns pointer to it
ItemType insert(const wxString& name)
{
iterator pos = std::find_if(itemsM.begin(), itemsM.end(),
InsertionPosByName(name));
- ItemType item(new T(getDatabase(), name));
+ ItemType item = newItem(name);// (new T(getDatabase(), name));
initializeLockCount(item, getLockCount());
itemsM.insert(pos, item);
notifyObservers();
@@ -154,7 +159,7 @@ class MetadataCollection : public MetadataCollectionBase
iterator oldPos = getPosition(itemName);
if (oldPos == itemsM.end())
{
- ItemType item(new T(database, names[i]));
+ ItemType item = newItem(names[i]);//(new T(database, names[i]));
newItems.push_back(item);
initializeLockCount(item, getLockCount());
}
diff --git a/src/metadata/database.cpp b/src/metadata/database.cpp
index 67b2f391..d7b0e7b4 100644
--- a/src/metadata/database.cpp
+++ b/src/metadata/database.cpp
@@ -1212,7 +1212,7 @@ void Database::connect(const wxString& password, ProgressIndicator* indicator)
initializeLockCount(sysIndicesM, lockCount);
usrIndicesM.reset(new UsrIndices(me));
initializeLockCount(usrIndicesM, lockCount);
- usersM.reset(new Users30(me));
+ usersM.reset(new Users20(me));
initializeLockCount(usersM, lockCount);
// first start a transaction for metadata loading, then lock the