aboutsummaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/main/java/org
diff options
context:
space:
mode:
authorkaixiliu <liukaixi@chinamobile.com>2023-08-29 10:45:18 +0800
committerkaixiliu <liukaixi@chinamobile.com>2023-08-29 10:45:56 +0800
commitb32a2d2af10287b1420f8c54b6a90b6aeabff12f (patch)
tree754e63eb3a7fed43304ac4cc71c2b1c511deea71 /intentanalysis/src/main/java/org
parentd87439a9b1e844c130ab1581e3fd174f401a498d (diff)
Modify Intent Model
Issue-ID: USECASEUI-819 Change-Id: I63041d772aac1e4591d2f8d71be7f699c25be3a1 Signed-off-by: kaixiliu <liukaixi@chinamobile.com>
Diffstat (limited to 'intentanalysis/src/main/java/org')
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/Thread/CreateCallable.java3
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObject.java6
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java1
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java37
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceKnowledgeModule.java51
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java1
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java13
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java7
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ObjectInstanceMapper.java4
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ObjectInstanceService.java4
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java11
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java44
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ObjectInstanceServiceImpl.java8
14 files changed, 81 insertions, 111 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/Thread/CreateCallable.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/Thread/CreateCallable.java
index 2d548f2..3f029be 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/Thread/CreateCallable.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/Thread/CreateCallable.java
@@ -15,6 +15,7 @@
*/
package org.onap.usecaseui.intentanalysis.Thread;
+import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
@@ -25,6 +26,7 @@ import org.springframework.context.ApplicationContext;
import java.util.concurrent.Callable;
+@Slf4j
public class CreateCallable implements Callable<String> {
private Intent originalIntent;
private IntentGoalBean intentGoalBean;
@@ -58,6 +60,7 @@ public class CreateCallable implements Callable<String> {
String intentStatus = "success";
IntentCreateEvent intentCreateEvent = new IntentCreateEvent(this, originalIntent, intentGoalBean, handler, intentStatus);
applicationContext.publishEvent(intentCreateEvent);
+ log.info(intentGoalBean.getIntent().getIntentName() + " Intent operate finished");
return intentGoalBean.getIntent().getIntentName() +" Intent operate finished";
}
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObject.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObject.java
index eb4d0a8..a94948c 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObject.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ExpectationObject.java
@@ -16,19 +16,17 @@
package org.onap.usecaseui.intentanalysis.bean.models;
-
import java.util.List;
+
import lombok.Data;
import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
-
@Data
-
public class ExpectationObject {
private ObjectType objectType;
- private String objectInstance;
+ private List<String> objectInstance;
private List<Context> objectContexts;
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java
index e2865bf..6135195 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java
@@ -84,7 +84,6 @@ public class CLLAssuranceIntentManagementFunction extends IntentManagementFuncti
CreateCallable assuranceCallable = new CreateCallable(originalIntent, intentGoalBean, handler, applicationContext);
FutureTask<String> futureTask = new FutureTask<>(assuranceCallable);
executor.submit(futureTask);
- log.info(futureTask.get());
} catch (Exception ex) {
log.error("exception is {}", ex.getMessage());
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java
index 27efe40..1c515c7 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java
@@ -48,16 +48,18 @@ public class CLLAssuranceActuationModule extends ActuationModule {
@Override
public void directOperation(IntentGoalBean intentGoalBean) {
Intent intent = intentGoalBean.getIntent();
- String cllId = getCLLId(intent);
- String bandwidth = getBandwidth(cllId);
- IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
- if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) {
- policyService.updateIntentConfigPolicy(cllId, bandwidth, "true");
- } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) {
- policyService.updateIntentConfigPolicy(cllId, bandwidth, "false");
- } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) {
- policyService.updateIntentConfigPolicy(cllId, bandwidth, "false");
- }
+ List<String> cllIds = getCLLId(intent);
+ cllIds.forEach(cllId -> {
+ String bandwidth = getBandwidth(cllId);
+ IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
+ if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) {
+ policyService.updateIntentConfigPolicy(cllId, bandwidth, "true");
+ } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) {
+ policyService.updateIntentConfigPolicy(cllId, bandwidth, "false");
+ } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) {
+ policyService.updateIntentConfigPolicy(cllId, bandwidth, "false");
+ }
+ });
}
@Override
@@ -94,9 +96,16 @@ public class CLLAssuranceActuationModule extends ActuationModule {
log.info("expectationObject is empty,expectationId is {}", deliveryExpectation.getExpectationId());
continue;
}
- String objectInstance = expectationObject.getObjectInstance();
- if (!StringUtils.equalsIgnoreCase(cllId, objectInstance)) {
- log.info("cllId and objectInstance are not equal,cllId is {},objectInstance is {}", cllId, objectInstance);
+ List<String> objectInstances = expectationObject.getObjectInstance();
+ String object = "";
+ for (String objectInstance : objectInstances) {
+ if (StringUtils.equalsIgnoreCase(cllId, objectInstance)) {
+ object = objectInstance;
+ break;
+ }
+ }
+ if (StringUtils.isEmpty(object)) {
+ log.info("no objectInstance is equal cllId {}", cllId);
continue;
}
List<ExpectationTarget> deliveryTargetList = deliveryExpectation.getExpectationTargets();
@@ -121,7 +130,7 @@ public class CLLAssuranceActuationModule extends ActuationModule {
return null;
}
- public String getCLLId(Intent intent) {
+ private List<String> getCLLId(Intent intent) {
List<Expectation> expectationList = intent.getIntentExpectations();
for (Expectation expectation : expectationList) {
if (StringUtils.equalsIgnoreCase("assurance", expectation.getExpectationType().name())) {
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceKnowledgeModule.java
index 44fb9f8..899eef9 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceKnowledgeModule.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceKnowledgeModule.java
@@ -15,41 +15,15 @@
*/
package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.cllassurancemodule;
-import com.alibaba.fastjson.JSONObject;
import lombok.extern.log4j.Log4j2;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.onap.usecaseui.intentanalysis.adapters.aai.apicall.AAIAPICall;
-import org.onap.usecaseui.intentanalysis.adapters.aai.apicall.AAIAuthConfig;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
-import org.onap.usecaseui.intentanalysis.util.RestfulServices;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import retrofit2.Response;
-
-import java.io.IOException;
@Log4j2
@Component
public class CLLAssuranceKnowledgeModule extends KnowledgeModule {
- private AAIAPICall aaiapiCall;
- @Autowired
- AAIAuthConfig aaiAuthConfig;
-
- public AAIAPICall getAaiApiCall() {
- if (null == aaiapiCall) {
- this.aaiapiCall = RestfulServices.create(AAIAPICall.class,
- aaiAuthConfig.getUserName(), aaiAuthConfig.getPassword());
- }
- return this.aaiapiCall;
- }
-
- public void setAAIApiCall(AAIAPICall aaiApiCall) {
- this.aaiapiCall = aaiApiCall;
- }
-
@Override
public IntentGoalBean intentCognition(Intent intent) {
return null;
@@ -69,29 +43,4 @@ public class CLLAssuranceKnowledgeModule extends KnowledgeModule {
public boolean recieveDeleteIntent() {
return true;
}
-
- /**
- * healthy check
- */
- int getSystemStatus(Intent intent) {
- try {
- if (CollectionUtils.isEmpty(intent.getIntentExpectations())) {
- return -1;
- }
- String objectInstance = intent.getIntentExpectations().get(0).getExpectationObject().getObjectInstance();
- if (StringUtils.isEmpty(objectInstance)){
- return -1;
- }
- Response<JSONObject> response = getAaiApiCall().getInstanceInfo(objectInstance).execute();
- log.debug(response.toString());
- if (response.isSuccessful()) {
- // TODO: 2022/9/20 judge by the return result
- }
- log.error("getIntentInstance Create Statue Error:" + response.toString());
- return -1;
- } catch (Exception ex) {
- log.error("Details:" + ex.getMessage());
- return 0;
- }
- }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java
index 1c5f7af..6286e60 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java
@@ -83,7 +83,6 @@ public class CLLDeliveryIntentManagementFunction extends IntentManagementFunctio
CreateCallable deliveryCallable = new CreateCallable(originalIntent, intentGoalBean, handler, applicationContext);
FutureTask<String> futureTask = new FutureTask<>(deliveryCallable);
executor.submit(futureTask);
- log.info(futureTask.get());
} catch (Exception ex) {
log.error("exception is {}", ex.getMessage());
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java
index 33d05f9..93b7043 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryActuationModule.java
@@ -34,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -97,7 +98,7 @@ public class CLLDeliveryActuationModule extends ActuationModule {
updateFulfillment(params, deliveryExpectation.getExpectationId());
// fill and update the objectInstance of intent expectation(include delivery and report)
- String objectInstance = (String) params.get("name");
+ List<String> objectInstance = Collections.singletonList((String) params.get("name"));
intent.getIntentExpectations().forEach(expectation -> {
ExpectationObject expectationObject = expectationObjectService.getExpectationObject(expectation.getExpectationId());
expectationObject.setObjectInstance(objectInstance);
@@ -105,11 +106,11 @@ public class CLLDeliveryActuationModule extends ActuationModule {
expectationObjectService.updateExpectationObject(expectationObject, expectation.getExpectationId());
});
} else if (StringUtils.equalsIgnoreCase("delete", intentGoalBean.getIntentGoalType().name())) {
- String instanceId = deliveryExpectation.getExpectationObject().getObjectInstance();
- soService.deleteIntentInstance(instanceId);
+ List<String> objectInstance = deliveryExpectation.getExpectationObject().getObjectInstance();
+ objectInstance.forEach(instanceId->soService.deleteIntentInstance(instanceId));
} else {
- String instanceId = deliveryExpectation.getExpectationObject().getObjectInstance();
- soService.deleteIntentInstance(instanceId);
+ List<String> objectInstance = deliveryExpectation.getExpectationObject().getObjectInstance();
+ objectInstance.forEach(instanceId->soService.deleteIntentInstance(instanceId));
intentService.deleteIntent(intent.getIntentId());
}
}
@@ -188,7 +189,7 @@ public class CLLDeliveryActuationModule extends ActuationModule {
.filter(expectation -> ExpectationType.DELIVERY.equals(expectation.getExpectationType()))
.collect(Collectors.toList());
List<Expectation> originIntentExpectationList = originIntent.getIntentExpectations();
- String objectInstance = deliveryIntentExpectationList.get(0).getExpectationObject().getObjectInstance();
+ List<String> objectInstance = deliveryIntentExpectationList.get(0).getExpectationObject().getObjectInstance();
for (Expectation originExpectation : originIntentExpectationList) {
ExpectationObject originExpectationObject = originExpectation.getExpectationObject();
originExpectationObject.setObjectInstance(objectInstance);
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java
index 65f40cb..c3c152a 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java
@@ -71,7 +71,7 @@ public class IntentManagementFunction {
protected void saveFulfillmentAndObjectInstance(String intentId, FulfillmentInfo fulfillmentInfo) {
// save fulfillmentInfo and objectInstance
fulfillmentInfoService.saveFulfillmentInfo(intentId, fulfillmentInfo);
- objectInstanceService.saveObjectInstances(intentId, fulfillmentInfo);
+ objectInstanceService.saveObjectInstances(intentId, fulfillmentInfo.getObjectInstances());
}
protected void generationIntentReport(IntentGoalBean intentGoalBean) {
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java
index d9df7c4..4881362 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java
@@ -16,13 +16,10 @@
package org.onap.usecaseui.intentanalysis.mapper;
-
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
-import java.util.List;
-
@Mapper
public interface ExpectationObjectMapper {
@@ -37,8 +34,4 @@ public interface ExpectationObjectMapper {
@Param(value = "expectationId") String expectationId);
int deleteExpectationObject(@Param(value = "expectationId") String expectationId);
-
- List<String> getExpectationIdByObjectInstance(@Param(value = "objectInstance") String objectInstance);
-
- List<String> getAllObjectInstances();
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ObjectInstanceMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ObjectInstanceMapper.java
index 5331177..6a780ae 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ObjectInstanceMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ObjectInstanceMapper.java
@@ -28,4 +28,8 @@ public interface ObjectInstanceMapper {
List<String> getObjectInstances(@Param(value = "parentId") String parentId);
int deleteObjectInstances(@Param(value = "parentId") String parentId);
+
+ List<String> queryAllObjectInstances();
+
+ List<String> getParentIdByInstance(@Param(value = "objectInstance") String objectInstance);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ObjectInstanceService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ObjectInstanceService.java
index 5925c2d..aaef15a 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ObjectInstanceService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ObjectInstanceService.java
@@ -16,8 +16,8 @@
package org.onap.usecaseui.intentanalysis.service;
-import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
+import java.util.List;
public interface ObjectInstanceService {
- void saveObjectInstances(String intentId, FulfillmentInfo eventModel);
+ void saveObjectInstances(String parentId, List<String> objectInstance);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java
index c9de92a..01f32a4 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java
@@ -25,7 +25,6 @@ import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.CommonException;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
-import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
import org.onap.usecaseui.intentanalysis.mapper.*;
import org.onap.usecaseui.intentanalysis.service.ComponentNotificationService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -39,10 +38,6 @@ import java.util.List;
@Slf4j
@Service
public class ComponentNotificationServiceImpl implements ComponentNotificationService {
-
- @Autowired
- private ExpectationObjectMapper expectationObjectMapper;
-
@Autowired
private ExpectationMapper expectationMapper;
@@ -50,7 +45,7 @@ public class ComponentNotificationServiceImpl implements ComponentNotificationSe
private ApplicationContext applicationContext;
@Autowired
- private IntentInterfaceService intentInterfaceService;
+ private ObjectInstanceMapper objectInstanceMapper;
/**
* Generate a new FulfillmentInfo based on third-party FulfillmentOperation
@@ -72,7 +67,7 @@ public class ComponentNotificationServiceImpl implements ComponentNotificationSe
throw new CommonException(msg, ResponseConsts.EMPTY_PARAM);
}
log.info("Get objectInstances is {}", objectInstances);
- List<String> expectationIds = expectationObjectMapper.getExpectationIdByObjectInstance(objectInstances.get(0));
+ List<String> expectationIds = objectInstanceMapper.getParentIdByInstance(objectInstances.get(0));
if (CollectionUtils.isEmpty(expectationIds)) {
String msg = "Get expectationId is null from database";
log.error(msg);
@@ -100,7 +95,7 @@ public class ComponentNotificationServiceImpl implements ComponentNotificationSe
} else {
function = (IntentManagementFunction) applicationContext.getBean(CLLDeliveryIntentManagementFunction.class.getSimpleName());
}
- intentInterfaceService.reportInterface(function, intentId, eventModel);
+ function.createReport(intentId, eventModel);
}
private ExpectationType getExpectationType(String operation) {
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java
index 2e7db09..b5b8022 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java
@@ -16,16 +16,15 @@
package org.onap.usecaseui.intentanalysis.service.impl;
-
-import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
+import org.onap.usecaseui.intentanalysis.mapper.ObjectInstanceMapper;
+import org.onap.usecaseui.intentanalysis.service.ObjectInstanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
import org.onap.usecaseui.intentanalysis.mapper.ExpectationObjectMapper;
@@ -33,13 +32,9 @@ import org.onap.usecaseui.intentanalysis.service.ContextService;
import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
import org.springframework.util.CollectionUtils;
-
@Service
@Slf4j
public class ExpectationObjectServiceImpl implements ExpectationObjectService {
-
- private ContextParentType contextParentType;
-
@Autowired
private ExpectationObjectMapper expectationObjectMapper;
@@ -49,6 +44,12 @@ public class ExpectationObjectServiceImpl implements ExpectationObjectService {
@Autowired
private ContextService contextService;
+ @Autowired
+ private ObjectInstanceService objectInstanceService;
+
+ @Autowired
+ private ObjectInstanceMapper objectInstanceMapper;
+
@Override
public void createExpectationObject(ExpectationObject expectationObject, String expectationId) {
if (expectationObjectService.getExpectationObject(expectationId) != null) {
@@ -56,19 +57,33 @@ public class ExpectationObjectServiceImpl implements ExpectationObjectService {
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
- contextService.createContextList(expectationObject.getObjectContexts(),
- expectationObjectMapper.selectExpectationObjectId(expectationId));
+
+ List<String> objectInstance = expectationObject.getObjectInstance();
+ if (!CollectionUtils.isEmpty(objectInstance)) {
+ objectInstanceService.saveObjectInstances(expectationId, objectInstance);
+ }
+
if (expectationObjectMapper.insertExpectationObject(expectationObject, expectationId) < 1) {
String msg = "Failed to create expectation object to database.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
+
+ String objectId = expectationObjectMapper.selectExpectationObjectId(expectationId);
+ List<Context> objectContexts = expectationObject.getObjectContexts();
+ if(!CollectionUtils.isEmpty(objectContexts)){
+ contextService.createContextList(objectContexts, objectId);
+ }
log.info("Successfully created expectation object to database.");
}
@Override
public ExpectationObject getExpectationObject(String expectationId) {
ExpectationObject expectationObject = expectationObjectMapper.selectExpectationObject(expectationId);
+ if (expectationObject == null) {
+ log.info("get expectationObject is empty,expectationId is {}", expectationId);
+ return null;
+ }
String expectationObjectId = expectationObjectMapper.selectExpectationObjectId(expectationId);
List<Context> contextList = contextService.getContextList(expectationObjectId);
if (!CollectionUtils.isEmpty(contextList)) {
@@ -76,6 +91,8 @@ public class ExpectationObjectServiceImpl implements ExpectationObjectService {
} else {
log.info(String.format("Expectation object is null, expectationObjectId = %s", expectationObjectId));
}
+ List<String> objectInstances = objectInstanceMapper.getObjectInstances(expectationId);
+ expectationObject.setObjectInstance(objectInstances);
return expectationObject;
}
@@ -87,8 +104,9 @@ public class ExpectationObjectServiceImpl implements ExpectationObjectService {
} else if (expectationObject != null && expectationObjectFromDB == null) {
expectationObjectService.createExpectationObject(expectationObject, expectationId);
} else if (expectationObject != null) {
- contextService.updateContextList(expectationObject.getObjectContexts(),
- expectationObjectMapper.selectExpectationObjectId(expectationId));
+ String objectId = expectationObjectMapper.selectExpectationObjectId(expectationId);
+ contextService.updateContextList(expectationObject.getObjectContexts(), objectId);
+ objectInstanceService.saveObjectInstances(expectationId, expectationObject.getObjectInstance());
if (expectationObjectMapper.updateExpectationObject(expectationObject, expectationId) < 1) {
String msg = "Failed to update expectation object to database.";
log.error(msg);
@@ -103,7 +121,9 @@ public class ExpectationObjectServiceImpl implements ExpectationObjectService {
public void deleteExpectationObject(String expectationId) {
ExpectationObject expectationObject = expectationObjectService.getExpectationObject(expectationId);
if (expectationObject != null) {
- contextService.deleteContextList(expectationObjectMapper.selectExpectationObjectId(expectationId));
+ String objectId = expectationObjectMapper.selectExpectationObjectId(expectationId);
+ contextService.deleteContextList(objectId);
+ objectInstanceMapper.deleteObjectInstances(expectationId);
if (expectationObjectMapper.deleteExpectationObject(expectationId) < 1) {
String msg = "Failed to update expectation object to database.";
log.error(msg);
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ObjectInstanceServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ObjectInstanceServiceImpl.java
index 1d60ca5..700964f 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ObjectInstanceServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ObjectInstanceServiceImpl.java
@@ -36,9 +36,9 @@ public class ObjectInstanceServiceImpl implements ObjectInstanceService {
private ObjectInstanceMapper objectInstanceMapper;
@Override
- public void saveObjectInstances(String intentId, FulfillmentInfo eventModel) {
- List<String> instances = new ArrayList<>(eventModel.getObjectInstances());
- List<String> objectInstancesDb = objectInstanceMapper.getObjectInstances(intentId);
+ public void saveObjectInstances(String parentId, List<String> objectInstance) {
+ List<String> instances = new ArrayList<>(objectInstance);
+ List<String> objectInstancesDb = objectInstanceMapper.getObjectInstances(parentId);
if (!CollectionUtils.isEmpty(objectInstancesDb)) {
instances.removeAll(objectInstancesDb);
if (CollectionUtils.isEmpty(instances)) {
@@ -46,7 +46,7 @@ public class ObjectInstanceServiceImpl implements ObjectInstanceService {
return;
}
}
- int objectInstanceNum = objectInstanceMapper.insertObjectInstanceList(instances, intentId);
+ int objectInstanceNum = objectInstanceMapper.insertObjectInstanceList(instances, parentId);
if (objectInstanceNum < 1) {
String msg = "Failed to insert objectInstances to database.";
log.error(msg);