Documentation ¶
Overview ¶
Package db to support openM++ model database operations.
Database may contain multiple openM++ models and consists of two parts: (a) metadata to describe models: data types, input parameters, output tables, etc. (b) actual modeling data itself: database tables for input parameters and output tables.
To run the model we need to have a set of model input parameters, called "input working set" or "workset". User can "open" workset in read-write mode and modify model input parameters. To use that set as model run input user must "close" it by marking workset as read-only. After model run user can again open workset as read-write and continue input editing. Each workset has a name (unique inside of the model) and set id (database unique positive int).
Result of model run stored in output tables and also include copy of all input parameters used to run the model. That pair of input and output data called "run" and identified by run id (database unique positive int).
Index ¶
- Constants
- func CheckOpenmppSchemaVersion(dbConn *sql.DB) error
- func CopyParameterFromRun(dbConn *sql.DB, modelDef *ModelMeta, ws *WorksetRow, paramName string, ...) error
- func CopyParameterFromWorkset(dbConn *sql.DB, modelDef *ModelMeta, dstWs *WorksetRow, paramName string, ...) error
- func DeleteModel(dbConn *sql.DB, modelId int) error
- func DeleteProfile(dbConn *sql.DB, name string) error
- func DeleteProfileOption(dbConn *sql.DB, name, key string) error
- func DeleteRun(dbConn *sql.DB, runId int) error
- func DeleteTask(dbConn *sql.DB, taskId int) error
- func DeleteWorkset(dbConn *sql.DB, setId int) error
- func DeleteWorksetAllParameters(dbConn *sql.DB, setId int) error
- func DeleteWorksetParameter(dbConn *sql.DB, modelId int, setName, paramName string) (int, error)
- func GetModelId(dbConn *sql.DB, name, digest string) (bool, int, error)
- func GetModelRunOptions(dbConn *sql.DB, modelId int) (map[int]map[string]string, error)
- func GetProfileList(dbConn *sql.DB) ([]string, error)
- func GetRunListText(dbConn *sql.DB, modelId int, langCode string) ([]RunRow, []RunTxtRow, error)
- func GetRunOptions(dbConn *sql.DB, runId int) (map[string]string, error)
- func GetTaskListText(dbConn *sql.DB, modelId int, langCode string) ([]TaskRow, []TaskTxtRow, error)
- func GetTaskSetIds(dbConn *sql.DB, taskId int) ([]int, error)
- func GetWorksetListText(dbConn *sql.DB, modelId int, langCode string) ([]WorksetRow, []WorksetTxtRow, error)
- func GetWorksetParam(dbConn *sql.DB, setId int, paramHid int) (int, int, error)
- func GetWorksetParamList(dbConn *sql.DB, setId int) ([]int, []int, []int, error)
- func GetWorksetRunIds(dbConn *sql.DB, setId int) ([]int, error)
- func IfEmptyMakeDefault(modelName, modelSqlitePath, dbConnStr, dbDriver string) (string, string)
- func IfEmptyMakeDefaultReadOnly(modelName, modelSqlitePath, dbConnStr, dbDriver string) (string, string)
- func IsRunCompleted(status string) bool
- func IsUnsafeQuote(c rune) bool
- func MakeSqliteDefault(modelSqlitePath string) string
- func MakeSqliteDefaultReadOnly(modelSqlitePath string) string
- func OpenmppSchemaVersion(dbConn *sql.DB) (int, error)
- func RenameRun(dbConn *sql.DB, runId int, newRunName string) (bool, error)
- func RenameTask(dbConn *sql.DB, taskId int, newTaskName string) (bool, error)
- func RenameWorkset(dbConn *sql.DB, setId int, newSetName string, isAnyReadonly bool) (bool, error)
- func SelectFirst(dbConn *sql.DB, query string, cvt func(row *sql.Row) error) error
- func SelectRows(dbConn *sql.DB, query string, cvt func(rows *sql.Rows) error) error
- func SelectRowsTo(dbConn *sql.DB, query string, cvt func(rows *sql.Rows) (bool, error)) error
- func ToQuoted(src string) string
- func TrxSelectFirst(dbTrx *sql.Tx, query string, cvt func(row *sql.Row) error) error
- func TrxSelectRows(dbTrx *sql.Tx, query string, cvt func(rows *sql.Rows) error) error
- func TrxUpdate(dbTrx *sql.Tx, query string) error
- func TrxUpdateStatement(dbTrx *sql.Tx, query string, put func() (bool, []interface{}, error)) error
- func Update(dbConn *sql.DB, query string) error
- func UpdateLanguage(dbConn *sql.DB, langDef *LangMeta) error
- func UpdateModel(dbConn *sql.DB, dbFacet Facet, modelDef *ModelMeta) (bool, error)
- func UpdateModelText(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, modelTxt *ModelTxtMeta) error
- func UpdateModelWord(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, mwDef *ModelWordMeta) error
- func UpdateProfile(dbConn *sql.DB, profile *ProfileMeta) error
- func UpdateProfileOption(dbConn *sql.DB, name, key, val string) error
- func UpdateRunParameterText(dbConn *sql.DB, modelDef *ModelMeta, runId int, ...) error
- func UpdateRunValueDigest(dbConn *sql.DB, runId int) (string, error)
- func UpdateWorksetParameterText(dbConn *sql.DB, modelDef *ModelMeta, setName string, ...) error
- func UpdateWorksetReadonly(dbConn *sql.DB, setId int, isReadonly bool) error
- func UpdateWorksetReadonlyByName(dbConn *sql.DB, modelId int, name string, isReadonly bool) error
- func WriteOutputTableFrom(dbConn *sql.DB, modelDef *ModelMeta, layout *WriteTableLayout, ...) error
- func WriteParameterFrom(dbConn *sql.DB, modelDef *ModelMeta, layout *WriteParamLayout, ...) error
- type CellAcc
- type CellAccConverter
- func (cellCvt CellAccConverter) CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error)
- func (cellCvt CellAccConverter) CsvHeader(modelDef *ModelMeta, name string) ([]string, error)
- func (cellCvt CellAccConverter) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error)
- func (cellCvt CellAccConverter) CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
- func (cellCvt CellAccConverter) CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
- func (cellCvt CellAccConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt CellAccConverter) KeyIds(name string) (func(interface{}, []int) error, error)
- type CellAllAcc
- type CellAllAccConverter
- func (cellCvt CellAllAccConverter) CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error)
- func (cellCvt CellAllAccConverter) CsvHeader(modelDef *ModelMeta, name string) ([]string, error)
- func (cellCvt CellAllAccConverter) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error)
- func (cellCvt CellAllAccConverter) CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
- func (cellCvt CellAllAccConverter) CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
- func (cellCvt CellAllAccConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt CellAllAccConverter) KeyIds(name string) (func(interface{}, []int) error, error)
- type CellCodeAcc
- type CellCodeAllAcc
- type CellCodeExpr
- type CellCodeParam
- type CellCodeTableCmp
- type CellExpr
- type CellExprConverter
- func (cellCvt CellExprConverter) CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error)
- func (cellCvt CellExprConverter) CsvHeader(modelDef *ModelMeta, name string) ([]string, error)
- func (cellCvt CellExprConverter) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error)
- func (cellCvt CellExprConverter) CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
- func (cellCvt CellExprConverter) CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
- func (cellCvt CellExprConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt CellExprConverter) KeyIds(name string) (func(interface{}, []int) error, error)
- type CellParam
- type CellParamConverter
- func (cellCvt CellParamConverter) CodeToIdCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt CellParamConverter) CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error)
- func (cellCvt CellParamConverter) CsvHeader(modelDef *ModelMeta, name string) ([]string, error)
- func (cellCvt CellParamConverter) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error)
- func (cellCvt CellParamConverter) CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
- func (cellCvt CellParamConverter) CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
- func (cellCvt CellParamConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt CellParamConverter) KeyIds(name string) (func(interface{}, []int) error, error)
- type CellTableCmp
- type CellTableCmpConverter
- func (cellCvt CellTableCmpConverter) CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error)
- func (cellCvt CellTableCmpConverter) CsvHeader(modelDef *ModelMeta, name string) ([]string, error)
- func (cellCvt CellTableCmpConverter) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error)
- func (cellCvt CellTableCmpConverter) CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
- func (cellCvt CellTableCmpConverter) CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
- func (cellCvt CellTableCmpConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
- func (cellCvt CellTableCmpConverter) KeyIds(name string) (func(interface{}, []int) error, error)
- type CellToCodeConverter
- type CellToIdConverter
- type CompareLayout
- type CompareTableLayout
- type CsvConverter
- type DescrNote
- type Facet
- type FilterColumn
- type FilterIdColumn
- type FilterOp
- type GroupLstRow
- type GroupMeta
- type GroupPcRow
- type GroupTxtRow
- type LangLstRow
- type LangMeta
- type LangNote
- type ModelDicRow
- type ModelMeta
- func (src *ModelMeta) Clone() (*ModelMeta, error)
- func (dst *ModelMeta) FromJson(srcJson []byte) (bool, error)
- func (meta *ModelMeta) OutTableByDigest(digest string) (int, bool)
- func (meta *ModelMeta) OutTableByHid(tableHid int) (int, bool)
- func (meta *ModelMeta) OutTableByKey(tableId int) (int, bool)
- func (meta *ModelMeta) OutTableByName(name string) (int, bool)
- func (meta *ModelMeta) OutTableHidById(tableId int) int
- func (meta *ModelMeta) OutTableIdByHid(tableHid int) int
- func (meta *ModelMeta) ParamByDigest(digest string) (int, bool)
- func (meta *ModelMeta) ParamByHid(paramHid int) (int, bool)
- func (meta *ModelMeta) ParamByKey(paramId int) (int, bool)
- func (meta *ModelMeta) ParamByName(name string) (int, bool)
- func (meta *ModelMeta) ParamHidById(paramId int) int
- func (meta *ModelMeta) ParamIdByHid(paramHid int) int
- func (meta *ModelMeta) TypeByKey(typeId int) (int, bool)
- type ModelTxtMeta
- type ModelTxtRow
- type ModelWordMeta
- type OrderByColumn
- type ParamDicRow
- type ParamDimsRow
- type ParamDimsTxtRow
- type ParamImportRow
- type ParamMeta
- type ParamRunSetPub
- type ParamRunSetTxtPub
- type ParamTxtRow
- type ParamValuePub
- type ProfileMeta
- type ReadLayout
- type ReadPageLayout
- func CompareOutputTable(dbConn *sql.DB, modelDef *ModelMeta, layout *CompareTableLayout, runIds []int) (*list.List, *ReadPageLayout, error)
- func ReadOutputTableTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadTableLayout, ...) (*ReadPageLayout, error)
- func ReadParameterTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadParamLayout, ...) (*ReadPageLayout, error)
- func SelectToList(dbConn *sql.DB, query string, layout ReadPageLayout, ...) (*list.List, *ReadPageLayout, error)
- type ReadParamLayout
- type ReadTableLayout
- type RunMeta
- func (meta *RunMeta) ToPublic(dbConn *sql.DB, modelDef *ModelMeta) (*RunPub, error)
- func (meta *RunMeta) UpdateRun(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, doubleFmt string) (bool, error)
- func (meta *RunMeta) UpdateRunText(dbConn *sql.DB, modelDef *ModelMeta, runId int, langDef *LangMeta) error
- type RunParamTxtRow
- type RunProgress
- type RunPub
- type RunRow
- func GetFirstRun(dbConn *sql.DB, modelId int) (*RunRow, error)
- func GetLastCompletedRun(dbConn *sql.DB, modelId int) (*RunRow, error)
- func GetLastRun(dbConn *sql.DB, modelId int) (*RunRow, error)
- func GetLastRunByName(dbConn *sql.DB, modelId int, name string) (*RunRow, error)
- func GetRun(dbConn *sql.DB, runId int) (*RunRow, error)
- func GetRunByDigest(dbConn *sql.DB, digest string) (*RunRow, error)
- func GetRunByDigestOrStampOrName(dbConn *sql.DB, modelId int, rdsn string) (*RunRow, error)
- func GetRunByName(dbConn *sql.DB, modelId int, name string) (*RunRow, error)
- func GetRunByStamp(dbConn *sql.DB, modelId int, stamp string) (*RunRow, error)
- func GetRunList(dbConn *sql.DB, modelId int) ([]RunRow, error)
- func GetRunListByDigestOrStampOrName(dbConn *sql.DB, modelId int, rdsn string) ([]RunRow, error)
- type RunTxtRow
- type TableAccRow
- type TableAccTxtRow
- type TableDicRow
- type TableDimsRow
- type TableDimsTxtRow
- type TableExprRow
- type TableExprTxtRow
- type TableMeta
- type TableRunPub
- type TableTxtRow
- type TaskDef
- type TaskDefPub
- type TaskMeta
- func (meta *TaskMeta) MergeTaskDef(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta) error
- func (meta *TaskMeta) ReplaceTaskDef(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta) error
- func (meta *TaskMeta) ToPublic(dbConn *sql.DB, modelDef *ModelMeta) (*TaskPub, error)
- func (meta *TaskMeta) UpdateTaskFull(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta) error
- type TaskPub
- type TaskRow
- type TaskRunRow
- func GetTaskFirstRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
- func GetTaskLastCompletedRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
- func GetTaskLastRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
- func GetTaskRun(dbConn *sql.DB, taskRunId int) (*TaskRunRow, error)
- func GetTaskRunByName(dbConn *sql.DB, taskId int, name string) (*TaskRunRow, error)
- func GetTaskRunByStamp(dbConn *sql.DB, taskId int, stamp string) (*TaskRunRow, error)
- func GetTaskRunByStampOrName(dbConn *sql.DB, taskId int, trsn string) (*TaskRunRow, error)
- func GetTaskRunListByStampOrName(dbConn *sql.DB, taskId int, trsn string) ([]TaskRunRow, error)
- type TaskRunSetRow
- type TaskRunSetTxt
- type TaskTxtRow
- type TypeDicRow
- type TypeEnumRow
- type TypeEnumTxtRow
- type TypeMeta
- type TypeTxtRow
- type WorksetCreatePub
- type WorksetHdrPub
- type WorksetMeta
- func (meta *WorksetMeta) ToPublic(dbConn *sql.DB, modelDef *ModelMeta) (*WorksetPub, error)
- func (meta *WorksetMeta) UpdateWorkset(dbConn *sql.DB, modelDef *ModelMeta, isReplace bool, langDef *LangMeta) error
- func (meta *WorksetMeta) UpdateWorksetParameterFrom(dbConn *sql.DB, modelDef *ModelMeta, isReplaceMeta bool, param *ParamRunSetPub, ...) (int, error)
- type WorksetParamTxtRow
- type WorksetPub
- type WorksetRow
- type WorksetTxtRow
- type WriteLayout
- type WriteParamLayout
- type WriteTableLayout
Constants ¶
const ( SQLiteDbDriver = "SQLite" // default db driver name SQLiteTimeout = 86400 // default SQLite busy timeout Sqlite3DbDriver = "sqlite3" // SQLite db driver name OdbcDbDriver = "odbc" // ODBC db driver name )
Database connection values
const ( InitRunStatus = "i" // i = initial status ProgressRunStatus = "p" // p = run in progress WaitRunStatus = "w" // w = wait: run in progress, under external supervision DoneRunStatus = "s" // s = completed successfully ExitRunStatus = "x" // x = exit and not completed ErrorRunStatus = "e" // e = error failure )
Model run status (run_lst table) and modeling task run status (task_run_lst table):
if task status = w (wait) then model wait and NOT completed until other process set status to one of finals: s,x,e model check if any new sets inserted into task_set and run it as they arrive
const IsOdbcSupported = false
IsOdbcSupported indicate support of ODBC connections built-in
const MaxSchemaVersion = 102
MaxSchemaVersion is a maximum compatible db schema version
const MinSchemaVersion = 102
MinSchemaVersion is a minimal compatible db schema version
const TotalEnumCode = "all"
TotalEnumCode is predefined enum code for "total" enum
Variables ¶
This section is empty.
Functions ¶
func CheckOpenmppSchemaVersion ¶
CheckOpenmppSchemaVersion return error if it is not openM++ db or schema version incompatible
func CopyParameterFromRun ¶
func CopyParameterFromRun(dbConn *sql.DB, modelDef *ModelMeta, ws *WorksetRow, paramName string, isReplace bool, rs *RunRow) error
CopyParameterFromRun copy parameter metadata and parameter values into workset from model run.
If isReplace is true and parameter already exist in destination workset then error returned. If isReplace is false then delete existing metadata and new insert new from model run. Destination workset must be in read-write state. Source model run must be completed, run status one of: s=success, x=exit, e=error.
func CopyParameterFromWorkset ¶
func CopyParameterFromWorkset(dbConn *sql.DB, modelDef *ModelMeta, dstWs *WorksetRow, paramName string, isReplace bool, srcWs *WorksetRow) error
CopyParameterFromWorkset copy parameter metadata and parameter values from one workset to another.
If isReplace is true and parameter already exist in destination workset then error returned. If isReplace is false then delete existing metadata and new insert new from source workset. Destination workset must be in read-write state, source workset must be read-only.
func DeleteModel ¶
DeleteModel delete existing model metadata and drop model data tables from database.
func DeleteProfile ¶
DeleteProfile delete rows from profile in profile_lst and profile_option tables.
func DeleteProfileOption ¶
DeleteProfileOption delete row from profile_option table.
func DeleteRun ¶
DeleteRun delete model run metadata, parameters run values and output tables run values from database.
func DeleteTask ¶
DeleteTask delete modeling task and task run history from database.
func DeleteWorkset ¶
DeleteWorkset delete workset metadata and workset parameter values from database.
func DeleteWorksetAllParameters ¶ added in v1.6.3
DeleteWorksetAllParameters delete all parameters metadata and values from workset.
Workset must be read-write in order to delete all parameters. If workset does not exist then nothing deleted and no errors returned, it is empty operation.
func DeleteWorksetParameter ¶
DeleteWorksetParameter do delete parameter metadata and values from workset.
If parameter not exist in workset then nothing deleted. Workset must be read-write in order to delete parameter. It is return parameter Hid = 0 if nothing deleted.
func GetModelId ¶
GetModelId return model id if exists.
Model selected by name and/or digest, i.e.: ("modelOne", "abcd20120817160459148") if digest is empty then first model with min(model_id) is used
func GetModelRunOptions ¶
GetModelOptions return model run_option table rows as map of maps: map(run_id, map(key, value)).
func GetProfileList ¶
GetProfileList return profile names: profile_lst table rows.
Profile is a named group of (key, value) options, similar to ini-file. Default model options has profile_name = model_name.
func GetRunListText ¶
GetRunListText return list of model runs with description and notes: run_lst and run_txt rows.
If langCode not empty then only specified language selected else all languages
func GetRunOptions ¶
GetRunOptions return run_option table rows as (key, value) map.
func GetTaskListText ¶
GetTaskListText return list of modeling tasks with description and notes: task_lst and task_txt rows.
If langCode not empty then only specified language selected else all languages
func GetTaskSetIds ¶
GetTaskSetIds return modeling task set id's by task id from task_set db table
func GetWorksetListText ¶
func GetWorksetListText(dbConn *sql.DB, modelId int, langCode string) ([]WorksetRow, []WorksetTxtRow, error)
GetWorksetListText return list of model worksets, description and notes: workset_lst and workset_txt rows.
If langCode not empty then only specified language selected else all languages
func GetWorksetParam ¶ added in v1.6.3
GetWorksetParam return sub-values count and default sub-value id for workset parameter: SELECT sub_count, default_sub_id FROM workset_parameter
func GetWorksetParamList ¶
GetWorksetParamList return Hid, sub-values count and default sub-value id for all parameters included in that workset: SELECT parameter_hid, sub_count, default_sub_id FROM workset_parameter
func GetWorksetRunIds ¶
GetWorksetRunIds return ids of model run results (run_id) where input parameters are from specified working set.
Only successfully completed run ids returned, not failed, not "in progress". This method is "local" to database and if data transfered between databases it very likely return wrong results. This method is not recommended, use modeling task to establish relationship between input set and model run.
func IfEmptyMakeDefault ¶
IfEmptyMakeDefault return SQLite connection string and driver name based on model name:
Database=modelName.sqlite; Timeout=86400; OpenMode=ReadWrite;
func IfEmptyMakeDefaultReadOnly ¶ added in v1.9.0
func IfEmptyMakeDefaultReadOnly(modelName, modelSqlitePath, dbConnStr, dbDriver string) (string, string)
IfEmptyMakeDefaultReadOnly return read-only SQLite connection string and driver name based on model name:
Database=modelName.sqlite; Timeout=86400; OpenMode=ReadWrite;
func IsRunCompleted ¶
IsRunCompleted return true if run status one of: s=success, x=exit, e=error
func IsUnsafeQuote ¶ added in v1.9.0
return true if character is can be interpreted as sql ' quote MSSQL silently replace following utf-16 chars with 'single' quote:
ʹ 697 Modifier Letter Prime ʼ 700 Modifier Letter Apostrophe ˈ 712 Modifier Letter Vertical Line ′ 8242 Prime ' 65287 Fullwidth Apostrophe
func MakeSqliteDefault ¶
MakeSqliteDefault return default SQLite connection string based on model.sqlite file path:
Database=model.sqlite; Timeout=86400; OpenMode=ReadWrite;
func MakeSqliteDefaultReadOnly ¶ added in v1.9.0
MakeSqliteDefaultReadOnly return default read-only SQLite connection string based on model.sqlite file path:
Database=model.sqlite; Timeout=86400; OpenMode=ReadOnly;
func OpenmppSchemaVersion ¶
OpenmppSchemaVersion return db schema: select id_value from id_lst where id_key = 'openmpp'
func RenameTask ¶ added in v1.6.3
RenameTask do rename task if new name is not empty "" string
func RenameWorkset ¶ added in v1.6.3
RenameWorkset do rename workset if new name is not empty "" string.
If isAnyReadonly parameter is true then do rename regarless of workset read-only status else return error if workset is not read-write.
func SelectFirst ¶
SelectFirst select first db row and pass it to cvt() for row.Scan()
func SelectRows ¶
SelectRows select db rows and pass each to cvt() for rows.Scan()
func SelectRowsTo ¶ added in v1.9.7
SelectRowsTo select db rows and pass each row to cvt(). cvt() return true to continue or false to stop rows processing.
func TrxSelectFirst ¶
TrxSelectFirst select first db row in transaction scope and pass it to cvt() for row.Scan()
func TrxSelectRows ¶
TrxSelectRows select db rows in transaction scope and pass each to cvt() for rows.Scan()
func TrxUpdateStatement ¶
TrxUpdateStatement execute sql statement in transaction scope until put() return true
func UpdateLanguage ¶
UpdateLanguage insert new or update existing language and words in lang_lst and lang_word tables. Language ids updated with actual id's from database
func UpdateModel ¶
UpdateModel insert new model metadata in database, return true if model inserted or false if already exist.
If model with same digest already exist then call simply return existing model metadata (no changes made in database). Parameters and output tables Hid's and db table names updated with actual database values If new model inserted then modelDef updated with actual id's (model id, parameter Hid...) If parameter (output table) not exist then create db tables for parameter values (output table values) If db table names is "" empty then make db table names for parameter values (output table values)
func UpdateModelText ¶
func UpdateModelText(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, modelTxt *ModelTxtMeta) error
UpdateModelText insert new or update existing model text (description and notes) in database.
Model id, type Hid, parameter Hid, table Hid, language id updated with actual database id's
func UpdateModelWord ¶
func UpdateModelWord(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, mwDef *ModelWordMeta) error
UpdateModelWord insert new or update existing model language-specific strings in model_word table.
func UpdateProfile ¶
func UpdateProfile(dbConn *sql.DB, profile *ProfileMeta) error
UpdateProfile insert new or replace existing profile in profile_lst and profile_option tables.
It always replacing all existing rows by delete from profile_lst and profile_option where profile_name = profile.Name and insert new rows into profile_lst and profile_option tables.
func UpdateProfileOption ¶
UpdateProfileOption insert new or replace existing profile option in profile_option table. It is also will insert profile name into profile_lst table if such name does not already exist.
func UpdateRunParameterText ¶ added in v1.9.3
func UpdateRunParameterText(dbConn *sql.DB, modelDef *ModelMeta, runId int, paramTxtPub []ParamRunSetTxtPub, langDef *LangMeta) error
UpdateRunParameterText merge (insert or update) run parameter value notes into run_parameter_txt table.
New parameter notes merged with existing db rows by update or insert if rows not exist db tables. If run does not exist then function does nothing. Run status must be completed (success, exit or error) otherwise error returned. If input array of ParamRunSetTxtPub is empty then it is empty operation and return is success.
func UpdateRunValueDigest ¶
UpdateRunValueDigest does recalculate and update run_lst table with new run value digest and return it. If run not exist or status is not success or exit then digest is "" empty (not updated).
func UpdateWorksetParameterText ¶ added in v1.9.3
func UpdateWorksetParameterText(dbConn *sql.DB, modelDef *ModelMeta, setName string, paramTxtPub []ParamRunSetTxtPub, langDef *LangMeta) error
UpdateWorksetParameterText merge parameter value notes into workset_parameter_txt table.
Set name is used to find workset and set id updated with actual database value. Workset must exist and must be read-write for replace or merge.
Parameter must exist exist in the model otherwise it is an error. If parameter not exist in workset then function does nothing (it is empty operation). If input array of ParamRunSetTxtPub is empty then it is empty operation and return is success.
func UpdateWorksetReadonly ¶
UpdateWorksetReadonly update workset readonly status.
func UpdateWorksetReadonlyByName ¶
UpdateWorksetReadonlyByName update workset readonly status by workset name.
func WriteOutputTableFrom ¶ added in v1.9.7
func WriteOutputTableFrom( dbConn *sql.DB, modelDef *ModelMeta, layout *WriteTableLayout, accFrom func() (interface{}, error), exprFrom func() (interface{}, error), ) error
WriteOutputTableFrom insert output table values (accumulators or expressions) into model run from accFrom() and exprFrom() readers.
Model run must exist and be in completed state (i.e. success or error state). Model run should not already contain output table values: it can be inserted only once in model run and cannot be updated after. Accumulators and expressions values must come in the order of primary key otherwise digest calculated incorrectly. Double format is used for float model types digest calculation, if non-empty format supplied.
func WriteParameterFrom ¶ added in v1.9.7
func WriteParameterFrom(dbConn *sql.DB, modelDef *ModelMeta, layout *WriteParamLayout, from func() (interface{}, error)) error
WriteParameterFrom insert or update parameter values in workset or insert parameter values into model run until from() return not nil CellParam value.
If this is model run update (layout.IsToRun is true) then model run must exist and be in completed state (i.e. success or error state). Model run should not already contain parameter values: parameter can be inserted only once in model run and cannot be updated after. Parameter values must come in the order of primary key otherwise digest calculated incorrectly.
If workset already contain parameter values then values updated else inserted. If only "page" of workset parameter rows supplied (layout.IsPage is true) then each row deleted by primary key before insert else all rows deleted by one delete by set id.
Double format is used for float model types digest calculation, if non-empty format supplied.
Types ¶
type CellAcc ¶
type CellAcc struct { AccId int // output table accumulator id SubId int // output table subvalue id // contains filtered or unexported fields }
CellAcc is value of output table accumulator.
type CellAccConverter ¶ added in v1.9.2
type CellAccConverter struct { DoubleFmt string // if not empty then format string is used to sprintf if value type is float, double, long double IsIdHeader bool // if isIdHeader is true then column names: acc_id,sub_id,dim0,dim1,acc_value else: acc_name,sub_id,dim0,dim1,acc_value }
CellAccConverter is a converter for output table accumulator to implement CsvConverter interface.
func (CellAccConverter) CsvFileName ¶ added in v1.9.2
func (cellCvt CellAccConverter) CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error)
CsvFileName return file name of csv file to store output table accumulator rows
func (CellAccConverter) CsvHeader ¶ added in v1.9.2
func (cellCvt CellAccConverter) CsvHeader(modelDef *ModelMeta, name string) ([]string, error)
CsvHeader return first line for csv file: column names. Column names can be like: acc_name,sub_id,dim0,dim1,acc_value or if isIdHeader is true then: acc_id,sub_id,dim0,dim1,acc_value
func (CellAccConverter) CsvToCell ¶ added in v1.9.2
func (cellCvt CellAccConverter) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error)
CsvToCell return closure to convert csv row []string to output table accumulator cell (dimensions and value).
It does return error if len(row) not equal to number of fields in cell db-record. If dimension type is enum based then csv row is enum code and it is converted into cell.DimIds (into dimension type type enum ids).
func (CellAccConverter) CsvToIdRow ¶ added in v1.9.2
func (cellCvt CellAccConverter) CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
CsvToIdRow return converter from output table cell (acc_id, sub_id, dimensions, value) to csv row []string.
Converter simply does Sprint() for each dimension item id, accumulator id, subvalue number and value. Converter will return error if len(row) not equal to number of fields in csv record.
func (CellAccConverter) CsvToRow ¶ added in v1.9.2
func (cellCvt CellAccConverter) CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
CsvToRow return converter from output table cell (acc_id, sub_id, dimensions, value) to csv row []string (acc_name, sub_id, dimensions, value).
Converter will return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum code and cell.DimIds is enum id.
func (CellAccConverter) IdToCodeCell ¶ added in v1.9.2
func (cellCvt CellAccConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from output table cell of ids: (acc_id, sub_id, dimensions, value) to cell of codes: (acc_id, sub_id, dimensions as enum code, value)
If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string.
func (CellAccConverter) KeyIds ¶ added in v1.9.7
func (cellCvt CellAccConverter) KeyIds(name string) (func(interface{}, []int) error, error)
KeyIds return converter to copy primary key: (acc_id, sub_id, dimension ids) into key []int.
Converter will return error if len(key) not equal to row key size.
type CellAllAcc ¶
type CellAllAcc struct { DimIds []int // dimensions item as enum ids or int values if dimension type simple SubId int // output table subvalue id IsNull []bool // if true then value is NULL Value []float64 // accumulator value(s) }
CellAllAcc is value of multiple output table accumulators.
type CellAllAccConverter ¶ added in v1.9.2
type CellAllAccConverter struct { DoubleFmt string // if not empty then format string is used to sprintf if value type is float, double, long double ValueName string // If ValueName is "" empty then all accumulators use for csv else one }
CellAllAccConverter is a converter for multiple output table accumulators to implement CsvConverter interface.
func (CellAllAccConverter) CsvFileName ¶ added in v1.9.2
func (cellCvt CellAllAccConverter) CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error)
CsvFileName return file name of csv file to store all accumulators rows
func (CellAllAccConverter) CsvHeader ¶ added in v1.9.2
func (cellCvt CellAllAccConverter) CsvHeader(modelDef *ModelMeta, name string) ([]string, error)
CsvHeader return first line for csv file: column names. Column names can be like: sub_id,dim0,dim1,acc0,acc1,acc2 If ValueName is "" empty then use all accumulators for csv else only one where accumulator name is ValueName
func (CellAllAccConverter) CsvToCell ¶ added in v1.9.2
func (cellCvt CellAllAccConverter) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error)
CsvToCell return closure to convert csv row []string to output table accumulator cell (dimensions and value).
It does return error if len(row) not equal to number of fields in cell db-record. If dimension type is enum based then csv row is enum code and it is converted into cell.DimIds (into dimension type type enum ids).
func (CellAllAccConverter) CsvToIdRow ¶ added in v1.9.2
func (cellCvt CellAllAccConverter) CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
CsvToIdRow return converter from output table cell (sub_id, dimensions, acc0, acc1, acc2) to csv row []string.
Converter simply does Sprint() for each dimension item id, subvalue number and value(s). Converter will return error if len(row) not equal to number of fields in csv record. Double format string is used if parameter type is float, double, long double If ValueName is "" empty then all accumulators converted else one
func (CellAllAccConverter) CsvToRow ¶ added in v1.9.2
func (cellCvt CellAllAccConverter) CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
CsvToRow return converter from output table cell (sub_id, dimensions, acc0, acc1, acc2 to csv row []string (acc_name, sub_id, dimensions, value).
Converter will return error if len(row) not equal to number of fields in csv record. Double format string is used if parameter type is float, double, long double If dimension type is enum based then csv row is enum code and cell.DimIds is enum id. If ValueName is "" empty then all accumulators converted else one
func (CellAllAccConverter) IdToCodeCell ¶ added in v1.9.2
func (cellCvt CellAllAccConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from output table cell of ids: (sub_id, dimensions, acc0, acc1, acc2) to cell of codes: (sub_id, dimensions as enum code, acc0, acc1, acc2)
If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string.
type CellCodeAcc ¶
type CellCodeAcc struct { AccId int // output table accumulator id SubId int // output table subvalue id // contains filtered or unexported fields }
CellCodeAcc is value of output table accumulator. Dimension(s) items are enum codes, not enum ids.
type CellCodeAllAcc ¶
type CellCodeAllAcc struct { Dims []string // dimensions as enum codes or string of item if dimension type simple then SubId int // output table subvalue id IsNull []bool // if true then value is NULL Value []float64 // accumulator value(s) }
CellCodeAllAcc is value of multiple output table accumulators. Dimension(s) items are enum codes, not enum ids.
type CellCodeExpr ¶
type CellCodeExpr struct { ExprId int // output table expression id // contains filtered or unexported fields }
CellCodeExpr is value of output table expression. Dimension(s) items are enum codes, not enum ids.
type CellCodeParam ¶
type CellCodeParam struct { SubId int // parameter subvalue id // contains filtered or unexported fields }
CellCodeParam is value of input parameter. Dimension(s) items are enum codes, not enum ids.
type CellCodeTableCmp ¶ added in v1.9.2
type CellCodeTableCmp struct { RunDigest string // model run digest // contains filtered or unexported fields }
CellCodeTableCmp is value of output table comparison expression. Dimension(s) items are enum codes, not enum ids.
type CellExpr ¶
type CellExpr struct { ExprId int // output table expression id // contains filtered or unexported fields }
CellExpr is value of output table expression.
type CellExprConverter ¶ added in v1.9.2
type CellExprConverter struct { DoubleFmt string // if not empty then format string is used to sprintf if value type is float, double, long double IsIdHeader bool // if isIdHeader is true then column names: expr_id,dim0,dim1,expr_value else: expr_name,dim0,dim1,expr_value }
CellExprConverter is a converter for output table expression to implement CsvConverter interface.
func (CellExprConverter) CsvFileName ¶ added in v1.9.2
func (cellCvt CellExprConverter) CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error)
CsvFileName return file name of csv file to store output table expression rows
func (CellExprConverter) CsvHeader ¶ added in v1.9.2
func (cellCvt CellExprConverter) CsvHeader(modelDef *ModelMeta, name string) ([]string, error)
CsvHeader return first line for csv file: column names. Column names can be like: expr_name,dim0,dim1,expr_value or if isIdHeader is true: expr_id,dim0,dim1,expr_value
func (CellExprConverter) CsvToCell ¶ added in v1.9.2
func (cellCvt CellExprConverter) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error)
CsvToCell return closure to convert csv row []string to output table expression cell (dimensions and value).
It does return error if len(row) not equal to number of fields in cell db-record. If dimension type is enum based then csv row is enum code and it is converted into cell.DimIds (into dimension type type enum ids).
func (CellExprConverter) CsvToIdRow ¶ added in v1.9.2
func (cellCvt CellExprConverter) CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
CsvToIdRow return converter from output table cell (expr_id, dimensions, value) to csv row []string.
Converter simply does Sprint() for each dimension item id, expression id and value. Converter will return error if len(row) not equal to number of fields in csv record.
func (CellExprConverter) CsvToRow ¶ added in v1.9.2
func (cellCvt CellExprConverter) CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
CsvToRow return converter from output table cell (expr_id, dimensions, value) to csv row []string (expr_name, dimensions, value).
Converter will return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum code and cell.DimIds is enum id.
func (CellExprConverter) IdToCodeCell ¶ added in v1.9.2
func (cellCvt CellExprConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from output table cell of ids: (expr_id, dimensions enum ids, value) to cell of codes: (expr_id, dimensions as enum codes, value).
If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string.
type CellParam ¶
type CellParam struct { SubId int // parameter subvalue id // contains filtered or unexported fields }
CellParam is value of input parameter.
type CellParamConverter ¶ added in v1.9.2
type CellParamConverter struct {
DoubleFmt string // if not empty then format string is used to sprintf if value type is float, double, long double
}
CellParamConverter is a converter for input parameter to implement CsvConverter interface.
func (CellParamConverter) CodeToIdCell ¶ added in v1.9.2
func (cellCvt CellParamConverter) CodeToIdCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
CodeToIdCell return converter from parameter cell of codes: (sub id, dimensions as enum code, value) to cell of ids: (sub id, dimensions, value)
If dimension type is enum based then dimensions enum codes converted to enum ids. If dimension type is simple (bool or int) then dimension code converted from string to dimension type. If parameter type is enum based then cell value enum code converted to enum id.
func (CellParamConverter) CsvFileName ¶ added in v1.9.2
func (cellCvt CellParamConverter) CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error)
CsvFileName return file name of csv file to store parameter rows
func (CellParamConverter) CsvHeader ¶ added in v1.9.2
func (cellCvt CellParamConverter) CsvHeader(modelDef *ModelMeta, name string) ([]string, error)
CsvHeader return first line for csv file: column names, it's look like: sub_id,dim0,dim1,param_value.
func (CellParamConverter) CsvToCell ¶ added in v1.9.2
func (cellCvt CellParamConverter) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error)
CsvToCell return closure to convert csv row []string to parameter cell (sub id, dimensions, value).
It does return error if len(row) not equal to number of fields in cell db-record. If dimension type is enum based then csv row is enum code and it is converted into cell.DimIds (into dimension type type enum ids). If parameter type is enum based then csv row value is enum code and it is converted into value enum id.
func (CellParamConverter) CsvToIdRow ¶ added in v1.9.2
func (cellCvt CellParamConverter) CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
CsvToIdRow return converter from parameter cell (sub id, dimensions, value) to csv row []string.
Converter simply does Sprint() for each sub-value id, dimension item id and value. Converter will return error if len(row) not equal to number of fields in csv record.
func (CellParamConverter) CsvToRow ¶ added in v1.9.2
func (cellCvt CellParamConverter) CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
CsvToRow return converter from parameter cell (sub id, dimensions, value) to csv row []string.
Converter will return error if len(row) not equal to number of fields in csv record. If dimension type is enum based then csv row is enum code and cell.DimIds is enum id. If parameter type is enum based then csv row value is enum code and cell value is enum id.
func (CellParamConverter) IdToCodeCell ¶ added in v1.9.2
func (cellCvt CellParamConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from parameter cell of ids: (sub id, dimensions, value) to cell of codes: (sub id, dimensions as enum code, value)
If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string. If parameter type is enum based then cell value enum id converted to enum code.
type CellTableCmp ¶ added in v1.9.2
type CellTableCmp struct { RunId int // model run id // contains filtered or unexported fields }
CellTableCmp is value of output table comparison expression.
type CellTableCmpConverter ¶ added in v1.9.2
type CellTableCmpConverter struct { DoubleFmt string // if not empty then format string is used to sprintf if value type is float, double, long double IdToDigest map[int]string // map of run id's to run digests DigestToId map[string]int // map of run digests to run id's }
CellTableCmpConverter is a converter for output table comparison cell to implement CsvConverter interface.
func (CellTableCmpConverter) CsvFileName ¶ added in v1.9.2
func (cellCvt CellTableCmpConverter) CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error)
CsvFileName return file name of csv file to store output table comparison rows
func (CellTableCmpConverter) CsvHeader ¶ added in v1.9.2
func (cellCvt CellTableCmpConverter) CsvHeader(modelDef *ModelMeta, name string) ([]string, error)
CsvHeader return first line for csv file: column names, it's look like: run_digest,dim0,dim1,value
func (CellTableCmpConverter) CsvToCell ¶ added in v1.9.2
func (cellCvt CellTableCmpConverter) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error)
CsvToCell return closure to convert csv row []string to output table comparison cell (run id, dimensions and value).
It does return error if len(row) not equal to number of fields in cell db-record. If dimension type is enum based then csv row is enum code and it is converted into cell.DimIds (into dimension type type enum ids).
func (CellTableCmpConverter) CsvToIdRow ¶ added in v1.9.2
func (cellCvt CellTableCmpConverter) CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
CsvToIdRow return converter from output table comparison cell (run_id, dimensions, value) to csv row []string.
Converter simply does Sprint() for each dimension item id, run id and value. Converter will return error if len(row) not equal to number of fields in csv record.
func (CellTableCmpConverter) CsvToRow ¶ added in v1.9.2
func (cellCvt CellTableCmpConverter) CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error)
CsvToRow return converter from output table comparison cell (run_id, dimensions, value) to csv row []string (run digest, dimensions, value).
Converter will return error if len(row) not equal to number of fields in csv record. Converter will return error if run_id not exist in the list of model runs (in run_lst table). Double format string is used if parameter type is float, double, long double. If dimension type is enum based then csv row is enum code and cell.DimIds is enum id.
func (CellTableCmpConverter) IdToCodeCell ¶ added in v1.9.2
func (cellCvt CellTableCmpConverter) IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error)
IdToCodeCell return converter from output table comparison cell of ids: (run_id, dimensions enum ids, value) to cell of codes: (run_digest, dimensions as enum codes, value).
If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string.
func (CellTableCmpConverter) KeyIds ¶ added in v1.9.7
func (cellCvt CellTableCmpConverter) KeyIds(name string) (func(interface{}, []int) error, error)
KeyIds return converter to copy primary key: (run_id, dimension ids) into key []int.
Converter will return error if len(key) not equal to row key size.
type CellToCodeConverter ¶
type CellToCodeConverter interface { // IdToCodeCell return converter from id cell to code cell. // Cell is dimensions and value of parameter or output table. // It does convert from enum id to code for all dimensions and enum-based parameter value. IdToCodeCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error) }
CellToCodeConverter provide methods to convert parameters or output table row from enum id to enum code. If dimension type is enum based then dimensions enum ids can be converted to enum code. If dimension type is simple (bool or int) then dimension value converted to string. If parameter type is enum based then cell value enum id converted to enum code.
type CellToIdConverter ¶
type CellToIdConverter interface { // CodeToIdCell return converter from code cell to id cell. // Cell is dimensions and value of parameter or output table. // It does convert from enum code to id for all dimensions and enum-based parameter value. CodeToIdCell(modelDef *ModelMeta, name string) (func(interface{}) (interface{}, error), error) }
CellToIdConverter provide methods to convert parameters or output table row from enum code to enum id. If dimension type is enum based then dimensions enum codes converted to enum ids. If dimension type is simple (bool or int) then dimension code converted from string to dimension type. If parameter type is enum based then cell value enum code converted to enum id.
type CompareLayout ¶ added in v1.9.2
type CompareLayout struct { Comparison string // comparison expression, ex.: Expr0[base] - Expr0[variant] ReadLayout // parameter or output table name, page size, where filters and order by }
CompareLayout describes source and size of data page to read and compare parameters or output table values from multiple model runs.
type CompareTableLayout ¶ added in v1.9.2
type CompareTableLayout struct { CompareLayout // output table name, page size, where filters and order by IsAccum bool // if true then select output table accumulator else expression }
CompareTableLayout describes source and size of data page to read and compare output table values from multiple model runs.
type CsvConverter ¶
type CsvConverter interface { // return file name of csv file to store parameter or output table rows CsvFileName(modelDef *ModelMeta, name string, isIdCsv bool) (string, error) // return first line of csv file with column names: expr_name,dim0,dim1,expr_value. // if isIdHeader is true: expr_id,dim0,dim1,expr_value // if isAllAcc is true: sub_id,dim0,dim1,acc0,acc1,acc2 CsvHeader(modelDef *ModelMeta, name string) ([]string, error) // KeyIds return converter to copy row primary key into key []int. // Row primary key is: (acc_id, sub_id, dimension ids) or (expr_id, dimension ids) or (sub_id, dimension ids) KeyIds(name string) (func(interface{}, []int) error, error) // return converter from cell (dimensions and value) of parameter or output table to csv row []string. // it simply sprint() dimension id's and value into []string. CsvToIdRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error) // return converter from cell (dimensions and value) of parameter or output table to csv row []string. // it does convert from enum id to code for all dimensions and enum-based parameter value. CsvToRow(modelDef *ModelMeta, name string) (func(interface{}, []string) error, error) // return converter from csv row []string to parameter or output table cell (dimensions and value) CsvToCell(modelDef *ModelMeta, name string, subCount int) (func(row []string) (interface{}, error), error) }
CsvConverter provide methods to convert parameters or output table data from or to row []string for csv file. Double format string is used for output bale values or if parameter type is float, double, long double. If dimension type is enum based then csv row is enum code and cell.DimIds is enum id. If parameter type is enum based then cell value is enum id and csv row value is enum code.
type DescrNote ¶
type DescrNote struct { LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
DescrNote is a holder for language code, descripriton and notes
type Facet ¶
type Facet uint8
Facet is type to define database provider and driver facets, ie: name of bigint type
func Open ¶
Open database connection.
Default driver name: "SQLite" and connection string is compatible with model connection, ie:
Database=modelName.sqlite; Timeout=86400; OpenMode=ReadWrite;
Otherwise it is expected to be driver-specific connection string, ie:
DSN=ms2014; UID=sa; PWD=secret; file:m1.sqlite?mode=rw&_busy_timeout=86400000
If isFacetRequired is true then database facet determined
type FilterColumn ¶
type FilterColumn struct { DimName string // dimension name Op FilterOp // filter operator: equal, IN, BETWEEN Enums []string // enum code(s): one, two or many ids depending on filter condition }
FilterColumn define dimension column and condition to filter enum codes to build select where
type FilterIdColumn ¶
type FilterIdColumn struct { DimName string // dimension name Op FilterOp // filter operator: equal, IN, BETWEEN EnumIds []int // enum id(s): one, two or many ids depending on filter condition }
FilterIdColumn define dimension column and condition to filter enum ids to build select where
type FilterOp ¶
type FilterOp string
FilterOp is enum type for filter operators in select where conditions
const ( InAutoOpFilter FilterOp = "IN_AUTO" // auto convert IN list filter into equal or BETWEEN if possible InOpFilter FilterOp = "IN" // dimension enum ids in: dim2 IN (11, 22, 33) EqOpFilter FilterOp = "=" // dimension equal: dim1 = 12 BetweenOpFilter FilterOp = "BETWEEN" // dimension enum ids between: dim3 BETWEEN 44 AND 88 )
Select filter operators for dimension enum ids.
type GroupLstRow ¶
type GroupLstRow struct { ModelId int // model_id INT NOT NULL GroupId int // group_id INT NOT NULL IsParam bool // is_parameter SMALLINT NOT NULL, -- if <> 0 then parameter group else output table group Name string // group_name VARCHAR(255) NOT NULL IsHidden bool // is_hidden SMALLINT NOT NULL }
GroupLstRow is db row of group_lst table
type GroupMeta ¶
type GroupMeta struct { GroupLstRow // parameters or output tables group rows: group_lst GroupPc []GroupPcRow // group parent-child relationship rows: group_pc }
GroupMeta is db rows to describe parent-child group of parameters or output tables, it is join of group_lst to group_pc
type GroupPcRow ¶
type GroupPcRow struct { ModelId int // model_id INT NOT NULL GroupId int // group_id INT NOT NULL ChildPos int // child_pos INT NOT NULL ChildGroupId int // child_group_id INT NULL, -- if not NULL then id of child group ChildLeafId int // leaf_id INT NULL, -- if not NULL then id of parameter or output table }
GroupPcRow is db row of group_pc table
type GroupTxtRow ¶
type GroupTxtRow struct { ModelId int // model_id INT NOT NULL GroupId int // group_id INT NOT NULL DescrNote // language, description, notes }
GroupTxtRow is db row of group_txt table
type LangLstRow ¶
type LangLstRow struct { LangCode string // lang_code VARCHAR(32) NOT NULL Name string // lang_name VARCHAR(255) NOT NULL // contains filtered or unexported fields }
LangLstRow is db row of lang_lst table.
langId is db-unique id of the language. LangCode is unique language code: EN, FR.
type LangMeta ¶
type LangMeta struct { Lang []langWord // languages and words in that language // contains filtered or unexported fields }
LangMeta is language and words in that language
func GetLanguages ¶
GetLanguages return language rows from lang_lst join to lang_word tables and map from lang_code to lang_id.
func (*LangMeta) CodeById ¶
CodeIdId return language code by language id or first language if id not found
type LangNote ¶
type LangNote struct { LangCode string // lang_code VARCHAR(32) NOT NULL Note string // note VARCHAR(32000) }
LangNote is a holder for language code and notes
type ModelDicRow ¶
type ModelDicRow struct { ModelId int // model_id INT NOT NULL Name string // model_name VARCHAR(255) NOT NULL Digest string // model_digest VARCHAR(32) NOT NULL Type int // model_type INT NOT NULL Version string // model_ver VARCHAR(32) NOT NULL CreateDateTime string // create_dt VARCHAR(32) NOT NULL DefaultLangCode string // model default language code }
ModelDicRow is db row of model_dic table.
ModelId (model_dic.model_id) is db-unique id of the model, use digest to find same model in other db.
func GetModelList ¶
func GetModelList(dbConn *sql.DB) ([]ModelDicRow, error)
GetModelList return list of the models: model_dic table rows.
func GetModelRow ¶ added in v1.6.3
func GetModelRow(dbConn *sql.DB, modelId int) (*ModelDicRow, error)
GetModelRow return model_dic table row by model id.
type ModelMeta ¶
type ModelMeta struct { Model ModelDicRow // model_dic table row Type []TypeMeta // types metadata: type name and enums Param []ParamMeta // parameters metadata: parameter name, type, dimensions Table []TableMeta // output tables metadata: table name, dimensions, accumulators, expressions Group []GroupMeta // groups of parameters or output tables }
ModelMeta is model metadata db rows, language-neutral portion of it.
Types, parameters and output tables can be shared between different models and even between different databases. Use digest hash to find same type (parameter, table or model) in other database. As it is today language-specific part of model metadata (labels, description, notes, etc.) does not considered for "equality" comparison and not included in digest.
For example, logical type consists of 2 enum (code, value) pairs: [(0, "false") (1, "true")] and even it has different labels in different databases, i.e. (1, "Truth") vs (1, "OK") such type(s) considered the same and should have identical digest(s).
Inside of database *_hid (type_hid, parameter_hid, table_hid) is a unique id of corresponding object (primary key). Those _hid's are database-unique and should be used to find same type (parameter, output table) in other database. Also each type, parameter, output table have model-unique *_id (type_id, parameter_id, table_id) assigned by compiler and it is possible to find type, parameter or table by combination of (model_id, type_id).
Unless otherwise specified each array is ordered by model-specific id's and binary search can be used. For example type array is ordered by (model_id, type_id) and type enum array by (model_id, type_id, enum_id).
func GetModel ¶
GetModel return model metadata: parameters and output tables definition.
Model selected by name and/or digest, i.e.: ("modelOne", "abcd201208171604590148") if digest is empty then first model with min(model_id) is used
func GetModelById ¶
GetModelById return model metadata: parameters and output tables definition.
Model selected by model id, which expected to be positive.
func (*ModelMeta) OutTableByDigest ¶
OutTableByDigest return index of output table by digest
func (*ModelMeta) OutTableByHid ¶
OutTableByHid return index of output table by table Hid
func (*ModelMeta) OutTableByKey ¶
OutTableByKey return index of output table by key: tableId
func (*ModelMeta) OutTableByName ¶
OutTableByName return index of output table by name
func (*ModelMeta) OutTableHidById ¶
OutTableHidById return output table Hid by id or -1 if not found
func (*ModelMeta) OutTableIdByHid ¶
OutTableIdByHid return output table id by Hid or -1 if not found
func (*ModelMeta) ParamByDigest ¶
ParamByDigest return index of parameter by parameter digest
func (*ModelMeta) ParamByHid ¶
ParamByHid return index of parameter by parameter Hid
func (*ModelMeta) ParamByKey ¶
ParamByKey return index of parameter by key: paramId
func (*ModelMeta) ParamByName ¶
ParamByName return index of parameter by name
func (*ModelMeta) ParamHidById ¶
ParamHidById return parameter Hid by id or -1 if not found
func (*ModelMeta) ParamIdByHid ¶
ParamIdByHid return parameter id by Hid or -1 if not found
type ModelTxtMeta ¶
type ModelTxtMeta struct { ModelName string // model name for text metadata ModelDigest string // model digest for text metadata ModelTxt []ModelTxtRow // model text rows: model_dic_txt TypeTxt []TypeTxtRow // model type text rows: type_dic_txt join to model_type_dic TypeEnumTxt []TypeEnumTxtRow // type enum text rows: type_enum_txt join to model_type_dic ParamTxt []ParamTxtRow // model parameter text rows: parameter_dic_txt join to model_parameter_dic ParamDimsTxt []ParamDimsTxtRow // parameter dimension text rows: parameter_dims_txt join to model_parameter_dic TableTxt []TableTxtRow // model output table text rows: table_dic_txt join to model_table_dic TableDimsTxt []TableDimsTxtRow // output table dimension text rows: table_dims_txt join to model_table_dic TableAccTxt []TableAccTxtRow // output table accumulator text rows: table_acc_txt join to model_table_dic TableExprTxt []TableExprTxtRow // output table expression text rows: table_expr_txt join to model_table_dic GroupTxt []GroupTxtRow // group text rows: group_txt }
ModelTxtMeta is language-specific portion of model metadata db rows.
func GetModelText ¶
GetModelText return model text metadata: description and notes. If langCode not empty then only specified language selected else all languages.
type ModelTxtRow ¶
type ModelTxtRow struct { ModelId int // model_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
ModelTxtRow is db row of model_dic_txt join to model_dic
func GetModelTextById ¶
GetModelTextById return model_dic_txt table rows by model id.
If langCode not empty then only specified language selected else all languages.
type ModelWordMeta ¶
type ModelWordMeta struct { ModelName string // model name for text metadata ModelDigest string // model digest for text metadata ModelWord []modelLangWord // language and db rows of model_word in that language }
ModelWordMeta is language-specific model_word db rows.
func GetModelWord ¶
GetModelWord return model "words": language-specific stirngs. If langCode not empty then only specified language selected else all languages.
type OrderByColumn ¶
type OrderByColumn struct { IndexOne int // one-based column index IsDesc bool // if true then descending order }
OrderByColumn define column to order by rows selected from parameter or output table.
type ParamDicRow ¶
type ParamDicRow struct { ModelId int // model_id INT NOT NULL ParamId int // model_parameter_id INT NOT NULL ParamHid int // parameter_hid INT NOT NULL, -- unique parameter id Name string // parameter_name VARCHAR(255) NOT NULL Digest string // parameter_digest VARCHAR(32) NOT NULL Rank int // parameter_rank INT NOT NULL TypeId int // model_type_id INT NOT NULL IsExtendable bool // is_extendable SMALLINT NOT NULL IsHidden bool // is_hidden SMALLINT NOT NULL NumCumulated int // num_cumulated INT NOT NULL DbRunTable string // db_run_table VARCHAR(64) NOT NULL DbSetTable string // db_set_table VARCHAR(64) NOT NULL ImportDigest string // import_digest VARCHAR(32) NOT NULL }
ParamDicRow is db row of parameter_dic join to model_parameter_dic table
ParamHid (parameter_dic.parameter_hid) is db-unique id of the parameter, use digest to find same parameter in other db. ParamId (model_parameter_dic.model_parameter_id) is model-unique parameter id, assigned by model compiler.
type ParamDimsRow ¶
type ParamDimsRow struct { ModelId int // model_id INT NOT NULL ParamId int // model_parameter_id INT NOT NULL DimId int // dim_id INT NOT NULL Name string // dim_name VARCHAR(255) NOT NULL TypeId int // model_type_id INT NOT NULL // contains filtered or unexported fields }
ParamDimsRow is db row of parameter_dims join to model_parameter_dic table
type ParamDimsTxtRow ¶
type ParamDimsTxtRow struct { ModelId int // model_id INT NOT NULL ParamId int // model_parameter_id INT NOT NULL DimId int // dim_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
ParamDimsTxtRow is db row of parameter_dims_txt join to model_parameter_dic table
type ParamImportRow ¶
type ParamImportRow struct { ModelId int // model_id INT NOT NULL ParamId int // model_parameter_id INT NOT NULL FromName string // from_name VARCHAR(255) NOT NULL FromModel string // from_model_name VARCHAR(255) NOT NULL IsSampleDim bool // is_sample_dim SMALLINT NOT NULL }
ParamImportRow is db row of model_parameter_import table
type ParamMeta ¶
type ParamMeta struct { ParamDicRow // model parameter row: parameter_dic join to model_parameter_dic table Dim []ParamDimsRow // parameter dimension rows: parameter_dims join to model_parameter_dic table Import []ParamImportRow // parameter import from upstream model // contains filtered or unexported fields }
ParamMeta is parameter metadata: parameter name, type, dimensions
type ParamRunSetPub ¶
type ParamRunSetPub struct { ParamRunSetTxtPub SubCount int // number of parameter sub-values DefaultSubId int // default sub-value id for that parameter workset ValueDigest string // value digest, not empty only as result of select from run_parameter; input from "public" value digest is ignored }
ParamRunSetPub is "public" run or workset parameter value metadata for json import-export
type ParamRunSetTxtPub ¶ added in v1.9.3
type ParamRunSetTxtPub struct { Name string // parameter name Txt []LangNote // parameter value notes by language }
ParamRunSetTxtPub is "public" run or workset parameter metadata for json import-export: name, description and notes
type ParamTxtRow ¶
type ParamTxtRow struct { ModelId int // model_id INT NOT NULL ParamId int // model_parameter_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
ParamTxtRow is db row of parameter_dic_txt join to model_parameter_dic table
type ParamValuePub ¶
type ParamValuePub struct { ParamRunSetPub // parameter metadata Kind string // where to get parameter from: "value", "run", "set" or empty "" which is "value" by default From string // run digest (or name or stamp) or workset name to copy parameter from Value []CellCodeParam // parameter value(s) }
ParamValuePub is "public" run or workset parameter metadata and values for json import-export.
type ProfileMeta ¶
type ProfileMeta struct { Name string // profile name Opts map[string]string // profile (key, value) options }
ProfileMeta is rows from profile_option table.
Profile is a named group of (key, value) options, similar to ini-file. Default model options has profile_name = model_name.
func GetProfile ¶
func GetProfile(dbConn *sql.DB, name string) (*ProfileMeta, error)
GetProfile return profile_option table rows as (key, value) map.
Profile is a named group of (key, value) options, similar to ini-file. Default model options has profile_name = model_name.
type ReadLayout ¶
type ReadLayout struct { Name string // parameter name or output table name FromId int // run id or set id to select input parameter or output table values ReadPageLayout // read page first row offset, size and last page flag Filter []FilterColumn // dimension filters, final WHERE does join all filters by AND FilterById []FilterIdColumn // dimension filters by enum ids, final WHERE does join filters by AND OrderBy []OrderByColumn // order by columnns, if empty then dimension id ascending order is used }
ReadLayout describes source and size of data page to read input parameter or output table values.
Row filters combined by AND and allow to select dimension items, it can be enum codes or enum id's, ex.: dim0 = 'CA' AND dim1 IN (2010, 2011, 2012)
Order by applied to output columns, dimension columns always contain enum id's, therefore result ordered by id's and not by enum codes. Columns list depending on output table or parameter query:
parameter values:
SELECT sub_id, dim0, dim1, param_value FROM parameterTable ORDER BY...
output table expressions:
SELECT expr_id, dim0, dim1, expr_value FROM outputTable ORDER BY...
output table accumulators:
SELECT acc_id, sub_id, dim0, dim1, acc_value FROM outputTable ORDER BY...
all-accumulators view:
SELECT sub_id, dim0, dim1, acc0_value, acc1_value... FROM outputTable ORDER BY...
type ReadPageLayout ¶
type ReadPageLayout struct { Offset int64 // first row to return from select, zero-based ofsset Size int64 // max row count to select, if <= 0 then all rows IsLastPage bool // last page flag: if true then read returned last page of rows }
ReadPageLayout describes first row offset and size of data page to read input parameter or output table values.
func CompareOutputTable ¶ added in v1.9.2
func CompareOutputTable(dbConn *sql.DB, modelDef *ModelMeta, layout *CompareTableLayout, runIds []int) (*list.List, *ReadPageLayout, error)
CompareOutputTable read output table page (dimensions and values) from model run results.
If layout.IsAccum true then select accumulator(s) else output expression value(s) If layout.ValueName not empty then select only that expression (accumulator) else all expressions (accumulators)
func ReadOutputTableTo ¶ added in v1.9.7
func ReadOutputTableTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadTableLayout, cvtTo func(src interface{}) (bool, error)) (*ReadPageLayout, error)
ReadOutputTableTo read output table page (dimensions and values) from model run results and process each row by cvtTo().
If layout.IsAccum true then select accumulator(s) else output expression value(s) If layout.ValueName not empty then select only that expression (accumulator) else all expressions (accumulators)
func ReadParameterTo ¶ added in v1.9.7
func ReadParameterTo(dbConn *sql.DB, modelDef *ModelMeta, layout *ReadParamLayout, cvtTo func(src interface{}) (bool, error)) (*ReadPageLayout, error)
ReadParameterTo read input parameter rows (sub id, dimensions, value) from workset or model run results and process each row by cvtTo().
func SelectToList ¶
func SelectToList( dbConn *sql.DB, query string, layout ReadPageLayout, cvt func(rows *sql.Rows) (interface{}, error)) (*list.List, *ReadPageLayout, error)
SelectToList select db rows into list using cvt to convert (scan) each db row into struct.
It selects "page size" number of rows starting from row number == offset (zero based). If page size <= 0 then all rows returned.
type ReadParamLayout ¶
type ReadParamLayout struct { ReadLayout // parameter name, page size, where filters and order by IsFromSet bool // if true then select from workset else from model run IsEditSet bool // if true then workset must be editable (readonly = false) }
ReadParamLayout describes source and size of data page to read input parameter values.
It can read parameter values from model run results or from input working set (workset). If this is read from workset then it can be read-only or read-write (editable) workset.
type ReadTableLayout ¶
type ReadTableLayout struct { ReadLayout // output table name, page size, where filters and order by ValueName string // if not empty then expression or accumulator name to select IsAccum bool // if true then select output table accumulator else expression IsAllAccum bool // if true then select from all accumulators view else from accumulators table }
ReadTableLayout describes source and size of data page to read output table values.
If ValueName is not empty then only accumulator or output expression with that name selected (i.e: "acc1" or "expr4") else all output table accumulators (expressions) selected.
type RunMeta ¶
type RunMeta struct { Run RunRow // model run master row: run_lst Txt []RunTxtRow // run text rows: run_txt Opts map[string]string // options used to run the model: run_option Param []runParam // run parameters: parameter_hid, sub-value count, run_parameter_txt table rows Table []runTable // run tables: table_hid fom run_table rows Progress []RunProgress // run progress by sub-values: run_progress table rows }
RunMeta is metadata of model run: name, status, run options, description, notes.
func GetRunFull ¶
GetRunFull return full metadata for completed model run: run_lst, run_option, run_parameter, run_table, run_progress rows.
func GetRunFullText ¶
GetRunFullText return full metadata, including text, for completed model run: run_lst, run_txt, run_option, run_parameter, run_parameter_txt, run_table, run_progress rows.
It does not return non-completed runs (run in progress). If langCode not empty then only specified language selected else all languages
func GetRunFullTextList ¶
func GetRunFullTextList(dbConn *sql.DB, modelId int, isSuccess bool, langCode string) ([]RunMeta, error)
GetRunFullTextList return list of full metadata, including text, for completed model runs: run_lst, run_txt, run_option, run_parameter, run_parameter_txt, run_table, run_progress rows.
If isSuccess true then return only successfully completed runs else all completed runs. It does not return non-completed runs (run in progress). If langCode not empty then only specified language selected else all languages
func (*RunMeta) ToPublic ¶
ToPublic convert model run db rows into "public" model run format for json import-export.
func (*RunMeta) UpdateRun ¶
func (meta *RunMeta) UpdateRun(dbConn *sql.DB, modelDef *ModelMeta, langDef *LangMeta, doubleFmt string) (bool, error)
UpdateRun insert new or return existing model run metadata in database.
Run status must be completed (success, exit or error) otherwise error returned. If this run already exist then nothing is updated in database, only metadata updated with actual run id. Run digest is used to find existing model run, it cannot be empty "" string otherwise error returned.
Double format is used for progress value float conversion, if non-empty format supplied.
It return "is found" flag and update metadata with actual run id in database.
func (*RunMeta) UpdateRunText ¶
func (meta *RunMeta) UpdateRunText(dbConn *sql.DB, modelDef *ModelMeta, runId int, langDef *LangMeta) error
UpdateRunText merge run text (run description and notes) and run parameter notes into run_txt and run_parameter_txt tables.
New run text merged with existing db rows by update or insert if rows not exist db tables. If run not exist then function does nothing. Run status must be completed (success, exit or error) otherwise error returned. Run id of the input run metadata updated with runId value.
type RunParamTxtRow ¶
type RunParamTxtRow struct { RunId int // run_id INT NOT NULL ParamHid int // parameter_hid INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Note string // note VARCHAR(32000) }
RunParamTxtRow is db row of run_parameter_txt
func GetRunAllParamText ¶
GetRunAllParamText return all run parameters value notes: run_parameter_txt table rows.
If langCode not empty then only specified language selected else all languages
func GetRunParamText ¶
func GetRunParamText(dbConn *sql.DB, runId int, paramHid int, langCode string) ([]RunParamTxtRow, error)
GetRunParamText return run parameter value notes: run_parameter_txt table rows.
If langCode not empty then only specified language selected else all languages
type RunProgress ¶
type RunProgress struct { SubId int // sub_id INT NOT NULL, -- sub-value id (zero based index) CreateDateTime string // create_dt VARCHAR(32) NOT NULL, -- start date-time Status string // status VARCHAR(1) NOT NULL, -- run status: i=init p=progress s=success x=exit e=error(failed) UpdateDateTime string // update_dt VARCHAR(32) NOT NULL, -- last update date-time Count int // progress_count INT NOT NULL, -- progress count: percent completed Value float64 // progress_value FLOAT NOT NULL, -- progress value: number of cases (case based) or time (time based) }
RunProgress is a "public" sub-value run_progress db row
func GetRunProgress ¶
func GetRunProgress(dbConn *sql.DB, runId int) ([]RunProgress, error)
GetRunProgress return sub-values run progress for specified run id: run_progress table rows.
type RunPub ¶
type RunPub struct { ModelName string // model name for that run ModelDigest string // model digest for that run Name string // run_name VARCHAR(255) NOT NULL SubCount int // sub_count INT NOT NULL, -- subvalue count SubStarted int // sub_started INT NOT NULL, -- number of subvalues started SubCompleted int // sub_completed INT NOT NULL, -- number of subvalues completed CreateDateTime string // create_dt VARCHAR(32) NOT NULL, -- start date-time Status string // status VARCHAR(1) NOT NULL, -- run status: i=init p=progress s=success x=exit e=error(failed) UpdateDateTime string // update_dt VARCHAR(32) NOT NULL, -- last update date-time RunDigest string // run_digest VARCHAR(32) NULL, -- digest of the run metadata: model digest, run name, sub count, created date-time, run stamp ValueDigest string // value_digest VARCHAR(32), -- if not NULL then digest of the run values: all parameters and output tables RunStamp string // run_stamp VARCHAR(32) NOT NULL, -- process run stamp, by default is log time stamp Txt []DescrNote // run text: description and notes by language Opts map[string]string // options used to run the model: run_option Param []ParamRunSetPub // run parameters: name, sub-value count and value notes by language Table []TableRunPub // run tables: name for tables included in run_table Progress []RunProgress // run progress by sub-values: run_progress table rows }
RunPub is "public" model run metadata for json import-export
type RunRow ¶
type RunRow struct { RunId int // run_id INT NOT NULL, -- unique run id ModelId int // model_id INT NOT NULL Name string // run_name VARCHAR(255) NOT NULL, -- model run name SubCount int // sub_count INT NOT NULL, -- subvalue count SubStarted int // sub_started INT NOT NULL, -- number of subvalues started SubCompleted int // sub_completed INT NOT NULL, -- number of subvalues completed CreateDateTime string // create_dt VARCHAR(32) NOT NULL, -- start date-time Status string // status VARCHAR(1) NOT NULL, -- run status: i=init p=progress s=success x=exit e=error(failed) UpdateDateTime string // update_dt VARCHAR(32) NOT NULL, -- last update date-time RunDigest string // run_digest VARCHAR(32) NULL, -- digest of the run metadata: model digest, run name, sub count, created date-time, run stamp ValueDigest string // value_digest VARCHAR(32), -- if not NULL then digest of the run values: all parameters and output tables RunStamp string // run_stamp VARCHAR(32) NOT NULL, -- process run stamp, by default is log time stamp }
RunRow is model run row: run_lst table row.
Run status: i=init p=progress s=success x=exit e=error(failed). Run id must be different from working set id (use id_lst to get it)
func GetFirstRun ¶
GetFirstRun return first run of the model: run_lst table row.
func GetLastCompletedRun ¶
GetLastCompletedRun return last completed run of the model: run_lst table row.
Run completed if run status one of: s=success, x=exit, e=error
func GetLastRun ¶
GetLastRun return last run of the model: run_lst table row.
func GetLastRunByName ¶ added in v1.6.3
GetLastRunByName return model run row by run name: run_lst table row.
If there is multiple runs with this name then run with max(run_id) returned
func GetRunByDigest ¶
GetRunByDigest return model run row by digest: run_lst table row.
func GetRunByDigestOrStampOrName ¶
GetRunByDigestOrStampOrName return model run row by run digest or run stamp or run name: run_lst table row.
It does select run row by digest, if not found then by model id and stamp, if not found by model id and run name. If there is multiple runs with this stamp or name then run with min(run_id) returned
func GetRunByName ¶
GetRunByName return model run row by run name: run_lst table row.
If there is multiple runs with this name then run with min(run_id) returned
func GetRunByStamp ¶
GetRunByStamp return model run row by run stamp: run_lst table row.
If there is multiple runs with this stamp then run with min(run_id) returned
func GetRunList ¶
GetRunList return list of model runs by model_id: run_lst rows.
func GetRunListByDigestOrStampOrName ¶
GetRunListByDigestOrStampOrName return list of model run rows by run digest or run stamp or run name: run_lst table rows.
It does select run row by digest, if not found then by model id and stamp, if not found by model id and run name. If there is multiple runs with this stamp or name then multiple rows returned
type RunTxtRow ¶
type RunTxtRow struct { RunId int // run_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
RunTxtRow is db row of run_txt
type TableAccRow ¶
type TableAccRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL AccId int // acc_id INT NOT NULL Name string // acc_name VARCHAR(255) NOT NULL IsDerived bool // is_derived SMALLINT NOT NULL SrcAcc string // acc_src VARCHAR(255) NOT NULL AccSql string // acc_sql VARCHAR(2048) NOT NULL // contains filtered or unexported fields }
TableAccRow is db row of table_acc join to model_table_dic table
type TableAccTxtRow ¶
type TableAccTxtRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL AccId int // acc_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TableAccTxtRow is db row of table_acc_txt join to model_table_dic table
type TableDicRow ¶
type TableDicRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL TableHid int // table_hid INT NOT NULL, -- unique table id Name string // table_name VARCHAR(255) NOT NULL Digest string // table_digest VARCHAR(32) NOT NULL IsUser bool // is_user SMALLINT NOT NULL Rank int // table_rank INT NOT NULL IsSparse bool // is_sparse SMALLINT NOT NULL DbExprTable string // db_expr_table VARCHAR(64) NOT NULL DbAccTable string // db_acc_table VARCHAR(64) NOT NULL DbAccAllView string // db_acc_all_view VARCHAR(64) NOT NULL ExprPos int // expr_dim_pos INT NOT NULL IsHidden bool // is_hidden SMALLINT NOT NULL ImportDigest string // import_digest VARCHAR(32) NOT NULL }
TableDicRow is db row of table_dic join to model_table_dic table.
TableHid (table_dic.table_hid) is db-unique id of the output table, use digest to find same table in other db. TableId (model_table_dic.model_table_id) is model-unique output table id, assigned by model compiler.
type TableDimsRow ¶
type TableDimsRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL DimId int // dim_id INT NOT NULL Name string // dim_name VARCHAR(255) NOT NULL TypeId int // model_type_id INT NOT NULL IsTotal bool // is_total SMALLINT NOT NULL DimSize int // dim_size INT NOT NULL // contains filtered or unexported fields }
TableDimsRow is db row of table_dims join to model_table_dic table
type TableDimsTxtRow ¶
type TableDimsTxtRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL DimId int // dim_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TableDimsTxtRow is db row of table_dims_txt join to model_table_dic table
type TableExprRow ¶
type TableExprRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL ExprId int // expr_id INT NOT NULL Name string // expr_name VARCHAR(255) NOT NULL Decimals int // expr_decimals INT NOT NULL SrcExpr string // expr_src VARCHAR(255) NOT NULL ExprSql string // expr_sql VARCHAR(2048) NOT NULL // contains filtered or unexported fields }
TableExprRow is db row of table_expr join to model_table_dic table
type TableExprTxtRow ¶
type TableExprTxtRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL ExprId int // expr_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TableExprTxtRow is db row of table_expr_txt join to model_table_dic table
type TableMeta ¶
type TableMeta struct { TableDicRow // model output table row: table_dic join to model_table_dic Dim []TableDimsRow // output table dimension rows: table_dims join to model_table_dic Acc []TableAccRow // output table accumulator rows: table_acc join to model_table_dic Expr []TableExprRow // output table expression rows: table_expr join to model_table_dic // contains filtered or unexported fields }
TableMeta is output table metadata: table name, dimensions, accumulators, expressions
type TableRunPub ¶ added in v1.8.4
type TableRunPub struct { Name string // parameter name ValueDigest string // value digest, not empty only as result of select from table_parameter; input from "public" value digest is ignored }
TableRunPub is "public" metadata for output tables included in model run results
type TableTxtRow ¶
type TableTxtRow struct { ModelId int // model_id INT NOT NULL TableId int // model_table_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) ExprDescr string // expr_descr VARCHAR(255) NOT NULL ExprNote string // expr_note VARCHAR(32000) }
TableTxtRow is db row of table_dic_txt join to model_table_dic table
type TaskDef ¶
type TaskDef struct { Task TaskRow // modeling task row: task_lst Txt []TaskTxtRow // task text rows: task_txt Set []int // task body (current list of workset id's): task_set }
TaskDef is modeling task definition: metadata and input worksets
type TaskDefPub ¶
type TaskDefPub struct { ModelName string // model name for that task list ModelDigest string // model digest for that task list Name string // task_name VARCHAR(255) NOT NULL Txt []DescrNote // task text: description and notes by language Set []string // task body: list of workset names }
TaskDefPub is "public" modeling task metadata and task input worksets for json import-export
type TaskMeta ¶
type TaskMeta struct { TaskDef // task definition: metadata and input worksets TaskRun []taskRunItem // task run history: task_run_lst and task_run_set rows }
TaskMeta is metadata for modeling task: name, status, description, notes, task run history.
Modeling task is a named set of input model inputs (of workset ids) to run the model. Typical use case: create multiple input sets by varying some model parameters, combine it under named "task" and run the model with that task name. As result multiple model "runs" created ("run" is input and output data of model run). Such run of model called "task run" and allow to study dependencies between model input and output.
Task can be edited by user: new input workset ids added or some workset id(s) excluded. As result current task body (workset ids of the task) may be different from older version of it: task_set set_id's may not be same as task_run_set set_id's. TaskRun and TaskRunSet is a history and result of that task run, but there is no guarantee of any workset in task history still exist or contain same input parameter values as it was at the time of task run. To find actual input for any particular model run and/or task run we must use run_id.
func GetTaskFull ¶
GetTaskFull return modeling task metadata, description, notes and run history from db-tables: task_lst, task_txt, task_set, task_run_lst, task_run_set.
It does not return non-completed task runs (run in progress). If langCode not empty then only specified language selected else all languages
func GetTaskFullList ¶
func GetTaskFullList(dbConn *sql.DB, modelId int, isSuccess bool, langCode string) ([]TaskMeta, error)
GetTaskFullList return list of modeling tasks metadata, description, notes and run history from db-tables: task_lst, task_txt, task_set, task_run_lst, task_run_set.
If isSuccess true then return only successfully completed task runs else all completed runs. It does not return non-completed task runs (run in progress). If langCode not empty then only specified language selected else all languages
func GetTaskRunList ¶
GetTaskRunList return model run history: master row from task_lst and all rows from task_run_lst, task_run_set where task run is completed.
It does not return non-completed task runs (run in progress). Task run completed if run status one of: s=success, x=exit, e=error
func (*TaskMeta) MergeTaskDef ¶
MergeTaskDef update existing and insert new modeling task definition: task metadata and task input worksets.
It does replace: task_txt and task_set db rows. It does not change anything in task run history: task_run_lst and task_run_set tables. If task not exist then new task created. Task input worksets (new content of task_set table) must exist in workset_lst.set_id. Model id and task id updated with actual database id's.
func (*TaskMeta) ReplaceTaskDef ¶
ReplaceTaskDef delete existing and insert new modeling task definition: task metadata and task input worksets.
It does replace: task_txt and task_set db rows. It does not change anything in task run history: task_run_lst and task_run_set tables. If task not exist then new task created. Task input worksets (new content of task_set table) must exist in workset_lst.set_id. Model id and task id updated with actual database id's.
func (*TaskMeta) ToPublic ¶
ToPublic convert modeling task metadata db rows into "public" modeling task format for json import-export.
func (*TaskMeta) UpdateTaskFull ¶
UpdateTaskFull delete existing and insert new modeling task and task run history in database.
Model id, task id, run id, set id updated with actual database id's. Task input worksets (new content of task_set table) must exist in workset_lst table.
type TaskPub ¶
type TaskPub struct { TaskDefPub // task definition: metadata and input worksets TaskRun []taskRunPub // task run history: task_run_lst }
TaskPub is "public" modeling task metadata, task input worksets and task run history for json import-export
func (*TaskPub) FromPublic ¶
FromPublic convert modeling task metadata from "public" format (coming from json import-export) into db rows.
It return task metadata and two boolean flags: (1) isSetNotFound = true if some of task workset names not found in current database (2) isTaskRunNotFound = true if some of task run (pairs of set, model run) set or model run not found in current database.
Worksets are searched by set name, which is unique inside of the model. Model run searched by run digest.
type TaskRow ¶
type TaskRow struct { TaskId int // task_id INT NOT NULL, -- unique task id ModelId int // model_id INT NOT NULL Name string // task_name VARCHAR(255) NOT NULL }
TaskRow is db row of task_lst.
func GetTask ¶
GetTask return modeling task rows by id: task_lst table row and set ids from task_set
func GetTaskByName ¶
GetTaskByName return modeling task rows by id: task_lst table row and set ids from task_set
type TaskRunRow ¶
type TaskRunRow struct { TaskRunId int // task_run_id INT NOT NULL, -- unique task run id TaskId int // task_id INT NOT NULL Name string // run_name VARCHAR(255) NOT NULL, -- task run name SubCount int // sub_count INT NOT NULL, -- subvalue count of task run CreateDateTime string // create_dt VARCHAR(32) NOT NULL, -- start date-time Status string // status VARCHAR(1) NOT NULL, -- task status: i=init p=progress w=wait s=success x=exit e=error(failed) UpdateDateTime string // update_dt VARCHAR(32) NOT NULL, -- last update date-time RunStamp string // run_stamp VARCHAR(32) NOT NULL, -- process run stamp, by default is log time stamp }
TaskRunRow is db row of task_run_lst. This table contains task run history and status.
Task status: i=init p=progress w=wait s=success x=exit e=error(failed)
if task status = w (wait) then model wait and NOT completed until other process set status to one of finals: s,x,e model check if any new sets inserted into task_set and run it as they arrive
func GetTaskFirstRun ¶
func GetTaskFirstRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
GetTaskFirstRun return first run of the modeling task: task_run_lst table row.
func GetTaskLastCompletedRun ¶
func GetTaskLastCompletedRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
GetTaskLastCompletedRun return last completed run of the modeling task: task_run_lst table row.
Task run completed if run status one of: s=success, x=exit, e=error
func GetTaskLastRun ¶
func GetTaskLastRun(dbConn *sql.DB, taskId int) (*TaskRunRow, error)
GetTaskLastRun return last run of the modeling task: task_run_lst table row.
func GetTaskRun ¶
func GetTaskRun(dbConn *sql.DB, taskRunId int) (*TaskRunRow, error)
GetTaskRun return modeling task run status: task_run_lst table row.
func GetTaskRunByName ¶
GetTaskRunByName return modeling task run status by task id and task run name: task_run_lst table row. If there is multiple task runs with this name then run with min(task_run_id) returned
func GetTaskRunByStamp ¶
GetTaskRunByStamp return modeling task run status by task id and task run stamp: task_run_lst table row. If there is multiple task runs with this stamp then run with min(task_run_id) returned
func GetTaskRunByStampOrName ¶
GetTaskRunByStampOrName return modeling task run status by task id and task run stamp or task run name: task_run_lst table row.
It does select task run row by task id and stamp, if not found then by task id and run name. If there is multiple task runs with this stamp or name then run with min(task_run_id) returned.
func GetTaskRunListByStampOrName ¶
GetTaskRunListByStampOrName return modeling task run rows from task_run_lst table by task id and task run stamp or task run name.
It does select task run rows by task id and stamp, if not found then by task id and run name. If there is multiple task runs with this stamp or name then multiple rows returned.
type TaskRunSetRow ¶
type TaskRunSetRow struct { TaskRunId int // task_run_id INT NOT NULL RunId int // run_id INT NOT NULL, -- if > 0 then result run id SetId int // set_id INT NOT NULL, -- if > 0 then input working set id TaskId int // task_id INT NOT NULL }
TaskRunSetRow is db row of task_run_set. This table contains task run input (working set id) and output (model run id)
func GetTaskRunSetRows ¶ added in v1.8.4
func GetTaskRunSetRows(dbConn *sql.DB, taskRunId int) ([]TaskRunSetRow, error)
GetTaskRunSetRows return task run body (pairs of run id and set id) by task run id: task_run_set table rows.
It does not return non-completed task run (run in progress). Task run completed if run status one of: s=success, x=exit, e=error
type TaskRunSetTxt ¶
type TaskRunSetTxt struct { SetTxt map[string][]DescrNote // map workset name to description and notes by language RunTxt map[string][]DescrNote // map run digest-or-name to description and notes by language }
TaskRunSetTxt is additional task text: description and notes by language for all input worksets and model runs of the task. Run identified by run digest or, if digest is null then by run name
func GetTaskRunSetText ¶
GetTaskRunSetText return additinal modeling task text description and notes for all task worksets and model runs: workset_txt, run_txt table rows.
It includes all input worksets text (description and notes) and comlpleted model runs text (description and notes). Task run completed if run status one of: s=success, x=exit, e=error If langCode not empty then only specified language selected else all languages.
type TaskTxtRow ¶
type TaskTxtRow struct { TaskId int // task_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TaskTxtRow is db row of task_txt
type TypeDicRow ¶
type TypeDicRow struct { ModelId int // model_id INT NOT NULL TypeId int // model_type_id INT NOT NULL TypeHid int // type_hid INT NOT NULL, -- unique type id Name string // type_name VARCHAR(255) NOT NULL, -- type name: int, double, etc. Digest string // type_digest VARCHAR(32) NOT NULL DicId int // dic_id INT NOT NULL, -- dictionary id: 0=simple 1=logical 2=classification 3=range 4=partition 5=link TotalEnumId int // total_enum_id INT NOT NULL, -- if total enabled this is enum_value of total item =max+1 }
TypeDicRow is db row of type_dic join to model_type_dic table.
TypeHid (type_dic.type_hid) is db-unique id of the type, use digest to find same type in other db. TypeId (model_type_dic.model_type_id) is model-unique type id, assigned by model compiler.
func (*TypeDicRow) IsBool ¶
func (typeRow *TypeDicRow) IsBool() bool
IsBool return true if model type is boolean.
func (*TypeDicRow) IsBuiltIn ¶
func (typeRow *TypeDicRow) IsBuiltIn() bool
IsBuiltIn return true if model type is built-in, ie: int, double, logical.
func (*TypeDicRow) IsFloat ¶
func (typeRow *TypeDicRow) IsFloat() bool
IsFloat return true if model type is float.
func (*TypeDicRow) IsInt ¶
func (typeRow *TypeDicRow) IsInt() bool
IsInt return true if model type is integer (not float, string or boolean). If type is not a built-in then it must be integer enums.
func (*TypeDicRow) IsString ¶
func (typeRow *TypeDicRow) IsString() bool
IsString return true if model type is string.
type TypeEnumRow ¶
type TypeEnumRow struct { ModelId int // model_id INT NOT NULL TypeId int // model_type_id INT NOT NULL EnumId int // enum_id INT NOT NULL Name string // enum_name VARCHAR(255) NOT NULL }
TypeEnumRow is db row of type_enum_lst join to model_type_dic table
type TypeEnumTxtRow ¶
type TypeEnumTxtRow struct { ModelId int // model_id INT NOT NULL TypeId int // model_type_id INT NOT NULL EnumId int // enum_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TypeEnumTxtRow is db row of type_enum_txt join to model_type_dic table
type TypeMeta ¶
type TypeMeta struct { TypeDicRow // model type rows: type_dic join to model_type_dic Enum []TypeEnumRow // type enum rows: type_enum_lst join to model_type_dic }
TypeMeta is type metadata: type name and enums
type TypeTxtRow ¶
type TypeTxtRow struct { ModelId int // model_id INT NOT NULL TypeId int // model_type_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
TypeTxtRow is db row of type_dic_txt join to model_type_dic table
type WorksetCreatePub ¶ added in v1.9.2
type WorksetCreatePub struct { WorksetHdrPub Param []ParamValuePub // workset parameters: name, text (value notes by language) and value }
WorksetCreatePub is "public" workset metadata and parameters list for json import-export. Each parameter must have metadata: name, subvalues count, optinal notes and value(s). Values can be either literal cell values or copy direction, for example run digest to copy from.
type WorksetHdrPub ¶
type WorksetHdrPub struct { ModelName string // model name for that workset ModelDigest string // model digest for that workset Name string // workset name: set_name VARCHAR(255) NOT NULL BaseRunDigest string // if not empty then digest of the base run IsReadonly bool // readonly flag UpdateDateTime string // last update date-time IsCleanBaseRun bool // if true then update set base run digest to NULL Txt []DescrNote // workset text: description and notes by language }
WorksetHdrPub is "public" workset metadata for json import-export
type WorksetMeta ¶
type WorksetMeta struct { Set WorksetRow // workset master row: workset_lst Txt []WorksetTxtRow // workset text rows: workset_txt Param []worksetParam // workset parameter: parameter_hid, sub-value count and workset_parameter_txt rows }
WorksetMeta is a model workset metadata: name, parameters, decription, notes.
Workset (working set of model input parameters): it can be a full set, which include all model parameters or subset and include only some parameters.
Each model must have "default" workset. Default workset must include ALL model parameters (it is a full set). Default workset is a first workset of the model: set_id = min(set_id). If workset is a subset (does not include all model parameters) then it can be based on model run results, specified by run_id (not NULL).
Workset can be editable or read-only. If workset is editable then you can modify input parameters or workset description, notes, etc. If workset is read-only then you can run the model using that workset as input.
Important: working set_id must be different from run_id (use id_lst to get it) Important: always update parameter values inside of transaction scope Important: before parameter update do is_readonly = is_readonly + 1 to "lock" workset
WorksetMeta is workset metadata db rows: workset_lst, workset_txt, workset_parameter, workset_parameter_txt
func GetWorksetFull ¶
func GetWorksetFull(dbConn *sql.DB, setRow *WorksetRow, langCode string) (*WorksetMeta, error)
GetWorksetFull return full workset metadata: workset_lst, workset_txt, workset_parameter, workset_parameter_txt table rows.
If langCode not empty then only specified language selected else all languages
func GetWorksetFullList ¶
func GetWorksetFullList(dbConn *sql.DB, modelId int, isReadonly bool, langCode string) ([]WorksetMeta, error)
GetWorksetFullList return list of full workset metadata: workset_lst, workset_txt, workset_parameter, workset_parameter_txt table rows.
If isReadonly true then return only readonly worksets else all worksets. If langCode not empty then only specified language selected else all languages
func (*WorksetMeta) ToPublic ¶
func (meta *WorksetMeta) ToPublic(dbConn *sql.DB, modelDef *ModelMeta) (*WorksetPub, error)
ToPublic convert workset db rows into "public" workset format for json import-export
func (*WorksetMeta) UpdateWorkset ¶
func (meta *WorksetMeta) UpdateWorkset(dbConn *sql.DB, modelDef *ModelMeta, isReplace bool, langDef *LangMeta) error
UpdateWorkset create new workset metadata, replace or merge existing workset metadata in database.
Set name is used to find workset and set id updated with actual database value. Workset must be read-write for replace or merge.
Only metadata updated: list of workset parameters not changed. To add or remove parameters form workset use UpdateWorksetParameterFrom() method. It is an error if incoming list parameters include any parameter which are not already in workset_parameter table.
If workset does not exist then empty workset created, without parameters. Parameter list in workset metadata must be empty if workset does not exist.
Replace is replace of existing metadata or create empty new workset. If workset exist then workset metadata replaced and parameters text metadata replaced.
Merge does merge of text metadata with existing workset or create empty new workset. If workset exist then text is updated if such language already exist or inserted if no text in that language.
func (*WorksetMeta) UpdateWorksetParameterFrom ¶ added in v1.9.7
func (meta *WorksetMeta) UpdateWorksetParameterFrom( dbConn *sql.DB, modelDef *ModelMeta, isReplaceMeta bool, param *ParamRunSetPub, langDef *LangMeta, from func() (interface{}, error), ) (int, error)
UpdateWorksetParameterFrom add new or replace existing workset parameter.
If parameter already exist in workset then parameter metadata either merged or replaced. If parameter not exist in workset then parameter values must be supplied, it cannot be empty. If parameter not exist in workset then new parameter metadata and values inserted. If from() not nil then parameter values completely replaced, on each call from() must return CellParam for all parameter values.
Set name is used to find workset and set id updated with actual database value. Workset must be read-write for replace or merge.
type WorksetParamTxtRow ¶
type WorksetParamTxtRow struct { SetId int // set_id INT NOT NULL ParamHid int // parameter_hid INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Note string // note VARCHAR(32000), -- parameter value note }
WorksetParamTxtRow is workset_parameter_txt table row.
func GetWorksetAllParamText ¶
func GetWorksetAllParamText(dbConn *sql.DB, setId int, langCode string) ([]WorksetParamTxtRow, error)
GetWorksetAllParamText return all workset parameters value notes: workset_parameter_txt table rows.
If langCode not empty then only specified language selected else all languages
func GetWorksetParamText ¶
func GetWorksetParamText(dbConn *sql.DB, setId int, paramHid int, langCode string) ([]WorksetParamTxtRow, error)
GetWorksetParamText return parameter value notes: workset_parameter_txt table rows.
If langCode not empty then only specified language selected else all languages
type WorksetPub ¶
type WorksetPub struct { WorksetHdrPub Param []ParamRunSetPub // workset parameters: name and text (value notes by language) }
WorksetPub is "public" workset metadata and parameter metadata for json import-export
func (*WorksetPub) FromPublic ¶
func (pub *WorksetPub) FromPublic(dbConn *sql.DB, modelDef *ModelMeta) (*WorksetMeta, error)
FromPublic convert workset metadata from "public" format (coming from json import-export) into db rows.
type WorksetRow ¶
type WorksetRow struct { SetId int // unique working set id BaseRunId int // if not NULL and positive then base run id (source run id) ModelId int // model_id INT NOT NULL Name string // set_name VARCHAR(255) NOT NULL IsReadonly bool // is_readonly SMALLINT NOT NULL UpdateDateTime string // update_dt VARCHAR(32) NOT NULL, -- last update date-time // contains filtered or unexported fields }
WorksetRow is workset_lst table row.
func GetDefaultWorkset ¶
func GetDefaultWorkset(dbConn *sql.DB, modelId int) (*WorksetRow, error)
GetDefaultWorkset return default working set for the model: workset_lst table row.
Default workset is a first workset for the model, each model must have default workset.
func GetWorkset ¶
func GetWorkset(dbConn *sql.DB, setId int) (*WorksetRow, error)
GetWorkset return working set by id: workset_lst table row.
func GetWorksetByName ¶
GetWorksetByName return working set by name.
If model has multiple worksets with that name then return first set.
func GetWorksetList ¶
func GetWorksetList(dbConn *sql.DB, modelId int) ([]WorksetRow, error)
GetWorksetList return list of model worksets: workset_lst rows.
type WorksetTxtRow ¶
type WorksetTxtRow struct { SetId int // set_id INT NOT NULL LangCode string // lang_code VARCHAR(32) NOT NULL Descr string // descr VARCHAR(255) NOT NULL Note string // note VARCHAR(32000) }
WorksetTxtRow is db row of workset_txt
func GetWorksetText ¶
GetWorksetText return workset description and notes: workset_txt table rows.
If langCode not empty then only specified language selected else all languages
type WriteLayout ¶
type WriteLayout struct { Name string // parameter name or output table name ToId int // run id or set id to write parameter or output table values SubCount int // sub-values count }
WriteLayout describes parameters or output tables values for insert or update.
Name is a parameter or output table name to read.
type WriteParamLayout ¶
type WriteParamLayout struct { WriteLayout // common write layout: parameter name, run or set id IsToRun bool // if true then write into into model run else into workset IsPage bool // if true then write only page of data else all parameter values DoubleFmt string // used for float model types digest calculation }
WriteParamLayout describes parameter values for insert or update. Double format string is used for digest calcultion if value type if float or double.
type WriteTableLayout ¶
type WriteTableLayout struct { WriteLayout // common write layout: output table name, run or set id DoubleFmt string // used for float model types digest calculation }
WriteTableLayout describes output table values for insert or update. Double format string is used for digest calcultion if value type if float or double.
Source Files ¶
- cellAcc.go
- cellAllAcc.go
- cellExpr.go
- cellParam.go
- cellTableCmp.go
- cellValue.go
- compare.go
- copyParameter.go
- db.go
- dbFacet.go
- dbModel.go
- dbModelCommon.go
- dbModelInternal.go
- dbModelRunSetTask.go
- db_no_odbc.go
- deleteModel.go
- deleteRun.go
- deleteTask.go
- deleteWorkset.go
- getCommon.go
- getLanguage.go
- getModel.go
- getModelText.go
- getRun.go
- getTask.go
- getWorkset.go
- publicRun.go
- publicTask.go
- publicWorkset.go
- readOutputTable.go
- readParameter.go
- readWriteLayout.go
- translateFnc.go
- translateHelper.go
- translateToSql.go
- updateCommon.go
- updateLanguage.go
- updateModel.go
- updateModelText.go
- updateProfile.go
- updateRun.go
- updateTask.go
- updateWorkset.go
- updateWorksetParameter.go
- writeOutputTable.go
- writeParameter.go