SiteCalibrationRepository
SiteCalibrationRepository
is the base class that every repository inherit from.
Extends
AbstractRepository
class SiteCalibrationReporitory extends AbstractRepository
Static Methods
::getName
static getName(): string
Returns:
Type: constant ("SiteCalibration" :string)
Overwritten Methods
findBy
findBy(filters: Object<string, *>): Array<SiteCalibration>
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
filters | Object<string, *> | Yes | - | An object with entity property as key and associated filter function as value. See search doc |
Returns:
Type: Array<SiteCalibration>
findOneBy
findOneBy(filters: Object<string, *>): SiteCalibration|null
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
filters | Object<string, *> | Yes | - | An object with entity property as key and associated filter function as value. See search doc |
Returns:
Type: SiteCalibration|null
isValid
isValid(entity: SiteCalibration): boolean
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
entity | SiteCalibration | Yes | - |
Returns:
Type: boolean
get
get(id: int|symbol|SiteCalibration|Reference<SiteCalibration>|null): SiteCalibration|null
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
id | int | symbol | SiteCalibration | Reference<SiteCalibration> | null | Yes | - |
Returns:
Type: SiteCalibration|null
getAll
getAll(): Array<SiteCalibration>
Returns:
Type: Array<SiteCalibration>
getList
getList(ids: Array<int|symbol|SiteCalibration|Reference<SiteCalibration>|null>): Array<SiteCalibration|null>
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
ids | Array<int | symbol | SiteCalibration | Reference<SiteCalibration> | null> | Yes | - |
Returns:
Type: Array<SiteCalibration|null>
persist
persist(entity: SiteCalibration): void
Create / Update an entity
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
entity | SiteCalibration | Yes | - |
Returns:
Type: void
remove
remove(entity: SiteCalibration|Reference<SiteCalibration>|symbol|int): void
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
entity | Array<int | symbol | SiteCalibration | Reference<SiteCalibration> | Yes | - |
Returns:
Type: void
validate
validate(entity: SiteCalibration): Map<string,string>
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
entity | SiteCalibration | Yes | - |
Returns:
A Map of invalid properties associated to error message
Type: Map<string,string>
validateProperty
validateProperty(entity: SiteCalibration, property: string): string|null
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
entity | SiteCalibration | Yes | - | |
property | string | Yes | - |
Returns:
The error message or null if it's valid
Type: string|null
Inherited Methods
isLoaded
isLoaded(): boolean
Returns:
Type: boolean
isLoading
isLoading(): boolean
Returns:
Type: boolean
load
async load(fallbackOnCache: boolean = true): Promise<void, Error>
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
fallbackOnCache | boolean | No | true | If request to API fail, then it will fallback to CacheManager if this parameter is true |
Returns:
Type: Promise<void, Error>
loadFromCache
async loadFromCache(allowOutdated: boolean = false): Promise<void, Error>
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
allowOutdated | boolean | No | false | If the cache is not up-to-date, it will reject the loading. See Offline - Cache First |
Returns:
Type: Promise<void, Error>
Overwritten Events
CREATE
EventDispatcher.subscribe(repository, REPOSITORY_EVENTS.CREATE, listener)
Create event is fired when persisting a new entity (i.e. id is null).
The listener will receive the following parameters
Listener Parameters:
Name | Type | Description |
---|---|---|
entity | SiteCalibration |
UPDATE
EventDispatcher.subscribe(repository, REPOSITORY_EVENTS.UPDATE, listener)
Create event is fired when persisting an existing entity.
The listener will receive the following parameters
Listener Parameters:
Name | Type | Description |
---|---|---|
data | object | |
data.current | SiteCalibration | A read-only copy of the newly updated entity |
data.previous | SiteCalibration | A read-only copy of the previous entity |
data.changes | string[] | An array containing all updated properties |
REMOVE
EventDispatcher.subscribe(repository, REPOSITORY_EVENTS.REMOVE, listener)
Create event is fired when removing entity.
The listener will receive the following parameters
Listener Parameters:
Name | Type | Description |
---|---|---|
entity | SiteCalibration |
IDENTIFIER_WILL_CHANGE
EventDispatcher.subscribe(repository, REPOSITORY_EVENTS.IDENTIFIER_WILL_CHANGE, listener)
This event is fired during flush BEFORE the object identifier is updated according to the remote server.
Usage: When a new entity is created, the EntityManager will assign a Symbol() as id. When flushing, the entity is saved on the remote server which will send it's real id.
The listener will receive the following parameters
Listener Parameters:
Name | Type | Description |
---|---|---|
data | Array<int | symbol> | An array of size 2 elements [first, second] respectively the next and current id |
data[0] | int | symbol | the new id |
data[1] | int | symbol | the current id |
IDENTIFIER_DID_CHANGE
EventDispatcher.subscribe(repository, REPOSITORY_EVENTS.IDENTIFIER_DID_CHANGE, listener)
This event is fired during flush AFTER the object identifier is updated according to the remote server.
Usage: When a new entity is created, the EntityManager will assign a Symbol() as id. When flushing, the entity is saved on the remote server which will send it's real id.
The listener will receive the following parameters
Listener Parameters:
Name | Type | Description |
---|---|---|
data | Array<int | symbol> | An array of size 2 elements [first, second] respectively the current and previous id |
data[0] | int | symbol | the current id |
data[1] | int | symbol | the previous id |