@Getter
public enum ObjectType {
- OBJECT1(0, "objectType1"),
- OBJECT2(1, "objectType2");
+ SLICING(0, "objectType1"),
+ CCVPN(1, "objectType2");
private int index;
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;
*/
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;
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;
+ }
+ }
}
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;
}
boolean needDecompostion = needDecompostion(intentGoalBean);
if (needDecompostion) {
intentDecomposition(intentGoalBean);
- }else{
+ } else {
intentMap.put(intentGoalBean, exploreIntentHandlers(intentGoalBean));
}
return intentMap;
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;
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;
}
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
create table if not exists intent_management_function_reg_info(
imfr_info_id varchar(255) primary key,
imfr_info_description varchar(255),
- support_area text ARRAY,
+ support_area varchar(255),
support_model varchar(255),
- support_interfaces text ARRAY,
+ support_interfaces varchar(255),
handle_name varchar(255),
intent_function_type varchar(255)
);
\ No newline at end of file
</insert>
<!-- 这里的查询有问题-->
<select id="selectConditionList" resultType="org.onap.usecaseui.intentanalysis.bean.models.Condition">
- select condition_id conditionId, condition_name conditionName, operator_type operator, condition_value conditionValue
+ select condition_id conditionId, condition_name conditionName, operator_type "operator", condition_value conditionValue
from condition
where parent_id = #{parentId}
</select>
<select id="selectCondition" resultType="org.onap.usecaseui.intentanalysis.bean.models.Condition">
- select condition_id conditionId, condition_name conditionName, operator_type operator, condition_value conditionValue
+ select condition_id conditionId, condition_name conditionName, operator_type "operator", condition_value conditionValue
from condition
where condition_id = #{conditionId}
</select>
<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.IMFRegInfoMapper">
- <resultMap id="mapIMFRInfo" type="org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo">
- <result column="support_area" property="supportArea" typeHandler="org.onap.usecaseui.intentanalysis.util.ListArrayTypeHandler" jdbcType="ARRAY" javaType="java.util.List"/>
- <result column="support_interfaces" property="supportInterfaces" typeHandler="org.onap.usecaseui.intentanalysis.util.ListArrayTypeHandler" jdbcType="ARRAY" javaType="java.util.List"/>
- </resultMap>
-
<insert id="insertIMFRegInfoRegInfo">
insert into intent_management_function_reg_info(imfr_info_id,imfr_info_description,support_area,support_model,support_interfaces,handle_name,intent_function_type)
values
(#{imfregInfo.id}, #{imfregInfo.description},#{imfregInfo.supportArea} , #{imfregInfo.supportModel},#{imfregInfo.supportInterfaces},#{imfregInfo.handleName},#{imfregInfo.intentFunctionType})
</insert>
- <select id="getImfRegInfoList" resultMap="mapIMFRInfo">
- select * from intent_management_function_reg_info
+ <select id="getImfRegInfoList" resultType="org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo">
+ select imfr_info_id id,imfr_info_description description,support_area supportArea, support_model supportModel,
+ support_interfaces supportInterfaces,handle_name handleName,intent_function_type intentFunctionType
+ from intent_management_function_reg_info
</select>
</mapper>
@Test
public void testSetExpectationObjectTest() {
ExpectationObject test = new ExpectationObject();
- test.setObjectType(ObjectType.OBJECT1);
+ test.setObjectType(ObjectType.SLICING);
test.setObjectInstance("");
test.setObjectContexts(new ArrayList<>());
}
IntentManagementFunctionRegInfo test = new IntentManagementFunctionRegInfo();
test.setId("");
test.setDescription("");
- test.setSupportArea(new ArrayList<SupportArea>());
+ test.setSupportArea("");
test.setSupportModel("");
- test.setSupportInterfaces(new ArrayList<>());
+ test.setSupportInterfaces("");
test.setHandleName("");
test.setIntentFunctionType(IntentFunctionType.INTERNALFUNCTION);
}
delivery.setExpectationName("deliveryExpectation");
delivery.setExpectationType(ExpectationType.DELIVERY);
ExpectationObject expectationObject = new ExpectationObject();
- expectationObject.setObjectType(ObjectType.OBJECT1);
+ expectationObject.setObjectType(ObjectType.SLICING);
//expetationTarget Context FulfilmentInfo is empty
delivery.setExpectationObject(expectationObject);
expectationList.add(delivery);
assurance.setExpectationName("assuranceExpectation");
assurance.setExpectationType(ExpectationType.ASSURANCE);
ExpectationObject expectationObject1 = new ExpectationObject();
- expectationObject1.setObjectType(ObjectType.OBJECT2);
+ expectationObject1.setObjectType(ObjectType.CCVPN);
//expetationTarget Context FulfilmentInfo is empty
assurance.setExpectationObject(expectationObject1);
expectationList.add(assurance);
delivery.setExpectationName("deliveryExpectation");
delivery.setExpectationType(ExpectationType.DELIVERY);
ExpectationObject expectationObject = new ExpectationObject();
- expectationObject.setObjectType(ObjectType.OBJECT1);
+ expectationObject.setObjectType(ObjectType.SLICING);
//expetationTarget Context FulfilmentInfo is empty
delivery.setExpectationObject(expectationObject);
List<ExpectationTarget> expectationTargets = new ArrayList<>();
assurance.setExpectationName("assuranceExpectation");
assurance.setExpectationType(ExpectationType.ASSURANCE);
ExpectationObject expectationObject1 = new ExpectationObject();
- expectationObject1.setObjectType(ObjectType.OBJECT2);
+ expectationObject1.setObjectType(ObjectType.CCVPN);
//expetationTarget Context FulfilmentInfo is empty
assurance.setExpectationObject(expectationObject1);
delivery.setExpectationName("deliveryExpectation");
delivery.setExpectationType(ExpectationType.DELIVERY);
ExpectationObject expectationObject = new ExpectationObject();
- expectationObject.setObjectType(ObjectType.OBJECT1);
+ expectationObject.setObjectType(ObjectType.SLICING);
//expetationTarget Context FulfilmentInfo is empty
delivery.setExpectationObject(expectationObject);
expectationList.add(delivery);
assurance.setExpectationName("assuranceExpectation");
assurance.setExpectationType(ExpectationType.ASSURANCE);
ExpectationObject expectationObject1 = new ExpectationObject();
- expectationObject1.setObjectType(ObjectType.OBJECT2);
+ expectationObject1.setObjectType(ObjectType.CCVPN);
//expetationTarget Context FulfilmentInfo is empty
assurance.setExpectationObject(expectationObject1);
expectationList.add(assurance);
delivery.setExpectationName("deliveryExpectation");
delivery.setExpectationType(ExpectationType.DELIVERY);
ExpectationObject expectationObject = new ExpectationObject();
- expectationObject.setObjectType(ObjectType.OBJECT1);
+ expectationObject.setObjectType(ObjectType.SLICING);
//expetationTarget Context FulfilmentInfo is empty
delivery.setExpectationObject(expectationObject);
expectationList.add(delivery);
assurance.setExpectationName("assuranceExpectation");
assurance.setExpectationType(ExpectationType.ASSURANCE);
ExpectationObject expectationObject1 = new ExpectationObject();
- expectationObject1.setObjectType(ObjectType.OBJECT2);
+ expectationObject1.setObjectType(ObjectType.CCVPN);
//expetationTarget Context FulfilmentInfo is empty
assurance.setExpectationObject(expectationObject1);
expectationList.add(assurance);
delivery.setExpectationName("deliveryExpectation");
delivery.setExpectationType(ExpectationType.DELIVERY);
ExpectationObject expectationObject = new ExpectationObject();
- expectationObject.setObjectType(ObjectType.OBJECT1);
+ expectationObject.setObjectType(ObjectType.SLICING);
//expetationTarget Context FulfilmentInfo is empty
delivery.setExpectationObject(expectationObject);
expectationList.add(delivery);
assurance.setExpectationName("assuranceExpectation");
assurance.setExpectationType(ExpectationType.ASSURANCE);
ExpectationObject expectationObject1 = new ExpectationObject();
- expectationObject1.setObjectType(ObjectType.OBJECT2);
+ expectationObject1.setObjectType(ObjectType.CCVPN);
//expetationTarget Context FulfilmentInfo is empty
assurance.setExpectationObject(expectationObject1);
expectationList.add(assurance);
delivery.setExpectationName("deliveryExpectation");
delivery.setExpectationType(ExpectationType.DELIVERY);
ExpectationObject expectationObject = new ExpectationObject();
- expectationObject.setObjectType(ObjectType.OBJECT1);
+ expectationObject.setObjectType(ObjectType.SLICING);
//expetationTarget Context FulfilmentInfo is empty
delivery.setExpectationObject(expectationObject);
expectationList.add(delivery);
assurance.setExpectationName("assuranceExpectation");
assurance.setExpectationType(ExpectationType.ASSURANCE);
ExpectationObject expectationObject1 = new ExpectationObject();
- expectationObject1.setObjectType(ObjectType.OBJECT2);
+ expectationObject1.setObjectType(ObjectType.CCVPN);
//expetationTarget Context FulfilmentInfo is empty
assurance.setExpectationObject(expectationObject1);
expectationList.add(assurance);
delivery.setExpectationName("deliveryExpectation");
delivery.setExpectationType(ExpectationType.DELIVERY);
ExpectationObject expectationObject = new ExpectationObject();
- expectationObject.setObjectType(ObjectType.OBJECT1);
+ expectationObject.setObjectType(ObjectType.SLICING);
//expetationTarget Context FulfilmentInfo is empty
delivery.setExpectationObject(expectationObject);
expectationList.add(delivery);
assurance.setExpectationName("assuranceExpectation");
assurance.setExpectationType(ExpectationType.ASSURANCE);
ExpectationObject expectationObject1 = new ExpectationObject();
- expectationObject1.setObjectType(ObjectType.OBJECT2);
+ expectationObject1.setObjectType(ObjectType.CCVPN);
//expetationTarget Context FulfilmentInfo is empty
assurance.setExpectationObject(expectationObject1);
expectationList.add(assurance);
delivery.setExpectationName("deliveryExpectation");
delivery.setExpectationType(ExpectationType.DELIVERY);
ExpectationObject expectationObject = new ExpectationObject();
- expectationObject.setObjectType(ObjectType.OBJECT1);
+ expectationObject.setObjectType(ObjectType.SLICING);
//expetationTarget Context FulfilmentInfo is empty
delivery.setExpectationObject(expectationObject);
expectationList.add(delivery);
assurance.setExpectationName("assuranceExpectation");
assurance.setExpectationType(ExpectationType.ASSURANCE);
ExpectationObject expectationObject1 = new ExpectationObject();
- expectationObject1.setObjectType(ObjectType.OBJECT2);
+ expectationObject1.setObjectType(ObjectType.CCVPN);
//expetationTarget Context FulfilmentInfo is empty
assurance.setExpectationObject(expectationObject1);
expectationList.add(assurance);
public ExpectationObject createTestObject(String testName) {
ExpectationObject expectationObject = new ExpectationObject();
- expectationObject.setObjectType(ObjectType.OBJECT1);
+ expectationObject.setObjectType(ObjectType.SLICING);
expectationObject.setObjectInstance("true");
List<Context> contextList = new ArrayList<>();
@Test
void testUpdateExpectationObjectToNullSuccess() {
ExpectationObject expectationObject = new ExpectationObject();
- expectationObject.setObjectType(ObjectType.OBJECT2);
+ expectationObject.setObjectType(ObjectType.CCVPN);
try {
expectationObjectService.updateExpectationObject(expectationObject, TEST_EXPECTATION_ID_2);
public void itCanGetImfRegInfoListWithIntentGoalBean() {
List<IntentManagementFunctionRegInfo> list = new ArrayList<>();
IntentManagementFunctionRegInfo info = new IntentManagementFunctionRegInfo();
- List<SupportArea> areas = new ArrayList<>();
- areas.add(SupportArea.CLLBUSINESS);
- info.setSupportArea(areas);
+ info.setSupportArea("CLLBUSINESS");
- List<SupportInterface> interList = new ArrayList<>();
- interList.add(SupportInterface.CREATE);
- info.setSupportInterfaces(interList);
+ info.setSupportInterfaces("CREATE");
list.add(info);
-- Records of intent_management_function_reg_info
-- ----------------------------
INSERT INTO intent_management_function_reg_info(imfr_info_id,imfr_info_description,support_area,support_model,support_interfaces,handle_name,intent_function_type)
-VALUES ('CLLBusinessId','CLLBusiness','{"CLLBUSINESS"}',null,'{"CREATE","DELETE","UPDATE","SEARCH"}','CLLBusinessIntentManagementFunction','INTERNALFUNCTION');
+VALUES ('CLLBusinessId','CLLBusiness','CLLBUSINESS',null,'CREATE,DELETE,UPDATE,SEARCH}','CLLBusinessIntentManagementFunction','INTERNALFUNCTION');
INSERT INTO intent_management_function_reg_info(imfr_info_id,imfr_info_description,support_area,support_model,support_interfaces,handle_name,intent_function_type)
-VALUES ('CLLDeliveryId','CLLDelivery','{"CLLBUSINESS","DELIVERY"}',null,'{"CREATE","DELETE","UPDATE","SEARCH"}','CLLDeliveryIntentManagementFunction','INTERNALFUNCTION');
+VALUES ('CLLDeliveryId','CLLDelivery','CLLBUSINESS,DELIVERY',null,'CREATE,DELETE,UPDATE,SEARCH}','CLLDeliveryIntentManagementFunction','INTERNALFUNCTION');
INSERT INTO intent_management_function_reg_info(imfr_info_id,imfr_info_description,support_area,support_model,support_interfaces,handle_name,intent_function_type)
-VALUES ('CLLAssuranceId','CLLAssurance','{"CLLBUSINESS","ASSURANCE"}',null,'{"CREATE","DELETE","UPDATE","SEARCH"}','CLLAssuranceIntentManagementFunction','INTERNALFUNCTION');
\ No newline at end of file
+VALUES ('CLLAssuranceId','CLLAssurance','CLLBUSINESS,ASSURANCE',null,'CREATE,DELETE,UPDATE,SEARCH','CLLAssuranceIntentManagementFunction','INTERNALFUNCTION');
\ No newline at end of file