Sync Integ to Master
[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,
26     InputBEModel, Module, ComponentMetadata, RelationshipModel, RequirementsGroup, CapabilitiesGroup,InputFEModel} 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
32 export class ComponentGenericResponse  implements Serializable<ComponentGenericResponse> {
33
34     public metadata: ComponentMetadata;
35     public deploymentArtifacts:ArtifactGroupModel;
36     public artifacts:ArtifactGroupModel;
37     public toscaArtifacts:ArtifactGroupModel;
38     public componentInstancesProperties:PropertiesGroup;
39     public componentInstancesAttributes:AttributesGroup;
40     public componentInstancesRelations:Array<RelationshipModel>;
41     public componentInstances:Array<ComponentInstance>;
42     public inputs:Array<InputBEModel>;
43     public capabilities:CapabilitiesGroup;
44     public requirements:RequirementsGroup;
45     public properties:Array<PropertyModel>;
46     public attributes:Array<AttributeModel>;
47     public policies:Array<PolicyInstance>;
48     public groups:Array<Module>;
49     public interfaces:any;
50     public additionalInformation:any;
51     public derivedList:Array<any>;
52
53     deserialize (response): ComponentGenericResponse {
54
55         if(response.componentInstancesProperties) {
56             this.componentInstancesProperties = new PropertiesGroup(response.componentInstancesProperties);
57         }
58         if(response.componentInstancesAttributes) {
59             this.componentInstancesAttributes = new AttributesGroup(response.componentInstancesAttributes);
60         }
61         if(response.componentInstances) {
62             this.componentInstances = CommonUtils.initComponentInstances(response.componentInstances);
63         }
64         if(response.componentInstancesRelations) {
65             this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(response.componentInstancesRelations);
66         }
67         if(response.deploymentArtifacts) {
68             this.deploymentArtifacts = new ArtifactGroupModel(response.deploymentArtifacts);
69         }
70         if(response.inputs) {
71             this.inputs = CommonUtils.initInputs(response.inputs);
72         }
73         if(response.attributes) {
74             this.attributes = CommonUtils.initAttributes(response.attributes);
75         }
76         if(response.artifacts) {
77             this.artifacts = new ArtifactGroupModel(response.artifacts);
78         }
79         if(response.properties) {
80             this.properties = CommonUtils.initProperties(response.properties);
81         }
82         if(response.capabilities) {
83             this.capabilities = new CapabilitiesGroup(response.capabilities);
84         }
85         if(response.requirements) {
86             this.requirements = new RequirementsGroup(response.requirements);
87         }
88         if(response.toscaArtifacts) {
89             this.toscaArtifacts = new ArtifactGroupModel(response.toscaArtifacts);
90         }
91         if(response.metadata) {
92             this.metadata = new ComponentMetadata().deserialize(response.metadata);
93         }
94         if(response.groups) {
95             this.groups = CommonUtils.initModules(response.groups);
96         }
97         if(response.policies) {
98             this.policies = CommonUtils.initPolicies(response.policies);
99         }
100         return this;
101     }
102 }