diff options
author | 2022-09-26 16:57:55 +0800 | |
---|---|---|
committer | 2022-09-26 16:58:32 +0800 | |
commit | ead03c73657e3c46f87d82a34939b84ae35e8417 (patch) | |
tree | 98d434ad3be8930234e2c7e01928e3d76063318a /intentanalysis/src/main/java/org/onap | |
parent | 1d3d6092e9db1daaac382eb0e859da65dc98a712 (diff) |
Add ImfRegInfo code .
Issue-ID: USECASEUI-696
Change-Id: I143d9c9aada3d9c0dfdbf5dae8cd04be0a2a3c5a
Signed-off-by: hekeguang <hekeguang@chinamobile.com>
Diffstat (limited to 'intentanalysis/src/main/java/org/onap')
5 files changed, 66 insertions, 11 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 afd1a04..d636856 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 @@ -20,8 +20,8 @@ import lombok.Setter; @Getter public enum ObjectType { - OBJECT1(0, "objectType1"), - OBJECT2(1, "objectType2"); + SLICING(0, "objectType1"), + CCVPN(1, "objectType2"); private int index; diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java index 7b3ff5a..d6ab5b8 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java @@ -26,9 +26,9 @@ import java.util.List; public class IntentManagementFunctionRegInfo { private String id; private String description; - private List<SupportArea> supportArea; + private String supportArea;//Separate multiple values with commas private String supportModel; - private List<SupportInterface> supportInterfaces; + private String supportInterfaces;//Separate multiple values with commas private String handleName; //distinguish internal or external function private IntentFunctionType intentFunctionType; diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceKnowledgeModule.java index c1300f0..dd560ff 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceKnowledgeModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceKnowledgeModule.java @@ -15,13 +15,41 @@ */ package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.cllassurancemodule; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.log4j.Log4j2; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.onap.usecaseui.intentanalysis.adapters.aai.apicall.AAIAPICall; +import org.onap.usecaseui.intentanalysis.adapters.aai.apicall.AAIAuthConfig; 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.util.RestfulServices; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import retrofit2.Response; +import java.io.IOException; + +@Log4j2 @Component public class CLLAssuranceKnowledgeModule extends KnowledgeModule { + private AAIAPICall aaiapiCall; + @Autowired + AAIAuthConfig aaiAuthConfig; + + public AAIAPICall getAaiApiCall() { + if (null == aaiapiCall) { + this.aaiapiCall = RestfulServices.create(AAIAPICall.class, + aaiAuthConfig.getUserName(), aaiAuthConfig.getPassword()); + } + return this.aaiapiCall; + } + + public void setAAIApiCall(AAIAPICall aaiApiCall) { + this.aaiapiCall = aaiApiCall; + } + @Override public IntentGoalBean intentCognition(Intent intent) { return null; @@ -41,4 +69,29 @@ public class CLLAssuranceKnowledgeModule extends KnowledgeModule { public boolean recieveDeleteIntent() { return false; } + + /** + * healthy check + */ + int getSystemStatus(Intent intent) { + try { + if (CollectionUtils.isEmpty(intent.getIntentExpectations())) { + return -1; + } + String objectInstance = intent.getIntentExpectations().get(0).getExpectationObject().getObjectInstance(); + if (StringUtils.isEmpty(objectInstance)){ + return -1; + } + Response<JSONObject> response = getAaiApiCall().getInstanceInfo(objectInstance).execute(); + log.debug(response.toString()); + if (response.isSuccessful()) { + // TODO: 2022/9/20 judge by the return result + } + log.error("getIntentInstance Create Statue Error:" + response.toString()); + return -1; + } catch (Exception ex) { + log.error("Details:" + ex.getMessage()); + return 0; + } + } } 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 968add2..507ada8 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 @@ -40,7 +40,7 @@ public class FormatIntentInputDecisionModule extends DecisionModule { public IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean) { // if intentName contain cll return if (intentGoalBean.getIntent().getIntentName().toLowerCase(Locale.ROOT).contains("cll")) { - return (IntentManagementFunction) applicationContext.getBean(CLLBusinessIntentManagementFunction.class.getSimpleName()); + return (IntentManagementFunction) applicationContext.getBean(CLLBusinessIntentManagementFunction.class.getSimpleName()); } return null; } @@ -63,7 +63,7 @@ public class FormatIntentInputDecisionModule extends DecisionModule { boolean needDecompostion = needDecompostion(intentGoalBean); if (needDecompostion) { intentDecomposition(intentGoalBean); - }else{ + } else { intentMap.put(intentGoalBean, exploreIntentHandlers(intentGoalBean)); } return intentMap; 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 595acad..ad636d8 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,7 @@ package org.onap.usecaseui.intentanalysis.service.impl; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; import org.onap.usecaseui.intentanalysis.bean.enums.SupportArea; @@ -58,14 +59,15 @@ public class ImfRegInfoServiceImpl implements ImfRegInfoService { for (IntentManagementFunctionRegInfo imfr : imfRegInfoList) { boolean containsArea = false; boolean containsInterface = false; - for (SupportArea area : imfr.getSupportArea()) { - if (StringUtils.containsIgnoreCase(intentName, area.name())) { + for (String area : imfr.getSupportArea().split(",")) { + if (StringUtils.containsIgnoreCase(intentName, area)) { containsArea = true; break; } } - for (SupportInterface supInterface : imfr.getSupportInterfaces()) { - if (StringUtils.containsIgnoreCase(supInterface.name(), intentGoalType.name())) { + if (!containsArea) break; + for (String supInterface : imfr.getSupportInterfaces().split(",")) { + if (StringUtils.containsIgnoreCase(supInterface, intentGoalType.name())) { containsInterface = true; break; } @@ -74,7 +76,7 @@ public class ImfRegInfoServiceImpl implements ImfRegInfoService { imfList.add(imfr); } } - if (!Optional.ofNullable(imfList).isPresent()) { + if (CollectionUtils.isEmpty(imfList)) { log.info("The intent name is %s not find the corresponding IntentManagementFunction", intentName); } //TODO call probe interface if fail intentFulfilmentInfo throw exception |