From 4455187a6add80c5226c178574e96b74a2541846 Mon Sep 17 00:00:00 2001 From: hekeguang Date: Thu, 15 Sep 2022 15:52:55 +0800 Subject: Bug fix . Issue-ID: USECASEUI-696 Change-Id: I91b6973e887d5601e678e889cb354f0c82ac8741 Signed-off-by: hekeguang --- .../FormatIntentInputActuationModule.java | 36 ++++++++++++++++++++++ .../FormatIntentInputDecisionModule.java | 4 +-- .../intentModule/KnowledgeModule.java | 9 ++++-- 3 files changed, 44 insertions(+), 5 deletions(-) (limited to 'intentanalysis') 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 1d397fd..2d308c4 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 @@ -16,17 +16,31 @@ package org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule; 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; import org.onap.usecaseui.intentanalysis.bean.models.Intent; +import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; +import org.onap.usecaseui.intentanalysis.service.IntentService; +import org.onap.usecaseui.intentanalysis.util.CommonUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + @Log4j2 @Component public class FormatIntentInputActuationModule extends ActuationModule { @Autowired IntentProcessService processService; + @Autowired + IntentService intentService; @Override public void toNextIntentHandler(Intent intent, IntentManagementFunction IntentHandler) { log.info("do nothing"); @@ -43,4 +57,26 @@ public class FormatIntentInputActuationModule extends ActuationModule { @Override public void fulfillIntent(Intent intent, IntentManagementFunction intentHandler) { } + @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); + 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 edb3814..968add2 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 @@ -75,8 +75,8 @@ public class FormatIntentInputDecisionModule extends DecisionModule { List expectationNameList = intentExpectations.stream().map(Expectation::getExpectationName) .distinct().collect(Collectors.toList()); if (expectationNameList.size() > 1) { - List cllList = expectationNameList.stream().filter(x -> StringUtils.equalsIgnoreCase(x, "cll")).collect(Collectors.toList()); - List slicingList = expectationNameList.stream().filter(x -> StringUtils.equalsIgnoreCase(x, "slicing")).collect(Collectors.toList()); + List cllList = expectationNameList.stream().filter(x -> StringUtils.containsIgnoreCase(x, "cll")).collect(Collectors.toList()); + List slicingList = expectationNameList.stream().filter(x -> StringUtils.containsIgnoreCase(x, "slicing")).collect(Collectors.toList()); if (cllList.size() > 0 && slicingList.size() > 0) { return true; } 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 bce9c95..b3dbcc2 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 @@ -17,8 +17,11 @@ package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; +import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType; import org.onap.usecaseui.intentanalysis.bean.models.*; +import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction; import org.onap.usecaseui.intentanalysis.service.IntentService; +import org.onap.usecaseui.intentanalysis.util.CommonUtil; import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; @@ -86,9 +89,9 @@ public abstract class KnowledgeModule { List contextConditions = context.getContextConditions(); boolean equals = false; for (Condition condition : contextConditions) { - String conditionstr = "ownerName = formatIntentInputManagementFunction"; - String concatStr = condition.getConditionName() + condition.getOperator() + condition.getConditionValue(); - if (StringUtils.equalsIgnoreCase(concatStr.trim(), conditionstr.trim())) { + String conditionstr = "ownerName equal to formatIntentInputManagementFunction"; + String concatStr = condition.getConditionName() + condition.getOperator().name() + condition.getConditionValue(); + if (StringUtils.equalsIgnoreCase(concatStr.trim(), conditionstr.replaceAll(" ",""))) { fiterList.add(intent); equals = true; break; -- cgit 1.2.3-korg