GnuCashew ~ GnuCash Enabled Web
GCW
Item.h
Go to the documentation of this file.
1 #line 2 "src/Dbo/Jobs/Item.h"
2 
3 #ifndef __DBO_JOBS_ITEM_H___
4 #define __DBO_JOBS_ITEM_H___
5 
6 #include "../BaseItem.h"
7 #include "Definition.h"
8 
9 /*
10 ** Predefine the Entries class that fixin to come up.
11 **
12 */
13 namespace GCW {
14  namespace Dbo {
15  namespace Jobs {
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::Jobs::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::Jobs::Item > : Wt::Dbo::dbo_traits< GCW::Dbo::Jobs::Item > {};
38 
39 /*
40 ** Now we can start building our class!
41 **
42 */
43 namespace GCW {
44  namespace Dbo {
45  namespace Jobs {
46 
47 /*!
48 ** \brief Jobs Class
49 **
50 **
51 ** \dot
52 ** digraph JobsMap
53 ** {
54 ** JobsItem;
55 ** }
56 ** \enddot
57 **
58 ** \par Native GnuCash Jobs Sqlite Schema
59 ** \code
60 ** CREATE TABLE jobs
61 ** (
62 ** guid text(32) PRIMARY KEY NOT NULL,
63 ** id text(2048) NOT NULL,
64 ** name text(2048) NOT NULL,
65 ** reference text(2048) NOT NULL,
66 ** active integer NOT NULL,
67 ** owner_type integer,
68 ** owner_guid text(32)
69 ** );
70 ** \endcode
71 **
72 */
73 class Item
74 : public GCW::Dbo::BaseItem< Item >
75 {
76  public:
77 
78  /*!
79  ** \brief ctor
80  */
81  Item(){}
82 
83  /*!
84  ** \brief ctor with guid
85  */
86  Item( const std::string & _guid ): m_guid( _guid ){}
87 
88  /*!
89  ** \brief GUID
90  **
91  ** Return account 'guid' value - the primary key for the account
92  */
93  auto guid() const-> const std::string & { return m_guid; }
94 
95  template< class Action > auto
96  persist( Action & action )-> void
97  {
98  Wt::Dbo::id ( action, m_guid , GCW::Dbo::Jobs::Field::guid , 32 ); // text(32) PRIMARY KEY NOT NULL,
99  Wt::Dbo::field( action, m_id , GCW::Dbo::Jobs::Field::id , 2048 ); // text(2048) NOT NULL,
100  Wt::Dbo::field( action, m_name , GCW::Dbo::Jobs::Field::name , 2048 ); // text(2048) NOT NULL,
101  Wt::Dbo::field( action, m_reference , GCW::Dbo::Jobs::Field::reference , 2048 ); // text(2048) NOT NULL,
102  Wt::Dbo::field( action, m_active , GCW::Dbo::Jobs::Field::active ); // integer NOT NULL,
103  Wt::Dbo::field( action, m_owner_type , GCW::Dbo::Jobs::Field::owner_type ); // integer,
104  Wt::Dbo::field( action, m_owner_guid , GCW::Dbo::Jobs::Field::owner_guid , 32 ); // text(32),
105 
106  } // endpersist( Action & action )-> void
107 
108  private:
109 
110  std::string m_guid ; // text(32) PRIMARY KEY NOT NULL,
111  std::string m_id ; // text(2048) NOT NULL,
112  std::string m_name ; // text(2048) NOT NULL,
113  std::string m_reference ; // text(2048) NOT NULL,
114  int m_active ; // integer NOT NULL,
115  int m_owner_type ; // integer,
116  std::string m_owner_guid ; // text(32),
117 
118 }; // endclass Item
119 
120  } // endnamespace Jobs {
121  } // endnamespace Dbo {
122 } // endnamespace GCW {
123 
124 #endif // __DBO_JOBS_ITEM_H___
125 
Jobs Class.
Definition: Item.h:75
Item(const std::string &_guid)
ctor with guid
Definition: Item.h:86
auto guid() const -> const std::string &
GUID.
Definition: Item.h:93
auto persist(Action &action) -> void
Definition: Item.h:96
std::string m_reference
Definition: Item.h:113
std::string m_owner_guid
Definition: Item.h:116
std::string m_guid
Definition: Item.h:110
std::string m_name
Definition: Item.h:112
std::string m_id
Definition: Item.h:111
const Wt::WFormModel::Field action
Definition: Entries.cpp:14
const Wt::WFormModel::Field id
Definition: Definition.h:17
const Wt::WFormModel::Field guid
Definition: Jobs.cpp:10
const Wt::WFormModel::Field owner_type
Definition: Jobs.cpp:15
const Wt::WFormModel::Field reference
Definition: Jobs.cpp:13
const Wt::WFormModel::Field active
Definition: Jobs.cpp:14
const Wt::WFormModel::Field owner_guid
Definition: Jobs.cpp:16
const Wt::WFormModel::Field name
Definition: Jobs.cpp:12
const Wt::WFormModel::Field id
Definition: Jobs.cpp:11
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
static auto invalidId() -> IdType
Definition: Item.h:32