Specify model at service creation
[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     public model:Model;
65
66     deserialize (response): ComponentGenericResponse {
67
68         if(response.componentInstancesProperties) {
69             this.componentInstancesProperties = new PropertiesGroup(response.componentInstancesProperties);
70         }
71         if(response.componentInstancesInputs) {
72             this.componentInstancesInputs = response.componentInstancesInputs;
73         }
74         if(response.componentInstancesAttributes) {
75             this.componentInstancesAttributes = new AttributesGroup(response.componentInstancesAttributes);
76         }
77         if(response.componentInstances) {
78             this.componentInstances = CommonUtils.initComponentInstances(response.componentInstances);
79         }
80         if(response.componentInstancesRelations) {
81             this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(response.componentInstancesRelations);
82         }
83         if(response.deploymentArtifacts) {
84             this.deploymentArtifacts = new ArtifactGroupModel(response.deploymentArtifacts);
85         }
86         if(response.inputs) {
87             this.inputs = CommonUtils.initInputs(response.inputs);
88         }
89         if (response.outputs) {
90             this.outputs = CommonUtils.initOutputs(response.outputs);
91         }
92         if(response.attributes) {
93             this.attributes = CommonUtils.initAttributes(response.attributes);
94         }
95         if(response.artifacts) {
96             this.artifacts = new ArtifactGroupModel(response.artifacts);
97         }
98         if(response.properties) {
99             this.properties = CommonUtils.initProperties(response.properties);
100         }
101         if(response.capabilities) {
102             this.capabilities = new CapabilitiesGroup(response.capabilities);
103         }
104         if(response.requirements) {
105             this.requirements = new RequirementsGroup(response.requirements);
106         }
107         if(response.toscaArtifacts) {
108             this.toscaArtifacts = new ArtifactGroupModel(response.toscaArtifacts);
109         }
110         if(response.interfaces) {
111             this.interfaces = CommonUtils.initInterfaces(response.interfaces);
112             this.interfaceOperations = CommonUtils.initInterfaceOperations(response.interfaces);
113         }
114         if (response.componentInstancesInterfaces) {
115             this.componentInstancesInterfaces = new Map();
116             for (let resourceId in response.componentInstancesInterfaces) {
117                 this.componentInstancesInterfaces[resourceId] = CommonUtils.initInterfaces(response.componentInstancesInterfaces[resourceId]);
118             }
119         }
120         if(response.metadata) {
121             this.metadata = new ComponentMetadata().deserialize(response.metadata);
122         }
123         if(response.groups) {
124             this.modules = CommonUtils.initModules(response.groups);
125             this.groupInstances = CommonUtils.initGroups(response.groups)
126         }
127         if(response.policies) {
128             this.policies = CommonUtils.initPolicies(response.policies);
129         }
130         if(response.nodeFilterforNode) {
131             this.nodeFilterforNode = response.nodeFilterforNode;
132         }
133         if(response.substitutionFilters) {
134             this.substitutionFilters = response.substitutionFilters;
135         }
136         if(response.derivedFromGenericType) {
137             this.derivedFromGenericType = response.derivedFromGenericType;
138         }
139         if(response.derivedFromGenericVersion) {
140             this.derivedFromGenericVersion = response.derivedFromGenericVersion;
141         }
142         if(response.model) {
143             this.model = response.model;
144         }
145         return this;
146     }
147 }