2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 load("nashorn:mozilla_compat.js");
23 var logger = executor.logger;
24 logger.trace("start: " + executor.subject.id);
25 logger.trace("-- infields: " + executor.inFields);
27 var ifCustomerName = executor.inFields["customerName"];
28 var ifLinks = executor.inFields["links"];
30 logger.trace("-- got infields, testing existing customer");
31 var ctxtCustomer = executor.getContextAlbum("albumCustomerMap").get(ifCustomerName);
32 if (ctxtCustomer != null) {
33 executor.getContextAlbum("albumCustomerMap").remove(ifCustomerName);
34 logger.trace("-- removed customer: <" + ifCustomerName + ">");
37 logger.trace("-- creating customer: <" + ifCustomerName + ">");
38 var links = new Array();
39 for (var i = 0; i < ifLinks.split(" ").length; i++) {
40 var link = executor.getContextAlbum("albumTopoEdges").get(ifLinks.split(" ")[i]);
42 logger.trace("-- link: <" + ifLinks.split(" ")[i] + ">");
43 links.push(ifLinks.split(" ")[i]);
45 logger.trace("-- unknown link: <" + ifLinks.split(" ")[i] + "> for customer <" + ifCustomerName + ">");
48 logger.trace("-- links: <" + links + ">");
49 ctxtCustomer = "{customerName:" + ifCustomerName + ", dtSLA:" + executor.inFields["dtSLA"] + ", dtYTD:"
50 + executor.inFields["dtYTD"] + ", priority:" + executor.inFields["priority"] + ", satisfaction:"
51 + executor.inFields["satisfaction"] + ", links:[" + links + "]}";
53 executor.getContextAlbum("albumCustomerMap").put(ifCustomerName, ctxtCustomer);
55 if (logger.isTraceEnabled()) {
56 logger.trace(" >> *** Customers ***");
57 if (executor.getContextAlbum("albumCustomerMap") != null) {
58 for (var i = 0; i < executor.getContextAlbum("albumCustomerMap").values().size(); i++) {
59 logger.trace(" >> >> " + executor.getContextAlbum("albumCustomerMap").values().get(i).get("customerName")
60 + " : " + "dtSLA=" + executor.getContextAlbum("albumCustomerMap").values().get(i).get("dtSLA")
61 + " : " + "dtYTD=" + executor.getContextAlbum("albumCustomerMap").values().get(i).get("dtYTD")
62 + " : " + "links=" + executor.getContextAlbum("albumCustomerMap").values().get(i).get("links")
64 + executor.getContextAlbum("albumCustomerMap").values().get(i).get("priority") + " : "
66 + executor.getContextAlbum("albumCustomerMap").values().get(i).get("satisfaction"));
69 logger.trace(" >> >> customer album is null");
73 executor.outFields["report"] = "customer ctxt :: added customer: " + ifCustomerName;
75 logger.info("vpnsla: ctxt added customer " + ifCustomerName);
77 var returnValueType = Java.type("java.lang.Boolean");
78 var returnValue = new returnValueType(true);
79 logger.trace("finished: " + executor.subject.id);