Skip to content

Commit

Permalink
divide files for different versions of FB
Browse files Browse the repository at this point in the history
  • Loading branch information
jdochoa committed Jan 8, 2024
1 parent 0fc71cc commit cfc289c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 199 deletions.
147 changes: 0 additions & 147 deletions src/metadata/User.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,151 +257,4 @@ const wxString Users::getTypeName() const
}


Users20::Users20(DatabasePtr database)
:Users(database)
{
}

void Users20::load(ProgressIndicator* progressIndicator)
{
DatabasePtr db = getDatabase();
IBPP::Service svc;
if (db->getServer()->getService(svc, NULL, true)) { // true = SYSDBA

std::vector<IBPP::User> usr;
svc->GetUsers(usr);
for (std::vector<IBPP::User>::iterator it = usr.begin();
it != usr.end(); ++it)
{
insert(it->username);
}
notifyObservers();
setChildrenLoaded(true);

}

}


Users30::Users30(DatabasePtr database)
:Users(database)
{
}

void Users30::load(ProgressIndicator* progressIndicator)
{
DatabasePtr db = getDatabase();
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(DatabasePtr database, const wxString& name)
:User(database, name)
{
}

wxString User30::getAlterSqlStatement()
{
ensurePropertiesLoaded();
wxString sql = "ALTER USER " + getName_() + " \n" +
"PASSWORD '' \n"
"FIRSTNAME '" + getFirstName() + "' \n"
"MIDDLENAME '" + getMiddleName() + "' \n"
"LASTNAME '" + getLastName() + "' \n"
"{GRANT | REVOKE} ADMIN ROLE \n"
;
return sql;
}

54 changes: 2 additions & 52 deletions src/metadata/User.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,72 +77,22 @@ class User: public MetadataItem
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);
};

class User30 : public User
{
protected:
virtual void loadProperties();
public:
User30(DatabasePtr database, const wxString& name);

virtual wxString getAlterSqlStatement();

};


class Users : public MetadataCollection<User>
{
protected:
virtual void loadChildren();
public:
Users(DatabasePtr database);

virtual void load(ProgressIndicator* progressIndicator) {};
virtual void load(ProgressIndicator* ) {};

virtual void acceptVisitor(MetadataItemVisitor* visitor);
virtual const wxString getTypeName() const;

};

class Users20 : public Users
{
public:
Users20(DatabasePtr database);
virtual void load(ProgressIndicator* progressIndicator);

virtual ItemType newItem(const wxString & name) {
ItemType item(new User20(getDatabase(), name));
return item;
}

};

class Users30 : public Users
{
public:
Users30(DatabasePtr database);
virtual void load(ProgressIndicator* progressIndicator);

virtual ItemType newItem(const wxString& name) {
ItemType item(new User30(getDatabase(), name));
return item;
}
};




#endif
#endif // FR_USER_H
3 changes: 3 additions & 0 deletions src/metadata/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
#include "metadata/table.h"
#include "metadata/trigger.h"
#include "metadata/view.h"
#include "metadata/User.h"
#include "metadata/FB20/User20.h"
#include "metadata/FB30/User30.h"

#include "sql/SqlStatement.h"
#include "sql/SqlTokenizer.h"
Expand Down

0 comments on commit cfc289c

Please sign in to comment.