diff options
author | hekeguang <hekeguang@chinamobile.com> | 2022-11-02 10:48:58 +0800 |
---|---|---|
committer | hekeguang <hekeguang@chinamobile.com> | 2022-11-02 10:49:14 +0800 |
commit | 6dce92da99be58aa2af3da3589e179ae1baf6a73 (patch) | |
tree | 8ecfbfa44eeabd1e797f6cb75e7d302dcf192aad | |
parent | 8c1785c9cc42116e19ea06e0c044bbfdf37e217c (diff) |
Bugfix for intent analysis server delete function.
Issue-ID: USECASEUI-749
Change-Id: I551057366c70b68c1ec8af0eaacc4403b4bfd7cc
Signed-off-by: hekeguang <hekeguang@chinamobile.com>
13 files changed, 79 insertions, 41 deletions
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 f073cc2..b9e48ed 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 @@ -163,8 +163,10 @@ public class CLLBusinessDecisionModule extends DecisionModule { IntentManagementFunction intentHandlerInfo = intentContextService.getHandlerInfo(intent); boolean bFindIntent = false; for (Expectation originExpectation : originIntentExpectationList) { - if (intent.getIntentName().equals(originExpectation.getExpectationName())){ + if (intent.getIntentName().replace("Intent","") + .equals(originExpectation.getExpectationName().replace("Expectation",""))){ bFindIntent = true; + break; } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java index c80c717..b1a0924 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java @@ -15,18 +15,20 @@ */ package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.cllassurancemodule; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.onap.usecaseui.intentanalysis.adapters.policy.PolicyService; import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; import org.onap.usecaseui.intentanalysis.bean.models.*; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; +import org.onap.usecaseui.intentanalysis.service.ContextService; import org.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; - +@Slf4j @Component public class CLLAssuranceActuationModule extends ActuationModule { @Autowired @@ -34,6 +36,8 @@ public class CLLAssuranceActuationModule extends ActuationModule { @Autowired private PolicyService policyService; + @Autowired + private ContextService contextService; @Override public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) { @@ -67,7 +71,8 @@ public class CLLAssuranceActuationModule extends ActuationModule { @Override public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){ - + log.info("cllDeliveryActuationModule begin to update originIntent subIntentInfo"); + contextService.updateContextList(originIntent.getIntentContexts(), originIntent.getIntentId()); } private String getBandwidth(String cllId) { diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java index b642586..cf1072c 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java @@ -21,6 +21,7 @@ import org.onap.usecaseui.intentanalysis.adapters.so.SOService; import org.onap.usecaseui.intentanalysis.bean.models.*; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; +import org.onap.usecaseui.intentanalysis.service.ContextService; import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService; import org.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.beans.factory.annotation.Autowired; @@ -43,6 +44,8 @@ public class CLLDeliveryActuationModule extends ActuationModule { @Autowired private IntentService intentService; + @Autowired + private ContextService contextService; @Override public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) { @@ -118,7 +121,7 @@ public class CLLDeliveryActuationModule extends ActuationModule { expectationObjectService.updateExpectationObject(originExpectationObject,originExpectation.getExpectationId()); } } - - + log.info("cllDeliveryActuationModule begin to update originIntent subIntentInfo"); + contextService.updateContextList(originIntent.getIntentContexts(), originIntent.getIntentId()); } } 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 6e5c7d4..fcbee7c 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 @@ -84,19 +84,9 @@ public class IntentController { public void removeIntentById(@PathVariable(INTENT_ID) String intentId) { processService.setIntentRole(formatIntentInputManagementFunction, null); - //save original intent Intent intent = intentService.getIntent(intentId); IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.DELETE); processService.intentProcess(intentGoalBean); } - @PostMapping(value = "/handleIntent", produces = MediaType.APPLICATION_JSON_VALUE) - public void handleIntent(@RequestBody Intent intent) { - processService.setIntentRole(formatIntentInputManagementFunction, null); - //save original intent - - IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); - IntentGoalBean newIntentGoalBean = processService.intentProcess(intentGoalBean); - intentService.createIntent(newIntentGoalBean.getIntent()); - } } 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 2f8756c..3572687 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 @@ -15,26 +15,17 @@ */ package org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule; -import lombok.extern.log4j.Log4j2; -import org.apache.commons.collections.CollectionUtils; -import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType; -import org.onap.usecaseui.intentanalysis.bean.models.Condition; -import org.onap.usecaseui.intentanalysis.bean.models.Context; +import lombok.extern.slf4j.Slf4j; import org.onap.usecaseui.intentanalysis.bean.models.Intent; import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; -import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; import org.onap.usecaseui.intentanalysis.service.IntentService; -import org.onap.usecaseui.intentanalysis.util.CommonUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.List; - -@Log4j2 +@Slf4j @Component public class FormatIntentInputActuationModule extends ActuationModule { @Autowired 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 0a01357..9e0a443 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 @@ -108,6 +108,9 @@ public class FormatIntentInputDecisionModule extends DecisionModule { public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationUpdateProcess(IntentGoalBean intentGoalBean) { //get format-cll intent LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>(); + // update format-cll intentContext + Intent intent1 = intentService.getIntent(intentGoalBean.getIntent().getIntentId()); + intentGoalBean.getIntent().setIntentContexts(intent1.getIntentContexts()); List<Intent> subIntentList = intentContextService.getSubIntentInfoFromContext(intentGoalBean.getIntent()); for (Intent intent : subIntentList) { IntentManagementFunction intentHandlerInfo = intentContextService.getHandlerInfo(intent); @@ -125,22 +128,25 @@ public class FormatIntentInputDecisionModule extends DecisionModule { int newIntentExpectationNum = originIntentExpectationList.size(); int oldIntentExpectationNum = intentExpectationList.size(); + List<Expectation> changeList = new ArrayList<>(); if (newIntentExpectationNum != oldIntentExpectationNum){ if (newIntentExpectationNum < oldIntentExpectationNum){ - boolean bFindExpectation = false; - for (Expectation oldExpectation : intentExpectationList) { - for (Expectation newExpectation : originIntentExpectationList) { + + for (Expectation oldExpectation : intentExpectationList) {//search + boolean bFindExpectation = false; + for (Expectation newExpectation : originIntentExpectationList) {//param if (oldExpectation.getExpectationName().equals(newExpectation.getExpectationName())){ bFindExpectation = true; + break; } } - if (bFindExpectation == false){ - intentExpectationList.remove(oldExpectation); + if (bFindExpectation){ + changeList.add(oldExpectation); } } } } - intent.setIntentExpectations(intentExpectationList); + intent.setIntentExpectations(changeList); } @Override diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/contextService/IntentContextService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/contextService/IntentContextService.java index 8a97783..76ff2d2 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/contextService/IntentContextService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/contextService/IntentContextService.java @@ -15,12 +15,13 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.contextService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType; import org.onap.usecaseui.intentanalysis.bean.models.Condition; import org.onap.usecaseui.intentanalysis.bean.models.Context; import org.onap.usecaseui.intentanalysis.bean.models.Intent; -import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.service.IntentService; import org.onap.usecaseui.intentanalysis.util.CommonUtil; @@ -30,7 +31,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; - +@Slf4j @Service public class IntentContextService { @@ -95,8 +96,8 @@ public class IntentContextService { conditionList.add(condition1); context.setContextConditions(conditionList); contextList.add(context); - originIntent.setIntentContexts(contextList); } + originIntent.setIntentContexts(contextList); } public void updateIntentOwnerHandlerContext(Intent intent, IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){ @@ -163,8 +164,9 @@ public class IntentContextService { if (context.getContextName().contains("handler info")) { List<Condition> conditionList = context.getContextConditions(); String handlerClassName = conditionList.get(0).getConditionValue(); + String handleName = StringUtils.substringAfterLast(handlerClassName,"."); handler = (IntentManagementFunction) applicationContext - .getBean(CLLBusinessIntentManagementFunction.class.getSimpleName()); + .getBean(handleName); } } return handler; @@ -175,13 +177,16 @@ public class IntentContextService { for (Context context : contextList) { if (context.getContextName().contains("subIntent info")) { List<Condition> conditionList = context.getContextConditions(); + List<Condition> newConditionList = new ArrayList<>(); for (Condition condition : conditionList) { - if (condition.getConditionValue() == deleteIntentId){ - conditionList.remove(condition); + if (!StringUtils.equals(condition.getConditionValue(), deleteIntentId)){ + newConditionList.add(condition); } } + context.setContextConditions(newConditionList); } } + log.info("deleteSubIntentContext from intent finished"); } } 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 5641e99..9b4c248 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,6 +15,7 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; import org.onap.usecaseui.intentanalysis.bean.models.Intent; @@ -24,6 +25,7 @@ import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservic import org.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.beans.factory.annotation.Autowired; +import java.util.List; import java.util.Map; public abstract class ActuationModule { @@ -52,6 +54,11 @@ public abstract class ActuationModule { //Delete intent information to the intent instance database public void deleteIntentToDb(Intent intent) { + //judge if exist subIntent,exist->don't delete + List<String> subIntentList = intentService.getSubIntentList(intent); + if (CollectionUtils.isNotEmpty(subIntentList)) { + return; + } intentService.deleteIntent(intent.getIntentId()); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java index 4cf00f3..92be843 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java @@ -67,7 +67,7 @@ public class IntentDefinitionService { intentActuationModule.updateIntentToDb(newIntentGoalBean.getIntent()); } if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.DELETE){ - intentActuationModule.deleteIntentToDb(newIntentGoalBean.getIntent()); + intentActuationModule.deleteIntentToDb(entry.getKey().getIntent()); } return newIntentGoalBean; } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java index 49f6d13..331628f 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java @@ -15,8 +15,8 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; +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.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.service.IntentService; @@ -79,6 +79,10 @@ public class IntentProcessService { intentOperationService.setIntentRole(intentOwner, next.getValue()); intentOperationService.operationProcess(originIntentGoalBean.getIntent(), newIdIntentGoalBean); } + //delete second intent + if (StringUtils.equals(originIntentGoalBean.getIntentGoalType().name(),IntentGoalType.DELETE.name())){ + intentService.deleteIntent(originIntentGoalBean.getIntent().getIntentId()); + } return newIntentGoalBean; } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java index d823245..51bbea5 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java @@ -33,4 +33,6 @@ public interface IntentService { void deleteIntent(String intentId); List<Intent> getIntentByName(String name); + + List<String> getSubIntentList(Intent intent); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java index bb1759c..d2b41bb 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java @@ -17,10 +17,15 @@ package org.onap.usecaseui.intentanalysis.service.impl; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.onap.usecaseui.intentanalysis.bean.models.Condition; +import org.onap.usecaseui.intentanalysis.bean.models.Context; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -151,4 +156,22 @@ public class IntentServiceImpl implements IntentService { } return intentList; } + + @Override + public List<String> getSubIntentList(Intent intent){ + List<Context> intentContexts = intent.getIntentContexts(); + List<String> subIntentIds= new ArrayList<>(); + if (CollectionUtils.isNotEmpty(intentContexts)) { + List<Context> subIntentInfoList = intentContexts.stream().filter(x -> StringUtils.equals(x.getContextName(), "subIntent info")).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(subIntentInfoList)) { + List<Condition> contextConditions = subIntentInfoList.get(0).getContextConditions(); + if (CollectionUtils.isNotEmpty(contextConditions)) { + for (Condition con:contextConditions) { + subIntentIds.add(con.getConditionValue()); + } + } + } + } + return subIntentIds; + } } diff --git a/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml index ccce147..f0bc629 100644 --- a/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml +++ b/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml @@ -49,7 +49,7 @@ </update> <delete id="deleteCondition"> - DELETE FROM condition WHERE condition_id = #{condition.conditionId} + DELETE FROM condition WHERE condition_id = #{conditionId} </delete> <delete id="deleteConditionList"> |