Qore TableMapper Module Reference  1.0
 All Classes Namespaces Functions Variables Groups Pages
TableMapper.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* TableMapper.qm Copyright 2014 Qore Technologies, sro
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 
25 // this module requires Qore 0.8.9 or better
26 
27 // require type definitions everywhere
28 
29 // enable all warnings
30 
31 // requires the Mapper module
32 // requires the SqlUtil module
33 
34 
35 /* Version History
36  * 2014-01-03 v1.0: David Nichols <david@qore.org>
37  + the initial version of the TableMapper module
38 */
39 
91 namespace TableMapper {
95 
96 public:
97  // no public members
98  public :
99 
100 public:
101 
102  private :
105 
108 
109 public:
110 
112 
137 
138 
140 
165 
166 
168  private checkMap();
169 
170 
172  private mapFieldType(string key, hash m, reference v, hash rec);
173 
174 
176  private bool hasMapping(hash fh);
177 
178 
180 
183  private checkMapField(string k, reference fh, hash th);
184 
185 
187 
189  hash validKeys();
190 
191 
193 
195  hash optionKeys();
196 
197 
199 
208 
209 
211 
219  hash insertRow(hash rec);
220 
221 
223  nothing commit();
224 
225 
227  nothing rollback();
228 
229 
231  string getTableName();
232 
233 
236 
237  };
238 
241 
242 public:
243  public :
244 
245 public:
246 
247  private :
250 
253 
255  int cnt = 0;
256 
259 
260 public:
261 
263 
291 
292 
294 
322 
323 
325 
349 
350 
352  hash getValue();
353 
354 
356 
360  bool next();
361 
362 
364  int commitLimit();
365 
366 
368  nothing commit();
369 
370 
372  nothing rollback();
373 
374 
376  string getTableName();
377 
378 
380 
382  int getCount();
383 
384 
386 
388  resetCount();
389 
390  };
391 };
string getTableName()
returns the table name
Qore::AbstractIterator i
int commitLimit()
returns the commit_limit value set in the constructor()
nothing commit()
commits the transaction
string getTableName()
returns the table name
provides a hash iterator based on a InboundTableMapper object and an iterator input source; for each ...
Definition: TableMapper.qm.dox.h:240
private bool hasMapping(hash fh)
returns True if the field has a mapping, False if not
int commit_limit
row commit limit (&lt;= 0 for no commits)
Definition: TableMapper.qm.dox.h:252
hash validKeys()
returns a list of valid field keys for this class (can be overridden in subclasses) ...
bool next()
Moves the current position of the input iterator to the next element; returns False if there are no m...
hash optionKeys()
returns a list of valid constructor options for this class (can be overridden in subclasses) ...
hash insertRowNoCommit(hash rec)
inserts a row into the target table based on a mapped input record; does not commit the transaction ...
private checkMap()
verifies the input map in the constructor
nothing rollback()
rolls back the transaction
hash val
a copy of the last hash value mapped
Definition: TableMapper.qm.dox.h:258
constructor(Qore::AbstractIterator i, SqlUtil::Table table, hash map, *hash opts, int commit_limit=0)
creates the iterator from the arguments passed
resetCount()
resets the internal record count
private checkMapField(string k, reference fh, hash th)
perform per-field pre-processing on the passed map in the constructor
SqlUtil::AbstractTable getTable()
returns the underlying SqlUtil::AbstractTable object
nothing rollback()
rolls back the transaction
int getCount()
returns the internal record count
nothing commit()
commits the transaction
int cnt
row count for commit
Definition: TableMapper.qm.dox.h:255
SqlUtil::AbstractDatabase db
the target Database object in case sequence value need to be acquired
Definition: TableMapper.qm.dox.h:107
TableMapper::InboundTableMapper map
data mapper
Definition: TableMapper.qm.dox.h:249
hash getValue()
returns the current row transformed with the mapper
private constructor()
provides an inbound data mapper to a Table target
Definition: TableMapper.qm.dox.h:94
hash insertRow(hash rec)
inserts a row into the target table based on a mapped input record; commits the transaction ...
hash hash(object obj)
SqlUtil::AbstractTable table
the target table object
Definition: TableMapper.qm.dox.h:104
private mapFieldType(string key, hash m, reference v, hash rec)
performs type handling