All files JenkinsView.ts

100% Statements 17/17
100% Branches 10/10
100% Functions 4/4
100% Lines 17/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61    28x 28x     2x     13x 13x 13x     26x 26x 14x   26x 14x   26x 14x   26x 14x   26x 14x                                                                
 
 
import { IJenkinsView}          from './jenkins-api-ts-typings';
import { IJenkinsJob }          from './jenkins-api-ts-typings';
 
export class JenkinsView implements IJenkinsView {
    jsonData:           JSON;
    
    name:               string;
    url:                string;
    
    description:        string;
    _class:             string;
    jobs:               Array<IJenkinsJob>;
    
    property:           Array<any>;
    
    constructor() {
        this.jobs = new Array<IJenkinsJob>();
        this.property = new Array<any>();
    }
    
    getJsonData(): string {
        return JSON.stringify(this.jsonData);
    }
    
    public fromJsonString(json: string) {
        let data:JSON = JSON.parse(json);
        this.jsonData = data;
        
        this.fromJson(data);
    }
    
    public fromJson(data: JSON) {
        this.jsonData = data;
        
        if(data.hasOwnProperty("name")) {
            this.name = (data as any)["name"];
        }
        
        if(data.hasOwnProperty("url")) {
            this.url = (data as any)["url"];
        }
        
        if(data.hasOwnProperty("description")) {
            this.description = (data as any)["description"];
        }
        
        if(data.hasOwnProperty("_class")) {
            this._class = (data as any)["_class"];
        }
        
        if(data.hasOwnProperty("property")) {
            this.property = (data as any)["property"];
        }
    }
}