diff options
author | hekeguang <hekeguang@chinamobile.com> | 2022-10-20 16:55:53 +0800 |
---|---|---|
committer | hekeguang <hekeguang@chinamobile.com> | 2022-10-20 16:56:22 +0800 |
commit | 8a2a118322360203bf25769c1566a2c07c0b85ad (patch) | |
tree | 88141b5bd93002ff35ef0479226d63e887812018 /intentanalysis/src/main | |
parent | 64b84cc8b0f77b7100ef992aa55abaad4a1f5077 (diff) |
Add modify and delete code.
Issue-ID: USECASEUI-696
Change-Id: If0fde6cccc74fdb9d0d10a8c2d5675a51f6a8a72
Signed-off-by: hekeguang <hekeguang@chinamobile.com>
Diffstat (limited to 'intentanalysis/src/main')
17 files changed, 442 insertions, 74 deletions
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 1cc6930..3cbffcb 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,6 +20,8 @@ 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 org.onap.usecaseui.intentanalysis.bean.models.Expectation; +import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject; import org.onap.usecaseui.intentanalysis.bean.models.Intent; import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; @@ -45,9 +47,9 @@ public class CLLBusinessActuationModule extends ActuationModule { @Override - public void toNextIntentHandler(Intent intent, IntentManagementFunction IntentHandler) { + public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) { processService.setIntentRole(IntentHandler, null); - processService.intentProcess(intent); + processService.intentProcess(intentGoalBean); } @Override @@ -62,7 +64,7 @@ public class CLLBusinessActuationModule extends ActuationModule { @Override public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) { - toNextIntentHandler(intentGoalBean.getIntent(),intentHandler); + toNextIntentHandler(intentGoalBean, intentHandler); } @Override @@ -89,4 +91,9 @@ public class CLLBusinessActuationModule extends ActuationModule { intent.setIntentContexts(intentContexts); intentService.createIntent(intent); } + + @Override + public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){ + + } } 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 3e4a53c..f073cc2 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 @@ -24,6 +24,7 @@ import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType; import org.onap.usecaseui.intentanalysis.bean.models.*; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.contextService.IntentContextService; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService; import org.onap.usecaseui.intentanalysis.service.IntentService; @@ -46,6 +47,9 @@ public class CLLBusinessDecisionModule extends DecisionModule { @Autowired IntentService intentService; + @Autowired + IntentContextService intentContextService; + @Override public void determineUltimateGoal() { } @@ -129,7 +133,7 @@ public class CLLBusinessDecisionModule extends DecisionModule { } @Override - public LinkedHashMap<IntentGoalBean, IntentManagementFunction> findHandler(IntentGoalBean intentGoalBean) { + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationCreateProcess(IntentGoalBean intentGoalBean) { boolean needDecompostion = needDecompostion(intentGoalBean); LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>(); if (needDecompostion) { @@ -145,27 +149,47 @@ public class CLLBusinessDecisionModule extends DecisionModule { return intentMap; } - @Override - public void updateIntentInfo(Intent originIntent, IntentGoalBean intentGoalBean){ - Intent subIntent = intentGoalBean.getIntent(); - if (subIntent.getIntentName().contains("delivery")){ - List<Expectation> deliveryIntentExpectationList = intentGoalBean.getIntent().getIntentExpectations(); - List<Expectation> originIntentExpectationList = originIntent.getIntentExpectations(); - ExpectationObject deliveryExpectationObject = deliveryIntentExpectationList.get(0).getExpectationObject(); - String objectInstance = deliveryExpectationObject.getObjectInstance(); + @Override + //format is + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationUpdateProcess(IntentGoalBean intentGoalBean) { + //get cll-delivery cll-assurance intent + Intent originIntent = intentGoalBean.getIntent(); + List<Expectation> originIntentExpectationList = originIntent.getIntentExpectations(); + LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>(); + List<Intent> subIntentList = intentContextService.getSubIntentInfoFromContext(intentGoalBean.getIntent()); + for (Intent intent : subIntentList) { + IntentManagementFunction intentHandlerInfo = intentContextService.getHandlerInfo(intent); + boolean bFindIntent = false; for (Expectation originExpectation : originIntentExpectationList) { - ExpectationObject originExpectationObject = originExpectation.getExpectationObject(); - originExpectationObject.setObjectInstance(objectInstance); + if (intent.getIntentName().equals(originExpectation.getExpectationName())){ + bFindIntent = true; + } + } + + if (false == bFindIntent){ + intentContextService.deleteSubIntentContext(originIntent, intent.getIntentId()); + IntentGoalBean subIntentGoalBean = new IntentGoalBean(intent, IntentGoalType.DELETE); + intentMap.put(subIntentGoalBean, intentHandlerInfo); + }else{ + IntentGoalBean subIntentGoalBean = new IntentGoalBean(intent, IntentGoalType.UPDATE); + intentMap.put(subIntentGoalBean, intentHandlerInfo); } } + return intentMap; } @Override - public void updateIntentWithOriginIntent(Intent originIntent, Intent intent){ - + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationDeleteProcess(IntentGoalBean intentGoalBean) { + LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>(); + List<Intent> subIntentList = intentContextService.getSubIntentInfoFromContext(intentGoalBean.getIntent()); + for (Intent intent : subIntentList) { + IntentManagementFunction intentHandlerInfo = intentContextService.getHandlerInfo(intent); + IntentGoalBean subIntentGoalBean = new IntentGoalBean(intent, IntentGoalType.DELETE); + intentMap.put(subIntentGoalBean, intentHandlerInfo); + } + return intentMap; } - } 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 9e4697f..6a091c5 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 @@ -24,7 +24,7 @@ import org.springframework.stereotype.Component; @Component public class CLLAssuranceActuationModule extends ActuationModule { @Override - public void toNextIntentHandler(Intent intent, IntentManagementFunction IntentHandler) { + public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) { } @@ -42,4 +42,8 @@ public class CLLAssuranceActuationModule extends ActuationModule { public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) { directOperation(); } + + public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){ + + } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceDecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceDecisionModule.java index 3e60bf5..abd10fd 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceDecisionModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceDecisionModule.java @@ -32,11 +32,6 @@ public class CLLAssuranceDecisionModule extends DecisionModule { } @Override - public void updateIntentInfo(Intent originIntent, IntentGoalBean intentGoalBean){ - - } - - @Override public IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean) { return null; } @@ -53,24 +48,17 @@ public class CLLAssuranceDecisionModule extends DecisionModule { } @Override - public LinkedHashMap<IntentGoalBean, IntentManagementFunction> findHandler(IntentGoalBean intentGoalBean) { + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationCreateProcess(IntentGoalBean intentGoalBean) { return null; } @Override - public void updateIntentWithOriginIntent(Intent originIntent, Intent intent){ - List<Expectation> originIntentExpectationList = originIntent.getIntentExpectations(); - - String instanceId = ""; - for (Expectation expectation : originIntentExpectationList) { - if (expectation.getExpectationName().contains("assurance")){ - instanceId = expectation.getExpectationObject().getObjectInstance(); - break; - } - } + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationUpdateProcess(IntentGoalBean intentGoalBean) { + return null; + } - for (Expectation expectation : intent.getIntentExpectations()) { - expectation.getExpectationObject().setObjectInstance(instanceId); - } + @Override + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationDeleteProcess(IntentGoalBean intentGoalBean) { + return null; } } 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 10b8cb7..cca03fe 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,16 +15,24 @@ */ package org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.clldeliverymodule; +import java.util.List; +import org.onap.usecaseui.intentanalysis.bean.models.Expectation; +import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject; 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.intentBaseService.intentModule.ActuationModule; +import org.onap.usecaseui.intentanalysis.service.IntentService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class CLLDeliveryActuationModule extends ActuationModule { + @Autowired + IntentService intentService; + @Override - public void toNextIntentHandler(Intent intent, IntentManagementFunction IntentHandler) { + public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) { } @@ -42,4 +50,23 @@ public class CLLDeliveryActuationModule extends ActuationModule { public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) { this.directOperation(); } + + public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){ + Intent subIntent = intentGoalBean.getIntent(); + if (subIntent.getIntentName().contains("delivery")){ + List<Expectation> deliveryIntentExpectationList = intentGoalBean.getIntent().getIntentExpectations(); + List<Expectation> originIntentExpectationList = originIntent.getIntentExpectations(); + ExpectationObject deliveryExpectationObject = deliveryIntentExpectationList.get(0).getExpectationObject(); + String objectInstance = deliveryExpectationObject.getObjectInstance(); + + for (Expectation originExpectation : originIntentExpectationList) { + ExpectationObject originExpectationObject = originExpectation.getExpectationObject(); + originExpectationObject.setObjectInstance(objectInstance); + } + } + intentService.updateIntent(originIntent); + } + + + } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryDecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryDecisionModule.java index 0ae0867..c18cb16 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryDecisionModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryDecisionModule.java @@ -46,17 +46,17 @@ public class CLLDeliveryDecisionModule extends DecisionModule { } @Override - public LinkedHashMap<IntentGoalBean, IntentManagementFunction> findHandler(IntentGoalBean intentGoalBean) { + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationCreateProcess(IntentGoalBean intentGoalBean) { return null; } @Override - public void updateIntentWithOriginIntent(Intent originIntent, Intent intent){ - + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationUpdateProcess(IntentGoalBean intentGoalBean) { + return null; } @Override - public void updateIntentInfo(Intent originIntent, IntentGoalBean intentGoalBean){ - + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationDeleteProcess(IntentGoalBean intentGoalBean) { + return null; } } 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 b274dfa..6e5c7d4 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 @@ -17,7 +17,10 @@ package org.onap.usecaseui.intentanalysis.controller; +import io.swagger.models.auth.In; +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.formatintentinputMgt.FormatIntentInputManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; import org.onap.usecaseui.intentanalysis.service.IntentService; @@ -56,26 +59,44 @@ public class IntentController { @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Intent> createIntent(@RequestBody Intent intent) { - return ResponseEntity.ok(intentService.createIntent(intent)); + + processService.setIntentRole(formatIntentInputManagementFunction, null); + //save original intent + IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); + IntentGoalBean newIntentGoalBean = processService.intentProcess(intentGoalBean); + return ResponseEntity.ok(intentService.createIntent(newIntentGoalBean.getIntent())); } @PutMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Intent> updateIntentById( @PathVariable(INTENT_ID) String intentId, @RequestBody Intent intent) { - return ResponseEntity.ok(intentService.updateIntent(intent)); + + processService.setIntentRole(formatIntentInputManagementFunction, null); + //save original intent + + IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.UPDATE); + IntentGoalBean newIntentGoalBean = processService.intentProcess(intentGoalBean); + return ResponseEntity.ok(intentService.updateIntent(newIntentGoalBean.getIntent())); } @DeleteMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE) public void removeIntentById(@PathVariable(INTENT_ID) String intentId) { - intentService.deleteIntent(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 - intentService.createIntent(intent); - processService.intentProcess(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 a017b80..8a5dfaf 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 @@ -41,8 +41,9 @@ public class FormatIntentInputActuationModule extends ActuationModule { IntentProcessService processService; @Autowired IntentService intentService; + @Override - public void toNextIntentHandler(Intent intent, IntentManagementFunction IntentHandler) { + public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) { log.info("do nothing"); } @@ -56,7 +57,9 @@ public class FormatIntentInputActuationModule extends ActuationModule { @Override public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) { + } + @Override public void saveIntentToDb(Intent intent){ List<Context> intentContexts = intent.getIntentContexts(); @@ -93,4 +96,8 @@ public class FormatIntentInputActuationModule extends ActuationModule { 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 7a24bf2..ce36d6d 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 @@ -15,13 +15,21 @@ */ package org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule; +import java.util.ArrayList; import org.apache.commons.lang.StringUtils; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; +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.Expectation; import org.onap.usecaseui.intentanalysis.bean.models.Intent; import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.contextService.IntentContextService; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; +import org.onap.usecaseui.intentanalysis.service.IntentService; +import org.onap.usecaseui.intentanalysis.util.CommonUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; @@ -35,6 +43,12 @@ public class FormatIntentInputDecisionModule extends DecisionModule { @Autowired ApplicationContext applicationContext; + @Autowired + public IntentContextService intentContextService; + + @Autowired + public IntentService intentService; + @Override public void determineUltimateGoal() { } @@ -58,7 +72,7 @@ public class FormatIntentInputDecisionModule extends DecisionModule { } @Override - public LinkedHashMap<IntentGoalBean, IntentManagementFunction> findHandler(IntentGoalBean intentGoalBean) { + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationCreateProcess(IntentGoalBean intentGoalBean) { LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>(); boolean needDecompostion = needDecompostion(intentGoalBean); if (needDecompostion) { @@ -89,14 +103,56 @@ public class FormatIntentInputDecisionModule extends DecisionModule { return null; } - @Override - public void updateIntentWithOriginIntent(Intent originIntent, Intent intent){ + //format is + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationUpdateProcess(IntentGoalBean intentGoalBean) { + //get format-cll intent + LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>(); + List<Intent> subIntentList = intentContextService.getSubIntentInfoFromContext(intentGoalBean.getIntent()); + for (Intent intent : subIntentList) { + IntentManagementFunction intentHandlerInfo = intentContextService.getHandlerInfo(intent); + UpdateIntentInfo(intentGoalBean.getIntent(), intent); + IntentGoalBean subIntentGoalBean = new IntentGoalBean(intent, IntentGoalType.UPDATE); + intentMap.put(subIntentGoalBean, intentHandlerInfo); + } + return intentMap; + } + + public void UpdateIntentInfo(Intent originIntent, Intent intent){ + + List<Expectation> originIntentExpectationList = originIntent.getIntentExpectations(); + List<Expectation> intentExpectationList = intent.getIntentExpectations(); + int newIntentExpectationNum = originIntentExpectationList.size(); + int oldIntentExpectationNum = intentExpectationList.size(); + + if (newIntentExpectationNum != oldIntentExpectationNum){ + if (newIntentExpectationNum < oldIntentExpectationNum){ + boolean bFindExpectation = false; + for (Expectation oldExpectation : intentExpectationList) { + for (Expectation newExpectation : originIntentExpectationList) { + if (oldExpectation.getExpectationName().equals(newExpectation.getExpectationName())){ + bFindExpectation = true; + } + } + if (bFindExpectation == false){ + intentExpectationList.remove(oldExpectation); + } + } + } + } } @Override - public void updateIntentInfo(Intent originIntent, IntentGoalBean intentGoalBean){ - + public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationDeleteProcess(IntentGoalBean intentGoalBean) { + LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>(); + List<Intent> subIntentList = intentContextService.getSubIntentInfoFromContext(intentGoalBean.getIntent()); + for (Intent intent : subIntentList) { + IntentManagementFunction intentHandlerInfo = intentContextService.getHandlerInfo(intent); + IntentGoalBean subIntentGoalBean = new IntentGoalBean(intent, IntentGoalType.DELETE); + intentMap.put(subIntentGoalBean, intentHandlerInfo); + } + return intentMap; } + } 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 new file mode 100644 index 0000000..1c0fe5f --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/contextService/IntentContextService.java @@ -0,0 +1,169 @@ +/* + * 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.contextService; + +import java.util.ArrayList; +import java.util.List; +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; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Service; + +@Service +public class IntentContextService { + + @Autowired + private IntentService intentService; + + @Autowired + ApplicationContext applicationContext; + + public void updateChindIntentContext(Intent originIntent, Intent intent){ + List<Context> contextList = intent.getIntentContexts(); + + Condition condition1 = new Condition(); + condition1.setConditionId(CommonUtil.getUUid()); + condition1.setConditionName(originIntent.getIntentName() + "id"); + condition1.setOperator(OperatorType.EQUALTO); + condition1.setConditionValue(originIntent.getIntentId()); + + Context context = new Context(); + context.setContextName("parentIntent info"); + context.setContextId(CommonUtil.getUUid()); + List<Condition> conditionList = new ArrayList<>(); + conditionList.add(condition1); + context.setContextConditions(conditionList); + contextList.add(context); + } + + public void updateParentIntentContext(Intent originIntent, Intent intent){ + List<Context> contextList = originIntent.getIntentContexts(); + + Condition condition1 = new Condition(); + condition1.setConditionId(CommonUtil.getUUid()); + condition1.setConditionName(intent.getIntentName() + "id"); + condition1.setOperator(OperatorType.EQUALTO); + condition1.setConditionValue(intent.getIntentId()); + + boolean isSubIntentInfoExist = false; + for (Context context : contextList) { + if (context.getContextName().contains("subIntent info")){ + List<Condition> conditionList = context.getContextConditions(); + conditionList.add(condition1); + isSubIntentInfoExist = true; + } + } + + if (isSubIntentInfoExist != true){ + Context context = new Context(); + context.setContextName("subIntent info"); + context.setContextId(CommonUtil.getUUid()); + List<Condition> conditionList = new ArrayList<>(); + conditionList.add(condition1); + context.setContextConditions(conditionList); + contextList.add(context); + + } + } + + public void updateIntentOwnerHandlerContext(Intent intent, IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){ + List<Context> contextList = intent.getIntentContexts(); + + Condition condition1 = new Condition(); + condition1.setConditionId(CommonUtil.getUUid()); + condition1.setConditionName("owner class name"); + condition1.setOperator(OperatorType.EQUALTO); + condition1.setConditionValue(intentOwner.getClass().getName()); + + Context context = new Context(); + context.setContextName("owner info"); + context.setContextId(CommonUtil.getUUid()); + List<Condition> conditionList = new ArrayList<>(); + conditionList.add(condition1); + context.setContextConditions(conditionList); + contextList.add(context); + + Condition condition2 = new Condition(); + condition2.setConditionId(CommonUtil.getUUid()); + condition2.setConditionName("handler class name"); + condition2.setOperator(OperatorType.EQUALTO); + condition2.setConditionValue(intentHandler.getClass().getName()); + + Context context2 = new Context(); + context2.setContextName("handler info"); + context2.setContextId(CommonUtil.getUUid()); + List<Condition> conditionList2 = new ArrayList<>(); + conditionList2.add(condition2); + context2.setContextConditions(conditionList2); + contextList.add(context2); + } + + public List<Intent> getSubIntentInfoFromContext(Intent originIntent){ + + List<Intent> subIntentList = new ArrayList<>(); + List<Context> contextList = originIntent.getIntentContexts(); + + for (Context context : contextList) { + if (context.getContextName().contains("subIntent info")){ + List<Condition> conditionList = context.getContextConditions(); + for (Condition condition : conditionList) { + String subIntentId = condition.getConditionValue(); + Intent subInent = intentService.getIntent(subIntentId); + subIntentList.add(subInent); + } + } + } + + return subIntentList; + } + + public IntentManagementFunction getHandlerInfo(Intent intent){ + List<Context> contextList = intent.getIntentContexts(); + IntentManagementFunction handler = new IntentManagementFunction(); + + for (Context context : contextList) { + if (context.getContextName().contains("handler info")) { + List<Condition> conditionList = context.getContextConditions(); + String handlerClassName = conditionList.get(0).getConditionValue(); + handler = (IntentManagementFunction) applicationContext + .getBean(CLLBusinessIntentManagementFunction.class.getSimpleName()); + } + } + return handler; + } + + public void deleteSubIntentContext(Intent intent, String deleteIntentId){ + List<Context> contextList = intent.getIntentContexts(); + for (Context context : contextList) { + if (context.getContextName().contains("subIntent info")) { + List<Condition> conditionList = context.getContextConditions(); + for (Condition condition : conditionList) { + if (condition.getConditionValue() == deleteIntentId){ + conditionList.remove(condition); + } + } + } + } + } + +} 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 90256eb..84c391e 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 @@ -33,7 +33,7 @@ public abstract class ActuationModule { IntentService intentService; //send to the next level intent handler - public abstract void toNextIntentHandler(Intent intent, IntentManagementFunction IntentHandler); + public abstract void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler); //Direct operation public abstract void directOperation(); @@ -45,6 +45,16 @@ public abstract class ActuationModule { intentService.createIntent(intent); } + //Update intent information to the intent instance database + public void updateIntentToDb(Intent intent) { + intentService.updateIntent(intent); + } + + //Delete intent information to the intent instance database + public void deleteIntentToDb(Intent intent) { + intentService.deleteIntent(intent.getIntentId()); + } + public boolean distrubuteIntentToHandler(Map.Entry<IntentGoalBean, IntentManagementFunction> entry) { IntentGoalType intentGoalType = entry.getKey().getIntentGoalType(); if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) { @@ -59,4 +69,6 @@ public abstract class ActuationModule { //determine if the intent is to be processed directly or sent to the next-level processor public abstract void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler); + + public abstract void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean); } 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 a8beef3..040ced3 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 @@ -37,20 +37,18 @@ public abstract class DecisionModule { List<Expectation> originalExpectationList = intent.getIntentExpectations(); List<Expectation> newExpectationList = getNewExpectationList(originalExpectationList); intent.setIntentExpectations(newExpectationList); - updateIntentWithOriginIntent(originIntent, intent); return intent; } - public abstract void updateIntentWithOriginIntent(Intent originIntent, Intent intent); - public abstract void decideSuitableAction(); public abstract void interactWithTemplateDb(); - public abstract void updateIntentInfo(Intent originIntent, IntentGoalBean intentGoalBean); + public abstract LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationCreateProcess(IntentGoalBean intentGoalBean); + public abstract LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationUpdateProcess(IntentGoalBean intentGoalBean); - public abstract LinkedHashMap<IntentGoalBean, IntentManagementFunction> findHandler(IntentGoalBean intentGoalBean); + public abstract LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationDeleteProcess(IntentGoalBean intentGoalBean); /** * build new Intent with uuid @@ -152,4 +150,6 @@ public abstract class DecisionModule { } return context; } + + } 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 d2fc54f..ef66c83 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 @@ -16,11 +16,14 @@ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; +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.intentBaseService.contextService.IntentContextService; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; @@ -31,6 +34,9 @@ public class IntentDefinitionService { private IntentManagementFunction intentHandler; private IntentManagementFunction intentOwner; + @Autowired + public IntentContextService intentContextService; + public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { if (intentOwner != null) { this.intentOwner = intentOwner; @@ -43,7 +49,23 @@ public class IntentDefinitionService { public void definitionPorcess(Intent originIntent, Map.Entry<IntentGoalBean, IntentManagementFunction> entry) { DecisionModule intentDecisionModule = intentOwner.getDecisionModule(); ActuationModule intentActuationModule = intentOwner.getActuationModule(); - Intent newIdIntent = intentDecisionModule.intentDefinition(originIntent, entry.getKey().getIntent()); - intentActuationModule.saveIntentToDb(newIdIntent);//id type + + IntentGoalBean newIntentGoalBean = entry.getKey(); + if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.CREATE){ + Intent newIdIntent = intentDecisionModule.intentDefinition(originIntent, entry.getKey().getIntent()); + intentContextService.updateIntentOwnerHandlerContext(newIdIntent, intentOwner, intentHandler); + intentContextService.updateParentIntentContext(originIntent, newIdIntent); + intentContextService.updateChindIntentContext(originIntent, newIdIntent); + intentActuationModule.saveIntentToDb(newIdIntent);//id type + } + + if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.UPDATE){ + intentActuationModule.updateIntentToDb(newIntentGoalBean.getIntent()); + } + + if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.DELETE){ + intentActuationModule.deleteIntentToDb(newIntentGoalBean.getIntent()); + } + } } 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 60c4f74..37a1819 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 @@ -15,6 +15,7 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; +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; @@ -36,9 +37,18 @@ public class IntentDetectionService { } } - public IntentGoalBean detectionProcess(Intent intent) { + public IntentGoalBean detectionProcess(IntentGoalBean originIntentGoalBean) { KnowledgeModule ownerKnowledgeModule = intentOwner.getKnowledgeModule(); - return ownerKnowledgeModule.intentCognition(intent); + if (originIntentGoalBean.getIntentGoalType() == IntentGoalType.UPDATE){ + return new IntentGoalBean(originIntentGoalBean.getIntent(), IntentGoalType.UPDATE); + } + + if (originIntentGoalBean.getIntentGoalType() == IntentGoalType.DELETE){ + return new IntentGoalBean(originIntentGoalBean.getIntent(), IntentGoalType.DELETE); + } + + return ownerKnowledgeModule.intentCognition(originIntentGoalBean.getIntent()); + } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java index ac4612f..891f7b3 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java @@ -15,30 +15,45 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; +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.intentBaseService.contextService.IntentContextService; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; @Service public class IntentInvestigationService { + + @Autowired + IntentContextService intentContextService; + private IntentManagementFunction intentHandler; private IntentManagementFunction intentOwner; public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){ - if (intentOwner!= null){ + if (intentOwner != null){ this.intentOwner = intentOwner; } - if (intentHandler!= null){ + if (intentHandler != null){ this.intentHandler= intentHandler; } } - public LinkedHashMap<IntentGoalBean,IntentManagementFunction> investigationProcess(IntentGoalBean intentGoalBean) { + public LinkedHashMap<IntentGoalBean,IntentManagementFunction> investigationProcess(IntentGoalBean intentGoalBean) { DecisionModule intentDecisionModule = intentOwner.getDecisionModule(); - return intentDecisionModule.findHandler(intentGoalBean); + + if (intentGoalBean.getIntentGoalType() == IntentGoalType.UPDATE){ + return intentDecisionModule.investigationUpdateProcess(intentGoalBean); + } + + if (intentGoalBean.getIntentGoalType() == IntentGoalType.DELETE){ + return intentDecisionModule.investigationDeleteProcess(intentGoalBean); + } + return intentDecisionModule.investigationCreateProcess(intentGoalBean); } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentOperationService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentOperationService.java index 575ca55..924508a 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentOperationService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentOperationService.java @@ -48,6 +48,6 @@ public class IntentOperationService { intentActuationModule.fulfillIntent(intentGoalBean, intentHandler); //update origin intent if need - intentDecisionModule.updateIntentInfo(originIntent, intentGoalBean); + intentActuationModule.updateIntentOperationInfo(originIntent, intentGoalBean); } } 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 8b50a47..5c447d9 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,6 +15,7 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; +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; @@ -53,29 +54,34 @@ public class IntentProcessService { } } - public void intentProcess(Intent intent) { + public IntentGoalBean intentProcess(IntentGoalBean originIntentGoalBean) { + intentDetectionService.setIntentRole(intentOwner, intentHandler); - IntentGoalBean intentGoalBean = intentDetectionService.detectionProcess(intent); + IntentGoalBean newIntentGoalBean = intentDetectionService.detectionProcess(originIntentGoalBean); + //如果是update,直接在investigationProcess获得intent中定义的handler的信息,然后一个update 或者两个update //investigation process intentInvestigationService.setIntentRole(intentOwner, intentHandler); LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = - intentInvestigationService.investigationProcess(intentGoalBean); + intentInvestigationService.investigationProcess(newIntentGoalBean); Iterator<Map.Entry<IntentGoalBean, IntentManagementFunction>> iterator = intentMap.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<IntentGoalBean, IntentManagementFunction> next = iterator.next(); //definition process save subintent intentDefinitionService.setIntentRole(intentOwner, intentHandler); - intentDefinitionService.definitionPorcess(intent, next); + intentDefinitionService.definitionPorcess(originIntentGoalBean.getIntent(), next); //distribution process intentDistributionService.setIntentRole(intentOwner, intentHandler); intentDistributionService.distributionProcess(next); intentOperationService.setIntentRole(intentOwner, next.getValue()); - intentOperationService.operationProcess(intent, next.getKey()); + intentOperationService.operationProcess(originIntentGoalBean.getIntent(), next.getKey()); } + + return newIntentGoalBean; } + } |