blob: 2ef839629ebbb867f5f3ed939cf789a6e399f6dd [file] [log] [blame]
sebdetc8d61302019-07-04 15:50:34 +02001/*-
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 */
sebdet4946e5b2019-07-10 12:32:36 +020023class LoopCache {
24 constructor() {
25 //this.loopJsonCache=loopJson;
26 this.loopJsonCache = require('./example.json'); //(with path)
sebdetc8d61302019-07-04 15:50:34 +020027 }
sebdet4946e5b2019-07-10 12:32:36 +020028
sebdetc8d61302019-07-04 15:50:34 +020029 updateMsProperties(type, newMsProperties) {
sebdet4946e5b2019-07-10 12:32:36 +020030 if (newMsProperties["name"] == type) {
31 for (var policy in this.loopJsonCache["microServicePolicies"]) {
32 if (this.loopJsonCache["microServicePolicies"][policy]["name"] == type) {
33 this.loopJsonCache["microServicePolicies"][policy] = newMsProperties;
34 }
35 }
36 }
sebdetc8d61302019-07-04 15:50:34 +020037 }
sebdet4946e5b2019-07-10 12:32:36 +020038
39 updateGlobalProperties(newGlobalProperties) {
40 this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties;
sebdetc8d61302019-07-04 15:50:34 +020041 }
sebdet4946e5b2019-07-10 12:32:36 +020042
43 updateOpPolicyProperties(newOpProperties) {
44 this.loopJsonCache["operationalPolicies"] = newOpProperties;
sebdetc8d61302019-07-04 15:50:34 +020045 }
sebdet4946e5b2019-07-10 12:32:36 +020046
47 getLoopName() {
48 return this.loopJsonCache["name"];
sebdetc8d61302019-07-04 15:50:34 +020049 }
sebdet4946e5b2019-07-10 12:32:36 +020050
51 getOperationalPolicyProperty() {
52 return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]["0"]["configurationsJson"]));
sebdetc8d61302019-07-04 15:50:34 +020053 }
sebdet4946e5b2019-07-10 12:32:36 +020054
55 getOperationalPolicies() {
56 return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]));
sebdetc8d61302019-07-04 15:50:34 +020057 }
sebdet4946e5b2019-07-10 12:32:36 +020058
59 getGlobalProperty() {
60 return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]));
sebdetc8d61302019-07-04 15:50:34 +020061 }
sebdet4946e5b2019-07-10 12:32:36 +020062
63 getDeploymentProperties() {
64 return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"]));
sebdetc8d61302019-07-04 15:50:34 +020065 }
sebdet4946e5b2019-07-10 12:32:36 +020066
67 getMsJson(type) {
68 var msProperties = this.loopJsonCache["microServicePolicies"];
69 for (var policy in msProperties) {
70 if (msProperties[policy]["name"] == type) {
71 return JSON.parse(JSON.stringify(msProperties[policy]));
72 }
73 }
74 return null;
sebdetc8d61302019-07-04 15:50:34 +020075 }
sebdet4946e5b2019-07-10 12:32:36 +020076
77 getMsProperty(type) {
78 var msProperties = this.loopJsonCache["microServicePolicies"];
79 for (var policy in msProperties) {
80 if (msProperties[policy]["name"] == type) {
81 if (msProperties[policy]["properties"] !== null && msProperties[policy]["properties"] !== undefined) {
82 return JSON.parse(JSON.stringify(msProperties[policy]["properties"]));
83 }
84 }
85 }
86 return null;
sebdetc8d61302019-07-04 15:50:34 +020087 }
sebdet4946e5b2019-07-10 12:32:36 +020088
89 getMsUI(type) {
90 var msProperties = this.loopJsonCache["microServicePolicies"];
91 for (var policy in msProperties) {
92 if (msProperties[policy]["name"] == type) {
93 return JSON.parse(JSON.stringify(msProperties[policy]["jsonRepresentation"]));
94 }
95 }
96 return null;
sebdetc8d61302019-07-04 15:50:34 +020097 }
sebdet4946e5b2019-07-10 12:32:36 +020098
99 getResourceDetailsVfProperty() {
sebdetc8d61302019-07-04 15:50:34 +0200100 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VF"];
101 }
sebdet4946e5b2019-07-10 12:32:36 +0200102
103 getResourceDetailsVfModuleProperty() {
sebdetc8d61302019-07-04 15:50:34 +0200104 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VFModule"];
105 }
sebdet4946e5b2019-07-10 12:32:36 +0200106
107 getLoopLogsArray() {
sebdetc8d61302019-07-04 15:50:34 +0200108 return this.loopJsonCache.loopLogs;
109 }
sebdet4946e5b2019-07-10 12:32:36 +0200110
111 getComponentStates() {
sebdetc8d61302019-07-04 15:50:34 +0200112 return this.loopJsonCache.components;
113 }
114
115}
116export default LoopCache;