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