All files JenkinsJob.ts

100% Statements 52/52
100% Branches 40/40
100% Functions 4/4
100% Lines 52/52
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153    110x 110x 110x 110x 110x 110x 110x     2x     54x 54x 54x     108x 108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x   108x 44x                                                                                                                                                    
 
 
import { IJenkinsJob }          from './jenkins-api-ts-typings';
import { IJenkinsBuild }        from './jenkins-api-ts-typings';
import { IJenkinsHealthReport } from './jenkins-api-ts-typings';
 
export class JenkinsJob implements IJenkinsJob {
    jsonData:           JSON;
    
    _class:             string;    
    name:               string;
    url:                string;
 
    displayName:        string;
    fullDisplayName:    string;
    description:        string;
    color:              string;
    buildable:          boolean;
    inQueue:            boolean;
    keepDependencies:   boolean;
    nextBuildNumber:    number;
    concurrentBuild:    boolean;
    displayNameOrNull:  string;
    fullName:           string;
    numberOfBuilds:     number;
    builds:             Array<IJenkinsBuild>;
    firstBuild:         IJenkinsBuild;
    lastBuild:          IJenkinsBuild;
    lastCompletedBuild: IJenkinsBuild;
    lastFailedBuild:    IJenkinsBuild;
    lastStableBuild:    IJenkinsBuild;
    lastSuccessfulBuild:IJenkinsBuild;
    lastUnstableBuild:  IJenkinsBuild;
    lastUnsuccessfulBuild: IJenkinsBuild;
    healthReport:       Array<IJenkinsHealthReport>;
    
    actions:            Array<any>;
    property:           Array<any>;
    queueItem:          any;
    downstreamProjects: Array<any>;
    upstreamProjects:   Array<any>;
    scm:                any;
    modules:            Array<any>;
 
    constructor() {
        this.builds = new Array<IJenkinsBuild>();
        this.downstreamProjects = new Array<JenkinsJob>();
        this.upstreamProjects = new Array<JenkinsJob>();
        this.actions = new Array<any>();
        this.healthReport = new Array<any>();
        this.property = new Array<any>();
        this.modules = new Array<any>();
    }
    
    getJsonData(): string {
        return JSON.stringify(this.jsonData);
    }
    
    public fromJsonString(json: string): void {
        let data:JSON = JSON.parse(json);
        this.jsonData = data;
        
        this.fromJson(data);
    }
    
    public fromJson(data: JSON): void {
        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("displayName")) {
            this.displayName = (data as any)["displayName"];
        }
        
        if(data.hasOwnProperty("fullDisplayName")) {
            this.fullDisplayName = (data as any)["fullDisplayName"];
        }
        
        if(data.hasOwnProperty("description")) {
            this.description = (data as any)["description"];
        }
        
        if(data.hasOwnProperty("color")) {
            this.color = (data as any)["color"];
        }
        
        if(data.hasOwnProperty("buildable")) {
            this.buildable = (data as any)["buildable"];
        }
        
        if(data.hasOwnProperty("inQueue")) {
            this.inQueue = (data as any)["inQueue"];
        }
        
        if(data.hasOwnProperty("keepDependencies")) {
            this.keepDependencies = (data as any)["keepDependencies"];
        }
        
        if(data.hasOwnProperty("nextBuildNumber")) {
            this.nextBuildNumber = (data as any)["nextBuildNumber"];
        }
        
        if(data.hasOwnProperty("concurrentBuild")) {
            this.concurrentBuild = (data as any)["concurrentBuild"];
        }
        
        if(data.hasOwnProperty("_class")) {
            this._class = (data as any)["_class"];
        }
        
        if(data.hasOwnProperty("displayNameOrNull")) {
            this.displayNameOrNull = (data as any)["displayNameOrNull"];
        }
        
        if(data.hasOwnProperty("fullName")) {
            this.fullName = (data as any)["fullName"];
        }
        
        if(data.hasOwnProperty("actions")) {
            this.actions = (data as any)["actions"];
        }
        
        if(data.hasOwnProperty("healthReport")) {
            this.healthReport = (data as any)["healthReport"];
        }
        
        if(data.hasOwnProperty("property")) {
            this.property = (data as any)["property"];
        }
        
        if(data.hasOwnProperty("queueItem")) {
            this.queueItem = (data as any)["queueItem"];
        }
        
        if(data.hasOwnProperty("scm")) {
            this.scm = (data as any)["scm"];
        }
        
        if(data.hasOwnProperty("modules")) {
            this.modules = (data as any)["modules"];
        }
    }
}