Constructor
new BusinessLogic(context, rowChanges)
Manages business logic invocation
Parameters:
Name | Type | Description |
---|---|---|
context |
Context | |
rowChanges |
Array.<ObjectRow> |
- Source:
Methods
addMessages(rowChange, bits, result, post) → {*}
Takes error messages and append them to results
Parameters:
Name | Type | Description |
---|---|---|
rowChange |
RowChange | |
bits |
string | 01 representation of sp result |
result |
BusinessLogicResult | set, messages are added to this list |
post |
boolean | true if post message |
- Source:
Returns:
- Type
- *
createAuditDataSet() → {DataSet}
Creates a dataset to read db checks
- Source:
Returns:
- Type
- DataSet
execCheckBatch(conn, checks, cmd, result, post) → {*}
Executes a batch and adds messages to results
Parameters:
Name | Type | Description |
---|---|---|
conn |
DataAccess | |
checks |
Array.<RowChange> | |
cmd |
string | |
result |
BusinessLogicResult | used to push found errors |
post |
boolean |
- Source:
Returns:
- Type
- *
filterParameters(r, post)
Evaluates the filter to obtain parameters for a audit call
Parameters:
Name | Type | Description |
---|---|---|
r |
DataRow | |
post |
boolean |
- Source:
getChecks(result, conn, post) → {Promise.<BusinessLogicResult>}
Evaluates a series of messages
Parameters:
Name | Type | Description |
---|---|---|
result |
BusinessLogicResult | |
conn |
DataAccess | Current connection having the transaction attached |
post |
boolean |
- Source:
Returns:
- Type
- Promise.<BusinessLogicResult>
getChecksAsync(result, conn, post) → {Promise.<BusinessLogicResult>}
Evaluates a series of messages
Parameters:
Name | Type | Description |
---|---|---|
result |
BusinessLogicResult | |
conn |
DataAccess | Current connection having the transaction attached |
post |
boolean |
- Source:
Returns:
- Type
- Promise.<BusinessLogicResult>
getFilterForRules() → {jsDataQuery}
- Source:
Returns:
- Type
- jsDataQuery
getProcFilter(r, post) → {sqlFun}
calculate a filter to obtain rule parameters
Parameters:
Name | Type | Description |
---|---|---|
r |
ObjectRow | |
post |
boolean |
- Source:
Returns:
- Type
- sqlFun
getProcName(r, post) → {string}
Get stored procedure name to be called to check r audits
Parameters:
Name | Type | Description |
---|---|---|
r |
ObjectRow | |
post |
boolean |
- Source:
Returns:
- Type
- string
getQuery(fromT, fromR, toTable, cols) → {jsDataQuery}
Evaluates a jsDataQuery to read data of toTable from database
FromT is a table while toTable could be a view, so could not have a primary key
Parameters:
Name | Type | Description |
---|---|---|
fromT |
DataTable | |
fromR |
DataRow | |
toTable |
DataTable | |
cols |
Array.<string> | key columns and eventually ayear field if it belongs to table columns |
- Source:
Returns:
- Type
- jsDataQuery
getRules(rowChanges) → {Deferred.<DataSet>}
Gets necessary rules from a database in order to save a set of row change. This can ben invoked
before the start of a transaction.
Parameters:
Name | Type | Description |
---|---|---|
rowChanges |
Array.<ObjectRow> | changes made in memory |
- Source:
Returns:
- Type
- Deferred.<DataSet>
isTempAutoIncrement(r, colName)
Establish if a field must be passed to Business audits
Parameters:
Name | Type | Description |
---|---|---|
r |
DataRow | |
colName |
string |
- Source:
opCode(r) → {string}
Gives a code for operation being applied to r
Parameters:
Name | Type | Description |
---|---|---|
r |
DataRow |
- Source:
Returns:
- Type
- string
parametersFor(auditParameters, rc, post) → {Array.<{name:string, value}>}
Returns a collection of (name, value) couples, evaluated basing on auditParameters
Parameters:
Name | Type | Description |
---|---|---|
auditParameters |
DataTable | |
rc |
RowChange | |
post |
boolean |
- Source:
Returns:
- Type
- Array.<{name:string, value}>
refineMessages(conn, results) → {Promise.<Array.<BusinessMessage>>}
Reads data from db in order to compile messages. Tries to optimize db access performing as little reads as possible
Parameters:
Name | Type | Description |
---|---|---|
conn |
DataAccess | |
results |
Array.<BusinessMessage> |
- Source:
Returns:
- Type
- Promise.<Array.<BusinessMessage>>
refineMessages_applySubstitutions(subs, msgs) → {*}
Apply substitutions basing on data got in subs
Parameters:
Name | Type | Description |
---|---|---|
subs |
Array.<SubstGroup> | |
msgs |
Array.<BusinessMessage> |
- Source:
Returns:
- Type
- *
refineMessages_evaluateQueries(d, results) → {Deferred}
Evaluate queries for business messages open substitutions calling setQuery and setCols
Parameters:
Name | Type | Description |
---|---|---|
d |
DataSet | |
results |
Array.<BusinessMessage> |
- Source:
Returns:
- Type
- Deferred
refineMessages_executeQueries(subs)
Execute queries stored in grouped substitutions
Parameters:
Name | Type | Description |
---|---|---|
subs |
Array.<SubstGroup> |
- Source:
refineMessages_groupQueries(results, maxQueryLength) → {Array.<SubstGroup>}
Group all queries into SubstGroup
Parameters:
Name | Type | Description |
---|---|---|
results |
Array.<BusinessMessage> | |
maxQueryLength |
int | max len for queries |
- Source:
Returns:
- Type
- Array.<SubstGroup>