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 | */ |
| 23 | class LoopCache |
| 24 | { |
| 25 | constructor(loopJson) { |
| 26 | this.loopJsonCache=loopJson; |
| 27 | } |
| 28 | |
| 29 | updateMsProperties(type, newMsProperties) { |
| 30 | if (newMsProperties["name"] == type) { |
| 31 | for (p in this.loopJsonCache["microServicePolicies"]) { |
| 32 | if (this.loopJsonCache["microServicePolicies"][p]["name"] == type) { |
| 33 | this.loopJsonCache["microServicePolicies"][p] = newMsProperties; |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | updateGlobalProperties(newGlobalProperties) { |
| 40 | this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties; |
| 41 | } |
| 42 | |
| 43 | updateOpPolicyProperties(newOpProperties) { |
| 44 | this.loopJsonCache["operationalPolicies"] = newOpProperties; |
| 45 | } |
| 46 | |
| 47 | getLoopName() { |
| 48 | return this.loopJsonCache["name"]; |
| 49 | } |
| 50 | |
| 51 | getOperationalPolicyProperty() { |
| 52 | return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]["0"]["configurationsJson"])); |
| 53 | } |
| 54 | |
| 55 | getOperationalPolicies() { |
| 56 | return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"])); |
| 57 | } |
| 58 | |
| 59 | getGlobalProperty() { |
| 60 | return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"])); |
| 61 | } |
| 62 | |
| 63 | getDeploymentProperties() { |
| 64 | return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"])); |
| 65 | } |
| 66 | |
| 67 | getMsJson(type) { |
| 68 | var msProperties = this.loopJsonCache["microServicePolicies"]; |
| 69 | for (p in msProperties) { |
| 70 | if (msProperties[p]["name"] == type) { |
| 71 | return JSON.parse(JSON.stringify(msProperties[p])); |
| 72 | } |
| 73 | } |
| 74 | return null; |
| 75 | } |
| 76 | |
| 77 | getMsProperty(type) { |
| 78 | var msProperties = this.loopJsonCache["microServicePolicies"]; |
| 79 | for (p in msProperties) { |
| 80 | if (msProperties[p]["name"] == type) { |
| 81 | if (msProperties[p]["properties"] !== null && msProperties[p]["properties"] !== undefined) { |
| 82 | return JSON.parse(JSON.stringify(msProperties[p]["properties"])); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | return null; |
| 87 | } |
| 88 | |
| 89 | getMsUI(type) { |
| 90 | var msProperties = this.loopJsonCache["microServicePolicies"]; |
| 91 | for (p in msProperties) { |
| 92 | if (msProperties[p]["name"] == type) { |
| 93 | return JSON.parse(JSON.stringify(msProperties[p]["jsonRepresentation"])); |
| 94 | } |
| 95 | } |
| 96 | return null; |
| 97 | } |
| 98 | |
| 99 | getResourceDetailsVfProperty() { |
| 100 | return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VF"]; |
| 101 | } |
| 102 | |
| 103 | getResourceDetailsVfModuleProperty() { |
| 104 | return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VFModule"]; |
| 105 | } |
| 106 | |
| 107 | getLoopLogsArray() { |
| 108 | return this.loopJsonCache.loopLogs; |
| 109 | } |
| 110 | |
| 111 | getComponentStates() { |
| 112 | return this.loopJsonCache.components; |
| 113 | } |
| 114 | |
| 115 | } |
| 116 | export default LoopCache; |