SDC Designers Integration - Part 1
[sdc.git] / catalog-ui / src / app / models / inputs.ts
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 /**
22  * Created by obarda on 8/24/2016.
23  */
24 'use strict';
25 import {PropertyModel} from "./properties";
26 import {InputPropertyBase} from "./input-property-base";
27 import {SchemaPropertyGroupModel} from "./aschema-property";
28
29 export interface IInputModel extends InputPropertyBase {
30     //server data
31     definition:boolean;
32     value:string;
33     componentInstanceName:string;
34     //costom properties
35     isNew:boolean;
36     properties:Array<PropertyModel>;
37     inputs:Array<InputModel>;
38     filterTerm:string;
39
40 }
41 export class InputModel implements IInputModel {
42
43     //server data
44     uniqueId:string;
45     name:string;
46     type:string;
47     password:boolean;
48     required:boolean;
49     definition:boolean;
50     parentUniqueId:string;
51     description:string;
52     componentInstanceName:string;
53     componentInstanceId:string;
54     schema:SchemaPropertyGroupModel;
55     defaultValue:string;
56     value:string;
57
58     //costom properties
59     isNew:boolean;
60     isDeleteDisabled:boolean;
61     properties:Array<PropertyModel>;
62     inputs:Array<InputModel>;
63     isAlreadySelected:boolean;
64     filterTerm:string;
65
66     constructor(input:InputModel) {
67
68         if (input) {
69             this.uniqueId = input.uniqueId;
70             this.name = input.name;
71             this.type = input.type;
72             this.description = input.description;
73             this.password = input.password;
74             this.required = input.required;
75             this.definition = input.definition;
76             this.parentUniqueId = input.parentUniqueId;
77             this.description = input.description;
78             this.componentInstanceName = input.componentInstanceName;
79             this.componentInstanceId = input.componentInstanceId;
80             this.schema = input.schema;
81             this.defaultValue = input.defaultValue;
82             this.value = input.value;
83             this.filterTerm = this.name + ' ' + this.description + ' ' + this.type + ' ' + this.componentInstanceName;
84             this.inputs = input.inputs;
85             this.properties = input.properties;
86         }
87     }
88
89     public toJSON = ():any => {
90         let input = angular.copy(this);
91         input.isNew = undefined;
92         input.isDeleteDisabled = undefined;
93         input.properties = undefined;
94         input.inputs = undefined;
95         input.isAlreadySelected = undefined;
96         input.filterTerm = undefined;
97         return input;
98     };
99 }
100