SVG Rendering
[clamp.git] / ui-react / src / api / LoopCache.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  *
22  */
23
24 export default class LoopCache {
25         loopJsonCache;
26
27         constructor(loopJson) {
28                 this.loopJsonCache=loopJson;
29         }
30
31         updateMicroServiceProperties(type, newMsProperties) {
32                 if (newMsProperties["name"] === type) {
33                         for (var policy in this.loopJsonCache["microServicePolicies"]) {
34                                 if (this.loopJsonCache["microServicePolicies"][policy]["name"] === type) {
35                                         this.loopJsonCache["microServicePolicies"][policy] = newMsProperties;
36                                 }
37                         }
38                 }
39         }
40
41         updateGlobalProperties(newGlobalProperties) {
42                 this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties;
43         }
44
45         updateOperationalPolicyProperties(newOpProperties) {
46                 this.loopJsonCache["operationalPolicies"] = newOpProperties;
47         }
48
49         getLoopName() {
50                 return this.loopJsonCache["name"];
51         }
52
53         getOperationalPolicyConfigurationJson() {
54                 return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]["0"]["configurationsJson"]));
55         }
56
57         getOperationalPolicies() {
58                 return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]));
59         }
60
61         getGlobalProperties() {
62                 return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]));
63         }
64
65         getDcaeDeploymentProperties() {
66                 return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"]));
67         }
68
69         getMicroServicesJsonForType(type) {
70                 var msProperties = this.loopJsonCache["microServicePolicies"];
71                 for (var policy in msProperties) {
72                         if (msProperties[policy]["name"] === type) {
73                                 return JSON.parse(JSON.stringify(msProperties[policy]));
74                         }
75                 }
76                 return null;
77         }
78
79         getMicroServiceProperties(type) {
80                 var msProperties = this.loopJsonCache["microServicePolicies"];
81                 for (var policy in msProperties) {
82                         if (msProperties[policy]["name"] === type) {
83                                 if (msProperties[policy]["properties"] !== null && msProperties[policy]["properties"] !== undefined) {
84                                         return JSON.parse(JSON.stringify(msProperties[policy]["properties"]));
85                                 }
86                         }
87                 }
88                 return null;
89         }
90
91         getMicroServiceJsonRepresentationForType(type) {
92                 var msProperties = this.loopJsonCache["microServicePolicies"];
93                 for (var policy in msProperties) {
94                         if (msProperties[policy]["name"] === type) {
95                                 return JSON.parse(JSON.stringify(msProperties[policy]["jsonRepresentation"]));
96                         }
97                 }
98                 return null;
99         }
100
101         getResourceDetailsVfProperty() {
102                 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VF"];
103         }
104
105         getResourceDetailsVfModuleProperty() {
106                 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VFModule"];
107         }
108
109         getLoopLogsArray() {
110                 return this.loopJsonCache.loopLogs;
111         }
112
113         getComponentStates() {
114                 return this.loopJsonCache.components;
115         }
116 }