sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 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 | */ |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 23 | class LoopCache { |
| 24 | constructor() { |
| 25 | //this.loopJsonCache=loopJson; |
| 26 | this.loopJsonCache = require('./example.json'); //(with path) |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 27 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 28 | |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 29 | updateMsProperties(type, newMsProperties) { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 30 | 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 | } |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 37 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 38 | |
| 39 | updateGlobalProperties(newGlobalProperties) { |
| 40 | this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 41 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 42 | |
| 43 | updateOpPolicyProperties(newOpProperties) { |
| 44 | this.loopJsonCache["operationalPolicies"] = newOpProperties; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 45 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 46 | |
| 47 | getLoopName() { |
| 48 | return this.loopJsonCache["name"]; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 49 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 50 | |
| 51 | getOperationalPolicyProperty() { |
| 52 | return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]["0"]["configurationsJson"])); |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 53 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 54 | |
| 55 | getOperationalPolicies() { |
| 56 | return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"])); |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 57 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 58 | |
| 59 | getGlobalProperty() { |
| 60 | return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"])); |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 61 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 62 | |
| 63 | getDeploymentProperties() { |
| 64 | return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"])); |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 65 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 66 | |
| 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; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 75 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 76 | |
| 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; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 87 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 88 | |
| 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; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 97 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 98 | |
| 99 | getResourceDetailsVfProperty() { |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 100 | return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VF"]; |
| 101 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 102 | |
| 103 | getResourceDetailsVfModuleProperty() { |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 104 | return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VFModule"]; |
| 105 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 106 | |
| 107 | getLoopLogsArray() { |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 108 | return this.loopJsonCache.loopLogs; |
| 109 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame^] | 110 | |
| 111 | getComponentStates() { |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 112 | return this.loopJsonCache.components; |
| 113 | } |
| 114 | |
| 115 | } |
| 116 | export default LoopCache; |