aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhekeguang <hekeguang@chinamobile.com>2022-10-08 10:10:04 +0800
committerhekeguang <hekeguang@chinamobile.com>2022-10-08 10:10:22 +0800
commit337b5ae680d3a1a37eba96b05a860f95dada7fe4 (patch)
treec449bf62602a483439ad563c1cb08a3a40107643
parentcaa0bcfe1e08d0ed1e795255e3708b7bedfdfa9f (diff)
Modify intent definition code.
Issue-ID: USECASEUI-696 Change-Id: I4b63fa0820405699e74765612fbb33b3ea1293ad Signed-off-by: hekeguang <hekeguang@chinamobile.com>
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ObjectType.java5
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessActuationModule.java33
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java15
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceDecisionModule.java4
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryDecisionModule.java4
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java12
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputActuationModule.java15
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java7
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java120
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java21
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java5
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationServiceTest.java2
-rw-r--r--intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/IntentServiceTest.java2
13 files changed, 201 insertions, 44 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ObjectType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ObjectType.java
index d636856..47a2c1a 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ObjectType.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ObjectType.java
@@ -16,12 +16,11 @@
package org.onap.usecaseui.intentanalysis.bean.enums;
import lombok.Getter;
-import lombok.Setter;
@Getter
public enum ObjectType {
- SLICING(0, "objectType1"),
- CCVPN(1, "objectType2");
+ SLICING(0, "slicing"),
+ CCVPN(1, "ccvpn");
private int index;
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 d6d72a6..1cc6930 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
@@ -16,6 +16,10 @@
package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule;
+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.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
@@ -23,9 +27,13 @@ import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.Actuatio
import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
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;
+
@Component
public class CLLBusinessActuationModule extends ActuationModule {
@Autowired
@@ -56,4 +64,29 @@ public class CLLBusinessActuationModule extends ActuationModule {
public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) {
toNextIntentHandler(intentGoalBean.getIntent(),intentHandler);
}
+
+ @Override
+ public void saveIntentToDb(Intent intent){ //ownerid parent intent id
+ List<Context> intentContexts = intent.getIntentContexts();
+ if (CollectionUtils.isEmpty(intentContexts)) {
+ intentContexts = new ArrayList<>();
+ }
+ //ownerId intentId="" show relatioship beteween intent
+ Context ownerIdContext = new Context();
+ ownerIdContext.setContextId(CommonUtil.getUUid());
+ ownerIdContext.setContextName("ownerId");
+ List<Condition> idConditionList = new ArrayList<>();
+ Condition idCondition = new Condition();
+ idCondition.setConditionValue(intent.getIntentId());
+ idCondition.setOperator(OperatorType.EQUALTO);
+ idCondition.setConditionName("intentId");
+ idCondition.setConditionId(CommonUtil.getUUid());
+
+ idConditionList.add(idCondition);
+ ownerIdContext.setContextConditions(idConditionList);
+
+ intentContexts.add(ownerIdContext);
+ intent.setIntentContexts(intentContexts);
+ intentService.createIntent(intent);
+ }
}
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 2a324e3..722fce9 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
@@ -17,14 +17,12 @@ package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule
import lombok.extern.log4j.Log4j2;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
-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.bean.models.IntentManagementFunctionRegInfo;
+import org.onap.usecaseui.intentanalysis.bean.models.*;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService;
@@ -56,9 +54,6 @@ public class CLLBusinessDecisionModule extends DecisionModule {
return (IntentManagementFunction) applicationContext.getBean(imfRegInfo.getHandleName());
}
- @Override
- public void intentDefinition() {
- }
@Override
public void decideSuitableAction() {
@@ -97,9 +92,10 @@ public class CLLBusinessDecisionModule extends DecisionModule {
for (Map.Entry<ObjectType, List<Expectation>> objEntry : objTypeMap.entrySet()) {
IntentGoalBean subIntentGoalBean = new IntentGoalBean();
Intent subIntent = new Intent();
- subIntent.setIntentId(CommonUtil.getUUid());
subIntent.setIntentName(objEntry.getValue().get(0).getExpectationName().replace("Expectation", "Intent"));
subIntent.setIntentExpectations(objEntry.getValue());
+ //List<Expectation> newExpectationList = getNewExpectationList(objEntry.getValue());
+ //subIntent.setIntentExpectations(newExpectationList);
//TODO intentFulfilmentInfo intentContexts
subIntentGoalBean.setIntentGoalType(intentGoalType);
subIntentGoalBean.setIntent(subIntent);
@@ -117,7 +113,7 @@ public class CLLBusinessDecisionModule extends DecisionModule {
StringUtils.containsIgnoreCase(x.getIntent().getIntentName(), "assurance")).collect(Collectors.toList());
List<IntentGoalBean> otherGoalList = subIntentGoalList.stream().filter(x ->
!StringUtils.containsIgnoreCase(x.getIntent().getIntentName(), "delivery")
- && !StringUtils.containsIgnoreCase(x.getIntent().getIntentName(), "assurance")).collect(Collectors.toList());
+ && !StringUtils.containsIgnoreCase(x.getIntent().getIntentName(), "assurance")).collect(Collectors.toList());
sortList.addAll(deliveryGoalList);
sortList.addAll(assuranceGoalList);
sortList.addAll(otherGoalList);
@@ -145,4 +141,5 @@ public class CLLBusinessDecisionModule extends DecisionModule {
return intentMap;
}
+
}
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 2054484..b2bf018 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
@@ -33,10 +33,6 @@ public class CLLAssuranceDecisionModule extends DecisionModule {
return null;
}
- @Override
- public void intentDefinition() {
-
- }
@Override
public void decideSuitableAction() {
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 e73aab4..62d7d4c 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
@@ -33,10 +33,6 @@ public class CLLDeliveryDecisionModule extends DecisionModule {
return null;
}
- @Override
- public void intentDefinition() {
-
- }
@Override
public void decideSuitableAction() {
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 41d2d2a..b274dfa 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,16 +17,16 @@
package org.onap.usecaseui.intentanalysis.controller;
-import java.util.List;
-
+import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService;
+import org.onap.usecaseui.intentanalysis.service.IntentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
-import org.onap.usecaseui.intentanalysis.bean.models.Intent;
-import org.onap.usecaseui.intentanalysis.service.IntentService;
+
+import java.util.List;
@RestController
@@ -71,9 +71,11 @@ public class IntentController {
intentService.deleteIntent(intentId);
}
- @PostMapping(value="/handleIntent",produces = MediaType.APPLICATION_JSON_VALUE)
+ @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);
}
}
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 230fcb8..a017b80 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
@@ -17,7 +17,6 @@ package org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinput
import lombok.extern.log4j.Log4j2;
import org.apache.commons.collections.CollectionUtils;
-import org.checkerframework.checker.units.qual.A;
import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType;
import org.onap.usecaseui.intentanalysis.bean.models.Condition;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
@@ -76,6 +75,20 @@ public class FormatIntentInputActuationModule extends ActuationModule {
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);
}
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 507ada8..dddadc6 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
@@ -25,7 +25,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
-import java.util.*;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
import java.util.stream.Collectors;
@Component
public class FormatIntentInputDecisionModule extends DecisionModule {
@@ -45,9 +47,6 @@ public class FormatIntentInputDecisionModule extends DecisionModule {
return null;
}
- @Override
- public void intentDefinition() {
- }
@Override
public void decideSuitableAction() {
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 52dab8e..7701acc 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
@@ -16,10 +16,15 @@
package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule;
-import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
+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 java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashMap;
+import java.util.List;
public abstract class DecisionModule {
public abstract void determineUltimateGoal();
@@ -27,12 +32,119 @@ public abstract class DecisionModule {
// find intentManageFunction
public abstract IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean);
- public abstract void intentDefinition();
+ public Intent intentDefinition(Intent intent) {
+ intent.setIntentId(CommonUtil.getUUid());
+ List<Expectation> originalExpectationList = intent.getIntentExpectations();
+ List<Expectation> newExpectationList = getNewExpectationList(originalExpectationList);
+ intent.setIntentExpectations(newExpectationList);
+ return intent;
+ }
public abstract void decideSuitableAction();
- public abstract void interactWithTemplateDb();
+ public abstract void interactWithTemplateDb();
- public abstract LinkedHashMap<IntentGoalBean,IntentManagementFunction> findHandler(IntentGoalBean intentGoalBean);
+ public abstract LinkedHashMap<IntentGoalBean, IntentManagementFunction> findHandler(IntentGoalBean intentGoalBean);
+
+ /**
+ * build new Intent with uuid
+ *
+ * @param originalExpectationList
+ * @return
+ */
+ public List<Expectation> getNewExpectationList(List<Expectation> originalExpectationList) {
+ if (CollectionUtils.isEmpty(originalExpectationList)) {
+ return Collections.emptyList();
+ }
+ List<Expectation> newExpectations = new ArrayList<>();
+ for (Expectation expectation : originalExpectationList) {
+ expectation.setExpectationId(CommonUtil.getUUid());
+ //ExpectationObject
+ ExpectationObject expectationObject = expectation.getExpectationObject();
+ ExpectationObject newExpectationObject = getNewExpectationObject(expectationObject);
+ expectation.setExpectationObject(newExpectationObject);
+ //ExpectationTarget
+ List<ExpectationTarget> expectationTargets = expectation.getExpectationTargets();
+ if (CollectionUtils.isNotEmpty(expectationTargets)) {
+ for (ExpectationTarget expectationTarget : expectationTargets) {
+ expectationTarget.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);
+ newTargetContexts.add(newContext);
+ }
+ expectationTarget.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);
+ newTargetConditions.add(newCondition);
+ }
+ expectationTarget.setTargetConditions(newTargetConditions);
+ }
+ }
+ }
+ //expectationContexts
+ List<Context> expectationContexts = expectation.getExpectationContexts();
+ if (CollectionUtils.isNotEmpty(expectationContexts)) {
+ List<Context> newEexpectationContexts = new ArrayList<>();
+ for (Context context : expectationContexts) {
+ Context newContext = getNewContext(context);
+ newEexpectationContexts.add(newContext);
+ }
+ expectation.setExpectationContexts(newEexpectationContexts);
+ }
+ newExpectations.add(expectation);
+ }
+ return newExpectations;
+ }
+
+ public ExpectationObject getNewExpectationObject(ExpectationObject expectationObject) {
+ if (null != expectationObject) {
+ List<Context> objectContexts = expectationObject.getObjectContexts();
+ if (CollectionUtils.isNotEmpty(objectContexts)) {
+ List<Context> newObjectContexts = new ArrayList<>();
+ for (Context context : objectContexts) {
+ Context newContext = getNewContext(context);
+ newObjectContexts.add(newContext);
+ }
+ expectationObject.setObjectContexts(newObjectContexts);
+ return expectationObject;
+ }
+ }
+ return expectationObject;
+ }
+
+ public Condition getNewCondition(Condition condition) {
+ condition.setConditionId(CommonUtil.getUUid());
+ List<Condition> conditionList = condition.getConditionList();
+ if (CollectionUtils.isEmpty(conditionList)) {
+ return condition;
+ } else {
+ for (Condition subCondition : conditionList) {
+ getNewCondition(subCondition);
+ }
+ }
+ return condition;
+ }
+
+ public Context getNewContext(Context context) {
+ context.setContextId(CommonUtil.getUUid());
+ List<Condition> contextConditions = context.getContextConditions();
+ if (CollectionUtils.isNotEmpty(contextConditions)) {
+ List<Condition> newConditionList = new ArrayList<>();
+ for (Condition condition : contextConditions) {
+ newConditionList.add(getNewCondition(condition));
+ }
+ context.setContextConditions(newConditionList);
+ }
+ return context;
+ }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java
index 8c86ca7..57483fe 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java
@@ -28,11 +28,15 @@ import java.util.stream.Collectors;
public abstract class KnowledgeModule {
@Autowired
private IntentService intentService;
+
//Parse, decompose, orchestrate the original intent
- public abstract IntentGoalBean intentCognition(Intent intent);
+ public abstract IntentGoalBean intentCognition(Intent intent);
+
// in distribution, ask permission from imf
public abstract boolean recieveCreateIntent();
+
public abstract boolean recieveUpdateIntent();
+
public abstract boolean recieveDeleteIntent();
public List<String> intentResolution(Intent intent) {
@@ -46,7 +50,7 @@ public abstract class KnowledgeModule {
for (Intent dbIntent : filterIntentList) {
String intentId = dbIntent.getIntentId();
int count = 0;
- for (Expectation expectation : expectationList) {//original expectations
+ for (Expectation expectation : expectationList) { //original expectations
//Determine if there is the same ObjectType
List<Expectation> sameObjTypeList = dbIntent.getIntentExpectations().stream()
.filter(x -> x.getExpectationObject().getObjectType().equals(expectation.getExpectationObject().getObjectType()))
@@ -76,9 +80,16 @@ public abstract class KnowledgeModule {
}
public List<Intent> filterIntent(List<Intent> list) {
- //// condition ownerName = foramtIntentInput
List<Intent> fiterList = new ArrayList<>();
for (Intent intent : list) {
+ //filter the intent which save first time in controller
+ List<Context> ownerIdContextList = intent.getIntentContexts().stream().filter(x ->
+ StringUtils.equalsIgnoreCase(x.getContextName(), "ownerId")).collect(Collectors.toList());
+ if (CollectionUtils.isEmpty(ownerIdContextList)) {
+ fiterList.add(intent);
+ continue;
+ }
+ // condition ownerName = foramtIntentInput
List<Context> ownerInfo = intent.getIntentContexts().stream().filter(x ->
StringUtils.equalsIgnoreCase(x.getContextName(), "ownerInfo")).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(ownerInfo)) {
@@ -88,13 +99,13 @@ public abstract class KnowledgeModule {
for (Condition condition : contextConditions) {
String conditionstr = "ownerName equal to formatIntentInputManagementFunction";
String concatStr = condition.getConditionName() + condition.getOperator().name() + condition.getConditionValue();
- if (StringUtils.equalsIgnoreCase(concatStr.trim(), conditionstr.replaceAll(" ",""))) {
+ if (StringUtils.equalsIgnoreCase(concatStr.trim(), conditionstr.replaceAll(" ", ""))) {
fiterList.add(intent);
equals = true;
break;
}
}
- if (equals==true) {
+ if (equals == true) {
break;
}
}
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 31119e1..a0e2eed 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,7 +23,6 @@ import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.Actuatio
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
import org.springframework.stereotype.Service;
-import java.util.List;
import java.util.Map;
@Service
@@ -44,7 +43,7 @@ public class IntentDefinitionService {
public void definitionPorcess(Map.Entry<IntentGoalBean, IntentManagementFunction> entry) {
DecisionModule intentDecisionModule = intentOwner.getDecisionModule();
ActuationModule intentActuationModule = intentOwner.getActuationModule();
- intentDecisionModule.intentDefinition();
- intentActuationModule.saveIntentToDb(entry.getKey().getIntent());//id type
+ Intent newIdIntent = intentDecisionModule.intentDefinition(entry.getKey().getIntent());
+ intentActuationModule.saveIntentToDb(newIdIntent);//id type
}
}
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationServiceTest.java
index 265c097..4d029c1 100644
--- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationServiceTest.java
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/ExpectationServiceTest.java
@@ -47,7 +47,7 @@ class ExpectationServiceTest extends AbstractJUnit4SpringContextTests {
Expectation expectation = new Expectation();
ExpectationObject object = new ExpectationObject();
- object.setObjectType(ObjectType.valueOf("OBJECT1"));
+ object.setObjectType(ObjectType.valueOf("SLICING"));
object.setObjectInstance("objectInstance");
Condition targetCondition = new Condition();
diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/IntentServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/IntentServiceTest.java
index ace1683..a1a31de 100644
--- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/IntentServiceTest.java
+++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/service/IntentServiceTest.java
@@ -76,7 +76,7 @@ public class IntentServiceTest extends AbstractJUnit4SpringContextTests {
target1.setTargetConditions(targetConditionList);
List<ExpectationTarget> expectationTargetList = new ArrayList<>();
expectationTargetList.add(target1);
- object1.setObjectType(ObjectType.valueOf("OBJECT1"));
+ object1.setObjectType(ObjectType.valueOf("SLICING"));
object1.setObjectInstance("objectInstance");
expectation1.setExpectationId("expectationId");
expectation1.setExpectationName("expectationName");