6011aabec88d5b34bd52d34bbbf5e42437cf6f6c
[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 { PolicyInstance } from "app/models/graph/zones/policy-instance";
30 import { GroupInstance } from "../../../models/graph/zones/group-instance";
31 import { InputsGroup } from "../../../models/inputs";
32 import { InterfaceModel } from "../../../models/operation";
33 import { OutputBEModel } from "app/models/attributes-outputs/output-be-model";
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 outputs:Array<OutputBEModel>;
49     public capabilities:CapabilitiesGroup;
50     public requirements:RequirementsGroup;
51     public properties:Array<PropertyModel>;
52     public attributes:Array<AttributeModel>;
53     public policies:Array<PolicyInstance>;
54     public groupInstances: Array<GroupInstance>;
55     public modules:Array<Module>;
56     public interfaces:any;
57     public interfaceOperations:Array<OperationModel>;
58     public additionalInformation:any;
59     public derivedList:Array<any>;
60     public nodeFilterforNode: Array<any>;
61     public substitutionFilters: any;
62     public derivedFromGenericType;
63     public derivedFromGenericVersion;
64
65     deserialize (response): ComponentGenericResponse {
66
67         if(response.componentInstancesProperties) {
68             this.componentInstancesProperties = new PropertiesGroup(response.componentInstancesProperties);
69         }
70         if(response.componentInstancesInputs) {
71             this.componentInstancesInputs = response.componentInstancesInputs;
72         }
73         if(response.componentInstancesAttributes) {
74             this.componentInstancesAttributes = new AttributesGroup(response.componentInstancesAttributes);
75         }
76         if(response.componentInstances) {
77             this.componentInstances = CommonUtils.initComponentInstances(response.componentInstances);
78         }
79         if(response.componentInstancesRelations) {
80             this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(response.componentInstancesRelations);
81         }
82         if(response.deploymentArtifacts) {
83             this.deploymentArtifacts = new ArtifactGroupModel(response.deploymentArtifacts);
84         }
85         if(response.inputs) {
86             this.inputs = CommonUtils.initInputs(response.inputs);
87         }
88         if (response.outputs) {
89             this.outputs = CommonUtils.initOutputs(response.outputs);
90         }
91         if(response.attributes) {
92             this.attributes = CommonUtils.initAttributes(response.attributes);
93         }
94         if(response.artifacts) {
95             this.artifacts = new ArtifactGroupModel(response.artifacts);
96         }
97         if(response.properties) {
98             this.properties = CommonUtils.initProperties(response.properties);
99         }
100         if(response.capabilities) {
101             this.capabilities = new CapabilitiesGroup(response.capabilities);
102         }
103         if(response.requirements) {
104             this.requirements = new RequirementsGroup(response.requirements);
105         }
106         if(response.toscaArtifacts) {
107             this.toscaArtifacts = new ArtifactGroupModel(response.toscaArtifacts);
108         }
109         if(response.interfaces) {
110             this.interfaces = CommonUtils.initInterfaces(response.interfaces);
111             this.interfaceOperations = CommonUtils.initInterfaceOperations(response.interfaces);
112         }
113         if (response.componentInstancesInterfaces) {
114             this.componentInstancesInterfaces = new Map();
115             for (let resourceId in response.componentInstancesInterfaces) {
116                 this.componentInstancesInterfaces[resourceId] = CommonUtils.initInterfaces(response.componentInstancesInterfaces[resourceId]);
117             }
118         }
119         if(response.metadata) {
120             this.metadata = new ComponentMetadata().deserialize(response.metadata);
121         }
122         if(response.groups) {
123             this.modules = CommonUtils.initModules(response.groups);
124             this.groupInstances = CommonUtils.initGroups(response.groups)
125         }
126         if(response.policies) {
127             this.policies = CommonUtils.initPolicies(response.policies);
128         }
129         if(response.nodeFilterforNode) {
130             this.nodeFilterforNode = response.nodeFilterforNode;
131         }
132         if(response.substitutionFilters) {
133             this.substitutionFilters = response.substitutionFilters;
134         }
135         if(response.derivedFromGenericType) {
136             this.derivedFromGenericType = response.derivedFromGenericType;
137         }
138         if(response.derivedFromGenericVersion) {
139             this.derivedFromGenericVersion = response.derivedFromGenericVersion;
140         }
141         return this;
142     }
143 }