2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 * Created by ob0695 on 4/18/2017.
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";
35 export class ComponentGenericResponse implements Serializable<ComponentGenericResponse> {
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;
65 deserialize (response): ComponentGenericResponse {
67 if(response.componentInstancesProperties) {
68 this.componentInstancesProperties = new PropertiesGroup(response.componentInstancesProperties);
70 if(response.componentInstancesInputs) {
71 this.componentInstancesInputs = response.componentInstancesInputs;
73 if(response.componentInstancesAttributes) {
74 this.componentInstancesAttributes = new AttributesGroup(response.componentInstancesAttributes);
76 if(response.componentInstances) {
77 this.componentInstances = CommonUtils.initComponentInstances(response.componentInstances);
79 if(response.componentInstancesRelations) {
80 this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(response.componentInstancesRelations);
82 if(response.deploymentArtifacts) {
83 this.deploymentArtifacts = new ArtifactGroupModel(response.deploymentArtifacts);
86 this.inputs = CommonUtils.initInputs(response.inputs);
88 if (response.outputs) {
89 this.outputs = CommonUtils.initOutputs(response.outputs);
91 if(response.attributes) {
92 this.attributes = CommonUtils.initAttributes(response.attributes);
94 if(response.artifacts) {
95 this.artifacts = new ArtifactGroupModel(response.artifacts);
97 if(response.properties) {
98 this.properties = CommonUtils.initProperties(response.properties);
100 if(response.capabilities) {
101 this.capabilities = new CapabilitiesGroup(response.capabilities);
103 if(response.requirements) {
104 this.requirements = new RequirementsGroup(response.requirements);
106 if(response.toscaArtifacts) {
107 this.toscaArtifacts = new ArtifactGroupModel(response.toscaArtifacts);
109 if(response.interfaces) {
110 this.interfaces = CommonUtils.initInterfaces(response.interfaces);
111 this.interfaceOperations = CommonUtils.initInterfaceOperations(response.interfaces);
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]);
119 if(response.metadata) {
120 this.metadata = new ComponentMetadata().deserialize(response.metadata);
122 if(response.groups) {
123 this.modules = CommonUtils.initModules(response.groups);
124 this.groupInstances = CommonUtils.initGroups(response.groups)
126 if(response.policies) {
127 this.policies = CommonUtils.initPolicies(response.policies);
129 if(response.nodeFilterforNode) {
130 this.nodeFilterforNode = response.nodeFilterforNode;
132 if(response.substitutionFilters) {
133 this.substitutionFilters = response.substitutionFilters;
135 if(response.derivedFromGenericType) {
136 this.derivedFromGenericType = response.derivedFromGenericType;
138 if(response.derivedFromGenericVersion) {
139 this.derivedFromGenericVersion = response.derivedFromGenericVersion;