Qore TableMapper Module Reference  1.1
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.11 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 
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  constructor(SqlUtil::Table table, hash map, *hash opts);
138 
139 
141 
166  constructor(SqlUtil::AbstractTable table, hash map, *hash opts);
167 
168 
170  private checkMap();
171 
172 
174  private mapFieldType(string key, hash m, reference v, hash rec);
175 
176 
178  private bool hasMapping(hash fh);
179 
180 
182 
185  private checkMapField(string k, reference fh, hash th);
186 
187 
189 
191  hash validKeys();
192 
193 
195 
197  hash optionKeys();
198 
199 
201 
210 
211 
213 
221  hash insertRow(hash rec);
222 
223 
225  nothing commit();
226 
227 
229  nothing rollback();
230 
231 
233  string getTableName();
234 
235 
238 
239 
241  AbstractDatasource getDatasource();
242 
243  };
244 
247 
248 public:
249  public :
250 
251 public:
252 
253  private :
256 
259 
261  int cnt = 0;
262 
265 
266 public:
267 
269 
297  constructor(Qore::AbstractIterator i, SqlUtil::Table table, hash map, *hash opts, int commit_limit = 0);
298 
299 
301 
329  constructor(Qore::AbstractIterator i, SqlUtil::AbstractTable table, hash map, *hash opts, int commit_limit = 0);
330 
331 
333 
357 
358 
360  hash getValue();
361 
362 
364 
368  bool next();
369 
370 
372  int commitLimit();
373 
374 
376  nothing commit();
377 
378 
380  nothing rollback();
381 
382 
384  string getTableName();
385 
386 
388 
390  int getCount();
391 
392 
394 
396  resetCount();
397 
398 
400  AbstractDatasource getDatasource();
401 
402  };
403 };
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
AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
provides a hash iterator based on a InboundTableMapper object and an iterator input source; for each ...
Definition: TableMapper.qm.dox.h:246
private bool hasMapping(hash fh)
returns True if the field has a mapping, False if not
int commit_limit
row commit limit (<= 0 for no commits)
Definition: TableMapper.qm.dox.h:258
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:264
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:261
SqlUtil::AbstractDatabase db
the target Database object in case sequence value need to be acquired
Definition: TableMapper.qm.dox.h:107
hash getValue()
returns the current row transformed with the mapper
the TableMapper namespace contains all the definitions in the TableMapper module
Definition: TableMapper.qm.dox.h:92
private constructor()
provides an inbound data mapper to a Table target
Definition: TableMapper.qm.dox.h:94
AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
hash insertRow(hash rec)
inserts a row into the target table based on a mapped input record; commits the transaction ...
TableMapper::InboundTableMapper mapc
data mapper
Definition: TableMapper.qm.dox.h:255
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