Source: job-run-dto.js

import FieldDTO from './field-dto.js'
import JobDTO from './job-dto.js'
import JobResultDTO from './job-result-dto.js'

/**
 *
 */
class JobRunDTO {
  constructor (json) {
    this.json = json
  }

  /**
   * @type {string}
   */
  get createdTimestamp () {
    return this.json.createdTimestamp
  }

  /**
   * @type {number}
   */
  get errorCount () {
    return this.json.errorCount
  }

  /**
   * @type {number}
   */
  get failureCount () {
    return this.json.failureCount
  }

  /**
   * @type {string}
   */
  get id () {
    return this.json.id
  }

  /**
   * @returns {JobDTO}
   */
  get job () {
    return new JobDTO(this.json.job)
  }

  /**
   * @type {string}
   */
  get name () {
    return this.json.name
  }

  /**
   * @type {number}
   */
  get processedCount () {
    return this.json.processedCount
  }

  /**
   * @type {number}
   */
  get recordCount () {
    return this.json.recordCount
  }

  /**
   * @type {JobResultDTO[]}
   */
  get results () {
    return this.json.results.map(o => new JobResultDTO(o))
  }

  /**
   * @type {string}
   */
  get status () {
    return this.json.status
  }

  /**
   * @type {number}
   */
  get successCount () {
    return this.json.successCount
  }

  /**
   * @type {Object<string, string>}
   */
  get values () {
    return this.json.values
  }

  /**
   * @returns {boolean}
   */
  isActive () {
    return this.status === 'CLASSIFYING' || this.status === 'INITIALIZING' || this.status === 'RUNNING' || this.status === 'STOPPING'
  }

  /**
   * @returns {FieldDTO[]}
   */
  expectedFields () {
    return this.job.fields.filter(f => f.fieldType === 'EXPECTED')
  }

  /**
   * @returns {FieldDTO[]}
   */
  inputFields () {
    return this.job.fields.filter(f => f.fieldType === 'INPUT')
  }

  /**
   * @returns {boolean}
   */
  stopped () {
    return this.status === 'COMPLETED' || this.status === 'ERROR'
  }
}

export default JobRunDTO