IntentManagementFunction intentHandlerInfo = intentContextService.getHandlerInfo(intent);
boolean bFindIntent = false;
for (Expectation originExpectation : originIntentExpectationList) {
- if (intent.getIntentName().equals(originExpectation.getExpectationName())){
+ if (intent.getIntentName().replace("Intent","")
+ .equals(originExpectation.getExpectationName().replace("Expectation",""))){
bFindIntent = true;
+ break;
}
}
*/
package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.cllassurancemodule;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.onap.usecaseui.intentanalysis.adapters.policy.PolicyService;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
import org.onap.usecaseui.intentanalysis.bean.models.*;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
+import org.onap.usecaseui.intentanalysis.service.ContextService;
import org.onap.usecaseui.intentanalysis.service.IntentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
-
+@Slf4j
@Component
public class CLLAssuranceActuationModule extends ActuationModule {
@Autowired
@Autowired
private PolicyService policyService;
+ @Autowired
+ private ContextService contextService;
@Override
public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) {
@Override
public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){
-
+ log.info("cllDeliveryActuationModule begin to update originIntent subIntentInfo");
+ contextService.updateContextList(originIntent.getIntentContexts(), originIntent.getIntentId());
}
private String getBandwidth(String cllId) {
import org.onap.usecaseui.intentanalysis.bean.models.*;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
+import org.onap.usecaseui.intentanalysis.service.ContextService;
import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
import org.onap.usecaseui.intentanalysis.service.IntentService;
import org.springframework.beans.factory.annotation.Autowired;
@Autowired
private IntentService intentService;
+ @Autowired
+ private ContextService contextService;
@Override
public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) {
expectationObjectService.updateExpectationObject(originExpectationObject,originExpectation.getExpectationId());
}
}
-
-
+ log.info("cllDeliveryActuationModule begin to update originIntent subIntentInfo");
+ contextService.updateContextList(originIntent.getIntentContexts(), originIntent.getIntentId());
}
}
public void removeIntentById(@PathVariable(INTENT_ID) String intentId) {
processService.setIntentRole(formatIntentInputManagementFunction, null);
- //save original intent
Intent intent = intentService.getIntent(intentId);
IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.DELETE);
processService.intentProcess(intentGoalBean);
}
- @PostMapping(value = "/handleIntent", produces = MediaType.APPLICATION_JSON_VALUE)
- public void handleIntent(@RequestBody Intent intent) {
- processService.setIntentRole(formatIntentInputManagementFunction, null);
- //save original intent
-
- IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE);
- IntentGoalBean newIntentGoalBean = processService.intentProcess(intentGoalBean);
- intentService.createIntent(newIntentGoalBean.getIntent());
- }
}
*/
package org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule;
-import lombok.extern.log4j.Log4j2;
-import org.apache.commons.collections.CollectionUtils;
-import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType;
-import org.onap.usecaseui.intentanalysis.bean.models.Condition;
-import org.onap.usecaseui.intentanalysis.bean.models.Context;
+import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
-import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction;
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.service.IntentService;
-import org.onap.usecaseui.intentanalysis.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.ArrayList;
-import java.util.List;
-
-@Log4j2
+@Slf4j
@Component
public class FormatIntentInputActuationModule extends ActuationModule {
@Autowired
public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationUpdateProcess(IntentGoalBean intentGoalBean) {
//get format-cll intent
LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>();
+ // update format-cll intentContext
+ Intent intent1 = intentService.getIntent(intentGoalBean.getIntent().getIntentId());
+ intentGoalBean.getIntent().setIntentContexts(intent1.getIntentContexts());
List<Intent> subIntentList = intentContextService.getSubIntentInfoFromContext(intentGoalBean.getIntent());
for (Intent intent : subIntentList) {
IntentManagementFunction intentHandlerInfo = intentContextService.getHandlerInfo(intent);
int newIntentExpectationNum = originIntentExpectationList.size();
int oldIntentExpectationNum = intentExpectationList.size();
+ List<Expectation> changeList = new ArrayList<>();
if (newIntentExpectationNum != oldIntentExpectationNum){
if (newIntentExpectationNum < oldIntentExpectationNum){
- boolean bFindExpectation = false;
- for (Expectation oldExpectation : intentExpectationList) {
- for (Expectation newExpectation : originIntentExpectationList) {
+
+ for (Expectation oldExpectation : intentExpectationList) {//search
+ boolean bFindExpectation = false;
+ for (Expectation newExpectation : originIntentExpectationList) {//param
if (oldExpectation.getExpectationName().equals(newExpectation.getExpectationName())){
bFindExpectation = true;
+ break;
}
}
- if (bFindExpectation == false){
- intentExpectationList.remove(oldExpectation);
+ if (bFindExpectation){
+ changeList.add(oldExpectation);
}
}
}
}
- intent.setIntentExpectations(intentExpectationList);
+ intent.setIntentExpectations(changeList);
}
@Override
*/
package org.onap.usecaseui.intentanalysis.intentBaseService.contextService;
+import lombok.extern.slf4j.Slf4j;
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.Condition;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
-import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.service.IntentService;
import org.onap.usecaseui.intentanalysis.util.CommonUtil;
import java.util.ArrayList;
import java.util.List;
-
+@Slf4j
@Service
public class IntentContextService {
conditionList.add(condition1);
context.setContextConditions(conditionList);
contextList.add(context);
- originIntent.setIntentContexts(contextList);
}
+ originIntent.setIntentContexts(contextList);
}
public void updateIntentOwnerHandlerContext(Intent intent, IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){
if (context.getContextName().contains("handler info")) {
List<Condition> conditionList = context.getContextConditions();
String handlerClassName = conditionList.get(0).getConditionValue();
+ String handleName = StringUtils.substringAfterLast(handlerClassName,".");
handler = (IntentManagementFunction) applicationContext
- .getBean(CLLBusinessIntentManagementFunction.class.getSimpleName());
+ .getBean(handleName);
}
}
return handler;
for (Context context : contextList) {
if (context.getContextName().contains("subIntent info")) {
List<Condition> conditionList = context.getContextConditions();
+ List<Condition> newConditionList = new ArrayList<>();
for (Condition condition : conditionList) {
- if (condition.getConditionValue() == deleteIntentId){
- conditionList.remove(condition);
+ if (!StringUtils.equals(condition.getConditionValue(), deleteIntentId)){
+ newConditionList.add(condition);
}
}
+ context.setContextConditions(newConditionList);
}
}
+ log.info("deleteSubIntentContext from intent finished");
}
}
*/
package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule;
+import org.apache.commons.collections.CollectionUtils;
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.service.IntentService;
import org.springframework.beans.factory.annotation.Autowired;
+import java.util.List;
import java.util.Map;
public abstract class ActuationModule {
//Delete intent information to the intent instance database
public void deleteIntentToDb(Intent intent) {
+ //judge if exist subIntent,exist->don't delete
+ List<String> subIntentList = intentService.getSubIntentList(intent);
+ if (CollectionUtils.isNotEmpty(subIntentList)) {
+ return;
+ }
intentService.deleteIntent(intent.getIntentId());
}
intentActuationModule.updateIntentToDb(newIntentGoalBean.getIntent());
}
if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.DELETE){
- intentActuationModule.deleteIntentToDb(newIntentGoalBean.getIntent());
+ intentActuationModule.deleteIntentToDb(entry.getKey().getIntent());
}
return newIntentGoalBean;
}
*/
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.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.service.IntentService;
intentOperationService.setIntentRole(intentOwner, next.getValue());
intentOperationService.operationProcess(originIntentGoalBean.getIntent(), newIdIntentGoalBean);
}
+ //delete second intent
+ if (StringUtils.equals(originIntentGoalBean.getIntentGoalType().name(),IntentGoalType.DELETE.name())){
+ intentService.deleteIntent(originIntentGoalBean.getIntent().getIntentId());
+ }
return newIntentGoalBean;
}
}
void deleteIntent(String intentId);
List<Intent> getIntentByName(String name);
+
+ List<String> getSubIntentList(Intent intent);
}
package org.onap.usecaseui.intentanalysis.service.impl;
+import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.onap.usecaseui.intentanalysis.bean.models.Condition;
+import org.onap.usecaseui.intentanalysis.bean.models.Context;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
}
return intentList;
}
+
+ @Override
+ public List<String> getSubIntentList(Intent intent){
+ List<Context> intentContexts = intent.getIntentContexts();
+ List<String> subIntentIds= new ArrayList<>();
+ if (CollectionUtils.isNotEmpty(intentContexts)) {
+ List<Context> subIntentInfoList = intentContexts.stream().filter(x -> StringUtils.equals(x.getContextName(), "subIntent info")).collect(Collectors.toList());
+ if (CollectionUtils.isNotEmpty(subIntentInfoList)) {
+ List<Condition> contextConditions = subIntentInfoList.get(0).getContextConditions();
+ if (CollectionUtils.isNotEmpty(contextConditions)) {
+ for (Condition con:contextConditions) {
+ subIntentIds.add(con.getConditionValue());
+ }
+ }
+ }
+ }
+ return subIntentIds;
+ }
}
</update>
<delete id="deleteCondition">
- DELETE FROM condition WHERE condition_id = #{condition.conditionId}
+ DELETE FROM condition WHERE condition_id = #{conditionId}
</delete>
<delete id="deleteConditionList">