public IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean) {
// db filter imf supportArea;
//SupportInterface> supportInterfaces;
- IntentManagementFunctionRegInfo imfRegInfo = imfRegInfoService.getImfRegInfoList(intentGoalBean);
+ IntentManagementFunctionRegInfo imfRegInfo = imfRegInfoService.getImfRegInfo(intentGoalBean);
return (IntentManagementFunction) applicationContext.getBean(imfRegInfo.getHandleName());
}
public interface ImfRegInfoService {
int insertIMFRegInfoRegInfo(IntentManagementFunctionRegInfo regInfo);
- List<IntentManagementFunctionRegInfo> getImfRegInfoList();
- IntentManagementFunctionRegInfo getImfRegInfoList(IntentGoalBean intentGoalBean);
+ List<IntentManagementFunctionRegInfo> getImfRegInfoList();
+ IntentManagementFunctionRegInfo getImfRegInfo(IntentGoalBean intentGoalBean);
}
package org.onap.usecaseui.intentanalysis.service.impl;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
+import org.onap.usecaseui.intentanalysis.bean.enums.SupportArea;
+import org.onap.usecaseui.intentanalysis.bean.enums.SupportInterface;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
private IMFRegInfoMapper imfRegInfoMapper;
@Override
- public int insertIMFRegInfoRegInfo(org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo regInfo) {
+ public int insertIMFRegInfoRegInfo(IntentManagementFunctionRegInfo regInfo) {
return imfRegInfoMapper.insertIMFRegInfoRegInfo(regInfo);
}
}
@Override
- public IntentManagementFunctionRegInfo getImfRegInfoList(IntentGoalBean intentGoalBean) {
+ public IntentManagementFunctionRegInfo getImfRegInfo(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());
+ List<IntentManagementFunctionRegInfo> imfList = new ArrayList<>();
+ for (IntentManagementFunctionRegInfo imfr : imfRegInfoList) {
+ boolean containsArea = false;
+ boolean containsInterface = false;
+ for (SupportArea area : imfr.getSupportArea()) {
+ if (StringUtils.containsIgnoreCase(intentName, area.name())) {
+ containsArea = true;
+ break;
+ }
+ }
+ for (SupportInterface supInterface : imfr.getSupportInterfaces()) {
+ if (StringUtils.containsIgnoreCase(supInterface.name(), intentGoalType.name())) {
+ containsInterface = true;
+ break;
+ }
+ }
+ if (containsArea && containsInterface) {
+ imfList.add(imfr);
+ }
+ }
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
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_model varchar(255),
+ support_interfaces text ARRAY,
handle_name varchar(255),
intent_function_type varchar(255)
);
\ No newline at end of file
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
<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_model,handle_name,intent_function_type)
+ 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.supportModel},#{imfregInfo.handleName},#{imfregInfo.intentFunctionType})
+ (#{imfregInfo.id}, #{imfregInfo.description},#{imfregInfo.supportArea} , #{imfregInfo.supportModel},#{imfregInfo.supportInterfaces},#{imfregInfo.handleName},#{imfregInfo.intentFunctionType})
</insert>
- <select id="getImfRegInfoList" resultType="org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo">
- select * from intent_management_function_reg_info
+ <select id="getImfRegInfoList" resultMap="mapIMFRInfo">
+ select * from intent_management_function_reg_info
</select>
</mapper>
+/*
+ * 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.intentProcessService;
import org.junit.Assert;
MERGE INTO fulfilment_info (fulfilment_info_id, fulfilment_info_status, not_fulfilled_state, not_fulfilled_reason) KEY (fulfilment_info_id)
values ('intentId2', 'NOT_FULFILLED', 'COMPLIANT', 'NotFulfilledReason');
+
+-- ----------------------------
+-- 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');
+
+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');
+
+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
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_model varchar(255),
+ support_interfaces text ARRAY,
handle_name varchar(255),
intent_function_type varchar(255)
);
-