2 * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.cllassurancemodule;
18 import com.alibaba.fastjson.JSONObject;
19 import lombok.extern.log4j.Log4j2;
20 import org.apache.commons.collections.CollectionUtils;
21 import org.apache.commons.lang.StringUtils;
22 import org.onap.usecaseui.intentanalysis.adapters.aai.apicall.AAIAPICall;
23 import org.onap.usecaseui.intentanalysis.adapters.aai.apicall.AAIAuthConfig;
24 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
25 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
26 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
27 import org.onap.usecaseui.intentanalysis.util.RestfulServices;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.stereotype.Component;
30 import retrofit2.Response;
32 import java.io.IOException;
36 public class CLLAssuranceKnowledgeModule extends KnowledgeModule {
37 private AAIAPICall aaiapiCall;
39 AAIAuthConfig aaiAuthConfig;
41 public AAIAPICall getAaiApiCall() {
42 if (null == aaiapiCall) {
43 this.aaiapiCall = RestfulServices.create(AAIAPICall.class,
44 aaiAuthConfig.getUserName(), aaiAuthConfig.getPassword());
46 return this.aaiapiCall;
49 public void setAAIApiCall(AAIAPICall aaiApiCall) {
50 this.aaiapiCall = aaiApiCall;
54 public IntentGoalBean intentCognition(Intent intent) {
59 public boolean recieveCreateIntent() {
64 public boolean recieveUpdateIntent() {
69 public boolean recieveDeleteIntent() {
76 int getSystemStatus(Intent intent) {
78 if (CollectionUtils.isEmpty(intent.getIntentExpectations())) {
81 String objectInstance = intent.getIntentExpectations().get(0).getExpectationObject().getObjectInstance();
82 if (StringUtils.isEmpty(objectInstance)){
85 Response<JSONObject> response = getAaiApiCall().getInstanceInfo(objectInstance).execute();
86 log.debug(response.toString());
87 if (response.isSuccessful()) {
88 // TODO: 2022/9/20 judge by the return result
90 log.error("getIntentInstance Create Statue Error:" + response.toString());
92 } catch (Exception ex) {
93 log.error("Details:" + ex.getMessage());