From 6788e2dd2bf8f3de3b4efa4d809cd64d4c8781cf Mon Sep 17 00:00:00 2001 From: hekeguang Date: Thu, 22 Sep 2022 09:34:52 +0800 Subject: Add intent management registration code. Issue-ID: USECASEUI-696 Change-Id: I20500eaf08f6f41007478a21ff608071e393b54f Signed-off-by: hekeguang --- .../CLLBusinessDecisionModule.java | 2 +- .../intentanalysis/service/ImfRegInfoService.java | 4 +-- .../service/impl/ImfRegInfoServiceImpl.java | 33 +++++++++++++++++----- .../src/main/resources/intent-analysis-init.sql | 2 ++ .../resources/mybatis/sql/IMFRegInfoMapper.xml | 14 ++++++--- .../IntentProcessServiceTest.java | 15 ++++++++++ .../src/test/resources/intentdb-test-data.sql | 12 ++++++++ .../src/test/resources/intentdb-test-init.sql | 3 +- 8 files changed, 70 insertions(+), 15 deletions(-) (limited to 'intentanalysis') 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 95da991..bc07b79 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 @@ -52,7 +52,7 @@ public class CLLBusinessDecisionModule extends DecisionModule { 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()); } 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 c148975..f4f0242 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 @@ -23,8 +23,8 @@ import java.util.List; public interface ImfRegInfoService { int insertIMFRegInfoRegInfo(IntentManagementFunctionRegInfo regInfo); - List getImfRegInfoList(); - IntentManagementFunctionRegInfo getImfRegInfoList(IntentGoalBean intentGoalBean); + List getImfRegInfoList(); + IntentManagementFunctionRegInfo getImfRegInfo(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 ba1a4fe..595acad 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,7 +16,10 @@ 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; @@ -24,6 +27,7 @@ import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService; 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; @@ -35,7 +39,7 @@ public class ImfRegInfoServiceImpl implements ImfRegInfoService { private IMFRegInfoMapper imfRegInfoMapper; @Override - public int insertIMFRegInfoRegInfo(org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo regInfo) { + public int insertIMFRegInfoRegInfo(IntentManagementFunctionRegInfo regInfo) { return imfRegInfoMapper.insertIMFRegInfoRegInfo(regInfo); } @@ -45,20 +49,35 @@ public class ImfRegInfoServiceImpl implements ImfRegInfoService { } @Override - public IntentManagementFunctionRegInfo getImfRegInfoList(IntentGoalBean intentGoalBean) { + public IntentManagementFunctionRegInfo getImfRegInfo(IntentGoalBean intentGoalBean) { String intentName = intentGoalBean.getIntent().getIntentName(); IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType(); List imfRegInfoList = imfRegInfoMapper.getImfRegInfoList(); - List imfList = imfRegInfoList.stream(). - filter(x -> x.getSupportArea().contains(intentName) - && x.getSupportInterfaces().contains(intentGoalType)).collect(Collectors.toList()); + List 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 diff --git a/intentanalysis/src/main/resources/intent-analysis-init.sql b/intentanalysis/src/main/resources/intent-analysis-init.sql index d7c513c..e5af890 100644 --- a/intentanalysis/src/main/resources/intent-analysis-init.sql +++ b/intentanalysis/src/main/resources/intent-analysis-init.sql @@ -64,7 +64,9 @@ create table if not exists condition( 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 diff --git a/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml index 03af60b..fd632b3 100644 --- a/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml +++ b/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml @@ -2,16 +2,22 @@ + + + + + + - 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}) - + select * from intent_management_function_reg_info diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessServiceTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessServiceTest.java index 7836793..d58652c 100644 --- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessServiceTest.java +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessServiceTest.java @@ -1,3 +1,18 @@ +/* + * 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; diff --git a/intentanalysis/src/test/resources/intentdb-test-data.sql b/intentanalysis/src/test/resources/intentdb-test-data.sql index c03acd6..ec183fe 100644 --- a/intentanalysis/src/test/resources/intentdb-test-data.sql +++ b/intentanalysis/src/test/resources/intentdb-test-data.sql @@ -101,3 +101,15 @@ values ('intentId1', 'NOT_FULFILLED', 'COMPLIANT', 'NotFulfilledReason'); 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 diff --git a/intentanalysis/src/test/resources/intentdb-test-init.sql b/intentanalysis/src/test/resources/intentdb-test-init.sql index 3a60df7..06effe6 100644 --- a/intentanalysis/src/test/resources/intentdb-test-init.sql +++ b/intentanalysis/src/test/resources/intentdb-test-init.sql @@ -81,8 +81,9 @@ create table if not exists condition 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) ); - -- cgit 1.2.3-korg