GnuCashew ~ GnuCash Enabled Web
GCW
Item.h
Go to the documentation of this file.
1 #line 2 "src/Dbo/Employees/Item.h"
2 
3 #ifndef __DBO_EMPLOYEES_ITEM_H___
4 #define __DBO_EMPLOYEES_ITEM_H___
5 
6 #include "../BaseItem.h"
7 #include "Definition.h"
8 
9 /*
10 ** Predefine the Account class that fixin to come up.
11 **
12 */
13 namespace GCW {
14  namespace Dbo {
15  namespace Employees {
16  class Item;
17  }
18  }
19 }
20 
21 /*
22 ** Define these dbo_traits to prevent the system from
23 ** automatically generating an ID field or a VERSION
24 ** field, and instead substitute the guid field
25 ** as the primary key.
26 **
27 */
28 template<> struct Wt::Dbo::dbo_traits< GCW::Dbo::Employees::Item >
29 : public Wt::Dbo::dbo_default_traits
30 {
31  using IdType = std::string;
32  static auto invalidId()-> IdType { return std::string(); }
33  static auto surrogateIdField()-> const char * { return nullptr; }
34  static auto versionField()-> const char * { return nullptr; }
35 };
36 
37 template<> struct Wt::Dbo::dbo_traits< const GCW::Dbo::Employees::Item > : Wt::Dbo::dbo_traits< GCW::Dbo::Employees::Item > {};
38 
39 /*
40 ** Now we can start building our class!
41 **
42 */
43 namespace GCW {
44  namespace Dbo {
45  namespace Employees {
46 
47 /*!
48 ** \brief Employee Item Class
49 **
50 ** This class represents an 'employee' within gnucash. This is a Dbo object
51 ** so this class is used as the interface between the gnucashew application
52 ** and the back-end database.
53 **
54 ** \dot
55 ** digraph EmployeeMap
56 ** {
57 ** EmployeesItem;
58 ** }
59 ** \enddot
60 **
61 ** \par Native GnuCash Employee Sqlite Schema
62 ** \code
63 ** CREATE TABLE employees
64 ** (
65 ** guid text(32) PRIMARY KEY NOT NULL,
66 ** username text(2048) NOT NULL,
67 ** id text(2048) NOT NULL,
68 ** language text(2048) NOT NULL,
69 ** acl text(2048) NOT NULL,
70 ** active integer NOT NULL,
71 ** currency text(32) NOT NULL,
72 ** ccard_guid text(32),
73 ** workday_num bigint NOT NULL,
74 ** workday_denom bigint NOT NULL,
75 ** rate_num bigint NOT NULL,
76 ** rate_denom bigint NOT NULL,
77 ** addr_name text(1024),
78 ** addr_addr1 text(1024),
79 ** addr_addr2 text(1024),
80 ** addr_addr3 text(1024),
81 ** addr_addr4 text(1024),
82 ** addr_phone text(128),
83 ** addr_fax text(128),
84 ** addr_email text(256)
85 ** );
86 ** \endcode
87 **
88 */
89 class Item
90 : public GCW::Dbo::BaseItem< Item >
91 {
92  public:
93 
94  /*!
95  ** \brief ctor
96  */
97  Item(){}
98 
99  /*!
100  ** \brief ctor with guid.
101  */
102  Item( const std::string & _guid ): m_guid( _guid ){}
103 
104  /*!
105  ** \brief GUID
106  **
107  ** Return account 'guid' value - the primary key for the account
108  */
109  auto guid() const-> const std::string & { return m_guid; }
110 
111  /*!
112  ** \brief persist the data
113  **
114  ** This connects this object to the back-end database.
115  */
116  template< class Action > void persist( Action & action )
117  {
118  Wt::Dbo::id ( action, m_guid , GCW::Dbo::Employees::Field::guid , 32 ); // text(32) PRIMARY KEY NOT NULL,
119  Wt::Dbo::field( action, m_username , GCW::Dbo::Employees::Field::username , 2048 ); // text(2048) NOT NULL,
120  Wt::Dbo::field( action, m_id , GCW::Dbo::Employees::Field::id , 2048 ); // text(2048) NOT NULL,
121  Wt::Dbo::field( action, m_language , GCW::Dbo::Employees::Field::language , 2048 ); // text(2048) NOT NULL,
122  Wt::Dbo::field( action, m_acl , GCW::Dbo::Employees::Field::acl , 2048 ); // text(2048) NOT NULL,
123  Wt::Dbo::field( action, m_active , GCW::Dbo::Employees::Field::active ); // integer NOT NULL,
124  Wt::Dbo::field( action, m_currency , GCW::Dbo::Employees::Field::currency , 32 ); // text(32) NOT NULL,
125  Wt::Dbo::field( action, m_ccard_guid , GCW::Dbo::Employees::Field::ccard_guid , 32 ); // text(32),
126  Wt::Dbo::field( action, m_workday_num , GCW::Dbo::Employees::Field::workday_num ); // bigint NOT NULL,
127  Wt::Dbo::field( action, m_workday_denom , GCW::Dbo::Employees::Field::workday_denom ); // bigint NOT NULL,
128  Wt::Dbo::field( action, m_rate_num , GCW::Dbo::Employees::Field::rate_num ); // bigint NOT NULL,
129  Wt::Dbo::field( action, m_rate_denom , GCW::Dbo::Employees::Field::rate_denom ); // bigint NOT NULL,
130  Wt::Dbo::field( action, m_addr_name , GCW::Dbo::Employees::Field::addr_name , 1024 ); // text(1024),
131  Wt::Dbo::field( action, m_addr_addr1 , GCW::Dbo::Employees::Field::addr_addr1 , 1024 ); // text(1024),
132  Wt::Dbo::field( action, m_addr_addr2 , GCW::Dbo::Employees::Field::addr_addr2 , 1024 ); // text(1024),
133  Wt::Dbo::field( action, m_addr_addr3 , GCW::Dbo::Employees::Field::addr_addr3 , 1024 ); // text(1024),
134  Wt::Dbo::field( action, m_addr_addr4 , GCW::Dbo::Employees::Field::addr_addr4 , 1024 ); // text(1024),
135  Wt::Dbo::field( action, m_addr_phone , GCW::Dbo::Employees::Field::addr_phone , 128 ); // text(128),
136  Wt::Dbo::field( action, m_addr_fax , GCW::Dbo::Employees::Field::addr_fax , 128 ); // text(128),
137  Wt::Dbo::field( action, m_addr_email , GCW::Dbo::Employees::Field::addr_email , 256 ); // text(256)
138 
139  }
140 
141  private:
142 
143  std::string m_guid ; // text(32) PRIMARY KEY NOT NULL,
144  std::string m_username ; // text(2048) NOT NULL,
145  std::string m_id ; // text(2048) NOT NULL,
146  std::string m_language ; // text(2048) NOT NULL,
147  std::string m_acl ; // text(2048) NOT NULL,
148  int m_active ; // integer NOT NULL,
149  std::string m_currency ; // text(32) NOT NULL,
150  std::string m_ccard_guid ; // text(32),
151  int m_workday_num ; // bigint NOT NULL,
152  int m_workday_denom ; // bigint NOT NULL,
153  int m_rate_num ; // bigint NOT NULL,
154  int m_rate_denom ; // bigint NOT NULL,
155  std::string m_addr_name ; // text(1024),
156  std::string m_addr_addr1 ; // text(1024),
157  std::string m_addr_addr2 ; // text(1024),
158  std::string m_addr_addr3 ; // text(1024),
159  std::string m_addr_addr4 ; // text(1024),
160  std::string m_addr_phone ; // text(128),
161  std::string m_addr_fax ; // text(128),
162  std::string m_addr_email ; // text(256)
163 
164 }; // endclass Item
165 
166  } // endnamespace Employees {
167  } // endnamespace Dbo {
168 } // endnamespace GCW {
169 
170 #endif // __EMPLOYEES_H___
171 
Employee Item Class.
Definition: Item.h:91
auto guid() const -> const std::string &
GUID.
Definition: Item.h:109
std::string m_username
Definition: Item.h:144
std::string m_ccard_guid
Definition: Item.h:150
std::string m_addr_phone
Definition: Item.h:160
std::string m_guid
Definition: Item.h:143
std::string m_addr_name
Definition: Item.h:155
std::string m_acl
Definition: Item.h:147
std::string m_addr_addr3
Definition: Item.h:158
std::string m_addr_email
Definition: Item.h:162
std::string m_id
Definition: Item.h:145
std::string m_addr_fax
Definition: Item.h:161
std::string m_addr_addr1
Definition: Item.h:156
Item(const std::string &_guid)
ctor with guid.
Definition: Item.h:102
std::string m_language
Definition: Item.h:146
std::string m_addr_addr2
Definition: Item.h:157
std::string m_addr_addr4
Definition: Item.h:159
std::string m_currency
Definition: Item.h:149
void persist(Action &action)
persist the data
Definition: Item.h:116
const Wt::WFormModel::Field addr_addr2
Definition: Employees.cpp:23
const Wt::WFormModel::Field workday_denom
Definition: Employees.cpp:18
const Wt::WFormModel::Field addr_name
Definition: Employees.cpp:21
const Wt::WFormModel::Field acl
Definition: Employees.cpp:13
const Wt::WFormModel::Field guid
Definition: Employees.cpp:9
const Wt::WFormModel::Field language
Definition: Employees.cpp:12
const Wt::WFormModel::Field rate_num
Definition: Employees.cpp:19
const Wt::WFormModel::Field addr_addr3
Definition: Employees.cpp:24
const Wt::WFormModel::Field username
Definition: Employees.cpp:10
const Wt::WFormModel::Field addr_email
Definition: Employees.cpp:28
const Wt::WFormModel::Field rate_denom
Definition: Employees.cpp:20
const Wt::WFormModel::Field addr_addr1
Definition: Employees.cpp:22
const Wt::WFormModel::Field ccard_guid
Definition: Employees.cpp:16
const Wt::WFormModel::Field currency
Definition: Employees.cpp:15
const Wt::WFormModel::Field workday_num
Definition: Employees.cpp:17
const Wt::WFormModel::Field id
Definition: Employees.cpp:11
const Wt::WFormModel::Field addr_addr4
Definition: Employees.cpp:25
const Wt::WFormModel::Field addr_phone
Definition: Employees.cpp:26
const Wt::WFormModel::Field active
Definition: Employees.cpp:14
const Wt::WFormModel::Field addr_fax
Definition: Employees.cpp:27
const Wt::WFormModel::Field action
Definition: Entries.cpp:14
const Wt::WFormModel::Field id
Definition: Definition.h:17
Definition: App.h:17
Definition: guid.cpp:397
static auto surrogateIdField() -> const char *
Definition: Item.h:33
static auto versionField() -> const char *
Definition: Item.h:34