--- /dev/null
+package org.onap.usecaseui.intentanalysis.assuranceIntentmgt;
+
+import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
+
+public class AssuranceIntentManagementFunction extends IntentManagementFunction {
+}
--- /dev/null
+package org.onap.usecaseui.intentanalysis.assuranceIntentmgt.assurancemodule;
+
+public class AssuranceActuationModule {
+}
--- /dev/null
+package org.onap.usecaseui.intentanalysis.assuranceIntentmgt.assurancemodule;
+
+public class AssuranceDecisionModule {
+}
--- /dev/null
+package org.onap.usecaseui.intentanalysis.assuranceIntentmgt.assurancemodule;
+
+public class AssuranceKnowledgeModule {
+}
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.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService;
import java.util.stream.Collectors;
@Service
-public class CLLBusinessActuationModule implements ActuationModule {
+public class CLLBusinessActuationModule extends ActuationModule {
@Autowired
IntentProcessService processService;
@Autowired
- IntentHandleService intentHandleService;
- @Autowired
IntentService intentService;
@Autowired
IntentInterfaceService intentInterfaceService;
}
}
-
- @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;
- }
}
@Log4j2
@Service
-public class CLLBusinessDecisionModule implements DecisionModule {
+public class CLLBusinessDecisionModule extends DecisionModule {
@Autowired
private ImfRegInfoService imfRegInfoService;
@Autowired
import java.util.stream.Collectors;
@Service
-public class CLLBusinessKnowledgeModule implements KnowledgeModule {
+public class CLLBusinessKnowledgeModule extends KnowledgeModule {
private static Logger LOGGER = LoggerFactory.getLogger(CLLBusinessKnowledgeModule.class);
@Autowired
@Override
public IntentGoalBean intentCognition(Intent intent) {
- List<String> intendIdList = intentDetectionService.intentResolution(intent);
+ List<String> intendIdList = intentResolution(intent);
getSystemStatus();
return determineDetectionGoal(intent, intendIdList);
}
import java.util.List;
-import org.onap.usecaseui.intentanalysis.intentBaseService.IntentHandleService;
+import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction;
+import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
private IntentService intentService;
@Autowired
- private IntentHandleService intentHandleService;
+ private IntentProcessService processService;
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Intent>> getIntentList() {
@PostMapping(value="/handleIntent",produces = MediaType.APPLICATION_JSON_VALUE)
public void handleIntent(@RequestBody Intent intent) {
- intentHandleService.handleOriginalIntent(intent);
+ processService.setIntentRole(new FormatIntentInputManagementFunction(), null);
+ processService.intentProcess(intent);
}
}
--- /dev/null
+package org.onap.usecaseui.intentanalysis.deliveryIntentmgt;
+
+import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessActuationModule;
+import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessDecisionModule;
+import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessKnowledgeModule;
+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 DeliveryManagementFunction extends IntentManagementFunction {
+ private ActuationModule actuationModule = new CLLBusinessActuationModule();
+ private DecisionModule decisoinModule = new CLLBusinessDecisionModule();
+ private KnowledgeModule knowledgeModule = new CLLBusinessKnowledgeModule();
+}
--- /dev/null
+package org.onap.usecaseui.intentanalysis.deliveryIntentmgt.deliverymodule;
+
+public class DeliveryActuationModule {
+}
--- /dev/null
+package org.onap.usecaseui.intentanalysis.deliveryIntentmgt.deliverymodule;
+
+public class DeliveryDecisionModule {
+}
--- /dev/null
+package org.onap.usecaseui.intentanalysis.deliveryIntentmgt.deliverymodule;
+
+public class DeliveryKnowledgeModule {
+}
import java.util.List;
import java.util.Map;
-public class FormatIntentInputActuationModule implements ActuationModule {
+public class FormatIntentInputActuationModule extends ActuationModule {
@Override
public void sendToIntentHandler(IntentManagementFunction IntentHandler) {
}
import java.util.Map;
import java.util.stream.Collectors;
-public class FormatIntentInputDecisionModule implements DecisionModule {
+public class FormatIntentInputDecisionModule extends DecisionModule {
@Autowired
ApplicationContext applicationContext;
import java.util.List;
-public class FormatIntentInputKnowledgeModule implements KnowledgeModule {
+public class FormatIntentInputKnowledgeModule extends KnowledgeModule {
@Autowired
IntentDetectionService intentDetectionService;
@Override
public IntentGoalBean intentCognition(Intent intent) {
- List<String> intendIdList = intentDetectionService.intentResolution(intent);
+ List<String> intendIdList = intentResolution(intent);
getSystemStatus();
return determineDetectionGoal(intent, intendIdList);
}
+++ /dev/null
-/*
- * 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;
-
-import lombok.extern.slf4j.Slf4j;
-import org.onap.usecaseui.intentanalysis.bean.models.Intent;
-import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo;
-import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
-import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
-import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService;
-import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-@Slf4j
-@Service
-public class IntentHandleService {
- @Autowired
- private IntentProcessService processService;
- @Autowired
- private ImfRegInfoService imfRegInfoService;
- @Autowired
- private ApplicationContext applicationContext;
-
- /**
- * Process the original intent and find the corresponding IntentManagementFunction
- *
- * @param intent todo
- */
- public void handleOriginalIntent(Intent intent) {
- IntentManagementFunction intentOwner = getOriginalIMF(intent);
- handleIntent(intent, intentOwner);
- }
-
- public void handleIntent(Intent intent, IntentManagementFunction intentOwner) {
- processService.setIntentRole(intentOwner, null);
- processService.intentProcess(intent);
- }
-
- public IntentManagementFunction selectIntentManagementFunction(Intent intent) {
- //select the IntentManagementFunctionRegInfo Based on the IMFRegistry information.
- //Only internalFunction support.
- //and based on the IntentManagementFunctionRegInfo, get the right IntentManagementFunction bean.
- //if no IntentManagementFunction selected, that means this intent is not supported by this system.
- return null;
- }
-
- public IntentManagementFunctionRegInfo selectIntentManagementFunctionRegInfo(Intent intent) {
- //select the IntentManagementFunctionRegInfo Based on the IMFRegistry information.
- //Both internalFunction and externalFunction support.
- //This is used to get he IntentManagementFunction for a subIntent decomposition.
- return null;
- }
-
- public IntentManagementFunction getOriginalIMF(Intent intent) {
- //select IntentManagementFunction based on intent name
- String intentName = intent.getIntentName();
- List<IntentManagementFunctionRegInfo> imfRegInfoList = imfRegInfoService.getImfRegInfoList();
- List<IntentManagementFunctionRegInfo> list = imfRegInfoList.stream().filter(x -> x.getSupportArea().contains(intentName)).collect(Collectors.toList());
- if (!Optional.ofNullable(list).isPresent()) {
- String msg = String.format("Intent name %s doesn't exist IntentManagementFunction in database.", intent.getIntentName());
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
- }
- return (IntentManagementFunction) applicationContext.getBean(list.get(0).getHandleName());
- }
-}
*/
package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule;
+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.intentinterfaceservice.IntentInterfaceService;
+import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Map;
-public interface ActuationModule {
+public abstract class ActuationModule {
+ @Autowired
+ IntentInterfaceService intentInterfaceService;
+
//actuationModel & knownledgeModel interact
- void sendToIntentHandler(IntentManagementFunction IntentHandler);
- void sendToNonIntentHandler();//直接操作
- void interactWithIntentHandle();
+ public abstract void sendToIntentHandler(IntentManagementFunction IntentHandler);
+
+ public abstract void sendToNonIntentHandler();//直接操作
+
+ public abstract void interactWithIntentHandle();
+
//Save intent information to the intent instance database
- void saveIntentToDb(List<Map<IntentGoalBean,IntentManagementFunction>> intentMapList);
- boolean distrubuteIntentToHandler(Map<IntentGoalBean,IntentManagementFunction> intentMap);
+ public abstract void saveIntentToDb(List<Map<IntentGoalBean, IntentManagementFunction>> intentMapList);
+ 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;
+ }
}
import java.util.List;
import java.util.Map;
-public interface DecisionModule {
- void determineUltimateGoal();
+public abstract class DecisionModule {
+ public abstract void determineUltimateGoal();
// find intentManageFunction
- IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean);
+ public abstract IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean);
- void intentDefinition();
+ public abstract void intentDefinition();
- void decideSuitableAction();
+ public abstract void decideSuitableAction();
- public void interactWithTemplateDb();
+ public abstract void interactWithTemplateDb();
- public List<Map<IntentGoalBean, IntentManagementFunction>> findHandler(IntentGoalBean intentGoalBean);
+ public abstract List<Map<IntentGoalBean, IntentManagementFunction>> findHandler(IntentGoalBean intentGoalBean);
}
*/
package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule;
-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.models.*;
+import org.onap.usecaseui.intentanalysis.service.IntentService;
+import org.springframework.beans.factory.annotation.Autowired;
-public interface KnowledgeModule {
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public abstract class KnowledgeModule {
+ @Autowired
+ IntentService intentService;
//Parse, decompose, orchestrate the original intent
- IntentGoalBean intentCognition(Intent intent);
+ public abstract IntentGoalBean intentCognition(Intent intent);
// in distribution, ask permission from imf
- boolean recieveCreateIntent();// ·Ö¿ªÐ´
- boolean recieveUpdateIntent();
- boolean recieveDeleteIntent();
+ public abstract boolean recieveCreateIntent();
+ public abstract boolean recieveUpdateIntent();
+ public abstract boolean recieveDeleteIntent();
+
+ 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;
+ }
}
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;
- }
}
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;
- }
}