# new Manager(baseManager, tableName, indexes, callbackopt)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
baseManager |
BaseManager
|
||
tableName |
string
|
the name of the table this manager handles |
|
indexes |
Array.<string>
|
the indexes to be added to the table |
|
callback |
function
|
<optional> |
optional callback for better application flow control |
Methods
# _deleteMessage()
Proxy call to MessageManager#deleteMessage().
Proxy call to MessageManager#deleteMessage().
# protected _err(message, err, callback)
Wrapper around OpenDSU's error wrapper
.Wrapper around OpenDSU's error wrapper
Parameters:
| Name | Type | Description |
|---|---|---|
message |
string
|
|
err |
err
|
|
callback |
function
|
- See:
-
- _err
# protected _getDSUInfo(keySSI)
Util function that loads a dsu and reads and JSON parses from the dsu's INFO_PATH
.Util function that loads a dsu and reads and JSON parses from the dsu's INFO_PATH
Parameters:
| Name | Type | Description |
|---|---|---|
keySSI |
string
|
KeySSI
|
|
callback. |
function
|
object is the /info parsed as JSON. |
# _getKeySSISpace()
will be binded as the one from participant manager on initialization
.will be binded as the one from participant manager on initialization
# _getMessages()
Proxy call to MessageManager#getMessages() using tableName as the api value.
Proxy call to MessageManager#getMessages() using tableName as the api value.
# _getResolver()
will be binded as the one from participant manager on initialization
.will be binded as the one from participant manager on initialization
# protected _getTableName() → {string}
if the manager has no tableName
Error
the tableName passed in the constructor
string
# protected _indexItem(key, itemopt, record) → {any}
Must wrap the entry in an object like:
{
index1: ...
Must wrap the entry in an object like:
{
index1: ...
index2: ...
value: item
}
so the DB can be queried by each of the indexes and still allow for lazy loading
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
key |
string
|
||
item |
object
|
string
|
<optional> |
|
record |
string
|
object
|
the indexed object to be stored in the db
any
# protected _iterator(records, getter, accumulatoropt, callback)
Util iterator function
.Util iterator function
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
records |
Array.<string>
|
||
getter |
function
|
||
accumulator |
Array.<result>
|
<optional> |
defaults to [] |
callback |
function
|
# protected _keywordToQuery(keyword, queryConditions) → {Array.<string>}
Converts the text typed in a general text box into the query for the db Subclasses should override this
.Converts the text typed in a general text box into the query for the db Subclasses should override this
Parameters:
| Name | Type | Description |
|---|---|---|
keyword |
string
|
|
queryConditions |
query
Array.<string>
# _loadDSU(keySSI)
will be binded as the one from participant manager on initialization
.will be binded as the one from participant manager on initialization
Parameters:
| Name | Type | Description |
|---|---|---|
keySSI |
string
|
KeySSI
|
# protected _messageCallback(err, …args)
Because Message sending is implemented as fire and forget (for the user experience) we need an async callback that might hold some specific logic
Meant to be overridden by subclasses when needed
.Because Message sending is implemented as fire and forget (for the user experience) we need an async callback that might hold some specific logic
Meant to be overridden by subclasses when needed
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
err |
|||
args |
<repeatable> |
# _registerMessageListener()
Proxy call to MessageManager#_registerMessageListener().
Proxy call to MessageManager#_registerMessageListener().
# _sendMessage(did, apiopt, message, callback)
Send a message to the specified DID
.Send a message to the specified DID
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
did |
string
|
W3cDID
|
||
api |
string
|
<optional> |
defaults to the tableName |
message |
string
|
||
callback |
function
|
# bindController(controller)
Util method to give optional access to the controller for event sending purposes and UI operations when required eg: refresh the view.
Util method to give optional access to the controller for event sending purposes and UI operations when required eg: refresh the view.
Accepts multiple calls (with keep the reference to all controllers)
Parameters:
| Name | Type | Description |
|---|---|---|
controller |
LocalizedController
|
# create(keyopt, item, callback)
Creates a new item
Child classes should override this so they can be called without the key param in Web Components (and also to actually create the DSUs)
.Creates a new item
Child classes should override this so they can be called without the key param in Web Components (and also to actually create the DSUs)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
key |
string
|
<optional> |
key is optional so child classes can override them |
item |
object
|
||
callback |
function
|
# createAll(keys, items, callback)
Creates several new items
.Creates several new items
Parameters:
| Name | Type | Description |
|---|---|---|
keys |
Array.<string>
|
key is optional so child classes can override them |
items |
Array.<object>
|
|
callback |
function
|
# deleteMessage()
- See:
-
- _deleteMessage
# deleteRecord(tableNameopt, key, callback)
Wrapper around the storage's deleteRecord where the tableName defaults to the manager's
.Wrapper around the storage's deleteRecord where the tableName defaults to the manager's
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
tableName |
string
|
<optional> |
defaults to the manager's table name |
key |
string
|
||
callback |
function
|
# fromModel(model) → {object}
Should translate the Controller Model into the Business Model
.Should translate the Controller Model into the Business Model
Parameters:
| Name | Type | Description |
|---|---|---|
model |
the Controller's Model |
the Business Model object ready to feed to the constructor
object
# getAll(readDSUopt, optionsopt, callback)
Lists all registered items according to query options provided
.Lists all registered items according to query options provided
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
readDSU |
boolean
|
<optional> |
defaults to true. decides if the manager loads and reads from the dsu's INFO_PATH or not |
options |
object
|
<optional> |
query options. defaults to DEFAULT_QUERY_OPTIONS |
callback |
function
|
# getIdentity(callback)
will be binded as the one from participant manager on initialization
.will be binded as the one from participant manager on initialization
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function
|
# getMessages()
- See:
-
- _getMessages
# getOne(key, readDSUopt, callback)
reads ssi for that gtin in the db.
reads ssi for that gtin in the db. loads is and reads the info at '/info'
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
key |
string
|
||
readDSU |
boolean
|
<optional> |
defaults to true. decides if the manager loads and reads from the dsu or not |
callback |
function
|
returns the Product if readDSU and the dsu, the keySSI otherwise |
# getOneStripped(key, callback)
reads ssi for that gtin in the db.
reads ssi for that gtin in the db. loads is and reads the info at '/info'
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string
|
|
callback |
function
|
returns the Product if readDSU and the dsu, the keySSI otherwise |
# getPage(itemsPerPage, page, dsuQuery:, keyword:, sort, readDSU, callback)
Returns a page object from provided dsuQuery or a keyword
.Returns a page object from provided dsuQuery or a keyword
Parameters:
| Name | Type | Description |
|---|---|---|
itemsPerPage |
number
|
|
page |
number
|
|
dsuQuery: |
Array.<string>
|
force a fixed CONDITION in all keyword query or for a simple query paginated. |
keyword: |
string
|
keyword to search on all indexes |
sort |
string
|
|
readDSU |
boolean
|
|
callback |
function
|
# getRecord(tableNameopt, key, callback)
Wrapper around the storage's getRecord where the tableName defaults to the manager's
.Wrapper around the storage's getRecord where the tableName defaults to the manager's
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
tableName |
string
|
<optional> |
defaults to the manager's table name |
key |
string
|
||
callback |
function
|
# getStorage()
Lazy loads the db Is created in the constructor
.Lazy loads the db Is created in the constructor
# insertRecord(tableNameopt, key, record, callback)
Wrapper around the storage's insertRecord where the tableName defaults to the manager's
.Wrapper around the storage's insertRecord where the tableName defaults to the manager's
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
tableName |
string
|
<optional> |
defaults to the manager's table name |
key |
string
|
||
record |
object
|
||
callback |
function
|
# processMessageRecord(record, callback)
Processes the received messages, saves them to the the table and deletes the message
.Processes the received messages, saves them to the the table and deletes the message
Parameters:
| Name | Type | Description |
|---|---|---|
record |
||
callback |
function
|
# processMessages(callback)
Process incoming, looking for receivedOrder messages.
Process incoming, looking for receivedOrder messages.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function
|
# query(tableNameopt, query, sort, limit, callback)
Wrapper around the storage's query where the tableName defaults to the manager's
.Wrapper around the storage's query where the tableName defaults to the manager's
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
tableName |
string
|
<optional> |
defaults to the manager's table name |
query |
function
|
||
sort |
string
|
||
limit |
number
|
||
callback |
function
|
# refreshController(propsopt)
Util method to give optional access to the controller to be able to refresh the view (will call the refresh method on all binded controllers via Manager#bindController)
.Util method to give optional access to the controller to be able to refresh the view (will call the refresh method on all binded controllers via Manager#bindController)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
props |
Object
|
<optional> |
option props to pass to the controllers refresh method |
# registerMessageListener()
- See:
-
- _registerMessageListener
# remove(key, callback)
Removes a product from the list (does not delete/invalidate DSU, simply 'forgets' the reference)
.Removes a product from the list (does not delete/invalidate DSU, simply 'forgets' the reference)
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string
|
number
|
|
callback |
function
|
# sendMessage(did, apiopt, message, callback)
Send a message to the specified DID
.Send a message to the specified DID
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
did |
string
|
W3cDID
|
||
api |
string
|
<optional> |
defaults to the tableName |
message |
string
|
||
callback |
function
|
# shutdownMessenger()
Stops the message service listener when it is running
.Stops the message service listener when it is running
# toModel(object, model) → {Object}
Parameters:
| Name | Type | Description |
|---|---|---|
object |
object
|
the business model object |
model |
the Controller's model object |
Object
# update(keyopt, newItem, callback)
updates an item
.updates an item
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
key |
string
|
<optional> |
key is optional so child classes can override them |
newItem |
object
|
||
callback |
function
|
# updateAll(keysopt, newItems, callback)
updates a bunch of items
.updates a bunch of items
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
keys |
Array.<string>
|
<optional> |
key is optional so child classes can override them |
newItems |
Array.<object>
|
||
callback |
function
|
# updateRecord(tableNameopt, key, newRecord, callback)
Wrapper around the storage's updateRecord where the tableName defaults to the manager's
.Wrapper around the storage's updateRecord where the tableName defaults to the manager's
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
tableName |
string
|
<optional> |
defaults to the manager's table name |
key |
string
|
||
newRecord |
*
|
string
|
||
callback |
function
|