diff options
author | kurczews <krzysztof.kurczewski@nokia.com> | 2019-09-16 12:55:00 +0200 |
---|---|---|
committer | kurczews <krzysztof.kurczewski@nokia.com> | 2019-09-18 07:13:54 +0200 |
commit | 75bb8e29cbeea1b3dbb682dbf248ffeede928c11 (patch) | |
tree | a55dac0b7640b7184fa481271f3fed3b49a3b2dd /bpmn/so-bpmn-tasks/src/main/java | |
parent | 80d6f2f06e538dbb212f968514f0943bb7dd41ba (diff) |
Fix default homing
Issue-ID: SO-2307
Change-Id: Iee2562c6f38a440006d3a6108ce6f6fd6dbedcf6
Signed-off-by: kurczews <krzysztof.kurczewski@nokia.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
-rw-r--r-- | bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java index 4e74e5d414..c223d3ff11 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java @@ -2,14 +2,15 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) Copyright (C) 2018 Bell Canada. + * Copyright (C) 2018 Bell Canada. + * Copyright (C) 2019 Nokia. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +21,6 @@ package org.onap.so.bpmn.buildingblock; -import java.util.Map; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -28,37 +28,37 @@ import org.springframework.stereotype.Component; @Component public class HomingV2 { - @Autowired - private OofHomingV2 oofHomingV2; - @Autowired + static final String HOMING_SNIRO = "sniro"; + static final String HOMING_OOF = "oof"; + static final String HOMING_SOLUTION = "Homing_Solution"; + private SniroHomingV2 sniroHomingV2; + private OofHomingV2 oofHomingV2; - private static final String HOMINGSOLUTION = "Homing_Solution"; + @Autowired + public HomingV2(OofHomingV2 oofHomingV2, SniroHomingV2 sniroHomingV2) { + this.oofHomingV2 = oofHomingV2; + this.sniroHomingV2 = sniroHomingV2; + } public void callHoming(BuildingBlockExecution execution) { - if (isOof(execution)) { - oofHomingV2.callOof(execution); - } else { + if (isSniro(execution)) { sniroHomingV2.callSniro(execution); + } else { + oofHomingV2.callOof(execution); } } public void processSolution(BuildingBlockExecution execution, String asyncResponse) { - if (isOof(execution)) { - oofHomingV2.processSolution(execution, asyncResponse); - } else { + if (isSniro(execution)) { sniroHomingV2.processSolution(execution, asyncResponse); + } else { + oofHomingV2.processSolution(execution, asyncResponse); } } - // Default solution is SNIRO. OOF gets called only if specified. - private boolean isOof(BuildingBlockExecution execution) { - for (Map<String, Object> params : execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters() - .getUserParams()) { - if (params.containsKey(HOMINGSOLUTION) && ("oof").equals(params.get(HOMINGSOLUTION))) { - return true; - } - } - return false; + private boolean isSniro(BuildingBlockExecution execution) { + return execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters().getUserParams().stream() + .anyMatch(params -> HOMING_SNIRO.equals(params.get(HOMING_SOLUTION))); } } |