From f80da8c8ae6c38ae5fbb2b20498133c68c2ed761 Mon Sep 17 00:00:00 2001 From: hekeguang Date: Sat, 29 Oct 2022 18:24:38 +0800 Subject: Bugfix for intent analysis server update and delete function. Issue-ID: USECASEUI-749 Change-Id: I6aa749924fdbd3b38cb60ea3e3a5ea7fbc6b458b Signed-off-by: hekeguang --- .../CLLDeliveryActuationModule.java | 9 ++--- .../FormatIntentInputActuationModule.java | 34 ------------------ .../FormatIntentInputDecisionModule.java | 2 +- .../contextService/IntentContextService.java | 34 +++++++++++++----- .../intentModule/DecisionModule.java | 41 ++++++++++++++++------ .../IntentDefinitionService.java | 9 +++-- .../intentProcessService/IntentProcessService.java | 12 +++---- .../src/main/resources/intent-analysis-data.sql | 8 +++-- 8 files changed, 79 insertions(+), 70 deletions(-) (limited to 'intentanalysis/src') 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 deliveryIntentExpectationList = intentGoalBean.getIntent().getIntentExpectations(); List 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 intentContexts = intent.getIntentContexts(); - if (CollectionUtils.isEmpty(intentContexts)) { - intentContexts = new ArrayList<>(); - } - Context ownerInfoCon = new Context(); - ownerInfoCon.setContextId(CommonUtil.getUUid()); - ownerInfoCon.setContextName("ownerInfo"); - List 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 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 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 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 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 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 getSubIntentInfoFromContext(Intent originIntent){ - List subIntentList = new ArrayList<>(); - List contextList = originIntent.getIntentContexts(); - + //form db + // List contextList = originIntent.getIntentContexts(); + Intent dbIntent = intentService.getIntent(originIntent.getIntentId()); + List contextList = dbIntent.getIntentContexts(); for (Context context : contextList) { if (context.getContextName().contains("subIntent info")){ List 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 originalExpectationList = intent.getIntentExpectations(); - List newExpectationList = getNewExpectationList(originalExpectationList); - intent.setIntentExpectations(newExpectationList); - return intent; + List newExpectationList = new ArrayList<>(); + for (Expectation exp:originalExpectationList) { + Expectation expectation = new Expectation(); + BeanUtils.copyProperties(exp,expectation); + newExpectationList.add(expectation); + } + List 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 expectationTargets = expectation.getExpectationTargets(); + List 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 targetContexts = expectationTarget.getTargetContexts(); if (CollectionUtils.isNotEmpty(targetContexts)) { List 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 targetConditions = expectationTarget.getTargetConditions(); if (CollectionUtils.isNotEmpty(targetConditions)) { List 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 expectationContexts = expectation.getExpectationContexts(); @@ -144,7 +163,9 @@ public abstract class DecisionModule { if (CollectionUtils.isNotEmpty(contextConditions)) { List 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 entry) { + public IntentGoalBean definitionPorcess(Intent originIntent, Map.Entry 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 intentMap = intentInvestigationService.investigationProcess(newIntentGoalBean); @@ -68,19 +68,17 @@ public class IntentProcessService { while (iterator.hasNext()) { Map.Entry 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' ) + -- cgit 1.2.3-korg