diff options
author | 2022-08-31 16:38:15 +0800 | |
---|---|---|
committer | 2022-08-31 16:38:28 +0800 | |
commit | 5fe39ec091801b3edee0c3e6f0e08ab99caaf053 (patch) | |
tree | a1e85624e60c18e6078674507fff9ba6297e69b8 /intentanalysis/src/main | |
parent | 83b6c03d6c54c1b305d5f050036985f5aafb06bd (diff) |
Add intent distribution process code .
Issue-ID: USECASEUI-696
Change-Id: I82e2e1c6a15a153fe9117ad219f18b678ab14756
Signed-off-by: hekeguang <hekeguang@chinamobile.com>
Diffstat (limited to 'intentanalysis/src/main')
18 files changed, 496 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 4209c1b..acd580f 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,12 +16,15 @@ package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule; +import org.apache.commons.lang.StringUtils; +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.IntentHandleService; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; 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.intentBaseService.intentinterfaceservice.IntentInterfaceService; import org.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,7 +32,6 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; @Service @@ -40,6 +42,8 @@ public class CLLBusinessActuationModule implements ActuationModule { IntentHandleService intentHandleService; @Autowired IntentService intentService; + @Autowired + IntentInterfaceService intentInterfaceService; @Override @@ -57,16 +61,31 @@ public class CLLBusinessActuationModule implements ActuationModule { } @Override - public void saveIntentToDb(List<Map<IntentGoalBean,IntentManagementFunction>> intentMapList) { + public void saveIntentToDb(List<Map<IntentGoalBean, IntentManagementFunction>> intentMapList) { List<IntentGoalBean> subIntentGoalLit = new ArrayList<>(); - for (Map<IntentGoalBean,IntentManagementFunction> map:intentMapList) { + for (Map<IntentGoalBean, IntentManagementFunction> map : intentMapList) { subIntentGoalLit.addAll(map.keySet()); } List<Intent> subIntentList = subIntentGoalLit.stream().map(IntentGoalBean::getIntent) .collect(Collectors.toList()); - for (Intent subIntent:subIntentList) { + for (Intent subIntent : subIntentList) { intentService.createIntent(subIntent); } } + + @Override + public boolean distrubuteIntentToHandler(Map<IntentGoalBean, IntentManagementFunction> intentMap) { + for (Map.Entry<IntentGoalBean, IntentManagementFunction> entry : intentMap.entrySet()) { + IntentGoalType intentGoalType = entry.getKey().getIntentGoalType(); + if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) { + return intentInterfaceService.createInterface(entry.getKey().getIntent(), entry.getValue()); + } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) { + return intentInterfaceService.updateInterface(entry.getKey().getIntent(), entry.getValue()); + } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) { + return intentInterfaceService.deleteInterface(entry.getKey().getIntent(), entry.getValue()); + } + } + return false; + } } 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 bcda367..3313af5 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 @@ -51,17 +51,8 @@ public class CLLBusinessDecisionModule implements DecisionModule { public IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean) { // db filter imf supportArea; //SupportInterface> supportInterfaces; - IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType(); - String intentName = intentGoalBean.getIntent().getIntentName(); - List<IntentManagementFunctionRegInfo> imfRegInfoList = imfRegInfoService.getImfRegInfoList(); - //todo - List<IntentManagementFunctionRegInfo> imfList = imfRegInfoList.stream(). - filter(x -> x.getSupportArea().contains(intentName) - && x.getSupportInterfaces().contains(intentGoalType)).collect(Collectors.toList()); - if (!Optional.ofNullable(imfList).isPresent()) { - log.info("The intent name is %s not find the corresponding IntentManagementFunction", intentName); - } - return (IntentManagementFunction) applicationContext.getBean(imfList.get(0).getHandleName()); + IntentManagementFunctionRegInfo imfRegInfo = imfRegInfoService.getImfRegInfoList(intentGoalBean); + return (IntentManagementFunction) applicationContext.getBean(imfRegInfo.getHandleName()); } @Override @@ -146,7 +137,6 @@ public class CLLBusinessDecisionModule implements DecisionModule { for (IntentGoalBean subIntentGoal : sortList) { Map<IntentGoalBean, IntentManagementFunction> map = new HashMap<>(); IntentManagementFunction imf = exploreIntentHandlers(subIntentGoal); - //TODO call probe interface if fail intentFulfilmentInfo throw exception map.put(subIntentGoal, imf); intentMapList.add(map); } @@ -157,4 +147,5 @@ public class CLLBusinessDecisionModule implements DecisionModule { } return intentMapList; } + } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java index 372b0d5..c7d0872 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java @@ -22,6 +22,7 @@ import org.onap.usecaseui.intentanalysis.bean.models.Expectation; import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget; import org.onap.usecaseui.intentanalysis.bean.models.Intent; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentDetectionService; import org.onap.usecaseui.intentanalysis.service.IntentService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,56 +39,29 @@ public class CLLBusinessKnowledgeModule implements KnowledgeModule { @Autowired IntentService intentService; + @Autowired + IntentDetectionService intentDetectionService; @Override public IntentGoalBean intentCognition(Intent intent) { - List<String> intendIdList = intentResolution(intent); + List<String> intendIdList = intentDetectionService.intentResolution(intent); getSystemStatus(); return determineDetectionGoal(intent, intendIdList); } - /** - * find similar intents in DB - * - * @param intent - */ + @Override + public boolean recieveCreateIntent() { + return false; + } - public List<String> intentResolution(Intent intent) { - //db contain original intent - List<Intent> sameNameIntentList = intentService.getIntentByName(intent.getIntentName()); - List<String> intentIdList = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(sameNameIntentList)) { - List<Expectation> expectationList = intent.getIntentExpectations(); - for (Intent dbIntent : sameNameIntentList) { - String intentId = dbIntent.getIntentId(); - int count = 0; - 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())) - .collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(sameObjTypeList)) { - //Determine the targetName of the Expectation which hava same ObjectType - List<String> targetNameList = expectation.getExpectationTargets() - .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList()); - for (Expectation dbExpectation : sameObjTypeList) { - List<String> dbTargetNameList = dbExpectation.getExpectationTargets() - .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList()); - //todo name compare need ai - if (dbTargetNameList.containsAll(targetNameList)) { - count++; - break; - } - } - } - if (count == expectationList.size()) { - intentIdList.add(intentId); - break; - } - } - } - } - return intentIdList; + @Override + public boolean recieveUpdateIntent() { + return false; + } + + @Override + public boolean recieveDeleteIntent() { + return false; } void intentReportResolution() { diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java new file mode 100644 index 0000000..235d638 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java @@ -0,0 +1,30 @@ +/* + * 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.formatintentinputMgt; + +import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputActuationModule; +import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputDecisionModule; +import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputKnowledgeModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule; + +public class FormatIntentInputManagementFunction extends IntentManagementFunction { + private ActuationModule actuationModule = new FormatIntentInputActuationModule(); + private DecisionModule decisoinModule = new FormatIntentInputDecisionModule(); + private KnowledgeModule knowledgeModule = new FormatIntentInputKnowledgeModule(); +} 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 new file mode 100644 index 0000000..e556356 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputActuationModule.java @@ -0,0 +1,47 @@ +/* + * 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.formatintentinputMgt.formatintentinputModule; + +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; +import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; + +import java.util.List; +import java.util.Map; + +public class FormatIntentInputActuationModule implements ActuationModule { + @Override + public void sendToIntentHandler(IntentManagementFunction IntentHandler) { + } + + @Override + public void sendToNonIntentHandler() { + } + + @Override + public void interactWithIntentHandle() { + } + + @Override + public void saveIntentToDb(List<Map<IntentGoalBean, IntentManagementFunction>> intentMapList) { + // + } + + @Override + public boolean distrubuteIntentToHandler(Map<IntentGoalBean, IntentManagementFunction> intentMap) { + return false; + } +} 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 new file mode 100644 index 0000000..af29747 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java @@ -0,0 +1,89 @@ +/* + * 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.formatintentinputMgt.formatintentinputModule; + +import org.apache.commons.lang.StringUtils; +import org.onap.usecaseui.intentanalysis.bean.models.Expectation; +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.intentModule.DecisionModule; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class FormatIntentInputDecisionModule implements DecisionModule { + @Autowired + ApplicationContext applicationContext; + + @Override + public void determineUltimateGoal() { + } + + @Override + public IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean) { + // if intentName contain cll return + if (StringUtils.equalsIgnoreCase(intentGoalBean.getIntent().getIntentName(), "cll")) { + return (IntentManagementFunction) applicationContext.getBean(CLLBusinessIntentManagementFunction.class.getName()); + } + return null; + } + + @Override + public void intentDefinition() { + } + + @Override + public void decideSuitableAction() { + } + + @Override + public void interactWithTemplateDb() { + } + + @Override + public List<Map<IntentGoalBean, IntentManagementFunction>> findHandler(IntentGoalBean intentGoalBean) { + boolean needDecompostion = needDecompostion(intentGoalBean); + if (needDecompostion) { + intentDecomposition(intentGoalBean); + } + exploreIntentHandlers(intentGoalBean); + return null; + } + + public boolean needDecompostion(IntentGoalBean intentGoalBean) { + //expectationName just contain cll and slicing need decompost + List<Expectation> intentExpectations = intentGoalBean.getIntent().getIntentExpectations(); + List<String> expectationNameList = intentExpectations.stream().map(Expectation::getExpectationName) + .distinct().collect(Collectors.toList()); + if (expectationNameList.size() > 1) { + List<String> cllList = expectationNameList.stream().filter(x -> StringUtils.equalsIgnoreCase(x, "cll")).collect(Collectors.toList()); + List<String> slicingList = expectationNameList.stream().filter(x -> StringUtils.equalsIgnoreCase(x, "slicing")).collect(Collectors.toList()); + if (cllList.size() > 0 && slicingList.size() > 0) { + return true; + } + } + return false; + } + + public List<IntentGoalBean> intentDecomposition(IntentGoalBean intentGoalBean) { + //todo + return null; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputKnowledgeModule.java new file mode 100644 index 0000000..d6952f4 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputKnowledgeModule.java @@ -0,0 +1,64 @@ +/* + * 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.formatintentinputMgt.formatintentinputModule; + +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.intentModule.KnowledgeModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentDetectionService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +public class FormatIntentInputKnowledgeModule implements KnowledgeModule { + @Autowired + IntentDetectionService intentDetectionService; + + @Override + public IntentGoalBean intentCognition(Intent intent) { + List<String> intendIdList = intentDetectionService.intentResolution(intent); + getSystemStatus(); + return determineDetectionGoal(intent, intendIdList); + } + + @Override + public boolean recieveCreateIntent() { + return false; + } + + @Override + public boolean recieveUpdateIntent() { + return false; + } + + @Override + public boolean recieveDeleteIntent() { + return false; + } + + public void getSystemStatus() { + } + + public IntentGoalBean determineDetectionGoal(Intent intent, List<String> intentIdList) { + int size = intentIdList.size(); + if (size == 0) { + return new IntentGoalBean(intent, IntentGoalType.CREATE); + } else { + return new IntentGoalBean(intent, IntentGoalType.UPDATE); + } + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java index 2d420d7..1f18c52 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java @@ -42,7 +42,7 @@ public class IntentHandleService { /** * Process the original intent and find the corresponding IntentManagementFunction * - * @param intent + * @param intent todo */ public void handleOriginalIntent(Intent intent) { IntentManagementFunction intentOwner = getOriginalIMF(intent); 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 2800c1e..8f753e4 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 @@ -28,5 +28,6 @@ public interface ActuationModule { void interactWithIntentHandle(); //Save intent information to the intent instance database void saveIntentToDb(List<Map<IntentGoalBean,IntentManagementFunction>> intentMapList); + boolean distrubuteIntentToHandler(Map<IntentGoalBean,IntentManagementFunction> intentMap); } 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 76601a8..113d50d 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 @@ -25,6 +25,7 @@ import java.util.Map; public interface DecisionModule { void determineUltimateGoal(); + // find intentManageFunction IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean); void intentDefinition(); @@ -34,4 +35,5 @@ public interface DecisionModule { public void interactWithTemplateDb(); public List<Map<IntentGoalBean, IntentManagementFunction>> findHandler(IntentGoalBean intentGoalBean); + } 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 d5caf1f..818b812 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 @@ -21,4 +21,9 @@ import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; public interface KnowledgeModule { //Parse, decompose, orchestrate the original intent IntentGoalBean intentCognition(Intent intent); + + // in distribution, ask permission from imf + boolean recieveCreateIntent();// ·Ö¿ªÐ´ + boolean recieveUpdateIntent(); + boolean recieveDeleteIntent(); } 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 699c1b1..3273925 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,24 +15,34 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; -import org.onap.usecaseui.intentanalysis.bean.models.Intent; -import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; +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.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule; +import org.onap.usecaseui.intentanalysis.service.IntentService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + @Service public class IntentDetectionService { private IntentManagementFunction intentHandler; private IntentManagementFunction intentOwner; + @Autowired + IntentService intentService; - public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){ - if (intentOwner!= null){ + public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { + if (intentOwner != null) { this.intentOwner = intentOwner; } - if (intentHandler!= null){ - this.intentHandler= intentHandler; + if (intentHandler != null) { + this.intentHandler = intentHandler; } } @@ -41,4 +51,73 @@ public class IntentDetectionService { return ownerKnowledgeModule.intentCognition(intent); } + + public List<String> intentResolution(Intent intent) { + //db contain original intent + List<Intent> sameNameIntentList = intentService.getIntentByName(intent.getIntentName()); + List<String> intentIdList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(sameNameIntentList)) { + //remove context.condition ownerName = formatIntentInputManagementFunction + List<Intent> filterIntentList = filterIntent(sameNameIntentList); + List<Expectation> expectationList = intent.getIntentExpectations(); + for (Intent dbIntent : filterIntentList) { + String intentId = dbIntent.getIntentId(); + int count = 0; + 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())) + .collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(sameObjTypeList)) { + //Determine the targetName of the Expectation which hava same ObjectType + List<String> targetNameList = expectation.getExpectationTargets() + .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList()); + for (Expectation dbExpectation : sameObjTypeList) { + List<String> dbTargetNameList = dbExpectation.getExpectationTargets() + .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList()); + //todo name compare need ai + if (dbTargetNameList.containsAll(targetNameList)) { + count++; + break; + } + } + } + if (count == expectationList.size()) { + intentIdList.add(intentId); + break; + } + } + } + } + return intentIdList; + } + + public List<Intent> filterIntent(List<Intent> list) { + //// condition ownerName = foramtIntentInput + List<Intent> fiterList = new ArrayList<>(); + for (Intent intent : list) { + List<Context> ownerInfo = intent.getIntentContexts().stream().filter(x -> + StringUtils.equalsIgnoreCase(x.getContextName(), "ownerInfo")).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(ownerInfo)) { + for (Context context : ownerInfo) { + List<Condition> 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())) { + fiterList.add(intent); + equals = true; + break; + } + } + if (equals==true) { + break; + } + } + } + } + list.removeAll(fiterList); + return list; + } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java index 4622aa1..d803718 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java @@ -16,29 +16,54 @@ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; +import org.apache.commons.lang.StringUtils; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; +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.intentBaseService.intentinterfaceservice.IntentInterfaceService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Map; + @Service public class IntentDistributionService { private IntentManagementFunction intentHandler; private IntentManagementFunction intentOwner; - public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){ - if (intentOwner!= null){ + @Autowired + IntentInterfaceService intentInterfaceService; + + public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { + if (intentOwner != null) { this.intentOwner = intentOwner; } - if (intentHandler!= null){ - this.intentHandler= intentHandler; + if (intentHandler != null) { + this.intentHandler = intentHandler; } } - public void distributionProcess() { - ActuationModule intentActuationModule = intentHandler.getActuationModule(); + public boolean distributionProcess(Map<IntentGoalBean, IntentManagementFunction> intentMap) { - intentActuationModule.sendToIntentHandler(intentHandler); + intentOwner.getActuationModule().distrubuteIntentToHandler(intentMap); + return false; } + public boolean distrubuteIntentToHandler(Map<IntentGoalBean, IntentManagementFunction> intentMap) { + + for (Map.Entry<IntentGoalBean, IntentManagementFunction> entry : intentMap.entrySet()) { + IntentGoalType intentGoalType = entry.getKey().getIntentGoalType(); + if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) { + return intentInterfaceService.createInterface(entry.getKey().getIntent(), entry.getValue()); + } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) { + return intentInterfaceService.updateInterface(entry.getKey().getIntent(), entry.getValue()); + } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) { + return intentInterfaceService.deleteInterface(entry.getKey().getIntent(), entry.getValue()); + } + } + return false; + } } + 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 ec4037e..5d4a5dc 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 @@ -66,7 +66,7 @@ public class IntentProcessService { //distribution process intentDistributionService.setIntentRole(intentOwner,intentHandler); - intentDistributionService.distributionProcess(); + intentDistributionService.distributionProcess(map); //operation process intentOperationService.setIntentRole(intentOwner,intentHandler); diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java new file mode 100644 index 0000000..4470d05 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java @@ -0,0 +1,27 @@ +/* + * 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.intentinterfaceservice; + +import org.onap.usecaseui.intentanalysis.bean.models.Intent; +import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; + +public interface IntentInterfaceService { + public boolean createInterface(Intent intent, IntentManagementFunction imf); + + public boolean updateInterface(Intent intent, IntentManagementFunction imf); + + public boolean deleteInterface(Intent intent, IntentManagementFunction imf); +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java new file mode 100644 index 0000000..1c6d853 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java @@ -0,0 +1,43 @@ +/* + * 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.intentinterfaceservice.impl; + +import org.onap.usecaseui.intentanalysis.bean.models.Intent; +import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService; +import org.springframework.stereotype.Service; + +@Service +public class IntentInterfaceServiceImpl implements IntentInterfaceService { + @Override + public boolean createInterface(Intent intent, IntentManagementFunction imf) { + //ask knowledgeModole of handler imf for permision + imf.getKnowledgeModule().recieveCreateIntent(); + return false; + } + + @Override + public boolean updateInterface(Intent intent, IntentManagementFunction imf) { + imf.getKnowledgeModule().recieveUpdateIntent(); + return false; + } + + @Override + public boolean deleteInterface(Intent intent, IntentManagementFunction imf) { + imf.getKnowledgeModule().recieveDeleteIntent(); + return false; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ImfRegInfoService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ImfRegInfoService.java index 0d7a6b1..c148975 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ImfRegInfoService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ImfRegInfoService.java @@ -15,6 +15,7 @@ */ package org.onap.usecaseui.intentanalysis.service; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo; import java.util.List; @@ -23,4 +24,7 @@ public interface ImfRegInfoService { int insertIMFRegInfoRegInfo(IntentManagementFunctionRegInfo regInfo); List<IntentManagementFunctionRegInfo> getImfRegInfoList(); + IntentManagementFunctionRegInfo getImfRegInfoList(IntentGoalBean intentGoalBean); + + } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java index 9fdc3ba..ba1a4fe 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java @@ -16,6 +16,8 @@ package org.onap.usecaseui.intentanalysis.service.impl; import lombok.extern.slf4j.Slf4j; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo; import org.onap.usecaseui.intentanalysis.mapper.IMFRegInfoMapper; import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService; @@ -23,6 +25,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; @Service @Slf4j @@ -39,4 +43,22 @@ public class ImfRegInfoServiceImpl implements ImfRegInfoService { public List<IntentManagementFunctionRegInfo> getImfRegInfoList() { return imfRegInfoMapper.getImfRegInfoList(); } + + @Override + public IntentManagementFunctionRegInfo getImfRegInfoList(IntentGoalBean intentGoalBean) { + String intentName = intentGoalBean.getIntent().getIntentName(); + IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType(); + List<IntentManagementFunctionRegInfo> imfRegInfoList = imfRegInfoMapper.getImfRegInfoList(); + + List<IntentManagementFunctionRegInfo> imfList = imfRegInfoList.stream(). + filter(x -> x.getSupportArea().contains(intentName) + && x.getSupportInterfaces().contains(intentGoalType)).collect(Collectors.toList()); + if (!Optional.ofNullable(imfList).isPresent()) { + log.info("The intent name is %s not find the corresponding IntentManagementFunction", intentName); + } + //TODO call probe interface if fail intentFulfilmentInfo throw exception + + return imfList.get(0); + } + }
\ No newline at end of file |