/
stream-definition.ts
52 lines (42 loc) · 1.28 KB
/
stream-definition.ts
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
import { Page } from '../../shared/model/page';
/**
* Represents a StreamDefiniton.
*
* @author Janne Valkealahti
* @author Gunnar Hillert
* @author Damien Vitrac
*/
export class StreamDefinition {
public name: string;
public dslText: string;
public status: string;
public deploymentProperties: any;
public force = false;
constructor(name: string, dslText: string, status: string) {
this.name = name;
this.dslText = dslText;
this.status = status;
}
/**
* Create a StreamDefinition from JSON
* @param input
* @returns {StreamDefinition}
*/
public static fromJSON(input): StreamDefinition {
const stream = new StreamDefinition(input.name, input.dslText, input.status);
stream.deploymentProperties = input.deploymentProperties ? JSON.parse(input.deploymentProperties) : null;
return stream;
}
/**
* Create a Page<StreamDefinition> from JSON
* @param input
* @returns {Page<StreamDefinition>}
*/
public static pageFromJSON(input): Page<StreamDefinition> {
const page = Page.fromJSON<StreamDefinition>(input);
if (input && input._embedded && input._embedded.streamDefinitionResourceList) {
page.items = input._embedded.streamDefinitionResourceList.map(StreamDefinition.fromJSON);
}
return page;
}
}