Created data sructures for user and permissions support

print
Zdenek Jonak 9 years ago
parent 6bc7fd8762
commit 2fc1090ed3

@ -15,7 +15,9 @@ SOURCES += \
data/user.cpp \
context.cpp \
imetadataplugin.cpp \
transaction.cpp
transaction.cpp \
data/role.cpp \
data/permission.cpp
HEADERS += core.h\
core_global.h \
@ -26,13 +28,15 @@ HEADERS += core.h\
imetadataplugin.h \
autotablemodel.h \
autoform.h \
transaction.h
transaction.h \
data/role.h \
data/permission.h
unix {
target.path = /usr/lib
INSTALLS += target
}
ODB_FILES = core/data/user.h
ODB_FILES = core/data/user.h core/data/role.h core/data/permission.h
H_DIR = $$PWD/data/*.h
include(../odb.pri)

@ -0,0 +1,76 @@
#include "permission.h"
Permission::Permission(QObject *parent) :
QObject(parent)
{
}
int Permission::id() const
{
return m_id;
}
void Permission::setId(int id)
{
m_id = id;
}
QString Permission::pluginId() const
{
return m_pluginId;
}
void Permission::setPluginId(const QString &pluginId)
{
m_pluginId = pluginId;
}
QString Permission::permissionName() const
{
return m_permissionName;
}
void Permission::setPermissionName(const QString &permissionName)
{
m_permissionName = permissionName;
}
QDateTime Permission::lastModDate() const
{
return m_lastModDate;
}
void Permission::setLastModDate(const QDateTime &lastModDate)
{
m_lastModDate = lastModDate;
}
QDateTime Permission::createDate() const
{
return m_createDate;
}
void Permission::setCreateDate(const QDateTime &createDate)
{
m_createDate = createDate;
}
bool Permission::active() const
{
return m_active;
}
void Permission::setActive(bool active)
{
m_active = active;
}
QList<QWeakPointer<Role> > Permission::listRoles() const
{
return m_listRoles;
}
void Permission::setListRoles(const QList<QWeakPointer<Role> > &listRoles)
{
m_listRoles = listRoles;
}

@ -0,0 +1,62 @@
#ifndef PERMISSION_H
#define PERMISSION_H
#include <QObject>
#include "role.h"
#include <QSharedPointer>
#include <QList>
#include <QWeakPointer>
#include <QDateTime>
#include <odb/core.hxx>
class Role;
#pragma db object
class Permission : public QObject
{
Q_OBJECT
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
Q_PROPERTY(QString permissionName READ permissionName WRITE setPermissionName)
Q_PROPERTY(QDateTime lastModDate READ lastModDate WRITE setLastModDate)
Q_PROPERTY(QDateTime createDate READ createDate WRITE setCreateDate)
Q_PROPERTY(bool active READ active WRITE setActive)
public:
explicit Permission(QObject *parent = 0);
int id() const;
void setId(int id);
QString pluginId() const;
void setPluginId(const QString &pluginId);
QString permissionName() const;
void setPermissionName(const QString &permissionName);
QDateTime lastModDate() const;
void setLastModDate(const QDateTime &lastModDate);
QDateTime createDate() const;
void setCreateDate(const QDateTime &createDate);
bool active() const;
void setActive(bool active);
QList<QWeakPointer<Role> > listRoles() const;
void setListRoles(const QList<QWeakPointer<Role> > &listRoles);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString m_pluginId;
QString m_permissionName;
QDateTime m_lastModDate;
QDateTime m_createDate;
bool m_active;
#pragma db value_not_null inverse(m_listPermissions)
QList<QWeakPointer<Role> > m_listRoles;
};
#endif // PERMISSION_H

@ -0,0 +1,76 @@
#include "role.h"
Role::Role(QObject *parent) :
QObject(parent)
{
}
int Role::id() const
{
return m_id;
}
void Role::setId(int id)
{
m_id = id;
}
QString Role::name() const
{
return m_name;
}
void Role::setName(const QString &name)
{
m_name = name;
}
QDateTime Role::lastModDate() const
{
return m_lastModDate;
}
void Role::setLastModDate(const QDateTime &lastModDate)
{
m_lastModDate = lastModDate;
}
QDateTime Role::createDate() const
{
return m_createDate;
}
void Role::setCreateDate(const QDateTime &createDate)
{
m_createDate = createDate;
}
bool Role::active() const
{
return m_active;
}
void Role::setActive(bool active)
{
m_active = active;
}
QList<QWeakPointer<User> > Role::listUsers() const
{
return m_listUsers;
}
void Role::setListUsers(const QList<QWeakPointer<User> > &listUsers)
{
m_listUsers = listUsers;
}
QList<QSharedPointer<Permission> > Role::listPermissions() const
{
return m_listPermissions;
}
void Role::setListPermissions(const QList<QSharedPointer<Permission> > &listPermissions)
{
m_listPermissions = listPermissions;
}

@ -0,0 +1,66 @@
#ifndef ROLE_H
#define ROLE_H
#include <QObject>
#include "user.h"
#include "permission.h"
#include <QSharedPointer>
#include <QList>
#include <QWeakPointer>
#include <QDateTime>
#include <odb/core.hxx>
class Permission;
class User;
#pragma db object
class Role : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QDateTime lastModDate READ lastModDate WRITE setLastModDate)
Q_PROPERTY(QDateTime createDate READ createDate WRITE setCreateDate)
Q_PROPERTY(bool active READ active WRITE setActive)
public:
explicit Role(QObject *parent = 0);
int id() const;
void setId(int id);
QString name() const;
void setName(const QString &name);
QDateTime lastModDate() const;
void setLastModDate(const QDateTime &lastModDate);
QDateTime createDate() const;
void setCreateDate(const QDateTime &createDate);
bool active() const;
void setActive(bool active);
QList<QWeakPointer<User> > listUsers() const;
void setListUsers(const QList<QWeakPointer<User> > &listUsers);
QList<QSharedPointer<Permission> > listPermissions() const;
void setListPermissions(const QList<QSharedPointer<Permission> > &listPermissions);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString m_name;
QDateTime m_lastModDate;
QDateTime m_createDate;
bool m_active;
#pragma db value_not_null inverse(m_listRoles)
QList<QWeakPointer<User> > m_listUsers;
#pragma db value_not_null unordered
QList<QSharedPointer<Permission> > m_listPermissions;
};
#endif // ROLE_H

@ -3,36 +3,97 @@
User::User()
{
}
int User::id() const
{
return m_id;
}
void User::setId(int id)
{
m_id = id;
}
QList<QSharedPointer<Role> > User::listRoles() const
{
return m_listRoles;
}
int User::getId() const
void User::setListRoles(const QList<QSharedPointer<Role> > &listRoles)
{
return id;
m_listRoles = listRoles;
}
void User::setId(int value)
QString User::login() const
{
id = value;
return m_login;
}
QString User::getLogin() const
void User::setLogin(const QString &login)
{
return login;
m_login = login;
}
void User::setLogin(const QString &value)
QString User::password() const
{
login = value;
return m_password;
}
QString User::getPassword() const
void User::setPassword(const QString &password)
{
return password;
m_password = password;
}
void User::setPassword(const QString &value)
QString User::name() const
{
return m_name;
}
void User::setName(const QString &name)
{
m_name = name;
}
QDateTime User::lastModDate() const
{
return m_lastModDate;
}
void User::setLastModDate(const QDateTime &lastModDate)
{
m_lastModDate = lastModDate;
}
QDateTime User::createDate() const
{
return m_createDate;
}
void User::setCreateDate(const QDateTime &createDate)
{
password = value;
m_createDate = createDate;
}
bool User::active() const
{
return m_active;
}
void User::setActive(bool active)
{
m_active = active;
}
bool User::isAdmin() const
{
return m_isAdmin;
}
void User::setIsAdmin(bool isAdmin)
{
m_isAdmin = isAdmin;
}

@ -3,32 +3,73 @@
#include <QObject>
#include <QString>
#include "role.h"
#include <QSharedPointer>
#include <QList>
#include <QDateTime>
#include <odb/core.hxx>
class Role;
#pragma db object
class User : public QObject
{
Q_OBJECT
Q_PROPERTY(QString login READ login WRITE setLogin)
Q_PROPERTY(QString password READ password WRITE setPassword)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QDateTime lastModDate READ lastModDate WRITE setLastModDate)
Q_PROPERTY(QDateTime createDate READ createDate WRITE setCreateDate)
Q_PROPERTY(bool active READ active WRITE setActive)
Q_PROPERTY(bool isAdmin READ isAdmin WRITE setIsAdmin)
public:
User();
int getId() const;
void setId(int value);
QString getLogin() const;
void setLogin(const QString &value);
int id() const;
void setId(int id);
QString login() const;
void setLogin(const QString &login);
QString password() const;
void setPassword(const QString &password);
QString name() const;
void setName(const QString &name);
QDateTime lastModDate() const;
void setLastModDate(const QDateTime &lastModDate);
QDateTime createDate() const;
void setCreateDate(const QDateTime &createDate);
bool active() const;
void setActive(bool active);
bool isAdmin() const;
void setIsAdmin(bool isAdmin);
QList<QSharedPointer<Role> > listRoles() const;
void setListRoles(const QList<QSharedPointer<Role> > &listRoles);
QString getPassword() const;
void setPassword(const QString &value);
private:
friend class odb::access;
#pragma db id auto
int id;
QString login;
QString password;
int m_id;
QString m_login;
QString m_password;
QString m_name;
QDateTime m_lastModDate;
QDateTime m_createDate;
bool m_active;
bool m_isAdmin;
#pragma db value_not_null unordered
QList<QSharedPointer<Role> > m_listRoles;
};
#endif // USER_H

Loading…
Cancel
Save