diff options
author | hekeguang <hekeguang@chinamobile.com> | 2022-10-29 18:24:38 +0800 |
---|---|---|
committer | hekeguang <hekeguang@chinamobile.com> | 2022-10-29 18:28:42 +0800 |
commit | f80da8c8ae6c38ae5fbb2b20498133c68c2ed761 (patch) | |
tree | 8e50bc2118ecbe83dda736dbd030d672e69f0f45 | |
parent | 6d26f1827217363f8f65398cc57c7ec793182c57 (diff) |
Bugfix for intent analysis server update and delete function.
Issue-ID: USECASEUI-749
Change-Id: I6aa749924fdbd3b38cb60ea3e3a5ea7fbc6b458b
Signed-off-by: hekeguang <hekeguang@chinamobile.com>
8 files changed, 79 insertions, 70 deletions
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 641ecaf..b642586 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 @@ -15,6 +15,7 @@ */ package org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.clldeliverymodule; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.onap.usecaseui.intentanalysis.adapters.so.SOService; import org.onap.usecaseui.intentanalysis.bean.models.*; @@ -31,6 +32,7 @@ import java.util.Map; import java.util.UUID; @Component +@Slf4j public class CLLDeliveryActuationModule extends ActuationModule { @Autowired @@ -104,7 +106,7 @@ public class CLLDeliveryActuationModule extends ActuationModule { public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){ Intent subIntent = intentGoalBean.getIntent(); - if (subIntent.getIntentName().contains("delivery")){ + if (StringUtils.containsIgnoreCase(subIntent.getIntentName(),"delivery")) { List<Expectation> deliveryIntentExpectationList = intentGoalBean.getIntent().getIntentExpectations(); List<Expectation> originIntentExpectationList = originIntent.getIntentExpectations(); ExpectationObject deliveryExpectationObject = deliveryIntentExpectationList.get(0).getExpectationObject(); @@ -113,11 +115,10 @@ public class CLLDeliveryActuationModule extends ActuationModule { for (Expectation originExpectation : originIntentExpectationList) { ExpectationObject originExpectationObject = originExpectation.getExpectationObject(); originExpectationObject.setObjectInstance(objectInstance); + expectationObjectService.updateExpectationObject(originExpectationObject,originExpectation.getExpectationId()); } } - intentService.updateIntent(originIntent); - } - + } } 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 c3c8f3d..2f8756c 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 @@ -60,41 +60,7 @@ public class FormatIntentInputActuationModule extends ActuationModule { } - @Override - public void saveIntentToDb(Intent intent){ - List<Context> intentContexts = intent.getIntentContexts(); - if (CollectionUtils.isEmpty(intentContexts)) { - intentContexts = new ArrayList<>(); - } - Context ownerInfoCon = new Context(); - ownerInfoCon.setContextId(CommonUtil.getUUid()); - ownerInfoCon.setContextName("ownerInfo"); - List<Condition> conditionList = new ArrayList<>(); - Condition condition = new Condition(); - condition.setConditionId(CommonUtil.getUUid()); - condition.setConditionName("ownerName"); - condition.setOperator(OperatorType.EQUALTO); - condition.setConditionValue(FormatIntentInputManagementFunction.class.getSimpleName()); - conditionList.add(condition); - ownerInfoCon.setContextConditions(conditionList); - intentContexts.add(ownerInfoCon); - //ownerId intentId=parent intent id - Context ownerIdContext = new Context(); - ownerIdContext.setContextId(CommonUtil.getUUid()); - ownerIdContext.setContextName("ownerId"); - List<Condition> idConditionList = new ArrayList<>(); - Condition idCondition = new Condition(); - idCondition.setConditionId(CommonUtil.getUUid()); - idCondition.setConditionName("intentId"); - idCondition.setOperator(OperatorType.EQUALTO); - idCondition.setConditionValue(intent.getIntentId()); - idConditionList.add(idCondition); - ownerIdContext.setContextConditions(idConditionList); - intentContexts.add(ownerIdContext); - intent.setIntentContexts(intentContexts); - intentService.createIntent(intent); - } public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){ 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 ce36d6d..0a01357 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 @@ -140,7 +140,7 @@ public class FormatIntentInputDecisionModule extends DecisionModule { } } } - + intent.setIntentExpectations(intentExpectationList); } @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 1c0fe5f..8a97783 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,8 +15,7 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.contextService; -import java.util.ArrayList; -import java.util.List; +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; @@ -29,6 +28,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; + @Service public class IntentContextService { @@ -40,7 +42,9 @@ public class IntentContextService { public void updateChindIntentContext(Intent originIntent, Intent intent){ List<Context> contextList = intent.getIntentContexts(); - + if (CollectionUtils.isEmpty(contextList)) { + contextList = new ArrayList<>(); + } Condition condition1 = new Condition(); condition1.setConditionId(CommonUtil.getUUid()); condition1.setConditionName(originIntent.getIntentName() + "id"); @@ -54,10 +58,15 @@ public class IntentContextService { conditionList.add(condition1); context.setContextConditions(conditionList); contextList.add(context); + intent.setIntentContexts(contextList); + } public void updateParentIntentContext(Intent originIntent, Intent intent){ List<Context> contextList = originIntent.getIntentContexts(); + if (CollectionUtils.isEmpty(contextList)) { + contextList = new ArrayList<>(); + } Condition condition1 = new Condition(); condition1.setConditionId(CommonUtil.getUUid()); @@ -69,7 +78,11 @@ public class IntentContextService { for (Context context : contextList) { if (context.getContextName().contains("subIntent info")){ List<Condition> conditionList = context.getContextConditions(); + if (CollectionUtils.isEmpty(conditionList)) { + conditionList = new ArrayList<>(); + } conditionList.add(condition1); + context.setContextConditions(conditionList); isSubIntentInfoExist = true; } } @@ -82,12 +95,15 @@ public class IntentContextService { conditionList.add(condition1); context.setContextConditions(conditionList); contextList.add(context); - + originIntent.setIntentContexts(contextList); } } public void updateIntentOwnerHandlerContext(Intent intent, IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){ List<Context> contextList = intent.getIntentContexts(); + if (CollectionUtils.isEmpty(contextList)){ + contextList = new ArrayList<>(); + } Condition condition1 = new Condition(); condition1.setConditionId(CommonUtil.getUUid()); @@ -116,13 +132,16 @@ public class IntentContextService { conditionList2.add(condition2); context2.setContextConditions(conditionList2); contextList.add(context2); + + intent.setIntentContexts(contextList); } public List<Intent> getSubIntentInfoFromContext(Intent originIntent){ - List<Intent> subIntentList = new ArrayList<>(); - List<Context> contextList = originIntent.getIntentContexts(); - + //form db + // List<Context> contextList = originIntent.getIntentContexts(); + Intent dbIntent = intentService.getIntent(originIntent.getIntentId()); + List<Context> contextList = dbIntent.getIntentContexts(); for (Context context : contextList) { if (context.getContextName().contains("subIntent info")){ List<Condition> conditionList = context.getContextConditions(); @@ -133,7 +152,6 @@ public class IntentContextService { } } } - return subIntentList; } 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 040ced3..27ae97c 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 @@ -20,6 +20,7 @@ import org.apache.commons.collections.CollectionUtils; import org.onap.usecaseui.intentanalysis.bean.models.*; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.util.CommonUtil; +import org.springframework.beans.BeanUtils; import java.util.ArrayList; import java.util.Collections; @@ -33,11 +34,20 @@ public abstract class DecisionModule { public abstract IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean); public Intent intentDefinition(Intent originIntent, Intent intent) { - intent.setIntentId(CommonUtil.getUUid()); + Intent newIntent = new Intent(); + newIntent.setIntentId(CommonUtil.getUUid()); + newIntent.setIntentName(intent.getIntentName()); + List<Expectation> originalExpectationList = intent.getIntentExpectations(); - List<Expectation> newExpectationList = getNewExpectationList(originalExpectationList); - intent.setIntentExpectations(newExpectationList); - return intent; + List<Expectation> newExpectationList = new ArrayList<>(); + for (Expectation exp:originalExpectationList) { + Expectation expectation = new Expectation(); + BeanUtils.copyProperties(exp,expectation); + newExpectationList.add(expectation); + } + List<Expectation> newIdExpectationList = getNewExpectationList(newExpectationList); + newIntent.setIntentExpectations(newIdExpectationList); + return newIntent; } public abstract void decideSuitableAction(); @@ -69,30 +79,39 @@ public abstract class DecisionModule { expectation.setExpectationObject(newExpectationObject); //ExpectationTarget List<ExpectationTarget> expectationTargets = expectation.getExpectationTargets(); + List<ExpectationTarget> newExpTargetList = new ArrayList<>(); if (CollectionUtils.isNotEmpty(expectationTargets)) { for (ExpectationTarget expectationTarget : expectationTargets) { - expectationTarget.setTargetId(CommonUtil.getUUid()); + ExpectationTarget expTarget =new ExpectationTarget(); + BeanUtils.copyProperties(expectationTarget,expTarget); + expTarget.setTargetId(CommonUtil.getUUid()); //targetContexts List<Context> targetContexts = expectationTarget.getTargetContexts(); if (CollectionUtils.isNotEmpty(targetContexts)) { List<Context> newTargetContexts = new ArrayList<>(); for (Context context : targetContexts) { - Context newContext = getNewContext(context); + Context con=new Context(); + BeanUtils.copyProperties(context,con); + Context newContext = getNewContext(con); newTargetContexts.add(newContext); } - expectationTarget.setTargetContexts(newTargetContexts); + expTarget.setTargetContexts(newTargetContexts); } //targetConditions List<Condition> targetConditions = expectationTarget.getTargetConditions(); if (CollectionUtils.isNotEmpty(targetConditions)) { List<Condition> newTargetConditions = new ArrayList<>(); for (Condition condition : targetConditions) { - Condition newCondition = getNewCondition(condition); + Condition con =new Condition(); + BeanUtils.copyProperties(condition,con); + Condition newCondition = getNewCondition(con); newTargetConditions.add(newCondition); } - expectationTarget.setTargetConditions(newTargetConditions); + expTarget.setTargetConditions(newTargetConditions); } + newExpTargetList.add(expTarget); } + expectation.setExpectationTargets(newExpTargetList); } //expectationContexts List<Context> expectationContexts = expectation.getExpectationContexts(); @@ -144,7 +163,9 @@ public abstract class DecisionModule { if (CollectionUtils.isNotEmpty(contextConditions)) { List<Condition> newConditionList = new ArrayList<>(); for (Condition condition : contextConditions) { - newConditionList.add(getNewCondition(condition)); + Condition con =new Condition(); + BeanUtils.copyProperties(condition,con); + newConditionList.add(getNewCondition(con)); } context.setContextConditions(newConditionList); } 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 ef66c83..4cf00f3 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 @@ -23,6 +23,7 @@ import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunct import org.onap.usecaseui.intentanalysis.intentBaseService.contextService.IntentContextService; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; +import org.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -36,6 +37,8 @@ public class IntentDefinitionService { @Autowired public IntentContextService intentContextService; + @Autowired + public IntentService intentService; public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { if (intentOwner != null) { @@ -46,7 +49,7 @@ public class IntentDefinitionService { } } - public void definitionPorcess(Intent originIntent, Map.Entry<IntentGoalBean, IntentManagementFunction> entry) { + public IntentGoalBean definitionPorcess(Intent originIntent, Map.Entry<IntentGoalBean, IntentManagementFunction> entry) { DecisionModule intentDecisionModule = intentOwner.getDecisionModule(); ActuationModule intentActuationModule = intentOwner.getActuationModule(); @@ -57,15 +60,15 @@ public class IntentDefinitionService { intentContextService.updateParentIntentContext(originIntent, newIdIntent); intentContextService.updateChindIntentContext(originIntent, newIdIntent); intentActuationModule.saveIntentToDb(newIdIntent);//id type + return new IntentGoalBean(newIdIntent,IntentGoalType.CREATE); } if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.UPDATE){ intentActuationModule.updateIntentToDb(newIntentGoalBean.getIntent()); } - if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.DELETE){ intentActuationModule.deleteIntentToDb(newIntentGoalBean.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 4dfc492..49f6d13 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 @@ -59,7 +59,7 @@ public class IntentProcessService { intentDetectionService.setIntentRole(intentOwner, intentHandler); IntentGoalBean newIntentGoalBean = intentDetectionService.detectionProcess(originIntentGoalBean); - //investigation process + //investigation process Decomposition intentInvestigationService.setIntentRole(intentOwner, intentHandler); LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = intentInvestigationService.investigationProcess(newIntentGoalBean); @@ -68,19 +68,17 @@ public class IntentProcessService { while (iterator.hasNext()) { Map.Entry<IntentGoalBean, IntentManagementFunction> next = iterator.next(); //definition process save subintent - intentDefinitionService.setIntentRole(intentOwner, intentHandler); - intentDefinitionService.definitionPorcess(originIntentGoalBean.getIntent(), next); + intentDefinitionService.setIntentRole(intentOwner, next.getValue()); + //obtain newID IntentGoalBean + IntentGoalBean newIdIntentGoalBean = intentDefinitionService.definitionPorcess(originIntentGoalBean.getIntent(), next); //distribution process intentDistributionService.setIntentRole(intentOwner, intentHandler); intentDistributionService.distributionProcess(next); intentOperationService.setIntentRole(intentOwner, next.getValue()); - intentOperationService.operationProcess(originIntentGoalBean.getIntent(), next.getKey()); + intentOperationService.operationProcess(originIntentGoalBean.getIntent(), newIdIntentGoalBean); } - return newIntentGoalBean; } - - } diff --git a/intentanalysis/src/main/resources/intent-analysis-data.sql b/intentanalysis/src/main/resources/intent-analysis-data.sql index c03f305..16c3739 100644 --- a/intentanalysis/src/main/resources/intent-analysis-data.sql +++ b/intentanalysis/src/main/resources/intent-analysis-data.sql @@ -1,6 +1,8 @@ -- ---------------------------- -- Records of intent_management_function_reg_info -- ---------------------------- -INSERT INTO intent_management_function_reg_info(imfr_info_id, imfr_info_description, support_area, support_model, support_interfaces, handle_name, intent_function_type) VALUES ('CLLBusinessId','CLLBusiness','CLLBUSINESS',null,'CREATE,DELETE,UPDATE,SEARCH','CLLBusinessIntentManagementFunction','INTERNALFUNCTION'); -INSERT INTO intent_management_function_reg_info(imfr_info_id, imfr_info_description, support_area, support_model, support_interfaces, handle_name, intent_function_type) VALUES ('CLLDeliveryId','CLLDelivery','CLLBUSINESS,DELIVERY',null,'CREATE,DELETE,UPDATE,SEARCH','CLLDeliveryIntentManagementFunction','INTERNALFUNCTION'); -INSERT INTO intent_management_function_reg_info(imfr_info_id, imfr_info_description, support_area, support_model, support_interfaces, handle_name, intent_function_type) VALUES ('CLLAssuranceId','CLLAssurance','CLLBUSINESS,ASSURANCE',null,'CREATE,DELETE,UPDATE,SEARCH','CLLAssuranceIntentManagementFunction','INTERNALFUNCTION'); + +insert into intent_management_function_reg_info(imfr_info_id, imfr_info_description, support_area, support_model, support_interfaces, handle_name, intent_function_type) select 'CLLBusinessId','CLLBusiness','CLLBUSINESS',null,'CREATE,DELETE,UPDATE,SEARCH','CLLBusinessIntentManagementFunction','INTERNALFUNCTION' where not exists(select * from intent_management_function_reg_info where imfr_info_id='CLLBusinessId' ) +insert into intent_management_function_reg_info(imfr_info_id, imfr_info_description, support_area, support_model, support_interfaces, handle_name, intent_function_type) select 'CLLDeliveryId','CLLDelivery','CLLBUSINESS,DELIVERY',null,'CREATE,DELETE,UPDATE,SEARCH','CLLDeliveryIntentManagementFunction','INTERNALFUNCTION' where not exists(select * from intent_management_function_reg_info where imfr_info_id='CLLDeliveryId' ) +insert into intent_management_function_reg_info(imfr_info_id, imfr_info_description, support_area, support_model, support_interfaces, handle_name, intent_function_type) select 'CLLAssuranceId','CLLAssurance','CLLBUSINESS,ASSURANCE',null,'CREATE,DELETE,UPDATE,SEARCH','CLLAssuranceIntentManagementFunction','INTERNALFUNCTION' where not exists(select * from intent_management_function_reg_info where imfr_info_id='CLLAssuranceId' ) + |