Update base types based on model
[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 import {Model} from "../../../models/model";
35
36 export class ComponentGenericResponse  implements Serializable<ComponentGenericResponse> {
37
38     public metadata: ComponentMetadata;
39     public deploymentArtifacts:ArtifactGroupModel;
40     public artifacts:ArtifactGroupModel;
41     public toscaArtifacts:ArtifactGroupModel;
42     public componentInstancesProperties:PropertiesGroup;
43     public componentInstancesInputs:InputsGroup;
44     public componentInstancesAttributes:AttributesGroup;
45     public componentInstancesRelations:Array<RelationshipModel>;
46     public componentInstances:Array<ComponentInstance>;
47     public componentInstancesInterfaces: Map<string, Array<InterfaceModel>>;
48     public inputs:Array<InputBEModel>;
49     public outputs:Array<OutputBEModel>;
50     public capabilities:CapabilitiesGroup;
51     public requirements:RequirementsGroup;
52     public properties:Array<PropertyModel>;
53     public attributes:Array<AttributeModel>;
54     public policies:Array<PolicyInstance>;
55     public groupInstances: Array<GroupInstance>;
56     public modules:Array<Module>;
57     public interfaces:any;
58     public interfaceOperations:Array<OperationModel>;
59     public additionalInformation:any;
60     public derivedList:Array<any>;
61     public nodeFilterforNode: Array<any>;
62     public substitutionFilters: any;
63     public derivedFromGenericType;
64     public derivedFromGenericVersion;
65     public model:string;
66
67     deserialize (response): ComponentGenericResponse {
68
69         if(response.componentInstancesProperties) {
70             this.componentInstancesProperties = new PropertiesGroup(response.componentInstancesProperties);
71         }
72         if(response.componentInstancesInputs) {
73             this.componentInstancesInputs = response.componentInstancesInputs;
74         }
75         if(response.componentInstancesAttributes) {
76             this.componentInstancesAttributes = new AttributesGroup(response.componentInstancesAttributes);
77         }
78         if(response.componentInstances) {
79             this.componentInstances = CommonUtils.initComponentInstances(response.componentInstances);
80         }
81         if(response.componentInstancesRelations) {
82             this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(response.componentInstancesRelations);
83         }
84         if(response.deploymentArtifacts) {
85             this.deploymentArtifacts = new ArtifactGroupModel(response.deploymentArtifacts);
86         }
87         if(response.inputs) {
88             this.inputs = CommonUtils.initInputs(response.inputs);
89         }
90         if (response.outputs) {
91             this.outputs = CommonUtils.initOutputs(response.outputs);
92         }
93         if(response.attributes) {
94             this.attributes = CommonUtils.initAttributes(response.attributes);
95         }
96         if(response.artifacts) {
97             this.artifacts = new ArtifactGroupModel(response.artifacts);
98         }
99         if(response.properties) {
100             this.properties = CommonUtils.initProperties(response.properties);
101         }
102         if(response.capabilities) {
103             this.capabilities = new CapabilitiesGroup(response.capabilities);
104         }
105         if(response.requirements) {
106             this.requirements = new RequirementsGroup(response.requirements);
107         }
108         if(response.toscaArtifacts) {
109             this.toscaArtifacts = new ArtifactGroupModel(response.toscaArtifacts);
110         }
111         if(response.interfaces) {
112             this.interfaces = CommonUtils.initInterfaces(response.interfaces);
113             this.interfaceOperations = CommonUtils.initInterfaceOperations(response.interfaces);
114         }
115         if (response.componentInstancesInterfaces) {
116             this.componentInstancesInterfaces = new Map();
117             for (let resourceId in response.componentInstancesInterfaces) {
118                 this.componentInstancesInterfaces[resourceId] = CommonUtils.initInterfaces(response.componentInstancesInterfaces[resourceId]);
119             }
120         }
121         if(response.metadata) {
122             this.metadata = new ComponentMetadata().deserialize(response.metadata);
123         }
124         if(response.groups) {
125             this.modules = CommonUtils.initModules(response.groups);
126             this.groupInstances = CommonUtils.initGroups(response.groups)
127         }
128         if(response.policies) {
129             this.policies = CommonUtils.initPolicies(response.policies);
130         }
131         if(response.nodeFilterforNode) {
132             this.nodeFilterforNode = response.nodeFilterforNode;
133         }
134         if(response.substitutionFilters) {
135             this.substitutionFilters = response.substitutionFilters;
136         }
137         if(response.derivedFromGenericType) {
138             this.derivedFromGenericType = response.derivedFromGenericType;
139         }
140         if(response.derivedFromGenericVersion) {
141             this.derivedFromGenericVersion = response.derivedFromGenericVersion;
142         }
143         if(response.model) {
144             this.model = response.model;
145         }
146         return this;
147     }
148 }