GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Dbo/Jobs/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*/
13namespace 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*/
28template<> struct Wt::Dbo::dbo_traits< GCW::Dbo::Jobs::Item >
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
37template<> 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*/
43namespace 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*/
73class 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,
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
Item(const std::string &_guid)
ctor with guid
auto guid() const -> const std::string &
GUID.
auto persist(Action &action) -> void
void id(Action &action, V &value, const std::string &name="id", int size=-1)
void field(Action &action, V &value, const std::string &name, int size=-1)
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:18
static auto surrogateIdField() -> const char *
static auto versionField() -> const char *