diff options
author | kaixiliu <liukaixi@chinamobile.com> | 2023-08-23 15:28:50 +0800 |
---|---|---|
committer | kaixiliu <liukaixi@chinamobile.com> | 2023-08-23 15:29:50 +0800 |
commit | 99ad19125b3e667cca2adfc7a30c2f5c1f4daf8c (patch) | |
tree | 7f8c10f49602c72034904c9196ce663d68993245 /intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java | |
parent | 25c3ab069bf8e326d3a6a609b71db30e8d5f90f9 (diff) |
Optimize the logic for generating intention reports
Issue-ID: USECASEUI-819
Change-Id: I1578f690cb94097abe7d1e263f47b7c976b8555a
Signed-off-by: kaixiliu <liukaixi@chinamobile.com>
Diffstat (limited to 'intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java')
-rw-r--r-- | intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java | 63 |
1 files changed, 3 insertions, 60 deletions
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 4ca532e..334a6d3 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 @@ -17,7 +17,6 @@ package org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinput import lombok.extern.slf4j.Slf4j; 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.models.*; import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction; @@ -26,21 +25,15 @@ import org.onap.usecaseui.intentanalysis.exception.IntentInputException; 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.IntentReportService; import org.onap.usecaseui.intentanalysis.service.IntentService; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @Slf4j @@ -55,12 +48,6 @@ public class FormatIntentInputDecisionModule extends DecisionModule { @Autowired public IntentService intentService; - @Autowired - private IntentReportService intentReportService; - - @Resource(name = "intentReportExecutor") - private ScheduledThreadPoolExecutor executor; - @Override public void determineUltimateGoal() { } @@ -91,14 +78,12 @@ public class FormatIntentInputDecisionModule extends DecisionModule { log.info("FormatIntentInputMgt investigation create process start"); LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>(); - IntentGoalBean newIntentGoalBean = removeReportExpectation(intentGoalBean); - - boolean needDecompostion = needDecompostion(newIntentGoalBean); + boolean needDecompostion = needDecompostion(intentGoalBean); log.debug("FormatIntentInputMgt need decompose :" + needDecompostion); if (needDecompostion) { - intentDecomposition(newIntentGoalBean); + intentDecomposition(intentGoalBean); } else { - intentMap.put(newIntentGoalBean, exploreIntentHandlers(newIntentGoalBean)); + intentMap.put(intentGoalBean, exploreIntentHandlers(intentGoalBean)); } log.info("FormatIntentInputMgt investigation create process finished"); return intentMap; @@ -182,46 +167,4 @@ public class FormatIntentInputDecisionModule extends DecisionModule { } return intentMap; } - - private IntentGoalBean removeReportExpectation(IntentGoalBean intentGoalBean) { - Intent intent = intentGoalBean.getIntent(); - List<Expectation> intentExpectations = intent.getIntentExpectations(); - List<Expectation> report = intentExpectations.stream() - .filter(expectation -> ExpectationType.REPORT.equals(expectation.getExpectationType())) - .collect(Collectors.toList()); - if (CollectionUtils.isEmpty(report)) { - log.info("No expectation of type report is entered"); - return intentGoalBean; - } - generationIntentReport(report.get(0), intent.getIntentId()); - Intent newIntent = new Intent(); - BeanUtils.copyProperties(intent, newIntent); - List<Expectation> notReport = intentExpectations.stream() - .filter(expectation -> !ExpectationType.REPORT.equals(expectation.getExpectationType())) - .collect(Collectors.toList()); - newIntent.setIntentExpectations(notReport); - return new IntentGoalBean(newIntent, intentGoalBean.getIntentGoalType()); - } - - private void generationIntentReport(Expectation expectation, String intentId) { - List<ExpectationTarget> expectationTargets = expectation.getExpectationTargets(); - if (CollectionUtils.isEmpty(expectationTargets)) { - log.error("The expectation target is empty,expectationId is {}", expectation.getExpectationId()); - return; - } - ExpectationTarget expectationTarget = expectationTargets.get(0); - List<Condition> targetConditions = expectationTarget.getTargetConditions(); - if (CollectionUtils.isEmpty(targetConditions)) { - log.error("The target condition is empty,expectationId is {}", expectation.getExpectationId()); - return; - } - Condition condition = targetConditions.get(0); - try { - int conditionValue = Integer.parseInt(condition.getConditionValue()); - log.info("Start executing scheduled intent report generation task "); - executor.scheduleAtFixedRate(() -> intentReportService.saveIntentReportByIntentId(intentId), 2, conditionValue, TimeUnit.SECONDS); - } catch (Exception e) { - log.error("The exception is {}", e.getMessage()); - } - } } |