2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.openecomp.sdnc.sli.provider;
24 import org.openecomp.sdnc.sli.SvcLogicContext;
25 import org.openecomp.sdnc.sli.SvcLogicException;
26 import org.openecomp.sdnc.sli.SvcLogicExpression;
27 import org.openecomp.sdnc.sli.SvcLogicGraph;
28 import org.openecomp.sdnc.sli.SvcLogicNode;
29 import org.openecomp.sdnc.sli.SvcLogicStore;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 public class CallNodeExecutor extends SvcLogicNodeExecutor {
35 private static final Logger LOG = LoggerFactory
36 .getLogger(CallNodeExecutor.class);
39 public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx)
40 throws SvcLogicException {
42 String outValue = "not-found";
44 SvcLogicGraph myGraph = node.getGraph();
48 LOG.debug("execute: getGraph returned null");
52 LOG.debug("execute: got SvcLogicGraph");
55 SvcLogicExpression moduleExpr = null;
59 moduleExpr = node.getAttribute("module");
60 if (moduleExpr != null)
62 module = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx);
65 if ((module == null) || (module.length() == 0))
69 module = myGraph.getModule();
70 LOG.debug("myGraph.getModule() returned "+module);
74 SvcLogicExpression rpcExpr = null;
76 rpcExpr = node.getAttribute("rpc");
79 rpc = SvcLogicExpressionResolver.evaluate(rpcExpr, node, ctx);
82 if ((rpc == null) || (rpc.length() == 0))
86 rpc = myGraph.getRpc();
87 LOG.debug("myGraph.getRpc() returned "+rpc);
93 moduleExpr = node.getAttribute("mode");
94 if (moduleExpr != null)
96 mode = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx);
99 if ((mode == null) || (mode.length() == 0))
103 mode = myGraph.getMode();
105 LOG.debug("myGraph.getMode() returned "+mode);
109 String version = null;
111 moduleExpr = node.getAttribute("version");
112 if (moduleExpr != null)
114 version = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx);
117 String parentGraph = ctx.getAttribute("currentGraph");
118 ctx.setAttribute("parentGraph", parentGraph);
120 SvcLogicStore store = SvcLogicActivator.getStore();
123 SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode);
124 LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString());
125 ctx.setAttribute("currentGraph", calledGraph.toString());
126 if (calledGraph != null) {
127 svc.execute(calledGraph, ctx);
129 outValue = ctx.getStatus();
131 LOG.error("Could not find service logic for [" + module + "," + rpc + "," + version + "," + mode + "]");
136 LOG.debug("Could not get SvcLogicStore reference");
139 SvcLogicNode nextNode = node.getOutcomeValue(outValue);
140 if (nextNode != null) {
141 if (LOG.isDebugEnabled()) {
142 LOG.debug("about to execute " + outValue + " branch");
144 ctx.setAttribute("currentGraph", parentGraph);
148 nextNode = node.getOutcomeValue("Other");
149 if (nextNode != null) {
150 if (LOG.isDebugEnabled()) {
151 LOG.debug("about to execute Other branch");
154 if (LOG.isDebugEnabled()) {
155 LOG.debug("no " + outValue + " or Other branch found");
158 ctx.setAttribute("currentGraph", parentGraph);
159 ctx.setAttribute("parentGraph", null);