/**
 * Copyright 2017 - 2018  The Hyve B.V.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */ import { CohortSubscriptionFrequency } from './cohort-subscription-frequency' ; import { CohortDiffRecord } from './cohort-diff-record' ; import { Constraint } from '../constraint-models/constraint' ; import { FormatHelper } from '../../utilities/format-helper' ; import { CombinationConstraint } from '../constraint-models/combination-constraint' ; export class Cohort { private _id : string ; private _name : string ; private _type : string ; private _description : string ; private _createDate : string ; private _createDateInfo : string ; private _updateDate : string ; private _updateDateInfo : string ; private _apiVersion : string ; private _bookmarked : boolean ; private _collapsed : boolean ; private _selected : boolean ; private _visible : boolean ; private _controlsEnabled : boolean ; private _constraint : Constraint ; private _subscribed : boolean ; private _subscriptionCollapsed : boolean ; private _subscriptionFreq : CohortSubscriptionFrequency ; private _numSubjects : number ; private _diffRecords : CohortDiffRecord [ ] ; constructor ( id , name ) { this . id = id ; this . name = name ; this . type = CombinationConstraint . TOP_LEVEL_DIMENSION ; this . collapsed = true ; this . visible = true ; this . bookmarked = false ; this . selected = false ; this . controlsEnabled = true ; this . subscribed = false ; this . subscriptionFreq = CohortSubscriptionFrequency . WEEKLY ; this . subscriptionCollapsed = true ; this . diffRecords = [ ] ; } get id ( ) : string { return this . _id ; } set id ( value ) { this . _id = value ; } get name ( ) : string { return this . _name ; } set name ( value ) { this . _name = value ; } get type ( ) : string { return this . _type ; } set type ( value ) { this . _type = value ; } get description ( ) : string { return this . _description ; } set description ( value ) { this . _description = value ; } get bookmarked ( ) : boolean { return this . _bookmarked ; } set bookmarked ( value ) { this . _bookmarked = value ; } get subscribed ( ) : boolean { return this . _subscribed ; } set subscribed ( value ) { this . _subscribed = value ; if ( value && ! this . subscriptionFreq ) { this . subscriptionFreq = CohortSubscriptionFrequency . WEEKLY ; } } get collapsed ( ) : boolean { return this . _collapsed ; } set collapsed ( value ) { this . _collapsed = value ; } get selected ( ) : boolean { return this . _selected ; } set selected ( value ) { this . _selected = value ; } get createDate ( ) : string { return this . _createDate ; } set createDate ( value ) { this . _createDate = value ; this . createDateInfo = FormatHelper . formatDateSemantics ( new Date ( value ) ) ; } get updateDate ( ) : string { return this . _updateDate ; } set updateDate ( value ) { this . _updateDate = value ; this . updateDateInfo = FormatHelper . formatDateSemantics ( new Date ( value ) ) ; } get apiVersion ( ) : string { return this . _apiVersion ; } set apiVersion ( value ) { this . _apiVersion = value ; } get visible ( ) : boolean { return this . _visible ; } set visible ( value ) { this . _visible = value ; } get createDateInfo ( ) : string { return this . _createDateInfo ; } set createDateInfo ( value ) { this . _createDateInfo = value ; } get updateDateInfo ( ) : string { return this . _updateDateInfo ; } set updateDateInfo ( value ) { this . _updateDateInfo = value ; } get subscriptionCollapsed ( ) : boolean { return this . _subscriptionCollapsed ; } set subscriptionCollapsed ( value ) { this . _subscriptionCollapsed = value ; } get subscriptionFreq ( ) : CohortSubscriptionFrequency { return this . _subscriptionFreq ; } set subscriptionFreq ( value ) { this . _subscriptionFreq = value ; } get numSubjects ( ) : number { return this . _numSubjects ; } set numSubjects ( value ) { this . _numSubjects = value ; } get diffRecords ( ) : CohortDiffRecord [ ] { return this . _diffRecords ; } set diffRecords ( value ) { this . _diffRecords = value ; } get constraint ( ) : Constraint { return this . _constraint ; } set constraint ( value ) { this . _constraint = value ; } get controlsEnabled ( ) : boolean { return this . _controlsEnabled ; } set controlsEnabled ( value ) { this . _controlsEnabled = value ; } }