blob: 80f02f027a70b23402eb2a83cc3086cc1a7cd640 [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 */
sebdete44fdb12019-07-12 12:25:56 +020023
sebdet4946e5b2019-07-10 12:32:36 +020024class LoopCache {
sebdete44fdb12019-07-12 12:25:56 +020025 loopJsonCache;
26
27 constructor(loopJson) {
28 this.loopJsonCache=loopJson;
29 //LoopCache.SET_LOOP_JSON_CACHE(require('./example.json');
sebdetc8d61302019-07-04 15:50:34 +020030 }
sebdet4946e5b2019-07-10 12:32:36 +020031
sebdetc8d61302019-07-04 15:50:34 +020032 updateMsProperties(type, newMsProperties) {
sebdet4946e5b2019-07-10 12:32:36 +020033 if (newMsProperties["name"] == type) {
34 for (var policy in this.loopJsonCache["microServicePolicies"]) {
35 if (this.loopJsonCache["microServicePolicies"][policy]["name"] == type) {
36 this.loopJsonCache["microServicePolicies"][policy] = newMsProperties;
37 }
38 }
39 }
sebdetc8d61302019-07-04 15:50:34 +020040 }
sebdet4946e5b2019-07-10 12:32:36 +020041
42 updateGlobalProperties(newGlobalProperties) {
43 this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties;
sebdetc8d61302019-07-04 15:50:34 +020044 }
sebdet4946e5b2019-07-10 12:32:36 +020045
46 updateOpPolicyProperties(newOpProperties) {
47 this.loopJsonCache["operationalPolicies"] = newOpProperties;
sebdetc8d61302019-07-04 15:50:34 +020048 }
sebdet4946e5b2019-07-10 12:32:36 +020049
50 getLoopName() {
51 return this.loopJsonCache["name"];
sebdetc8d61302019-07-04 15:50:34 +020052 }
sebdet4946e5b2019-07-10 12:32:36 +020053
54 getOperationalPolicyProperty() {
55 return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]["0"]["configurationsJson"]));
sebdetc8d61302019-07-04 15:50:34 +020056 }
sebdet4946e5b2019-07-10 12:32:36 +020057
58 getOperationalPolicies() {
59 return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]));
sebdetc8d61302019-07-04 15:50:34 +020060 }
sebdet4946e5b2019-07-10 12:32:36 +020061
62 getGlobalProperty() {
63 return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]));
sebdetc8d61302019-07-04 15:50:34 +020064 }
sebdet4946e5b2019-07-10 12:32:36 +020065
66 getDeploymentProperties() {
67 return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"]));
sebdetc8d61302019-07-04 15:50:34 +020068 }
sebdet4946e5b2019-07-10 12:32:36 +020069
70 getMsJson(type) {
71 var msProperties = this.loopJsonCache["microServicePolicies"];
72 for (var policy in msProperties) {
73 if (msProperties[policy]["name"] == type) {
74 return JSON.parse(JSON.stringify(msProperties[policy]));
75 }
76 }
77 return null;
sebdetc8d61302019-07-04 15:50:34 +020078 }
sebdet4946e5b2019-07-10 12:32:36 +020079
80 getMsProperty(type) {
81 var msProperties = this.loopJsonCache["microServicePolicies"];
82 for (var policy in msProperties) {
83 if (msProperties[policy]["name"] == type) {
84 if (msProperties[policy]["properties"] !== null && msProperties[policy]["properties"] !== undefined) {
85 return JSON.parse(JSON.stringify(msProperties[policy]["properties"]));
86 }
87 }
88 }
89 return null;
sebdetc8d61302019-07-04 15:50:34 +020090 }
sebdet4946e5b2019-07-10 12:32:36 +020091
92 getMsUI(type) {
93 var msProperties = this.loopJsonCache["microServicePolicies"];
94 for (var policy in msProperties) {
95 if (msProperties[policy]["name"] == type) {
96 return JSON.parse(JSON.stringify(msProperties[policy]["jsonRepresentation"]));
97 }
98 }
99 return null;
sebdetc8d61302019-07-04 15:50:34 +0200100 }
sebdet4946e5b2019-07-10 12:32:36 +0200101
102 getResourceDetailsVfProperty() {
sebdetc8d61302019-07-04 15:50:34 +0200103 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VF"];
104 }
sebdet4946e5b2019-07-10 12:32:36 +0200105
106 getResourceDetailsVfModuleProperty() {
sebdetc8d61302019-07-04 15:50:34 +0200107 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VFModule"];
108 }
sebdet4946e5b2019-07-10 12:32:36 +0200109
110 getLoopLogsArray() {
sebdetc8d61302019-07-04 15:50:34 +0200111 return this.loopJsonCache.loopLogs;
112 }
sebdet4946e5b2019-07-10 12:32:36 +0200113
114 getComponentStates() {
sebdetc8d61302019-07-04 15:50:34 +0200115 return this.loopJsonCache.components;
116 }
117
sebdete44fdb12019-07-12 12:25:56 +0200118 get getLoopJsonCache() {
119 return this.loopJsonCache;
120 }
121
122 set setLoopJsonCache(newJson) {
123 this.loopJsonCache = newJson;
124 }
sebdetc8d61302019-07-04 15:50:34 +0200125}
sebdete44fdb12019-07-12 12:25:56 +0200126
127export const LOOP_CACHE = new LoopCache(require('./example.json'));
128
sebdetc8d61302019-07-04 15:50:34 +0200129export default LoopCache;