import {ModelDefinition} from './BaseModels';
import {Asset} from './Asset';
import {Log} from './Log';
import {Manager} from './Manager';
import {Project} from './Project';
declare var Object: any;

export interface CctvDashboardInterface {
  name: string;
  description?: string;
  created?: Date;
  modified?: Date;
  deleted?: Date;
  id?: any;
  assetIds?: Array<any>;
  projectId?: any;
  assets?: Asset[];
  trackingLogs?: Log[];
  managers?: Manager[];
  project?: Project;
}

export class CctvDashboard implements CctvDashboardInterface {
  name: string;
  description: string;
  created: Date;
  modified: Date;
  deleted: Date;
  id: any;
  assetIds: Array<any> = [];
  projectId: any;
  assets?: Asset[];
  trackingLogs?: Log[];
  managers?: Manager[];
  project?: Project;
  constructor(data?: CctvDashboardInterface) {
    Object.assign(this, data);
  }

  /**
   * The name of the model represented by this $resource,
   * i.e. `CctvDashboard`.
   */
  public static getModelName(): string {
    return 'CctvDashboard';
  }

  /**
   * @method factory
   * @author Jonathan Casarrubias
   * @license MIT
   * This method creates an instance of CctvDashboard for dynamic purposes.
   */
  public static factory(data: CctvDashboardInterface): CctvDashboard{
    return new CctvDashboard(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: 'CctvDashboard',
      plural: 'CctvDashboards',
      path: 'CctvDashboards',
      idName: 'id',
      properties: {
        name: {
          name: 'name',
          type: 'string'
        },
        description: {
          name: 'description',
          type: 'string'
        },
        created: {
          name: 'created',
          type: 'Date'
        },
        modified: {
          name: 'modified',
          type: 'Date'
        },
        deleted: {
          name: 'deleted',
          type: 'Date',
          default: undefined
        },
        id: {
          name: 'id',
          type: 'any'
        },
        assetIds: {
          name: 'assetIds',
          type: 'Array&lt;any&gt;',
          default: []
        },
        projectId: {
          name: 'projectId',
          type: 'any'
        },
      },
      relations: {
        assets: {
          name: 'assets',
          type: 'Asset[]',
          model: 'Asset',
          relationType: 'referencesMany',
          keyFrom: 'assetIds',
          keyTo: 'id'
        },
        trackingLogs: {
          name: 'trackingLogs',
          type: 'Log[]',
          model: 'Log',
          relationType: 'hasMany',
          keyFrom: 'id',
          keyTo: 'trackingModelId'
        },
        managers: {
          name: 'managers',
          type: 'Manager[]',
          model: 'Manager',
          relationType: 'hasMany',
          modelThrough: 'ManagerCctvDashboard',
          keyThrough: 'managerId',
          keyFrom: 'id',
          keyTo: 'cctvDashboardId'
        },
        project: {
          name: 'project',
          type: 'Project',
          model: 'Project',
          relationType: 'belongsTo',
          keyFrom: 'projectId',
          keyTo: 'id'
        },
      }
    };
  }
}
