blob: 4c8f68c236f27e16a1adf1c57a24b025bab697a6 [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 * ===================================================================
xuegaof248df62019-07-15 15:16:18 +020021 *
sebdetc8d61302019-07-04 15:50:34 +020022 */
sebdete44fdb12019-07-12 12:25:56 +020023
sebdet493c3832019-07-15 17:26:18 +020024export default class LoopCache {
sebdete44fdb12019-07-12 12:25:56 +020025 loopJsonCache;
26
27 constructor(loopJson) {
28 this.loopJsonCache=loopJson;
sebdetc8d61302019-07-04 15:50:34 +020029 }
sebdet4946e5b2019-07-10 12:32:36 +020030
sebdet493c3832019-07-15 17:26:18 +020031 updateMicroServiceProperties(type, newMsProperties) {
xuegaof248df62019-07-15 15:16:18 +020032 if (newMsProperties["name"] === type) {
sebdet4946e5b2019-07-10 12:32:36 +020033 for (var policy in this.loopJsonCache["microServicePolicies"]) {
xuegaof248df62019-07-15 15:16:18 +020034 if (this.loopJsonCache["microServicePolicies"][policy]["name"] === type) {
sebdet4946e5b2019-07-10 12:32:36 +020035 this.loopJsonCache["microServicePolicies"][policy] = newMsProperties;
36 }
37 }
38 }
sebdetc8d61302019-07-04 15:50:34 +020039 }
sebdet4946e5b2019-07-10 12:32:36 +020040
41 updateGlobalProperties(newGlobalProperties) {
42 this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties;
sebdetc8d61302019-07-04 15:50:34 +020043 }
sebdet4946e5b2019-07-10 12:32:36 +020044
sebdet493c3832019-07-15 17:26:18 +020045 updateOperationalPolicyProperties(newOpProperties) {
sebdet4946e5b2019-07-10 12:32:36 +020046 this.loopJsonCache["operationalPolicies"] = newOpProperties;
sebdetc8d61302019-07-04 15:50:34 +020047 }
sebdet4946e5b2019-07-10 12:32:36 +020048
49 getLoopName() {
50 return this.loopJsonCache["name"];
sebdetc8d61302019-07-04 15:50:34 +020051 }
sebdet4946e5b2019-07-10 12:32:36 +020052
sebdet493c3832019-07-15 17:26:18 +020053 getOperationalPolicyConfigurationJson() {
sebdet4946e5b2019-07-10 12:32:36 +020054 return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]["0"]["configurationsJson"]));
sebdetc8d61302019-07-04 15:50:34 +020055 }
sebdet4946e5b2019-07-10 12:32:36 +020056
57 getOperationalPolicies() {
58 return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]));
sebdetc8d61302019-07-04 15:50:34 +020059 }
sebdet4946e5b2019-07-10 12:32:36 +020060
sebdet493c3832019-07-15 17:26:18 +020061 getGlobalProperties() {
sebdet4946e5b2019-07-10 12:32:36 +020062 return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]));
sebdetc8d61302019-07-04 15:50:34 +020063 }
sebdet4946e5b2019-07-10 12:32:36 +020064
sebdet493c3832019-07-15 17:26:18 +020065 getDcaeDeploymentProperties() {
sebdet4946e5b2019-07-10 12:32:36 +020066 return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"]));
sebdetc8d61302019-07-04 15:50:34 +020067 }
sebdet4946e5b2019-07-10 12:32:36 +020068
sebdet493c3832019-07-15 17:26:18 +020069 getMicroServicesJsonForType(type) {
sebdet4946e5b2019-07-10 12:32:36 +020070 var msProperties = this.loopJsonCache["microServicePolicies"];
71 for (var policy in msProperties) {
xuegaof248df62019-07-15 15:16:18 +020072 if (msProperties[policy]["name"] === type) {
sebdet4946e5b2019-07-10 12:32:36 +020073 return JSON.parse(JSON.stringify(msProperties[policy]));
74 }
75 }
76 return null;
sebdetc8d61302019-07-04 15:50:34 +020077 }
sebdet4946e5b2019-07-10 12:32:36 +020078
sebdet493c3832019-07-15 17:26:18 +020079 getMicroServiceProperties(type) {
sebdet4946e5b2019-07-10 12:32:36 +020080 var msProperties = this.loopJsonCache["microServicePolicies"];
81 for (var policy in msProperties) {
xuegaof248df62019-07-15 15:16:18 +020082 if (msProperties[policy]["name"] === type) {
sebdet4946e5b2019-07-10 12:32:36 +020083 if (msProperties[policy]["properties"] !== null && msProperties[policy]["properties"] !== undefined) {
84 return JSON.parse(JSON.stringify(msProperties[policy]["properties"]));
85 }
86 }
87 }
88 return null;
sebdetc8d61302019-07-04 15:50:34 +020089 }
sebdet4946e5b2019-07-10 12:32:36 +020090
sebdet493c3832019-07-15 17:26:18 +020091 getMicroServiceJsonRepresentationForType(type) {
sebdet4946e5b2019-07-10 12:32:36 +020092 var msProperties = this.loopJsonCache["microServicePolicies"];
93 for (var policy in msProperties) {
xuegaof248df62019-07-15 15:16:18 +020094 if (msProperties[policy]["name"] === type) {
sebdet4946e5b2019-07-10 12:32:36 +020095 return JSON.parse(JSON.stringify(msProperties[policy]["jsonRepresentation"]));
96 }
97 }
98 return null;
sebdetc8d61302019-07-04 15:50:34 +020099 }
sebdet4946e5b2019-07-10 12:32:36 +0200100
101 getResourceDetailsVfProperty() {
sebdetc8d61302019-07-04 15:50:34 +0200102 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VF"];
103 }
sebdet4946e5b2019-07-10 12:32:36 +0200104
105 getResourceDetailsVfModuleProperty() {
sebdetc8d61302019-07-04 15:50:34 +0200106 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VFModule"];
107 }
sebdet4946e5b2019-07-10 12:32:36 +0200108
109 getLoopLogsArray() {
sebdetc8d61302019-07-04 15:50:34 +0200110 return this.loopJsonCache.loopLogs;
111 }
sebdet4946e5b2019-07-10 12:32:36 +0200112
113 getComponentStates() {
sebdetc8d61302019-07-04 15:50:34 +0200114 return this.loopJsonCache.components;
115 }
sebdetc8d61302019-07-04 15:50:34 +0200116}