diff options
33 files changed, 1329 insertions, 75 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAPICall.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAPICall.java new file mode 100644 index 0000000..ead4d2c --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/aai/apicall/AAIAPICall.java @@ -0,0 +1,25 @@ +/* + * Copyright 2022 Huawei Technologies Co., Ltd. + * + * 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.adapters.aai.apicall; + +import com.alibaba.fastjson.JSONObject; +import retrofit2.Call; +import retrofit2.http.GET; + +public interface AAIAPICall { + @GET("/aai/v24/network/network-routes") + Call<JSONObject> queryNetworkRoute(); +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/SOService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/SOService.java index 92ef65c..4129b8e 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/SOService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/SOService.java @@ -15,4 +15,12 @@ */ package org.onap.usecaseui.intentanalysis.adapters.so; -public interface SOService { } +import org.onap.usecaseui.intentanalysis.bean.models.CCVPNInstance; + +public interface SOService { + + int createCCVPNInstance(CCVPNInstance instance); + + void deleteIntentInstance(String instanceId); + +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAPICall.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAPICall.java new file mode 100644 index 0000000..11fae26 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/apicall/SOAPICall.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Huawei Technologies Co., Ltd. + * + * 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.adapters.so.apicall; + +import com.alibaba.fastjson.JSONObject; +import okhttp3.RequestBody; +import retrofit2.Call; +import retrofit2.http.*; + +public interface SOAPICall { + @Headers({ + "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==", + "Accept: application/json" + }) + @POST("/so/infra/serviceIntent/v1/create") + Call<JSONObject> createIntentInstance(@Body RequestBody body); + + @Headers({ + "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==", + "Accept: application/json" + }) + @HTTP(method="DELETE", path="/so/infra/serviceIntent/v1/delete", hasBody = true) + Call<JSONObject> deleteIntentInstance(@Body RequestBody body); + + @Headers({ + "X-TransactionId: 9999", + "X-FromAppId: MSO", + "Authorization: Basic QUFJOkFBSQ==", + "Accept: application/json" + }) + @GET("/aai/v24/business/customers/customer/IBNCustomer/service-subscriptions/service-subscription/IBN/service-instances/service-instance/{resource-service-id}") + Call<JSONObject> getInstanceInfo(@Path("resource-service-id") String resourceServiceId); + +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java new file mode 100644 index 0000000..7f34584 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/so/impl/SOServiceImpl.java @@ -0,0 +1,176 @@ +/* + * Copyright 2022 Huawei Technologies Co., Ltd. + * + * 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.adapters.so.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import org.onap.usecaseui.intentanalysis.adapters.so.SOService; +import org.onap.usecaseui.intentanalysis.adapters.so.apicall.SOAPICall; +import org.onap.usecaseui.intentanalysis.bean.models.CCVPNInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import retrofit2.Response; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SOServiceImpl implements SOService { + + private static final Logger logger = LoggerFactory.getLogger(SOServiceImpl.class); + + + private SOAPICall soapiCall; + + @Override + public int createCCVPNInstance(CCVPNInstance ccvpnInstance) { + try{ + if (null == ccvpnInstance){ + logger.error("CCVPN instance is null!"); + return 0; + } + String jobId = createIntentInstanceToSO(ccvpnInstance); + if (null == jobId){ + logger.error("CCVPN instance creation error:jobId is null"); + return 0; + } + ccvpnInstance.setJobId(jobId); + ccvpnInstance.setResourceInstanceId("cll-"+ccvpnInstance.getInstanceId()); + + long startTime = System.currentTimeMillis(); + long maxWaitingPeriod = 30 * 1000; // wait for 30s + while (getCreateStatus(ccvpnInstance) != 1){ + if((System.currentTimeMillis() - startTime) > maxWaitingPeriod) { + logger.error("CCVPN instance creation error: failed to send to so within time frame"); + return 0; + } + } + // creation status equals to 1 + return 1; + } catch (Exception e) { + logger.error("Details:" + e.getMessage()); + return 0; + } + } + + @Override + public void deleteIntentInstance(String serviceInstanceId) { + try { + deleteInstanceToSO(serviceInstanceId); + }catch (Exception e) { + logger.error("delete instance to SO error :" + e); + } + } + + public String createIntentInstanceToSO(CCVPNInstance ccvpnInstance) throws IOException { + Map<String, Object> params = paramsSetUp(ccvpnInstance); + params.put("additionalProperties",additionalPropertiesSetUp(ccvpnInstance)); + okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params)); + Response<JSONObject> response = soapiCall.createIntentInstance(requestBody).execute(); + if (response.isSuccessful()) { + return response.body().getString("jobId"); + } + return null; + } + + private void deleteInstanceToSO(String serviceInstanceId) throws IOException { + JSONObject params = new JSONObject(); + params.put("serviceInstanceID", serviceInstanceId); + params.put("globalSubscriberId", "IBNCustomer"); + params.put("subscriptionServiceType", "IBN"); + params.put("serviceType", "CLL"); + JSONObject additionalProperties = new JSONObject(); + additionalProperties.put("enableSdnc", "true"); + params.put("additionalProperties", additionalProperties); + okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json"), JSON.toJSONString(params)); + soapiCall.deleteIntentInstance(requestBody).execute(); + } + + private int getCreateStatus(CCVPNInstance ccvpnInstance) throws IOException { + if (ccvpnInstance == null || ccvpnInstance.getResourceInstanceId() == null) { + return -1; + } + Response<JSONObject> response = soapiCall.getInstanceInfo(ccvpnInstance.getResourceInstanceId()).execute(); + logger.debug(response.toString()); + if (response.isSuccessful()) { + String status = response.body().getString("orchestration-status"); + if ("created".equals(status)) { + return 1; + } + } + logger.error("getIntentInstance Create Statue Error:" + response.toString()); + return -1; + } + + /** + * parameter set up for ccpvpn instance creation + * @param ccvpnInstance + * @return + */ + private Map<String, Object> paramsSetUp(CCVPNInstance ccvpnInstance) { + Map<String, Object> params = new HashMap<>(); + params.put("name", ccvpnInstance.getName()); + params.put("modelInvariantUuid", "6790ab0e-034f-11eb-adc1-0242ac120002"); + params.put("modelUuid", "6790ab0e-034f-11eb-adc1-0242ac120002"); + params.put("globalSubscriberId", "IBNCustomer"); + params.put("subscriptionServiceType", "IBN"); + params.put("serviceType", "CLL"); + return params; + } + + /** + * additional properties set up for ccvpn instance creation + * @param ccvpnInstance + * @return + */ + private Map<String, Object> additionalPropertiesSetUp(CCVPNInstance ccvpnInstance) { + Map<String, Object> additionalProperties = new HashMap<>(); + additionalProperties.put("enableSdnc", "true"); + additionalProperties.put("serviceInstanceID", "cll-" + ccvpnInstance.getInstanceId()); + + // create connection link + Map<String, Object> connectionLink = new HashMap<>(); + connectionLink.put("name", ""); + connectionLink.put("transportEndpointA", ccvpnInstance.getAccessPointOneName()); + connectionLink.put("transportEndpointB", ccvpnInstance.getCloudPointName()); + + // create sla + Map<String, Object> sla = new HashMap<>(); + sla.put("latency", "2"); + sla.put("maxBandwidth", ccvpnInstance.getAccessPointOneBandWidth()); + + // configuration for sla and connection link + if (ccvpnInstance.getProtectStatus() == 1) { + sla.put("protectionType", ccvpnInstance.getProtectionType()); + connectionLink.put("transportEndpointBProtection", ccvpnInstance.getProtectionCloudPointName()); + } + + List<Map<String, Object>> connectionLinks = new ArrayList<>(); + connectionLinks.add(connectionLink); + + Map<String, Object> transportNetwork = new HashMap<>(); + transportNetwork.put("id", ""); + transportNetwork.put("sla", sla); + transportNetwork.put("connectionLinks", connectionLinks); + + List<Map<String, Object>> transportNetworks = new ArrayList<>(); + transportNetworks.add(transportNetwork); + additionalProperties.put("transportNetworks", transportNetworks); + return additionalProperties; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/CCVPNInstance.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/CCVPNInstance.java new file mode 100644 index 0000000..b5d73f1 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/CCVPNInstance.java @@ -0,0 +1,58 @@ +package org.onap.usecaseui.intentanalysis.bean.models; + +import lombok.Data; +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Table(name="ccvpn_instance") +@Data + +public class CCVPNInstance implements Serializable { + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + @Column(name = "id") + private int id; + + @Column(name = "instance_id") + private String instanceId; + + @Column(name = "job_id") + private String jobId; + + @Column(name = "progress") + private int progress; + + @Column(name = "status") + private String status; + + @Column(name = "resource_instance_id") + private String resourceInstanceId; + + @Column(name = "name") + private String name; + + @Column(name = "cloud_point_name") + private String cloudPointName; + + @Column(name = "access_point_one_name") + private String accessPointOneName; + + @Column(name = "access_point_one_band_width") + private int accessPointOneBandWidth; + + @Column(name = "line_num") + private String lineNum; + + @Column(name = "protect_status") + private int protectStatus; + + @Column(name = "delete_state") + private int deleteState; + + @Column(name = "protection_cloud_point_name") + private String protectionCloudPointName; + + @Column(name = "protection_type") + private String protectionType; +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessActuationModule.java index 4209c1b..acd580f 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessActuationModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessActuationModule.java @@ -16,12 +16,15 @@ package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule; +import org.apache.commons.lang.StringUtils; +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.intentModule.ActuationModule; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService; import org.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,7 +32,6 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; @Service @@ -40,6 +42,8 @@ public class CLLBusinessActuationModule implements ActuationModule { IntentHandleService intentHandleService; @Autowired IntentService intentService; + @Autowired + IntentInterfaceService intentInterfaceService; @Override @@ -57,16 +61,31 @@ public class CLLBusinessActuationModule implements ActuationModule { } @Override - public void saveIntentToDb(List<Map<IntentGoalBean,IntentManagementFunction>> intentMapList) { + public void saveIntentToDb(List<Map<IntentGoalBean, IntentManagementFunction>> intentMapList) { List<IntentGoalBean> subIntentGoalLit = new ArrayList<>(); - for (Map<IntentGoalBean,IntentManagementFunction> map:intentMapList) { + for (Map<IntentGoalBean, IntentManagementFunction> map : intentMapList) { subIntentGoalLit.addAll(map.keySet()); } List<Intent> subIntentList = subIntentGoalLit.stream().map(IntentGoalBean::getIntent) .collect(Collectors.toList()); - for (Intent subIntent:subIntentList) { + for (Intent subIntent : subIntentList) { intentService.createIntent(subIntent); } } + + @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; + } } 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 bcda367..3313af5 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 @@ -51,17 +51,8 @@ public class CLLBusinessDecisionModule implements DecisionModule { public IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean) { // db filter imf supportArea; //SupportInterface> supportInterfaces; - IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType(); - String intentName = intentGoalBean.getIntent().getIntentName(); - List<IntentManagementFunctionRegInfo> imfRegInfoList = imfRegInfoService.getImfRegInfoList(); - //todo - List<IntentManagementFunctionRegInfo> imfList = imfRegInfoList.stream(). - filter(x -> x.getSupportArea().contains(intentName) - && x.getSupportInterfaces().contains(intentGoalType)).collect(Collectors.toList()); - if (!Optional.ofNullable(imfList).isPresent()) { - log.info("The intent name is %s not find the corresponding IntentManagementFunction", intentName); - } - return (IntentManagementFunction) applicationContext.getBean(imfList.get(0).getHandleName()); + IntentManagementFunctionRegInfo imfRegInfo = imfRegInfoService.getImfRegInfoList(intentGoalBean); + return (IntentManagementFunction) applicationContext.getBean(imfRegInfo.getHandleName()); } @Override @@ -146,7 +137,6 @@ public class CLLBusinessDecisionModule implements DecisionModule { for (IntentGoalBean subIntentGoal : sortList) { Map<IntentGoalBean, IntentManagementFunction> map = new HashMap<>(); IntentManagementFunction imf = exploreIntentHandlers(subIntentGoal); - //TODO call probe interface if fail intentFulfilmentInfo throw exception map.put(subIntentGoal, imf); intentMapList.add(map); } @@ -157,4 +147,5 @@ public class CLLBusinessDecisionModule implements DecisionModule { } return intentMapList; } + } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java index 372b0d5..c7d0872 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java @@ -22,6 +22,7 @@ import org.onap.usecaseui.intentanalysis.bean.models.Expectation; import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget; import org.onap.usecaseui.intentanalysis.bean.models.Intent; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentDetectionService; import org.onap.usecaseui.intentanalysis.service.IntentService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,56 +39,29 @@ public class CLLBusinessKnowledgeModule implements KnowledgeModule { @Autowired IntentService intentService; + @Autowired + IntentDetectionService intentDetectionService; @Override public IntentGoalBean intentCognition(Intent intent) { - List<String> intendIdList = intentResolution(intent); + List<String> intendIdList = intentDetectionService.intentResolution(intent); getSystemStatus(); return determineDetectionGoal(intent, intendIdList); } - /** - * find similar intents in DB - * - * @param intent - */ + @Override + public boolean recieveCreateIntent() { + return false; + } - 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)) { - List<Expectation> expectationList = intent.getIntentExpectations(); - for (Intent dbIntent : sameNameIntentList) { - 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; + @Override + public boolean recieveUpdateIntent() { + return false; + } + + @Override + public boolean recieveDeleteIntent() { + return false; } void intentReportResolution() { diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java new file mode 100644 index 0000000..235d638 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java @@ -0,0 +1,30 @@ +/* + * 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.formatintentinputMgt; + +import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputActuationModule; +import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputDecisionModule; +import org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule.FormatIntentInputKnowledgeModule; +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 FormatIntentInputManagementFunction extends IntentManagementFunction { + private ActuationModule actuationModule = new FormatIntentInputActuationModule(); + private DecisionModule decisoinModule = new FormatIntentInputDecisionModule(); + private KnowledgeModule knowledgeModule = new FormatIntentInputKnowledgeModule(); +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputActuationModule.java new file mode 100644 index 0000000..e556356 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputActuationModule.java @@ -0,0 +1,47 @@ +/* + * 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.formatintentinputMgt.formatintentinputModule; + +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; +import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; + +import java.util.List; +import java.util.Map; + +public class FormatIntentInputActuationModule implements ActuationModule { + @Override + public void sendToIntentHandler(IntentManagementFunction IntentHandler) { + } + + @Override + public void sendToNonIntentHandler() { + } + + @Override + public void interactWithIntentHandle() { + } + + @Override + public void saveIntentToDb(List<Map<IntentGoalBean, IntentManagementFunction>> intentMapList) { + // + } + + @Override + public boolean distrubuteIntentToHandler(Map<IntentGoalBean, IntentManagementFunction> intentMap) { + return false; + } +} 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 new file mode 100644 index 0000000..af29747 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java @@ -0,0 +1,89 @@ +/* + * 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.formatintentinputMgt.formatintentinputModule; + +import org.apache.commons.lang.StringUtils; +import org.onap.usecaseui.intentanalysis.bean.models.Expectation; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; +import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class FormatIntentInputDecisionModule implements DecisionModule { + @Autowired + ApplicationContext applicationContext; + + @Override + public void determineUltimateGoal() { + } + + @Override + public IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean) { + // if intentName contain cll return + if (StringUtils.equalsIgnoreCase(intentGoalBean.getIntent().getIntentName(), "cll")) { + return (IntentManagementFunction) applicationContext.getBean(CLLBusinessIntentManagementFunction.class.getName()); + } + return null; + } + + @Override + public void intentDefinition() { + } + + @Override + public void decideSuitableAction() { + } + + @Override + public void interactWithTemplateDb() { + } + + @Override + public List<Map<IntentGoalBean, IntentManagementFunction>> findHandler(IntentGoalBean intentGoalBean) { + boolean needDecompostion = needDecompostion(intentGoalBean); + if (needDecompostion) { + intentDecomposition(intentGoalBean); + } + exploreIntentHandlers(intentGoalBean); + return null; + } + + public boolean needDecompostion(IntentGoalBean intentGoalBean) { + //expectationName just contain cll and slicing need decompost + List<Expectation> intentExpectations = intentGoalBean.getIntent().getIntentExpectations(); + List<String> expectationNameList = intentExpectations.stream().map(Expectation::getExpectationName) + .distinct().collect(Collectors.toList()); + if (expectationNameList.size() > 1) { + List<String> cllList = expectationNameList.stream().filter(x -> StringUtils.equalsIgnoreCase(x, "cll")).collect(Collectors.toList()); + List<String> slicingList = expectationNameList.stream().filter(x -> StringUtils.equalsIgnoreCase(x, "slicing")).collect(Collectors.toList()); + if (cllList.size() > 0 && slicingList.size() > 0) { + return true; + } + } + return false; + } + + public List<IntentGoalBean> intentDecomposition(IntentGoalBean intentGoalBean) { + //todo + return null; + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputKnowledgeModule.java new file mode 100644 index 0000000..d6952f4 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputKnowledgeModule.java @@ -0,0 +1,64 @@ +/* + * 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.formatintentinputMgt.formatintentinputModule; + +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.intentModule.KnowledgeModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentDetectionService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +public class FormatIntentInputKnowledgeModule implements KnowledgeModule { + @Autowired + IntentDetectionService intentDetectionService; + + @Override + public IntentGoalBean intentCognition(Intent intent) { + List<String> intendIdList = intentDetectionService.intentResolution(intent); + getSystemStatus(); + return determineDetectionGoal(intent, intendIdList); + } + + @Override + public boolean recieveCreateIntent() { + return false; + } + + @Override + public boolean recieveUpdateIntent() { + return false; + } + + @Override + public boolean recieveDeleteIntent() { + return false; + } + + public void getSystemStatus() { + } + + public IntentGoalBean determineDetectionGoal(Intent intent, List<String> intentIdList) { + int size = intentIdList.size(); + if (size == 0) { + return new IntentGoalBean(intent, IntentGoalType.CREATE); + } else { + return new IntentGoalBean(intent, IntentGoalType.UPDATE); + } + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java index 2d420d7..1f18c52 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java @@ -42,7 +42,7 @@ public class IntentHandleService { /** * Process the original intent and find the corresponding IntentManagementFunction * - * @param intent + * @param intent todo */ public void handleOriginalIntent(Intent intent) { IntentManagementFunction intentOwner = getOriginalIMF(intent); diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/ActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/ActuationModule.java index 2800c1e..8f753e4 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/ActuationModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/ActuationModule.java @@ -28,5 +28,6 @@ public interface ActuationModule { void interactWithIntentHandle(); //Save intent information to the intent instance database void saveIntentToDb(List<Map<IntentGoalBean,IntentManagementFunction>> intentMapList); + boolean distrubuteIntentToHandler(Map<IntentGoalBean,IntentManagementFunction> intentMap); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java index 76601a8..113d50d 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java @@ -25,6 +25,7 @@ import java.util.Map; public interface DecisionModule { void determineUltimateGoal(); + // find intentManageFunction IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean); void intentDefinition(); @@ -34,4 +35,5 @@ public interface DecisionModule { public void interactWithTemplateDb(); public List<Map<IntentGoalBean, IntentManagementFunction>> findHandler(IntentGoalBean intentGoalBean); + } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java index d5caf1f..818b812 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java @@ -21,4 +21,9 @@ import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; public interface KnowledgeModule { //Parse, decompose, orchestrate the original intent IntentGoalBean intentCognition(Intent intent); + + // in distribution, ask permission from imf + boolean recieveCreateIntent();// ·Ö¿ªÐ´ + boolean recieveUpdateIntent(); + boolean recieveDeleteIntent(); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java index 699c1b1..3273925 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java @@ -15,24 +15,34 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; -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.enums.OperatorType; +import org.onap.usecaseui.intentanalysis.bean.models.*; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule; +import org.onap.usecaseui.intentanalysis.service.IntentService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + @Service public class IntentDetectionService { private IntentManagementFunction intentHandler; private IntentManagementFunction intentOwner; + @Autowired + IntentService intentService; - public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){ - if (intentOwner!= null){ + public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { + if (intentOwner != null) { this.intentOwner = intentOwner; } - if (intentHandler!= null){ - this.intentHandler= intentHandler; + if (intentHandler != null) { + this.intentHandler = intentHandler; } } @@ -41,4 +51,73 @@ public class IntentDetectionService { 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; + } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java index 4622aa1..d803718 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java @@ -16,29 +16,54 @@ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; +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.intentModule.ActuationModule; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Map; + @Service public class IntentDistributionService { private IntentManagementFunction intentHandler; private IntentManagementFunction intentOwner; - public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){ - if (intentOwner!= null){ + @Autowired + IntentInterfaceService intentInterfaceService; + + public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { + if (intentOwner != null) { this.intentOwner = intentOwner; } - if (intentHandler!= null){ - this.intentHandler= intentHandler; + if (intentHandler != null) { + this.intentHandler = intentHandler; } } - public void distributionProcess() { - ActuationModule intentActuationModule = intentHandler.getActuationModule(); + public boolean distributionProcess(Map<IntentGoalBean, IntentManagementFunction> intentMap) { - intentActuationModule.sendToIntentHandler(intentHandler); + intentOwner.getActuationModule().distrubuteIntentToHandler(intentMap); + 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; + } } + diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java index ec4037e..5d4a5dc 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java @@ -66,7 +66,7 @@ public class IntentProcessService { //distribution process intentDistributionService.setIntentRole(intentOwner,intentHandler); - intentDistributionService.distributionProcess(); + intentDistributionService.distributionProcess(map); //operation process intentOperationService.setIntentRole(intentOwner,intentHandler); diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java new file mode 100644 index 0000000..4470d05 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java @@ -0,0 +1,27 @@ +/* + * 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.intentinterfaceservice; + +import org.onap.usecaseui.intentanalysis.bean.models.Intent; +import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; + +public interface IntentInterfaceService { + public boolean createInterface(Intent intent, IntentManagementFunction imf); + + public boolean updateInterface(Intent intent, IntentManagementFunction imf); + + public boolean deleteInterface(Intent intent, IntentManagementFunction imf); +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java new file mode 100644 index 0000000..1c6d853 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java @@ -0,0 +1,43 @@ +/* + * 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.intentinterfaceservice.impl; + +import org.onap.usecaseui.intentanalysis.bean.models.Intent; +import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService; +import org.springframework.stereotype.Service; + +@Service +public class IntentInterfaceServiceImpl implements IntentInterfaceService { + @Override + public boolean createInterface(Intent intent, IntentManagementFunction imf) { + //ask knowledgeModole of handler imf for permision + imf.getKnowledgeModule().recieveCreateIntent(); + return false; + } + + @Override + public boolean updateInterface(Intent intent, IntentManagementFunction imf) { + imf.getKnowledgeModule().recieveUpdateIntent(); + return false; + } + + @Override + public boolean deleteInterface(Intent intent, IntentManagementFunction imf) { + imf.getKnowledgeModule().recieveDeleteIntent(); + return false; + } +} 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 0d7a6b1..c148975 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 @@ -15,6 +15,7 @@ */ package org.onap.usecaseui.intentanalysis.service; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo; import java.util.List; @@ -23,4 +24,7 @@ public interface ImfRegInfoService { int insertIMFRegInfoRegInfo(IntentManagementFunctionRegInfo regInfo); List<IntentManagementFunctionRegInfo> getImfRegInfoList(); + IntentManagementFunctionRegInfo getImfRegInfoList(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 9fdc3ba..ba1a4fe 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,8 @@ package org.onap.usecaseui.intentanalysis.service.impl; import lombok.extern.slf4j.Slf4j; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; +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.onap.usecaseui.intentanalysis.service.ImfRegInfoService; @@ -23,6 +25,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; @Service @Slf4j @@ -39,4 +43,22 @@ public class ImfRegInfoServiceImpl implements ImfRegInfoService { public List<IntentManagementFunctionRegInfo> getImfRegInfoList() { return imfRegInfoMapper.getImfRegInfoList(); } + + @Override + public IntentManagementFunctionRegInfo getImfRegInfoList(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()); + 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/test/java/org/onap/usecaseui/intentanalysis/bean/models/ConditionTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ConditionTest.java new file mode 100644 index 0000000..49f2cb5 --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ConditionTest.java @@ -0,0 +1,53 @@ +/* + * 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.bean.models; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType; + +import java.util.ArrayList; + +public class ConditionTest { + @Before + public void before() throws Exception { + } + + @After + public void after() throws Exception { + } + + @Test + public void testSetConditionTest() throws Exception { + Condition condition = new Condition(); + condition.setConditionId(""); + condition.setConditionName(""); + condition.setOperator(OperatorType.valueOf("OR")); + condition.setConditionValue(""); + condition.setConditionList(new ArrayList<Condition>()); + } + + @Test + public void testGetConditionTest() throws Exception{ + Condition condition = new Condition(); + condition.getConditionId(); + condition.getConditionName(); + condition.getOperator(); + condition.getConditionValue(); + condition.getConditionList(); + } +} diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ContextTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ContextTest.java new file mode 100644 index 0000000..5ead1c8 --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ContextTest.java @@ -0,0 +1,47 @@ +/* + * 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.bean.models; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; + +public class ContextTest { + @Before + public void before() throws Exception { + } + + @After + public void after() throws Exception { + } + @Test + public void testGetContestTest(){ + Context context = new Context(); + context.getContextId(); + context.getContextName(); + context.getContextConditions(); + } + @Test + public void testSetContestTest(){ + Context context = new Context(); + context.setContextId(""); + context.setContextName(""); + context.setContextConditions(new ArrayList<Condition>()); + } + +} diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObjectTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObjectTest.java new file mode 100644 index 0000000..52d8fbc --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObjectTest.java @@ -0,0 +1,49 @@ +/* + * 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.bean.models; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType; + +import java.util.ArrayList; + +public class ExpectationObjectTest { + @Before + public void before() throws Exception { + } + + @After + public void after() throws Exception { + } + + @Test + public void testGetExpectationObjectTest() { + ExpectationObject test = new ExpectationObject(); + test.getObjectType(); + test.getObjectInstance(); + test.getObjectContexts(); + } + + @Test + public void testSetExpectationObjectTest() { + ExpectationObject test = new ExpectationObject(); + test.setObjectType(ObjectType.OBJECT1); + test.setObjectInstance(""); + test.setObjectContexts(new ArrayList<>()); + } +} diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationTargetTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationTargetTest.java new file mode 100644 index 0000000..e879b11 --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationTargetTest.java @@ -0,0 +1,57 @@ +/* + * 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.bean.models; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType; + +import java.util.ArrayList; + +public class ExpectationTargetTest { + @Before + public void before() throws Exception { + } + + @After + public void after() throws Exception { + } + + @Test + public void testGetExpectationTest() { + Expectation test = new Expectation(); + test.getExpectationId(); + test.getExpectationName(); + test.getExpectationType(); + test.getExpectationObject(); + test.getExpectationTargets(); + test.getExpectationContexts(); + test.getExpectationFulfilmentInfo(); + } + + @Test + public void testSetExpectationTest() { + Expectation test = new Expectation(); + test.setExpectationId(""); + test.setExpectationName(""); + test.setExpectationType(ExpectationType.ASSURANCE); + test.setExpectationObject(new ExpectationObject()); + test.setExpectationTargets(new ArrayList<>()); + test.setExpectationContexts(new ArrayList<>()); + test.setExpectationFulfilmentInfo(new FulfilmentInfo()); + } +} diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationTest.java new file mode 100644 index 0000000..a3c2a09 --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationTest.java @@ -0,0 +1,57 @@ +/* + * 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.bean.models; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType; + +import java.util.ArrayList; + +public class ExpectationTest { + @Before + public void before() throws Exception { + } + + @After + public void after() throws Exception { + } + + @Test + public void testGetExpectationTest() { + Expectation test = new Expectation(); + test.getExpectationId(); + test.getExpectationContexts(); + test.getExpectationName(); + test.getExpectationType(); + test.getExpectationFulfilmentInfo(); + test.getExpectationObject(); + test.getExpectationTargets(); + } + + @Test + public void testSetExpectationTest() { + Expectation test = new Expectation(); + test.setExpectationId(""); + test.setExpectationContexts(new ArrayList<Context>()); + test.setExpectationName(""); + test.setExpectationTargets(new ArrayList<ExpectationTarget>()); + test.setExpectationType(ExpectationType.ASSURANCE); + test.setExpectationFulfilmentInfo(new FulfilmentInfo()); + test.setExpectationObject(new ExpectationObject()); + } +} diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/FulfilmentInfoTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/FulfilmentInfoTest.java new file mode 100644 index 0000000..24529fd --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/FulfilmentInfoTest.java @@ -0,0 +1,50 @@ +/* + * 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.bean.models; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.usecaseui.intentanalysis.bean.enums.FulfilmentStatus; +import org.onap.usecaseui.intentanalysis.bean.enums.NotFulfilledState; + +public class FulfilmentInfoTest { + @Before + public void before() throws Exception { + } + + @After + public void after() throws Exception { + } + + @Test + public void testGetFulfilmentInfoTest() { + FulfilmentInfo test = new FulfilmentInfo(); + test.getFulfilmentStatus(); + test.getNotFulfilledState(); + test.getNotFulfilledReason(); + + } + + @Test + public void testSetFulfilmentInfoTest() { + FulfilmentInfo test = new FulfilmentInfo(); + test.setFulfilmentStatus(FulfilmentStatus.FULFILLED); + test.setNotFulfilledState(NotFulfilledState.ACKNOWLEDGED); + test.setNotFulfilledReason(""); + + } +} diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/IntentGoalBeanTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/IntentGoalBeanTest.java new file mode 100644 index 0000000..8a5ac8a --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/IntentGoalBeanTest.java @@ -0,0 +1,45 @@ +/* + * 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.bean.models; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; + +public class IntentGoalBeanTest { + @Before + public void before() throws Exception { + } + + @After + public void after() throws Exception { + } + + @Test + public void testGetIntentGoalBeanTest() { + IntentGoalBean test = new IntentGoalBean(); + test.getIntent(); + test.getIntentGoalType(); + } + + @Test + public void testSetIntentGoalBeanTest() { + IntentGoalBean test = new IntentGoalBean(); + test.setIntent(new Intent()); + test.setIntentGoalType(IntentGoalType.DELETE); + } +} diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfoTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfoTest.java new file mode 100644 index 0000000..2368077 --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfoTest.java @@ -0,0 +1,59 @@ +/* + * 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.bean.models; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentFunctionType; +import org.onap.usecaseui.intentanalysis.bean.enums.SupportArea; + +import java.util.ArrayList; + +public class IntentManagementFunctionRegInfoTest { + @Before + public void before() throws Exception { + } + + @After + public void after() throws Exception { + } + + @Test + public void testGetIntentManagementFunctionRegInfoTest() { + IntentManagementFunctionRegInfo test = new IntentManagementFunctionRegInfo(); + test.getId(); + test.getDescription(); + test.getSupportArea(); + test.getSupportModel(); + test.getSupportInterfaces(); + test.getHandleName(); + test.getIntentFunctionType(); + + } + + @Test + public void testSetIntentManagementFunctionRegInfoTest() { + IntentManagementFunctionRegInfo test = new IntentManagementFunctionRegInfo(); + test.setId(""); + test.setDescription(""); + test.setSupportArea(new ArrayList<SupportArea>()); + test.setSupportModel(""); + test.setSupportInterfaces(new ArrayList<>()); + test.setHandleName(""); + test.setIntentFunctionType(IntentFunctionType.INTERNALFUNCTION); + } +} diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/IntentTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/IntentTest.java new file mode 100644 index 0000000..33609e9 --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/IntentTest.java @@ -0,0 +1,52 @@ +/* + * 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.bean.models; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; + +public class IntentTest { + @Before + public void before() throws Exception { + } + + @After + public void after() throws Exception { + } + + @Test + public void testGetIntentTest() { + Intent test = new Intent(); + test.getIntentId(); + test.getIntentName(); + test.getIntentExpectations(); + test.getIntentContexts(); + test.getIntentFulfilmentInfo(); + } + + @Test + public void testSetIntentTest() { + Intent test = new Intent(); + test.setIntentId(""); + test.setIntentName(""); + test.setIntentExpectations(new ArrayList<Expectation>()); + test.setIntentContexts(new ArrayList<Context>()); + test.setIntentFulfilmentInfo(new FulfilmentInfo()); + } +} diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/StateTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/StateTest.java new file mode 100644 index 0000000..e04ea3a --- /dev/null +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/bean/models/StateTest.java @@ -0,0 +1,49 @@ +/* + * 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.bean.models; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class StateTest { + @Before + public void before() throws Exception { + } + + @After + public void after() throws Exception { + } + + @Test + public void testGetStateTest() { + State test = new State(); + test.getStateId(); + test.getStateName(); + test.getCondition(); + test.getIsSatisfied(); + + } + + @Test + public void testSetStateTest() { + State test = new State(); + test.setStateId(""); + test.setStateName(""); + test.setCondition(""); + test.setIsSatisfied(true); + } +} |