8 #ifndef DB_META_TABLE_H
9 #define DB_META_TABLE_H
32 for (IRowBaseVec::const_iterator rowIt = i_rowVec.begin(); rowIt != i_rowVec.end(); ++rowIt) {
33 vec.push_back( *
dynamic_cast<TRow *
>(rowIt->get()) );
43 typedef function<bool(
const TRow & i_dbRow)>
RowEqual;
54 IRowBaseVec::difference_type
rowCount(
void)
const {
return rowsCRef().size(); }
57 vector<TRow>
rows(
void)
const
60 for (IRowBaseVec::const_iterator rowIt = rowsCRef().cbegin(); rowIt != rowsCRef().cend(); ++rowIt) {
61 vec.push_back(*
dynamic_cast<TRow *
>(rowIt->get()));
69 return dynamic_cast<TRow *
>(!rowsCRef().empty() ? rowsCRef()[0].get() :
nullptr);
76 for (IRowBaseVec::const_iterator rowIt = rowsCRef().cbegin(); rowIt != rowsCRef().cend(); ++rowIt) {
77 if (i_cmp(*
dynamic_cast<TRow *
>(rowIt->get()))) vec.push_back(*
dynamic_cast<TRow *
>(rowIt->get()));
86 const TRow *
byIndex(IRowBaseVec::difference_type i_index)
const
88 return (0 <= i_index && i_index < rowCount()) ?
dynamic_cast<TRow *
>(rowsCRef()[i_index].get()) :
nullptr;
92 IRowBaseVec::difference_type
indexOf(
RowEqual i_cmp, IRowBaseVec::difference_type i_startPos = 0)
const
94 if (i_startPos >= 0) {
95 for (IRowBaseVec::size_type pos = i_startPos; pos < rowsCRef().size(); pos++) {
96 if (i_cmp(*
dynamic_cast<TRow *
>(rowsCRef()[pos].get())))
return pos;
105 IRowBaseVec::size_type nCount = 0;
106 for (IRowBaseVec::const_iterator rowIt = rowsCRef().cbegin(); rowIt != rowsCRef().cend(); ++rowIt) {
107 if (i_cmp(*
dynamic_cast<TRow *
>(rowIt->get()))) nCount++;
116 if (i_dbExec ==
nullptr)
throw DbException(
"invalid (NULL) database connection");
119 stable_sort(vec.begin(), vec.end(), TRow::keyLess);
126 IRowBaseVec::const_iterator rowIt = lower_bound(rowsCRef().cbegin(), rowsCRef().cend(), i_row, TRow::keyLess);
127 return dynamic_cast<TRow *
>((rowIt != rowsCRef().cend() && TRow::keyEqual(*rowIt, i_row)) ? rowIt->get() :
nullptr);
183 static IModelDicTable * create(
IDbExec * i_dbExec,
const char * i_name =
nullptr,
const char * i_digest =
nullptr);
238 virtual const ModelWordRow *
byKey(
int i_modelId,
int i_langId,
const string & i_code)
const = 0;
308 virtual vector<TypeEnumLstRow>
byModelId(
int i_modelId)
const = 0;
311 virtual vector<TypeEnumLstRow>
byModelIdTypeId(
int i_modelId,
int i_typeId)
const = 0;
362 virtual vector<ParamDicRow>
byModelId(
int i_modelId)
const = 0;
390 virtual vector<ParamImportRow>
byModelId(
int i_modelId)
const = 0;
486 virtual vector<TableDicRow>
byModelId(
int i_modelId)
const = 0;
580 static ITableAccTable * create(
IDbExec * i_dbExec,
int i_modelId = 0,
bool i_isIncludeDerived =
false);
586 virtual vector<TableAccRow>
byModelId(
int i_modelId)
const = 0;
637 virtual vector<TableExprRow>
byModelId(
int i_modelId)
const = 0;
688 virtual vector<EntityDicRow>
byModelId(
int i_modelId)
const = 0;
787 virtual vector<GroupLstRow>
byModelId(
int i_modelId,
bool i_isParam)
const = 0;
832 virtual const GroupPcRow *
byKey(
int i_modelId,
int i_groupId,
int i_chidPos)
const = 0;
835 virtual vector<GroupPcRow>
byModelId(
int i_modelId)
const = 0;
838 virtual vector<int>
groupLeafs(
int i_modelId,
int i_groupId)
const = 0;
881 virtual vector<ProfileOptionRow>
byName(
const string & i_name)
const = 0;
900 static vector<RunLstRow> select(
IDbExec * i_dbExec,
int i_modelId = 0);
903 static vector<RunLstRow> byKey(
IDbExec * i_dbExec,
int i_runId);
906 static string digestRunValue(
IDbExec * i_dbExec,
int i_modelId,
int i_runId);
909 static string digestRunMeta(
const string & i_modelDigest,
const RunLstRow & i_runRow);
928 virtual bool isExist(
int i_runId,
const char * i_key)
const noexcept = 0;
931 virtual string strValue(
int i_runId,
const char * i_key,
const string & i_default =
"") const noexcept = 0;
934 virtual
bool boolValue(
int i_runId, const
char * i_key) const noexcept = 0;
942 virtual
int boolValueToInt(
int i_runId, const
char * i_key) const noexcept = 0;
945 virtual
int intValue(
int i_runId, const
char * i_key,
int i_default) const noexcept = 0;
948 virtual
long long longValue(
int i_runId, const
char * i_key,
long long i_default) const noexcept = 0;
951 virtual
double doubleValue(
int i_runId, const
char * i_key,
double i_default) const noexcept = 0;
970 static vector<WorksetLstRow> select(
IDbExec * i_dbExec,
int i_modelId = 0);
973 static vector<WorksetLstRow> byKey(
IDbExec * i_dbExec,
int i_setId);
986 static vector<WorksetTxtRow> select(
IDbExec * i_dbExec,
int i_setId,
int i_langId = -1);
989 static vector<WorksetTxtRow> byKey(
IDbExec * i_dbExec,
int i_setId,
int i_langId);
1002 static vector<WorksetParamRow> select(
IDbExec * i_dbExec,
int i_setId = 0);
1005 static vector<WorksetParamRow> byKey(
IDbExec * i_dbExec,
int i_setId,
int i_paramId);
1019 static vector<WorksetParamTxtRow> select(
IDbExec * i_dbExec,
int i_setId = 0,
int i_langId = -1);
1022 static vector<WorksetParamTxtRow> byKey(
IDbExec * i_dbExec,
int i_setId,
int i_paramId,
int i_langId);
1036 static vector<TaskLstRow> select(
IDbExec * i_dbExec,
int i_modelId = 0);
1039 static vector<TaskLstRow> byKey(
IDbExec * i_dbExec,
int i_taskId);
1052 static vector<TaskTxtRow> select(
IDbExec * i_dbExec,
int i_langId = -1);
1055 static vector<TaskTxtRow> byKey(
IDbExec * i_dbExec,
int i_taskId,
int i_langId);
1068 static vector<TaskSetRow> select(
IDbExec * i_dbExec,
int i_taskId = 0);
1071 static vector<TaskSetRow> byKey(
IDbExec * i_dbExec,
int i_taskId,
int i_setId);
1084 static vector<TaskRunLstRow> select(
IDbExec * i_dbExec,
int i_taskId = 0);
1087 static vector<TaskRunLstRow> byKey(
IDbExec * i_dbExec,
int i_taskRunId);
1100 static vector<TaskRunSetRow> select(
IDbExec * i_dbExec,
int i_taskRunId = 0);
1103 static vector<TaskRunSetRow> byKey(
IDbExec * i_dbExec,
int i_taskRunId,
int i_runId);
database connection wrapper to execute sql commands.
Definition: dbExec.h:21
virtual IRowBaseVec selectRowVector(const string &i_sql, const IRowAdapter &i_adapter)=0
select vector of rows, each row created and field values set by row adapter.
row factory and setter interface to select row from database
Definition: dbCommon.h:45
OpenM++ data library: public interface.
openM++ namespace
Definition: log.h:32
OpenmException< 4000, dbUnknownErrorMessage > DbException
db-exception
Definition: dbCommon.h:41
std::unique_ptr< IRowBase > IRowBaseUptr
unique pointer to db row
Definition: omHelper.h:232
std::vector< IRowBaseUptr > IRowBaseVec
db rows: vector of unique pointers to db row
Definition: omHelper.h:235
entity_attr table row.
Definition: dbMetaRow.h:1294
entity_attr_txt table row.
Definition: dbMetaRow.h:1340
entity_dic table row.
Definition: dbMetaRow.h:1200
entity_dic_txt table row.
Definition: dbMetaRow.h:1242
group_lst table row.
Definition: dbMetaRow.h:1396
group_pc table row.
Definition: dbMetaRow.h:1487
group_txt table row.
Definition: dbMetaRow.h:1435
entity_attr table public interface.
Definition: dbMetaTable.h:725
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const EntityAttrRow * byKey(int i_modelId, int i_entityId, int i_attrId) const =0
binary search row by unique key: model id, model entity id, attribute id; return NULL if not found.
virtual vector< EntityAttrRow > byModelIdEntityId(int i_modelId, int i_entityId) const =0
get list of rows by model id and entity id.
entity_attr_txt table public interface.
Definition: dbMetaTable.h:750
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const EntityAttrTxtRow * byKey(int i_modelId, int i_entityId, int i_attrId, int i_langId) const =0
binary search row by unique key: model id, model entity id, attribute id, language id; return NULL if...
entity_dic table public interface.
Definition: dbMetaTable.h:674
virtual vector< EntityDicRow > byModelId(int i_modelId) const =0
get list of rows by model id.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const EntityDicRow * byKey(int i_modelId, int i_entityId) const =0
binary search row by unique key: model id, model entity id, return NULL if not found.
virtual const EntityDicRow * byModelIdName(int i_modelId, const string &i_name) const =0
get first row by model id and entity name or NULL if not found.
entity_dic_txt table public interface.
Definition: dbMetaTable.h:702
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const EntityDicTxtRow * byKey(int i_modelId, int i_entityId, int i_langId) const =0
binary search row by unique key: model id, model entity id, language id; return NULL if not found.
group_lst table public interface.
Definition: dbMetaTable.h:773
virtual const GroupLstRow * byKey(int i_modelId, int i_groupId) const =0
binary search row by primary key: model id and group id, return NULL if not found.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual vector< GroupLstRow > byModelId(int i_modelId, bool i_isParam) const =0
get list of rows by model id and is parameter group flag.
group_pc table public interface.
Definition: dbMetaTable.h:821
virtual vector< GroupPcRow > byModelId(int i_modelId) const =0
get list of rows by model id.
virtual vector< int > groupLeafs(int i_modelId, int i_groupId) const =0
get list of parameter id's or table id's for the group: list of bottom level group members.
virtual const GroupPcRow * byKey(int i_modelId, int i_groupId, int i_chidPos) const =0
binary search row by primary key: model id, group id, child position; return NULL if not found.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
group_txt table public interface.
Definition: dbMetaTable.h:798
virtual const GroupTxtRow * byKey(int i_modelId, int i_groupId, int i_langId) const =0
binary search row by primary key: model id, group id, language id; return NULL if not found.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
lang_lst table public interface.
Definition: dbMetaTable.h:133
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const LangLstRow * byCode(const string &i_code) const =0
get first row by language code or NULL if not found.
virtual const LangLstRow * byKey(int i_langId) const =0
binary search row by primary key: language id, return NULL if not found.
lang_word table public interface.
Definition: dbMetaTable.h:154
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const LangWordRow * byKey(int i_langId, const string &i_code) const =0
binary search row by primary key: language id and word code, return NULL if not found.
model_dic table public interface.
Definition: dbMetaTable.h:175
virtual const ModelDicRow * byKey(int i_modelId) const =0
binary search row by primary key: model id, return NULL if not found.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const ModelDicRow * byNameDigest(const string &i_name, const string &i_digest) const =0
get find first row by model name and digest or NULL if not found.
model_dic_txt table public interface.
Definition: dbMetaTable.h:203
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const ModelDicTxtRow * byKey(int i_modelId, int i_langId) const =0
binary search row by primary key: model id and language, return NULL if not found.
model_word table public interface.
Definition: dbMetaTable.h:226
virtual const ModelWordRow * byKey(int i_modelId, int i_langId, const string &i_code) const =0
binary search row by primary key: model id, language and code, return NULL if not found.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
parameter_dic table public interface.
Definition: dbMetaTable.h:348
virtual const ParamDicRow * byKey(int i_modelId, int i_paramId) const =0
binary search row by unique key: model id and model parameter id, return NULL if not found.
virtual const ParamDicRow * byModelIdName(int i_modelId, const string &i_name) const =0
get first row by model id and parameter name or NULL if not found.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual vector< ParamDicRow > byModelId(int i_modelId) const =0
get list of rows by model id.
parameter_dic_txt table public interface.
Definition: dbMetaTable.h:401
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const ParamDicTxtRow * byKey(int i_modelId, int i_paramId, int i_langId) const =0
binary search row by unique key: model id, model parameter id, language id; return NULL if not found.
parameter_dims table public interface.
Definition: dbMetaTable.h:424
virtual const ParamDimsRow * byKey(int i_modelId, int i_paramId, int i_dimId) const =0
binary search row by unique key: model id, model parameter id, dimension id; return NULL if not found...
virtual vector< ParamDimsRow > byModelIdParamId(int i_modelId, int i_paramId) const =0
get list of rows by model id and parameter id.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
parameter_dims_txt table public interface.
Definition: dbMetaTable.h:449
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const ParamDimsTxtRow * byKey(int i_modelId, int i_paramId, int i_dimId, int i_langId) const =0
binary search row by unique key: model id, model parameter id, dimension id, language id; return NULL...
model_parameter_import table public interface.
Definition: dbMetaTable.h:376
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual vector< ParamImportRow > byModelId(int i_modelId) const =0
get list of rows by model id.
virtual const ParamImportRow * byKey(int i_modelId, int i_paramId) const =0
binary search row by unique key: model id, model parameter id, return NULL if not found.
profile_lst table public interface.
Definition: dbMetaTable.h:849
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const ProfileLstRow * byKey(const string &i_name) const =0
binary search row by primary key: profile name, return NULL if not found.
profile_option table public interface.
Definition: dbMetaTable.h:867
virtual const ProfileOptionRow * byKey(const string &i_name, const string &i_key) const =0
binary search row by primary key: profile name and option key, return NULL if not found.
virtual vector< ProfileOptionRow > byName(const string &i_name) const =0
get list of rows by profile name.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
run_lst table public interface.
Definition: dbMetaTable.h:892
run_option table public interface.
Definition: dbMetaTable.h:914
virtual string strValue(int i_runId, const char *i_key, const string &i_default="") const noexcept=0
return string value by primary key (run id, option key) or default value if not found.
virtual bool isExist(int i_runId, const char *i_key) const noexcept=0
return true if primary key (run id, option key) found.
virtual const RunOptionRow * byKey(int i_runId, const string &i_key) const =0
binary search row by primary key: run id and option key, return NULL if not found.
table_acc table public interface.
Definition: dbMetaTable.h:571
virtual vector< TableAccRow > byModelId(int i_modelId) const =0
get list of rows by model id.
virtual vector< TableAccRow > byModelIdTableId(int i_modelId, int i_tableId) const =0
get list of rows by model id and table id.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const TableAccRow * byKey(int i_modelId, int i_tableId, int i_accId) const =0
binary search row by unique key: model id, model table id, accumulator id; return NULL if not found.
table_acc_txt table public interface.
Definition: dbMetaTable.h:600
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const TableAccTxtRow * byKey(int i_modelId, int i_tableId, int i_accId, int i_langId) const =0
binary search row by unique key: model id, model table id, accumulator id, language id; return NULL i...
table_dic table public interface.
Definition: dbMetaTable.h:472
virtual vector< TableDicRow > byModelId(int i_modelId) const =0
get list of rows by model id.
virtual const TableDicRow * byKey(int i_modelId, int i_tableId) const =0
binary search row by unique key: model id, model table id, return NULL if not found.
virtual const TableDicRow * byModelIdName(int i_modelId, const string &i_name) const =0
get first row by model id and table name or NULL if not found.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
table_dic_txt table public interface.
Definition: dbMetaTable.h:500
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const TableDicTxtRow * byKey(int i_modelId, int i_tableId, int i_langId) const =0
binary search row by unique key: model id, model table id, language id; return NULL if not found.
table_dims table public interface.
Definition: dbMetaTable.h:523
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const TableDimsRow * byKey(int i_modelId, int i_tableId, int i_dimId) const =0
binary search row by unique key: model id, model table id, dimension id; return NULL if not found.
virtual vector< TableDimsRow > byModelIdTableId(int i_modelId, int i_tableId) const =0
get list of rows by model id and table id.
table_dims_txt table public interface.
Definition: dbMetaTable.h:548
virtual const TableDimsTxtRow * byKey(int i_modelId, int i_tableId, int i_dimId, int i_langId) const =0
binary search row by unique key: model id, model table id, dimension id, language id; return NULL if ...
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
table_expr table public interface.
Definition: dbMetaTable.h:623
virtual const TableExprRow * byKey(int i_modelId, int i_tableId, int i_exprId) const =0
binary search row by unique key: model id, model table id, expr id; return NULL if not found.
virtual vector< TableExprRow > byModelId(int i_modelId) const =0
get list of rows by model id.
virtual vector< TableExprRow > byModelIdTableId(int i_modelId, int i_tableId) const =0
get list of rows by model id and table id.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
table_expr_txt table public interface.
Definition: dbMetaTable.h:651
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const TableExprTxtRow * byKey(int i_modelId, int i_tableId, int i_exprId, int i_langId) const =0
binary search row by unique key: model id, model table id, expr id, language id; return NULL if not f...
task_lst table public interface.
Definition: dbMetaTable.h:1028
task_run_lst table public interface.
Definition: dbMetaTable.h:1076
task_run_set table public interface.
Definition: dbMetaTable.h:1092
task_set table public interface.
Definition: dbMetaTable.h:1060
task_txt table public interface.
Definition: dbMetaTable.h:1044
type_dic table public interface.
Definition: dbMetaTable.h:249
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const TypeDicRow * byKey(int i_modelId, int i_typeId) const =0
binary search row by unique key: model id, model type id, return NULL if not found.
type_dic_txt table public interface.
Definition: dbMetaTable.h:271
virtual const TypeDicTxtRow * byKey(int i_modelId, int i_typeId, int i_langId) const =0
binary search row by unique key: model id, model type id, language id; return NULL if not found.
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
type_enum_lst table public interface.
Definition: dbMetaTable.h:294
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const TypeEnumLstRow * byName(int i_modelId, int i_typeId, const char *i_name) const =0
find row by unique key: model id, model type id, enum name.
virtual const TypeEnumLstRow * byKey(int i_modelId, int i_typeId, int i_enumId) const =0
binary search row by unique key: model id, model type id, enum id return NULL if not found.
virtual vector< TypeEnumLstRow > byModelIdTypeId(int i_modelId, int i_typeId) const =0
get list of rows by model id, model type id.
virtual vector< TypeEnumLstRow > byModelId(int i_modelId) const =0
get list of rows by model id.
type_enum_txt table public interface.
Definition: dbMetaTable.h:325
virtual IRowBaseVec & rowsRef(void)=0
get reference to list of all table rows.
virtual const TypeEnumTxtRow * byKey(int i_modelId, int i_typeId, int i_enumId, int i_langId) const =0
binary search row by unique key: model id, model type id, enum id, language id; return NULL if not fo...
workset_lst table public interface.
Definition: dbMetaTable.h:962
workset_parameter table public interface.
Definition: dbMetaTable.h:994
workset_parameter_txt table public interface.
Definition: dbMetaTable.h:1010
workset_txt table public interface.
Definition: dbMetaTable.h:978
lang_lst table row.
Definition: dbMetaRow.h:37
lang_word table row.
Definition: dbMetaRow.h:81
model_dic table row.
Definition: dbMetaRow.h:112
model_dic_txt table row.
Definition: dbMetaRow.h:168
model_word table row.
Definition: dbMetaRow.h:216
parameter_dic join to model_parameter_dic table row.
Definition: dbMetaRow.h:473
parameter_dic_txt join to model_parameter_dic table row.
Definition: dbMetaRow.h:590
parameter_dims join to model_parameter_dic table row.
Definition: dbMetaRow.h:642
parameter_dims_txt join to model_parameter_dic table row.
Definition: dbMetaRow.h:685
parameter_dic join to model_parameter_import table row.
Definition: dbMetaRow.h:547
profile_lst table row.
Definition: dbMetaRow.h:1526
profile_option table row.
Definition: dbMetaRow.h:1547
run_lst table row.
Definition: dbMetaRow.h:1578
run_option table row.
Definition: dbMetaRow.h:1644
table_acc table row.
Definition: dbMetaRow.h:985
table_acc_txt table row.
Definition: dbMetaRow.h:1038
table_dic table row.
Definition: dbMetaRow.h:741
table_dic_txt table row.
Definition: dbMetaRow.h:819
table_dims table row.
Definition: dbMetaRow.h:879
table_dims_txt table row.
Definition: dbMetaRow.h:929
table_expr table row.
Definition: dbMetaRow.h:1094
table_expr_txt table row.
Definition: dbMetaRow.h:1144
type_dic join to model_type_dic table row.
Definition: dbMetaRow.h:264
type_dic_txt join to model_type_dic table row.
Definition: dbMetaRow.h:330
type_enum_lst join to model_type_dic table row.
Definition: dbMetaRow.h:382
type_enum_txt join to model_type_dic table row.
Definition: dbMetaRow.h:417
workset_lst table row.
Definition: dbMetaRow.h:1674