@xompass/sdk-cloud-api
Version:
Xompass Client for cloud-api
196 lines (190 loc) • 4.85 kB
text/typescript
import {ModelDefinition} from './BaseModels';
import {Asset} from './Asset';
import {Alert} from './Alert';
import {AlertHistory} from './AlertHistory';
import {AssetStateTemplate} from './AssetStateTemplate';
import {EventTriggerAssetState} from './EventTriggerAssetState';
import {Log} from './Log';
import {Sensor} from './Sensor';
import {SensorAssetState} from './SensorAssetState';
declare var Object: any;
export interface AssetStateInterface {
name?: string;
schedulerType: string;
scheduler?: any;
created?: Date;
modified?: Date;
deleted?: Date;
id?: any;
assetId?: any;
templateId?: any;
asset?: Asset;
alerts?: Alert[];
alertHistory?: AlertHistory[];
template?: AssetStateTemplate;
eventTriggerAssetStates?: EventTriggerAssetState[];
trackingLogs?: Log[];
sensors?: Sensor[];
states?: SensorAssetState[];
}
export class AssetState implements AssetStateInterface {
name: string;
schedulerType: string = 'NONE';
scheduler: any;
created: Date;
modified: Date;
deleted: Date;
id: any;
assetId: any;
templateId: any;
asset?: Asset;
alerts?: Alert[];
alertHistory?: AlertHistory[];
template?: AssetStateTemplate;
eventTriggerAssetStates?: EventTriggerAssetState[];
trackingLogs?: Log[];
sensors?: Sensor[];
states?: SensorAssetState[];
constructor(data?: AssetStateInterface) {
Object.assign(this, data);
}
/**
* The name of the model represented by this $resource,
* i.e. `AssetState`.
*/
public static getModelName(): string {
return 'AssetState';
}
/**
* @method factory
* @author Jonathan Casarrubias
* @license MIT
* This method creates an instance of AssetState for dynamic purposes.
*/
public static factory(data: AssetStateInterface): AssetState{
return new AssetState(data);
}
/**
* @method getModelDefinition
* @author Julien Ledun
* @license MIT
* This method returns an object that represents some of the model
* definitions.
*/
public static getModelDefinition(): ModelDefinition {
return {
name: 'AssetState',
plural: 'AssetStates',
path: 'AssetStates',
idName: 'id',
properties: {
name: {
name: 'name',
type: 'string'
},
schedulerType: {
name: 'schedulerType',
type: 'string',
default: 'NONE'
},
scheduler: {
name: 'scheduler',
type: 'any'
},
created: {
name: 'created',
type: 'Date'
},
modified: {
name: 'modified',
type: 'Date'
},
deleted: {
name: 'deleted',
type: 'Date',
default: undefined
},
id: {
name: 'id',
type: 'any'
},
assetId: {
name: 'assetId',
type: 'any'
},
templateId: {
name: 'templateId',
type: 'any'
},
},
relations: {
asset: {
name: 'asset',
type: 'Asset',
model: 'Asset',
relationType: 'belongsTo',
keyFrom: 'assetId',
keyTo: 'id'
},
alerts: {
name: 'alerts',
type: 'Alert[]',
model: 'Alert',
relationType: 'hasMany',
keyFrom: 'id',
keyTo: 'assetStateId'
},
alertHistory: {
name: 'alertHistory',
type: 'AlertHistory[]',
model: 'AlertHistory',
relationType: 'hasMany',
keyFrom: 'id',
keyTo: 'assetStateId'
},
template: {
name: 'template',
type: 'AssetStateTemplate',
model: 'AssetStateTemplate',
relationType: 'belongsTo',
keyFrom: 'templateId',
keyTo: 'id'
},
eventTriggerAssetStates: {
name: 'eventTriggerAssetStates',
type: 'EventTriggerAssetState[]',
model: 'EventTriggerAssetState',
relationType: 'hasMany',
keyFrom: 'id',
keyTo: 'assetStateId'
},
trackingLogs: {
name: 'trackingLogs',
type: 'Log[]',
model: 'Log',
relationType: 'hasMany',
keyFrom: 'id',
keyTo: 'trackingModelId'
},
sensors: {
name: 'sensors',
type: 'Sensor[]',
model: 'Sensor',
relationType: 'hasMany',
modelThrough: 'SensorAssetState',
keyThrough: 'sensorId',
keyFrom: 'id',
keyTo: 'assetStateId'
},
states: {
name: 'states',
type: 'SensorAssetState[]',
model: 'SensorAssetState',
relationType: 'hasMany',
keyFrom: 'id',
keyTo: 'assetStateId'
},
}
};
}
}