diff options
author | hekeguang <hekeguang@chinamobile.com> | 2022-09-01 17:10:39 +0800 |
---|---|---|
committer | hekeguang <hekeguang@chinamobile.com> | 2022-09-01 17:10:52 +0800 |
commit | e39a0b1353a299f379a37e511ede6d2ff85237c1 (patch) | |
tree | 870cd195cf3dc1e456eade9041098a3488c7e47e /intentanalysis/src/main/java/org/onap | |
parent | d004c121a83dfea3654d9ac47bd558e2237b7e6f (diff) |
Add intent operation process code .
Issue-ID: USECASEUI-696
Change-Id: I079ff3d58874122b6d5ae54fffcb5de4f033fcb6
Signed-off-by: hekeguang <hekeguang@chinamobile.com>
Diffstat (limited to 'intentanalysis/src/main/java/org/onap')
21 files changed, 178 insertions, 216 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/AssuranceIntentManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/AssuranceIntentManagementFunction.java new file mode 100644 index 0000000..b4d0e57 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/AssuranceIntentManagementFunction.java @@ -0,0 +1,6 @@ +package org.onap.usecaseui.intentanalysis.assuranceIntentmgt; + +import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; + +public class AssuranceIntentManagementFunction extends IntentManagementFunction { +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/assurancemodule/AssuranceActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/assurancemodule/AssuranceActuationModule.java new file mode 100644 index 0000000..2f0961a --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/assurancemodule/AssuranceActuationModule.java @@ -0,0 +1,4 @@ +package org.onap.usecaseui.intentanalysis.assuranceIntentmgt.assurancemodule; + +public class AssuranceActuationModule { +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/assurancemodule/AssuranceDecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/assurancemodule/AssuranceDecisionModule.java new file mode 100644 index 0000000..7965f7e --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/assurancemodule/AssuranceDecisionModule.java @@ -0,0 +1,4 @@ +package org.onap.usecaseui.intentanalysis.assuranceIntentmgt.assurancemodule; + +public class AssuranceDecisionModule { +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/assurancemodule/AssuranceKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/assurancemodule/AssuranceKnowledgeModule.java new file mode 100644 index 0000000..3e2e3d6 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/assuranceIntentmgt/assurancemodule/AssuranceKnowledgeModule.java @@ -0,0 +1,4 @@ +package org.onap.usecaseui.intentanalysis.assuranceIntentmgt.assurancemodule; + +public class AssuranceKnowledgeModule { +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessActuationModule.java index acd580f..d2a5c53 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessActuationModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessActuationModule.java @@ -20,7 +20,6 @@ import org.apache.commons.lang.StringUtils; import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; import org.onap.usecaseui.intentanalysis.bean.models.Intent; import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; -import org.onap.usecaseui.intentanalysis.intentBaseService.IntentHandleService; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; @@ -35,12 +34,10 @@ import java.util.Map; import java.util.stream.Collectors; @Service -public class CLLBusinessActuationModule implements ActuationModule { +public class CLLBusinessActuationModule extends ActuationModule { @Autowired IntentProcessService processService; @Autowired - IntentHandleService intentHandleService; - @Autowired IntentService intentService; @Autowired IntentInterfaceService intentInterfaceService; @@ -73,19 +70,4 @@ public class CLLBusinessActuationModule implements ActuationModule { } } - - @Override - public boolean distrubuteIntentToHandler(Map<IntentGoalBean, IntentManagementFunction> intentMap) { - for (Map.Entry<IntentGoalBean, IntentManagementFunction> entry : intentMap.entrySet()) { - IntentGoalType intentGoalType = entry.getKey().getIntentGoalType(); - if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) { - return intentInterfaceService.createInterface(entry.getKey().getIntent(), entry.getValue()); - } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) { - return intentInterfaceService.updateInterface(entry.getKey().getIntent(), entry.getValue()); - } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) { - return intentInterfaceService.deleteInterface(entry.getKey().getIntent(), entry.getValue()); - } - } - return false; - } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java index 3313af5..564429b 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java @@ -37,7 +37,7 @@ import java.util.stream.Collectors; @Log4j2 @Service -public class CLLBusinessDecisionModule implements DecisionModule { +public class CLLBusinessDecisionModule extends DecisionModule { @Autowired private ImfRegInfoService imfRegInfoService; @Autowired diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java index c7d0872..d93f3f5 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java @@ -34,7 +34,7 @@ import java.util.List; import java.util.stream.Collectors; @Service -public class CLLBusinessKnowledgeModule implements KnowledgeModule { +public class CLLBusinessKnowledgeModule extends KnowledgeModule { private static Logger LOGGER = LoggerFactory.getLogger(CLLBusinessKnowledgeModule.class); @Autowired @@ -44,7 +44,7 @@ public class CLLBusinessKnowledgeModule implements KnowledgeModule { @Override public IntentGoalBean intentCognition(Intent intent) { - List<String> intendIdList = intentDetectionService.intentResolution(intent); + List<String> intendIdList = intentResolution(intent); getSystemStatus(); return determineDetectionGoal(intent, intendIdList); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java index bb5e085..4983298 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java @@ -19,7 +19,8 @@ package org.onap.usecaseui.intentanalysis.controller; import java.util.List; -import org.onap.usecaseui.intentanalysis.intentBaseService.IntentHandleService; +import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -38,7 +39,7 @@ public class IntentController { private IntentService intentService; @Autowired - private IntentHandleService intentHandleService; + private IntentProcessService processService; @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<Intent>> getIntentList() { @@ -70,7 +71,8 @@ public class IntentController { @PostMapping(value="/handleIntent",produces = MediaType.APPLICATION_JSON_VALUE) public void handleIntent(@RequestBody Intent intent) { - intentHandleService.handleOriginalIntent(intent); + processService.setIntentRole(new FormatIntentInputManagementFunction(), null); + processService.intentProcess(intent); } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/DeliveryManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/DeliveryManagementFunction.java new file mode 100644 index 0000000..b30da14 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/DeliveryManagementFunction.java @@ -0,0 +1,15 @@ +package org.onap.usecaseui.intentanalysis.deliveryIntentmgt; + +import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessActuationModule; +import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessDecisionModule; +import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessKnowledgeModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule; + +public class DeliveryManagementFunction extends IntentManagementFunction { + private ActuationModule actuationModule = new CLLBusinessActuationModule(); + private DecisionModule decisoinModule = new CLLBusinessDecisionModule(); + private KnowledgeModule knowledgeModule = new CLLBusinessKnowledgeModule(); +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/deliverymodule/DeliveryActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/deliverymodule/DeliveryActuationModule.java new file mode 100644 index 0000000..82e4b9b --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/deliverymodule/DeliveryActuationModule.java @@ -0,0 +1,4 @@ +package org.onap.usecaseui.intentanalysis.deliveryIntentmgt.deliverymodule; + +public class DeliveryActuationModule { +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/deliverymodule/DeliveryDecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/deliverymodule/DeliveryDecisionModule.java new file mode 100644 index 0000000..44aed5e --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/deliverymodule/DeliveryDecisionModule.java @@ -0,0 +1,4 @@ +package org.onap.usecaseui.intentanalysis.deliveryIntentmgt.deliverymodule; + +public class DeliveryDecisionModule { +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/deliverymodule/DeliveryKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/deliverymodule/DeliveryKnowledgeModule.java new file mode 100644 index 0000000..47b30f9 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/deliveryIntentmgt/deliverymodule/DeliveryKnowledgeModule.java @@ -0,0 +1,4 @@ +package org.onap.usecaseui.intentanalysis.deliveryIntentmgt.deliverymodule; + +public class DeliveryKnowledgeModule { +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputActuationModule.java index e556356..936bf0e 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputActuationModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputActuationModule.java @@ -22,7 +22,7 @@ import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.Actuatio import java.util.List; import java.util.Map; -public class FormatIntentInputActuationModule implements ActuationModule { +public class FormatIntentInputActuationModule extends ActuationModule { @Override public void sendToIntentHandler(IntentManagementFunction IntentHandler) { } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java index af29747..ac116fd 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -public class FormatIntentInputDecisionModule implements DecisionModule { +public class FormatIntentInputDecisionModule extends DecisionModule { @Autowired ApplicationContext applicationContext; diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputKnowledgeModule.java index d6952f4..4fa9ee2 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputKnowledgeModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputKnowledgeModule.java @@ -24,13 +24,13 @@ import org.springframework.beans.factory.annotation.Autowired; import java.util.List; -public class FormatIntentInputKnowledgeModule implements KnowledgeModule { +public class FormatIntentInputKnowledgeModule extends KnowledgeModule { @Autowired IntentDetectionService intentDetectionService; @Override public IntentGoalBean intentCognition(Intent intent) { - List<String> intendIdList = intentDetectionService.intentResolution(intent); + List<String> intendIdList = intentResolution(intent); getSystemStatus(); return determineDetectionGoal(intent, intendIdList); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java deleted file mode 100644 index 1f18c52..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. - * - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.usecaseui.intentanalysis.intentBaseService; - -import lombok.extern.slf4j.Slf4j; -import org.onap.usecaseui.intentanalysis.bean.models.Intent; -import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo; -import org.onap.usecaseui.intentanalysis.common.ResponseConsts; -import org.onap.usecaseui.intentanalysis.exception.DataBaseException; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; -import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -@Slf4j -@Service -public class IntentHandleService { - @Autowired - private IntentProcessService processService; - @Autowired - private ImfRegInfoService imfRegInfoService; - @Autowired - private ApplicationContext applicationContext; - - /** - * Process the original intent and find the corresponding IntentManagementFunction - * - * @param intent todo - */ - public void handleOriginalIntent(Intent intent) { - IntentManagementFunction intentOwner = getOriginalIMF(intent); - handleIntent(intent, intentOwner); - } - - public void handleIntent(Intent intent, IntentManagementFunction intentOwner) { - processService.setIntentRole(intentOwner, null); - processService.intentProcess(intent); - } - - public IntentManagementFunction selectIntentManagementFunction(Intent intent) { - //select the IntentManagementFunctionRegInfo Based on the IMFRegistry information. - //Only internalFunction support. - //and based on the IntentManagementFunctionRegInfo, get the right IntentManagementFunction bean. - //if no IntentManagementFunction selected, that means this intent is not supported by this system. - return null; - } - - public IntentManagementFunctionRegInfo selectIntentManagementFunctionRegInfo(Intent intent) { - //select the IntentManagementFunctionRegInfo Based on the IMFRegistry information. - //Both internalFunction and externalFunction support. - //This is used to get he IntentManagementFunction for a subIntent decomposition. - return null; - } - - public IntentManagementFunction getOriginalIMF(Intent intent) { - //select IntentManagementFunction based on intent name - String intentName = intent.getIntentName(); - List<IntentManagementFunctionRegInfo> imfRegInfoList = imfRegInfoService.getImfRegInfoList(); - List<IntentManagementFunctionRegInfo> list = imfRegInfoList.stream().filter(x -> x.getSupportArea().contains(intentName)).collect(Collectors.toList()); - if (!Optional.ofNullable(list).isPresent()) { - String msg = String.format("Intent name %s doesn't exist IntentManagementFunction in database.", intent.getIntentName()); - log.error(msg); - throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY); - } - return (IntentManagementFunction) applicationContext.getBean(list.get(0).getHandleName()); - } -} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/ActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/ActuationModule.java index 8f753e4..e9ee3f7 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/ActuationModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/ActuationModule.java @@ -15,19 +15,41 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule; +import org.apache.commons.lang.StringUtils; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService; +import org.springframework.beans.factory.annotation.Autowired; import java.util.List; import java.util.Map; -public interface ActuationModule { +public abstract class ActuationModule { + @Autowired + IntentInterfaceService intentInterfaceService; + //actuationModel & knownledgeModel interact - void sendToIntentHandler(IntentManagementFunction IntentHandler); - void sendToNonIntentHandler();//直接操作 - void interactWithIntentHandle(); + public abstract void sendToIntentHandler(IntentManagementFunction IntentHandler); + + public abstract void sendToNonIntentHandler();//直接操作 + + public abstract void interactWithIntentHandle(); + //Save intent information to the intent instance database - void saveIntentToDb(List<Map<IntentGoalBean,IntentManagementFunction>> intentMapList); - boolean distrubuteIntentToHandler(Map<IntentGoalBean,IntentManagementFunction> intentMap); + public abstract void saveIntentToDb(List<Map<IntentGoalBean, IntentManagementFunction>> intentMapList); + public boolean distrubuteIntentToHandler(Map<IntentGoalBean, IntentManagementFunction> intentMap) { + for (Map.Entry<IntentGoalBean, IntentManagementFunction> entry : intentMap.entrySet()) { + IntentGoalType intentGoalType = entry.getKey().getIntentGoalType(); + if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) { + return intentInterfaceService.createInterface(entry.getKey().getIntent(), entry.getValue()); + } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) { + return intentInterfaceService.updateInterface(entry.getKey().getIntent(), entry.getValue()); + } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) { + return intentInterfaceService.deleteInterface(entry.getKey().getIntent(), entry.getValue()); + } + } + return false; + } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java index 113d50d..a89656b 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java @@ -22,18 +22,18 @@ import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunct import java.util.List; import java.util.Map; -public interface DecisionModule { - void determineUltimateGoal(); +public abstract class DecisionModule { + public abstract void determineUltimateGoal(); // find intentManageFunction - IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean); + public abstract IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean); - void intentDefinition(); + public abstract void intentDefinition(); - void decideSuitableAction(); + public abstract void decideSuitableAction(); - public void interactWithTemplateDb(); + public abstract void interactWithTemplateDb(); - public List<Map<IntentGoalBean, IntentManagementFunction>> findHandler(IntentGoalBean intentGoalBean); + public abstract List<Map<IntentGoalBean, IntentManagementFunction>> findHandler(IntentGoalBean intentGoalBean); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java index 818b812..133ce37 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java @@ -15,15 +15,93 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule; -import org.onap.usecaseui.intentanalysis.bean.models.Intent; -import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.onap.usecaseui.intentanalysis.bean.models.*; +import org.onap.usecaseui.intentanalysis.service.IntentService; +import org.springframework.beans.factory.annotation.Autowired; -public interface KnowledgeModule { +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public abstract class KnowledgeModule { + @Autowired + IntentService intentService; //Parse, decompose, orchestrate the original intent - IntentGoalBean intentCognition(Intent intent); + public abstract IntentGoalBean intentCognition(Intent intent); // in distribution, ask permission from imf - boolean recieveCreateIntent();// ֿд - boolean recieveUpdateIntent(); - boolean recieveDeleteIntent(); + public abstract boolean recieveCreateIntent(); + public abstract boolean recieveUpdateIntent(); + public abstract boolean recieveDeleteIntent(); + + public List<String> intentResolution(Intent intent) { + //db contain original intent + List<Intent> sameNameIntentList = intentService.getIntentByName(intent.getIntentName()); + List<String> intentIdList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(sameNameIntentList)) { + //remove context.condition ownerName = formatIntentInputManagementFunction + List<Intent> filterIntentList = filterIntent(sameNameIntentList); + List<Expectation> expectationList = intent.getIntentExpectations(); + for (Intent dbIntent : filterIntentList) { + String intentId = dbIntent.getIntentId(); + int count = 0; + for (Expectation expectation : expectationList) {//original expectations + //Determine if there is the same ObjectType + List<Expectation> sameObjTypeList = dbIntent.getIntentExpectations().stream() + .filter(x -> x.getExpectationObject().getObjectType().equals(expectation.getExpectationObject().getObjectType())) + .collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(sameObjTypeList)) { + //Determine the targetName of the Expectation which hava same ObjectType + List<String> targetNameList = expectation.getExpectationTargets() + .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList()); + for (Expectation dbExpectation : sameObjTypeList) { + List<String> dbTargetNameList = dbExpectation.getExpectationTargets() + .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList()); + //todo name compare need ai + if (dbTargetNameList.containsAll(targetNameList)) { + count++; + break; + } + } + } + if (count == expectationList.size()) { + intentIdList.add(intentId); + break; + } + } + } + } + return intentIdList; + } + + public List<Intent> filterIntent(List<Intent> list) { + //// condition ownerName = foramtIntentInput + List<Intent> fiterList = new ArrayList<>(); + for (Intent intent : list) { + List<Context> ownerInfo = intent.getIntentContexts().stream().filter(x -> + StringUtils.equalsIgnoreCase(x.getContextName(), "ownerInfo")).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(ownerInfo)) { + for (Context context : ownerInfo) { + List<Condition> contextConditions = context.getContextConditions(); + boolean equals = false; + for (Condition condition : contextConditions) { + String conditionstr = "ownerName = formatIntentInputManagementFunction"; + String concatStr = condition.getConditionName() + condition.getOperator() + condition.getConditionValue(); + if (StringUtils.equalsIgnoreCase(concatStr.trim(), conditionstr.trim())) { + fiterList.add(intent); + equals = true; + break; + } + } + if (equals==true) { + break; + } + } + } + } + list.removeAll(fiterList); + return list; + } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java index 3273925..389f7ce 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java @@ -51,73 +51,4 @@ public class IntentDetectionService { return ownerKnowledgeModule.intentCognition(intent); } - - public List<String> intentResolution(Intent intent) { - //db contain original intent - List<Intent> sameNameIntentList = intentService.getIntentByName(intent.getIntentName()); - List<String> intentIdList = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(sameNameIntentList)) { - //remove context.condition ownerName = formatIntentInputManagementFunction - List<Intent> filterIntentList = filterIntent(sameNameIntentList); - List<Expectation> expectationList = intent.getIntentExpectations(); - for (Intent dbIntent : filterIntentList) { - String intentId = dbIntent.getIntentId(); - int count = 0; - for (Expectation expectation : expectationList) {//original expectations - //Determine if there is the same ObjectType - List<Expectation> sameObjTypeList = dbIntent.getIntentExpectations().stream() - .filter(x -> x.getExpectationObject().getObjectType().equals(expectation.getExpectationObject().getObjectType())) - .collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(sameObjTypeList)) { - //Determine the targetName of the Expectation which hava same ObjectType - List<String> targetNameList = expectation.getExpectationTargets() - .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList()); - for (Expectation dbExpectation : sameObjTypeList) { - List<String> dbTargetNameList = dbExpectation.getExpectationTargets() - .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList()); - //todo name compare need ai - if (dbTargetNameList.containsAll(targetNameList)) { - count++; - break; - } - } - } - if (count == expectationList.size()) { - intentIdList.add(intentId); - break; - } - } - } - } - return intentIdList; - } - - public List<Intent> filterIntent(List<Intent> list) { - //// condition ownerName = foramtIntentInput - List<Intent> fiterList = new ArrayList<>(); - for (Intent intent : list) { - List<Context> ownerInfo = intent.getIntentContexts().stream().filter(x -> - StringUtils.equalsIgnoreCase(x.getContextName(), "ownerInfo")).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(ownerInfo)) { - for (Context context : ownerInfo) { - List<Condition> contextConditions = context.getContextConditions(); - boolean equals = false; - for (Condition condition : contextConditions) { - String conditionstr = "ownerName = formatIntentInputManagementFunction"; - String concatStr = condition.getConditionName() + condition.getOperator() + condition.getConditionValue(); - if (StringUtils.equalsIgnoreCase(concatStr.trim(), conditionstr.trim())) { - fiterList.add(intent); - equals = true; - break; - } - } - if (equals==true) { - break; - } - } - } - } - list.removeAll(fiterList); - return list; - } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java index d803718..9e6c921 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java @@ -51,19 +51,5 @@ public class IntentDistributionService { return false; } - public boolean distrubuteIntentToHandler(Map<IntentGoalBean, IntentManagementFunction> intentMap) { - - for (Map.Entry<IntentGoalBean, IntentManagementFunction> entry : intentMap.entrySet()) { - IntentGoalType intentGoalType = entry.getKey().getIntentGoalType(); - if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) { - return intentInterfaceService.createInterface(entry.getKey().getIntent(), entry.getValue()); - } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) { - return intentInterfaceService.updateInterface(entry.getKey().getIntent(), entry.getValue()); - } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) { - return intentInterfaceService.deleteInterface(entry.getKey().getIntent(), entry.getValue()); - } - } - return false; - } } |