Add substitution filter UI support
[sdc.git] / catalog-ui / src / app / ng2 / services / responses / component-generic-response.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 ob0695 on 4/18/2017.
23  */
24
25 import { ArtifactGroupModel, PropertyModel, PropertiesGroup, AttributeModel, AttributesGroup, ComponentInstance, OperationModel,
26     InputBEModel, Module, ComponentMetadata, RelationshipModel, RequirementsGroup, CapabilitiesGroup} from "app/models";
27 import {CommonUtils} from "app/utils";
28 import {Serializable} from "../utils/serializable";
29 import {PropertyBEModel} from "../../../models/properties-inputs/property-be-model";
30 import { PolicyInstance } from "app/models/graph/zones/policy-instance";
31 import { GroupInstance } from "../../../models/graph/zones/group-instance";
32 import { InputsGroup } from "../../../models/inputs";
33 import { InterfaceModel } from "../../../models/operation";
34
35 export class ComponentGenericResponse  implements Serializable<ComponentGenericResponse> {
36
37     public metadata: ComponentMetadata;
38     public deploymentArtifacts:ArtifactGroupModel;
39     public artifacts:ArtifactGroupModel;
40     public toscaArtifacts:ArtifactGroupModel;
41     public componentInstancesProperties:PropertiesGroup;
42     public componentInstancesInputs:InputsGroup;
43     public componentInstancesAttributes:AttributesGroup;
44     public componentInstancesRelations:Array<RelationshipModel>;
45     public componentInstances:Array<ComponentInstance>;
46     public componentInstancesInterfaces: Map<string, Array<InterfaceModel>>;
47     public inputs:Array<InputBEModel>;
48     public capabilities:CapabilitiesGroup;
49     public requirements:RequirementsGroup;
50     public properties:Array<PropertyModel>;
51     public attributes:Array<AttributeModel>;
52     public policies:Array<PolicyInstance>;
53     public groupInstances: Array<GroupInstance>;
54     public modules:Array<Module>;
55     public interfaces:any;
56     public interfaceOperations:Array<OperationModel>;
57     public additionalInformation:any;
58     public derivedList:Array<any>;
59     public nodeFilterData: Array<any>;
60     public substitutionFilterForTopologyTemplate: Array<any>;
61
62     deserialize (response): ComponentGenericResponse {
63
64         if(response.componentInstancesProperties) {
65             this.componentInstancesProperties = new PropertiesGroup(response.componentInstancesProperties);
66         }
67         if(response.componentInstancesInputs) {
68             this.componentInstancesInputs = response.componentInstancesInputs;
69         }
70         if(response.componentInstancesAttributes) {
71             this.componentInstancesAttributes = new AttributesGroup(response.componentInstancesAttributes);
72         }
73         if(response.componentInstances) {
74             this.componentInstances = CommonUtils.initComponentInstances(response.componentInstances);
75         }
76         if(response.componentInstancesRelations) {
77             this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(response.componentInstancesRelations);
78         }
79         if(response.deploymentArtifacts) {
80             this.deploymentArtifacts = new ArtifactGroupModel(response.deploymentArtifacts);
81         }
82         if(response.inputs) {
83             this.inputs = CommonUtils.initInputs(response.inputs);
84         }
85         if(response.attributes) {
86             this.attributes = CommonUtils.initAttributes(response.attributes);
87         }
88         if(response.artifacts) {
89             this.artifacts = new ArtifactGroupModel(response.artifacts);
90         }
91         if(response.properties) {
92             this.properties = CommonUtils.initProperties(response.properties);
93         }
94         if(response.capabilities) {
95             this.capabilities = new CapabilitiesGroup(response.capabilities);
96         }
97         if(response.requirements) {
98             this.requirements = new RequirementsGroup(response.requirements);
99         }
100         if(response.toscaArtifacts) {
101             this.toscaArtifacts = new ArtifactGroupModel(response.toscaArtifacts);
102         }
103         if(response.interfaces) {
104             this.interfaces = CommonUtils.initInterfaces(response.interfaces);
105             this.interfaceOperations = CommonUtils.initInterfaceOperations(response.interfaces);
106         }
107         if (response.componentInstancesInterfaces) {
108             this.componentInstancesInterfaces = new Map();
109             for (let resourceId in response.componentInstancesInterfaces) {
110                 this.componentInstancesInterfaces[resourceId] = CommonUtils.initInterfaces(response.componentInstancesInterfaces[resourceId]);
111             }
112         }
113         if(response.metadata) {
114             this.metadata = new ComponentMetadata().deserialize(response.metadata);
115         }
116         if(response.groups) {
117             this.modules = CommonUtils.initModules(response.groups);
118             this.groupInstances = CommonUtils.initGroups(response.groups)
119         }
120         if(response.policies) {
121             this.policies = CommonUtils.initPolicies(response.policies);
122         }
123         if(response.nodeFilterData) {
124             this.nodeFilterData = response.nodeFilterData;
125         }
126         if(response.substitutionFilterForTopologyTemplate) {
127             this.substitutionFilterForTopologyTemplate = response.substitutionFilterForTopologyTemplate;
128         }
129         return this;
130     }
131 }