diff options
Diffstat (limited to 'intentanalysis')
26 files changed, 97 insertions, 512 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunction.java index 5489070..6a7d7f8 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunction.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunction.java @@ -88,26 +88,36 @@ public class CLLBusinessIntentManagementFunction extends IntentManagementFunctio IntentGoalBean originIntentGoalBean = detection(intentGoalBean); LinkedHashMap<IntentGoalBean, IntentManagementFunction> linkedMap = investigation(originIntentGoalBean); implementIntent(intentGoalBean.getIntent(), linkedMap); - if (intentGoalBean.getIntentGoalType() == IntentGoalType.DELETE) { - intentService.deleteIntent(intentGoalBean.getIntent().getIntentId()); - } } @Override public void receiveIntentAsHandler(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) { ActuationModule actuationModule = handler.getActuationModule(); IntentGoalType type = intentGoalBean.getIntentGoalType(); + //before dataBase operate + handler.receiveIntentAsOwner(intentGoalBean); + if (type == IntentGoalType.CREATE) { actuationModule.saveIntentToDb(intentGoalBean.getIntent()); } else if (type == IntentGoalType.UPDATE) { actuationModule.updateIntentToDb(intentGoalBean.getIntent()); } else if (type == IntentGoalType.DELETE) { + //before delete cllBusinessIntent check subintent deleted + boolean deleteFinished = false; + Intent cllIntent = intentGoalBean.getIntent(); + //subIntent size and delete Intent size + List<Context> list = cllIntent.getIntentContexts().stream().filter(x -> + StringUtils.equals(x.getContextName(), "subIntent info")).collect(Collectors.toList()); + int subIntentSize = list.get(0).getContextConditions().size(); + while (!deleteFinished) { + List<IntentEventRecord> deleteList = intentEventRecordService.getRecordByPid(cllIntent.getIntentId(), + IntentGoalType.DELETE.name()); + if (subIntentSize <= deleteList.size()) { + deleteFinished = true; + } + } actuationModule.deleteIntentToDb(intentGoalBean.getIntent()); } - //update origin intent if need - actuationModule.updateIntentOperationInfo(originalIntent, intentGoalBean); - handler.receiveIntentAsOwner(intentGoalBean); - } public IntentGoalBean detection(IntentGoalBean intentGoalBean) { @@ -146,7 +156,7 @@ public class CLLBusinessIntentManagementFunction extends IntentManagementFunctio intentContextService.updateIntentOwnerHandlerContext(newIdIntent, this, next.getValue()); intentContextService.updateParentIntentContext(originIntent, newIdIntent); intentContextService.updateChindIntentContext(originIntent, newIdIntent); - contextService.updateContextList(originIntent.getIntentContexts(), originIntent.getIntentId()); + // contextService.updateContextList(originIntent.getIntentContexts(), originIntent.getIntentId()); //intent-Distribution-create boolean isAcceptCreate = intentInterfaceService.createInterface(originIntent, new IntentGoalBean(newIdIntent, IntentGoalType.CREATE), next.getValue()); @@ -158,11 +168,11 @@ public class CLLBusinessIntentManagementFunction extends IntentManagementFunctio int count = 1; while (!isPublish) { Thread.sleep(1000); - IntentEventRecord record = intentEventRecordService.getIntentEventRecordByntentId(newIdIntent.getIntentId(), "create"); + IntentEventRecord record = intentEventRecordService.getIntentEventRecordByIntentId(newIdIntent.getIntentId(), "create"); count++; // it will take one hour to wait operation end - if (count==3600){ - throw new CommonException("Operation took too long, failed",500); + if (count == 3600) { + throw new CommonException("Operation took too long, failed", 500); } if (null != record) { isPublish = true; 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 aa82ee9..243a313 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,31 +16,18 @@ package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule; -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 org.onap.usecaseui.intentanalysis.bean.models.Expectation; -import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject; 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.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.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; - @Component public class CLLBusinessActuationModule extends ActuationModule { @Autowired - IntentProcessService processService; - @Autowired IntentService intentService; @Autowired IntentInterfaceService intentInterfaceService; @@ -48,8 +35,6 @@ public class CLLBusinessActuationModule extends ActuationModule { @Override public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) { - processService.setIntentRole(IntentHandler, null); - processService.intentProcess(intentGoalBean); } @Override @@ -68,30 +53,6 @@ public class CLLBusinessActuationModule extends ActuationModule { intentHandler.receiveIntentAsOwner(intentGoalBean); } - @Override - public void saveIntentToDb(Intent intent){ //ownerid parent intent id - List<Context> intentContexts = intent.getIntentContexts(); - if (CollectionUtils.isEmpty(intentContexts)) { - intentContexts = new ArrayList<>(); - } - //ownerId intentId="" show relatioship beteween intent - Context ownerIdContext = new Context(); - ownerIdContext.setContextId(CommonUtil.getUUid()); - ownerIdContext.setContextName("ownerId"); - List<Condition> idConditionList = new ArrayList<>(); - Condition idCondition = new Condition(); - idCondition.setConditionValue(intent.getIntentId()); - idCondition.setOperator(OperatorType.EQUALTO); - idCondition.setConditionName("intentId"); - idCondition.setConditionId(CommonUtil.getUUid()); - - idConditionList.add(idCondition); - ownerIdContext.setContextConditions(idConditionList); - - intentContexts.add(ownerIdContext); - intent.setIntentContexts(intentContexts); - intentService.createIntent(intent); - } @Override public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){ 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 c57c707..9625cb6 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 @@ -19,7 +19,6 @@ 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.onap.usecaseui.intentanalysis.service.IntentService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,8 +33,6 @@ public class CLLBusinessKnowledgeModule extends KnowledgeModule { @Autowired IntentService intentService; - @Autowired - IntentDetectionService intentDetectionService; @Override public IntentGoalBean intentCognition(Intent intent) { 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 88c1264..c78ce5b 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 @@ -67,8 +67,8 @@ public class CLLAssuranceIntentManagementFunction extends IntentManagementFuncti try { log.debug("cllAssurance Intent {} begin time:{}", intentGoalBean.getIntentGoalType(), LocalDateTime.now()); log.debug(Thread.currentThread().getName()); - CreateCallable createCallable = new CreateCallable(originalIntent, intentGoalBean, handler, applicationContext); - FutureTask<String> futureTask = new FutureTask<>(createCallable); + CreateCallable assuranceCallable = new CreateCallable(originalIntent, intentGoalBean, handler, applicationContext); + FutureTask<String> futureTask = new FutureTask<>(assuranceCallable); executor.submit(futureTask); } catch (Exception ex) { ex.printStackTrace(); 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 b1a0924..2c7c7a3 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 @@ -71,8 +71,6 @@ public class CLLAssuranceActuationModule extends ActuationModule { @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) { 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 4e358cb..936076e 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 @@ -66,8 +66,8 @@ public class CLLDeliveryIntentManagementFunction extends IntentManagementFunctio //ask knowledgeModole of handler imf for permision and operate try { log.debug("cllDelivery Intent create begin time:" + LocalDateTime.now()); - CreateCallable createCallable = new CreateCallable(originalIntent, intentGoalBean, handler, applicationContext); - FutureTask<String> futureTask = new FutureTask<>(createCallable); + CreateCallable deliveryCallable = new CreateCallable(originalIntent, intentGoalBean, handler, applicationContext); + FutureTask<String> futureTask = new FutureTask<>(deliveryCallable); executor.submit(futureTask); } catch (Exception ex) { ex.printStackTrace(); 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 cf1072c..1ea7f9d 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 @@ -118,10 +118,8 @@ public class CLLDeliveryActuationModule extends ActuationModule { for (Expectation originExpectation : originIntentExpectationList) { ExpectationObject originExpectationObject = originExpectation.getExpectationObject(); originExpectationObject.setObjectInstance(objectInstance); - expectationObjectService.updateExpectationObject(originExpectationObject,originExpectation.getExpectationId()); } } log.info("cllDeliveryActuationModule begin to update originIntent subIntentInfo"); - contextService.updateContextList(originIntent.getIntentContexts(), originIntent.getIntentId()); } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java index ba28e71..d9871ea 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java @@ -18,7 +18,6 @@ package org.onap.usecaseui.intentanalysis.controller; import lombok.extern.log4j.Log4j2; -import org.onap.usecaseui.intentanalysis.bean.enums.IntentGenerateType; import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; import org.onap.usecaseui.intentanalysis.bean.models.Intent; import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; @@ -26,7 +25,6 @@ import org.onap.usecaseui.intentanalysis.bean.models.ResultHeader; import org.onap.usecaseui.intentanalysis.bean.models.ServiceResult; import org.onap.usecaseui.intentanalysis.exception.CommonException; import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; import org.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; @@ -129,7 +127,4 @@ public class IntentController { return new ServiceResult(new ResultHeader(exception.getRetCode(), exception.getMessage())); } } - - - }
\ No newline at end of file diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/eventAndPublish/listener/IntentEventListener.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/eventAndPublish/listener/IntentEventListener.java index 045a75b..d5a89c1 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/eventAndPublish/listener/IntentEventListener.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/eventAndPublish/listener/IntentEventListener.java @@ -35,22 +35,24 @@ public class IntentEventListener { private IntentEventRecordService intentEventRecordService; @EventListener - public void listenIntentCreateEvent(IntentCreateEvent intentCreateEvent){ - String intentStatus = intentCreateEvent.getIntentStatus();//create status - IntentGoalBean intentGoalBean = intentCreateEvent.getIntentGoalBean();//current operate intent - Intent currentIntent = intentGoalBean.getIntent(); - List<Context> owner_info = currentIntent.getIntentContexts().stream().filter(x -> - StringUtils.equals(x.getContextName(), "owner info")).collect(Collectors.toList()); - List<Context> handler_info = currentIntent.getIntentContexts().stream().filter(x -> - StringUtils.equals(x.getContextName(), "handler info")).collect(Collectors.toList()); - String owner = owner_info.get(0).getContextConditions().get(0).getConditionValue(); - String handler = handler_info.get(0).getContextConditions().get(0).getConditionValue(); + public void listenIntentCreateEvent(IntentCreateEvent intentCreateEvent) throws Exception{ + String intentStatus = intentCreateEvent.getIntentStatus();//create status + IntentGoalBean intentGoalBean = intentCreateEvent.getIntentGoalBean();//current operate intent + Intent currentIntent = intentGoalBean.getIntent(); + List<Context> owner_info = currentIntent.getIntentContexts().stream().filter(x -> + StringUtils.equals(x.getContextName(), "owner info")).collect(Collectors.toList()); + List<Context> handler_info = currentIntent.getIntentContexts().stream().filter(x -> + StringUtils.equals(x.getContextName(), "handler info")).collect(Collectors.toList()); + String owner = owner_info.get(0).getContextConditions().get(0).getConditionValue(); + String handler = handler_info.get(0).getContextConditions().get(0).getConditionValue(); + + IntentEventRecord intentEventRecord = new IntentEventRecord(); + intentEventRecord.setIntentId(currentIntent.getIntentId()); + intentEventRecord.setIntentName(currentIntent.getIntentName()); + intentEventRecord.setIntentStatus(intentStatus); + intentEventRecord.setOperateType(intentGoalBean.getIntentGoalType().name()); + intentEventRecordService.createIntentEventRecord(intentEventRecord, + intentCreateEvent.getOriginalIntent().getIntentId()); - IntentEventRecord intentEventRecord = new IntentEventRecord(); - intentEventRecord.setIntentId(currentIntent.getIntentId()); - intentEventRecord.setIntentName(currentIntent.getIntentName()); - intentEventRecord.setIntentStatus(intentStatus); - intentEventRecord.setOperateType(intentGoalBean.getIntentGoalType().name()); - intentEventRecordService.createIntentEventRecord(intentEventRecord); } } 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 index 79578ec..d893734 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java @@ -32,6 +32,7 @@ import org.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.*; @@ -67,6 +68,7 @@ public class FormatIntentInputManagementFunction extends IntentManagementFunctio @Autowired IntentService intentService; + @Transactional(rollbackFor = Exception.class) @Override public void receiveIntentAsOwner(IntentGoalBean intentGoalBean) { @@ -125,11 +127,11 @@ public class FormatIntentInputManagementFunction extends IntentManagementFunctio //update cllBusinessIntent's expectation Intent subIntent = newIntentGoalBean.getIntent(); updateIntentInfo(originIntent, subIntent); + //update userInput intent + intentService.updateIntent(originIntent); // intent-Distribution and operate |update cllBusiness intent boolean isAcceptUpdate = intentInterfaceService.updateInterface(originIntent, new IntentGoalBean(subIntent, IntentGoalType.UPDATE), next.getValue()); - //update userInput intent - intentService.updateIntent(originIntent); } else { //deal with userInput intent intentService.deleteIntent(originIntent.getIntentId()); 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 index 3572687..a9beafe 100644 --- 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 @@ -20,7 +20,6 @@ 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.intentBaseService.intentModule.ActuationModule; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; import org.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -29,8 +28,6 @@ import org.springframework.stereotype.Component; @Component public class FormatIntentInputActuationModule extends ActuationModule { @Autowired - IntentProcessService processService; - @Autowired IntentService intentService; @Override 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 index 22edc86..bf1a887 100644 --- 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 @@ -19,7 +19,6 @@ 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.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -29,8 +28,6 @@ import java.util.List; @Component public class FormatIntentInputKnowledgeModule extends KnowledgeModule { @Autowired - IntentDetectionService intentDetectionService; - @Autowired IntentService intentService; @Override diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentEventRecord/IntentEventRecordService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentEventRecord/IntentEventRecordService.java index 454d6bd..42338ee 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentEventRecord/IntentEventRecordService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentEventRecord/IntentEventRecordService.java @@ -20,19 +20,31 @@ import org.onap.usecaseui.intentanalysis.mapper.IntentEventRecordMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class IntentEventRecordService { @Autowired IntentEventRecordMapper intentEventRecordMapper; // insert into record table - public void createIntentEventRecord(IntentEventRecord intentEventRecord){ - intentEventRecordMapper.insertIntentRecord(intentEventRecord); + public void createIntentEventRecord(IntentEventRecord intentEventRecord,String parentId){ + intentEventRecordMapper.insertIntentRecord(intentEventRecord,parentId); } // get record by intent nameid, status - public IntentEventRecord getIntentEventRecordByntentId(String intentId,String operateType){ - return intentEventRecordMapper.getIntentEventRecordByntentId(intentId,operateType); + public IntentEventRecord getIntentEventRecordByIntentId(String intentId,String operateType){ + return intentEventRecordMapper.getIntentEventRecordByIntentId(intentId,operateType); + } + + /** + * get intentEventRecord by parentId and operateType + * @param parentId parentId + * @param operateType operateTypr + * @return List<IntentEventRecord> + */ + public List<IntentEventRecord> getRecordByPid(String parentId,String operateType){ + return intentEventRecordMapper.getIntentEventRecordByPid(parentId,operateType); } } 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 796bb19..5e7792d 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 @@ -15,8 +15,6 @@ */ 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.bean.models.IntentGoalBean; @@ -25,7 +23,6 @@ import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservic 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 { @@ -44,7 +41,7 @@ public abstract class ActuationModule { //Save intent information to the intent instance database public void saveIntentToDb(Intent intent) { - intentService.createIntent(intent); + intentService.createIntent(intent); } //Update intent information to the intent instance database @@ -54,11 +51,6 @@ 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()); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java deleted file mode 100644 index 64ab8c4..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; - - -import 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; -import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; -import org.onap.usecaseui.intentanalysis.intentBaseService.contextService.IntentContextService; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; -import org.onap.usecaseui.intentanalysis.service.IntentService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Map; -@Slf4j -@Service -public class IntentDefinitionService { - - private IntentManagementFunction intentHandler; - private IntentManagementFunction intentOwner; - - @Autowired - public IntentContextService intentContextService; - @Autowired - public IntentService intentService; - - public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { - if (intentOwner != null) { - this.intentOwner = intentOwner; - } - if (intentHandler != null) { - this.intentHandler = intentHandler; - } - } - - public IntentGoalBean definitionPorcess(Intent originIntent, Map.Entry<IntentGoalBean, IntentManagementFunction> entry) { - DecisionModule intentDecisionModule = intentOwner.getDecisionModule(); - ActuationModule intentActuationModule = intentOwner.getActuationModule(); - - IntentGoalBean newIntentGoalBean = entry.getKey(); - if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.CREATE){ - Intent newIdIntent = intentDecisionModule.intentObjectDefine(originIntent, entry.getKey().getIntent()); - intentContextService.updateIntentOwnerHandlerContext(newIdIntent, intentOwner, intentHandler); - intentContextService.updateParentIntentContext(originIntent, newIdIntent); - intentContextService.updateChindIntentContext(originIntent, newIdIntent); - log.debug(newIdIntent.toString()); - intentActuationModule.saveIntentToDb(newIdIntent); - return new IntentGoalBean(newIdIntent,IntentGoalType.CREATE); - } - - if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.UPDATE){ - intentActuationModule.updateIntentToDb(newIntentGoalBean.getIntent()); - } - if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.DELETE){ - intentActuationModule.deleteIntentToDb(entry.getKey().getIntent()); - } - return newIntentGoalBean; - } -} 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 deleted file mode 100644 index 37a1819..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; - -import org.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.intentBaseService.intentModule.KnowledgeModule; -import org.springframework.stereotype.Service; - -@Service -public class IntentDetectionService { - - private IntentManagementFunction intentHandler; - private IntentManagementFunction intentOwner; - - public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { - if (intentOwner != null) { - this.intentOwner = intentOwner; - } - if (intentHandler != null) { - this.intentHandler = intentHandler; - } - } - - public IntentGoalBean detectionProcess(IntentGoalBean originIntentGoalBean) { - KnowledgeModule ownerKnowledgeModule = intentOwner.getKnowledgeModule(); - - if (originIntentGoalBean.getIntentGoalType() == IntentGoalType.UPDATE){ - return new IntentGoalBean(originIntentGoalBean.getIntent(), IntentGoalType.UPDATE); - } - - if (originIntentGoalBean.getIntentGoalType() == IntentGoalType.DELETE){ - return new IntentGoalBean(originIntentGoalBean.getIntent(), IntentGoalType.DELETE); - } - - return ownerKnowledgeModule.intentCognition(originIntentGoalBean.getIntent()); - - } -} 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 deleted file mode 100644 index 83f9b00..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDistributionService.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; - - -import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; -import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Map; - -@Service -public class IntentDistributionService { - private IntentManagementFunction intentHandler; - private IntentManagementFunction intentOwner; - - @Autowired - IntentInterfaceService intentInterfaceService; - - public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { - if (intentOwner != null) { - this.intentOwner = intentOwner; - } - if (intentHandler != null) { - this.intentHandler = intentHandler; - } - } - - public boolean distributionProcess(Map.Entry<IntentGoalBean, IntentManagementFunction> entry) { - - return intentOwner.getActuationModule().distrubuteIntentToHandler(entry); - - } - -} - diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java deleted file mode 100644 index 891f7b3..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; - -import org.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.intentBaseService.contextService.IntentContextService; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; - -@Service -public class IntentInvestigationService { - - @Autowired - IntentContextService intentContextService; - - private IntentManagementFunction intentHandler; - private IntentManagementFunction intentOwner; - - public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){ - if (intentOwner != null){ - this.intentOwner = intentOwner; - } - if (intentHandler != null){ - this.intentHandler= intentHandler; - } - } - - public LinkedHashMap<IntentGoalBean,IntentManagementFunction> investigationProcess(IntentGoalBean intentGoalBean) { - DecisionModule intentDecisionModule = intentOwner.getDecisionModule(); - - if (intentGoalBean.getIntentGoalType() == IntentGoalType.UPDATE){ - return intentDecisionModule.investigationUpdateProcess(intentGoalBean); - } - - if (intentGoalBean.getIntentGoalType() == IntentGoalType.DELETE){ - return intentDecisionModule.investigationDeleteProcess(intentGoalBean); - } - return intentDecisionModule.investigationCreateProcess(intentGoalBean); - } -} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentOperationService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentOperationService.java deleted file mode 100644 index 924508a..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentOperationService.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; - - -import org.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.intentBaseService.intentModule.ActuationModule; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; -import org.springframework.stereotype.Service; - -@Service -public class IntentOperationService { - - private IntentManagementFunction intentHandler; - private IntentManagementFunction intentOwner; - - public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { - if (intentOwner != null) { - this.intentOwner = intentOwner; - } - if (intentHandler != null) { - this.intentHandler = intentHandler; - } - } - - public void operationProcess(Intent originIntent, IntentGoalBean intentGoalBean) { - DecisionModule intentDecisionModule = intentOwner.getDecisionModule(); - ActuationModule intentActuationModule = intentHandler.getActuationModule(); - - //intentDecisionModule.interactWithTemplateDb(); - intentActuationModule.interactWithIntentHandle(); - //determine whether to operate directly or send to next intent handler - intentActuationModule.fulfillIntent(intentGoalBean, intentHandler); - - //update origin intent if need - intentActuationModule.updateIntentOperationInfo(originIntent, intentGoalBean); - } -} 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 deleted file mode 100644 index 6776175..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; - -import org.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.service.IntentService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; - -@Service -public class IntentProcessService { - @Autowired - IntentDetectionService intentDetectionService; - @Autowired - IntentInvestigationService intentInvestigationService; - @Autowired - IntentDefinitionService intentDefinitionService; - @Autowired - IntentDistributionService intentDistributionService; - @Autowired - IntentOperationService intentOperationService; - @Autowired - IntentService intentService; - private IntentManagementFunction intentOwner; - private IntentManagementFunction intentHandler; - - - public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) { - if (intentOwner != null) { - this.intentOwner = intentOwner; - } - if (intentHandler != null) { - this.intentHandler = intentHandler; - } - } - - @Transactional(rollbackFor = Exception.class) - public IntentGoalBean intentProcess(IntentGoalBean originIntentGoalBean) { - - intentDetectionService.setIntentRole(intentOwner, intentHandler); - IntentGoalBean newIntentGoalBean = intentDetectionService.detectionProcess(originIntentGoalBean); - - //investigation process Decomposition - intentInvestigationService.setIntentRole(intentOwner, intentHandler); - LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = - intentInvestigationService.investigationProcess(newIntentGoalBean); - - Iterator<Map.Entry<IntentGoalBean, IntentManagementFunction>> iterator = intentMap.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry<IntentGoalBean, IntentManagementFunction> next = iterator.next(); - //definition process save subintent - intentDefinitionService.setIntentRole(intentOwner, next.getValue()); - //obtain newID IntentGoalBean - IntentGoalBean newIdIntentGoalBean = intentDefinitionService.definitionPorcess(originIntentGoalBean.getIntent(), next); - - //distribution process - intentDistributionService.setIntentRole(intentOwner, intentHandler); - intentDistributionService.distributionProcess(next); - - 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; - } -} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentEventRecordMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentEventRecordMapper.java index c5415aa..3ee7de4 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentEventRecordMapper.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentEventRecordMapper.java @@ -18,9 +18,15 @@ package org.onap.usecaseui.intentanalysis.mapper; import org.apache.ibatis.annotations.Param; import org.onap.usecaseui.intentanalysis.bean.models.IntentEventRecord; +import java.util.List; + public interface IntentEventRecordMapper { - int insertIntentRecord(@Param(value = "intentEventRecord") IntentEventRecord intentEventRecord); + int insertIntentRecord(@Param(value = "intentEventRecord") IntentEventRecord intentEventRecord, + @Param(value="parentId")String parentId); - IntentEventRecord getIntentEventRecordByntentId(@Param(value = "intentId") String intentId, + IntentEventRecord getIntentEventRecordByIntentId(@Param(value = "intentId") String intentId, @Param(value = "operateType") String operateType); + + List<IntentEventRecord> getIntentEventRecordByPid(@Param(value="parentId")String parentId, + @Param(value = "operateType")String operateType); } diff --git a/intentanalysis/src/main/resources/intent-analysis-init.sql b/intentanalysis/src/main/resources/intent-analysis-init.sql index a3834f9..4c985e4 100644 --- a/intentanalysis/src/main/resources/intent-analysis-init.sql +++ b/intentanalysis/src/main/resources/intent-analysis-init.sql @@ -77,5 +77,6 @@ create table if not exists intent_Event_Record( intentId varchar(255), intentName varchar(255), intentStatus varchar (225), - operateType varchar (225) + operateType varchar (225), + parent_id varchar(255) );
\ No newline at end of file diff --git a/intentanalysis/src/main/resources/mybatis/sql/IntentEventRecordMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IntentEventRecordMapper.xml index 296fc43..bd86b9e 100644 --- a/intentanalysis/src/main/resources/mybatis/sql/IntentEventRecordMapper.xml +++ b/intentanalysis/src/main/resources/mybatis/sql/IntentEventRecordMapper.xml @@ -5,13 +5,20 @@ <mapper namespace="org.onap.usecaseui.intentanalysis.mapper.IntentEventRecordMapper"> <insert id="insertIntentRecord"> - insert into intent_Event_Record(intentId, intentName, intentStatus, operateType) + insert into intent_Event_Record(intentId, intentName, intentStatus, operateType,parent_id) values(#{intentEventRecord.intentId}, #{intentEventRecord.intentName}, - #{intentEventRecord.intentStatus},#{intentEventRecord.operateType}) + #{intentEventRecord.intentStatus},#{intentEventRecord.operateType}, + #{parentId}) </insert> - <select id="getIntentEventRecordByntentId" resultType="org.onap.usecaseui.intentanalysis.bean.models.IntentEventRecord"> - select * from intent_Event_Record where intentId = #{intentId}; + <select id="getIntentEventRecordByIntentId" resultType="org.onap.usecaseui.intentanalysis.bean.models.IntentEventRecord"> + select id,intentId,intentName,intentStatus,operateType,parent_id parentId + from intent_Event_Record where intentId = #{intentId}; + </select> + + <select id="getIntentEventRecordByPid" resultType="org.onap.usecaseui.intentanalysis.bean.models.IntentEventRecord"> + select id,intentId,intentName,intentStatus,operateType,parent_id + from intent_Event_Record where parent_id = #{parentId} and operateType=#{operateType}; </select> </mapper> diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModuleTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModuleTest.java index fbb560b..95cb3e0 100644 --- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModuleTest.java +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModuleTest.java @@ -26,19 +26,16 @@ import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests; import org.onap.usecaseui.intentanalysis.adapters.policy.PolicyService; import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType; import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; -import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType; import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType; import org.onap.usecaseui.intentanalysis.bean.models.*; import org.onap.usecaseui.intentanalysis.service.ContextService; import org.onap.usecaseui.intentanalysis.service.IntentService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.util.ArrayList; import java.util.List; -import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -113,7 +110,7 @@ public class CLLAssuranceActuationModuleTest { originIntent.setIntentContexts(new ArrayList<>()); originIntent.setIntentId("12345"); cllAssuranceActuationModule.updateIntentOperationInfo(originIntent,new IntentGoalBean()); - verify(contextService, times(1)).updateContextList(originIntent.getIntentContexts(), originIntent.getIntentId()); + Assert.assertTrue(true); } @Test public void testDeleteIntentToDb(){ diff --git a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/controller/IntentControllerTest.java b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/controller/IntentControllerTest.java index 7c494f7..1c1b14f 100644 --- a/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/controller/IntentControllerTest.java +++ b/intentanalysis/src/test/java/org/onap/usecaseui/intentanalysis/controller/IntentControllerTest.java @@ -21,21 +21,17 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.Mockito; import org.onap.usecaseui.intentanalysis.IntentAnalysisApplicationTests; -import org.onap.usecaseui.intentanalysis.bean.enums.IntentGenerateType; 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.common.ResponseConsts; import org.onap.usecaseui.intentanalysis.exception.CommonException; import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; import org.onap.usecaseui.intentanalysis.service.IntentService; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @SpringBootTest(classes = IntentAnalysisApplicationTests.class) @@ -47,8 +43,6 @@ public class IntentControllerTest { @Mock IntentService intentService; @Mock - IntentProcessService intentProcessService; - @Mock FormatIntentInputManagementFunction formatIntentInputManagementFunction; @@ -81,26 +75,27 @@ public class IntentControllerTest { intentController.createIntent(intent); Assert.assertTrue(true); } + @Test - public void testUpdateIntentById(){ + public void testUpdateIntentById() { Intent intent = new Intent(); intent.setIntentId("test"); intent.setIntentName("cllBussinessIntent"); IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); - intentController.updateIntentById(intent.getIntentId(),intent); + intentController.updateIntentById(intent.getIntentId(), intent); verify(formatIntentInputManagementFunction, times(1)).receiveIntentAsOwner(any()); } + @Test public void testUpdateIntentByIdCommonException() { Intent intent = new Intent(); intent.setIntentName("cllBussinessIntent"); - when(intentProcessService.intentProcess(any())).thenThrow(new CommonException("MSG", ResponseConsts.RET_UPDATE_DATA_FAIL)); - intentController.updateIntentById(any(),any()); + intentController.updateIntentById(any(), any()); Assert.assertTrue(true); } @Test - public void testRemoveIntentById(){ + public void testRemoveIntentById() { Intent intent = new Intent(); intent.setIntentName("cllBussinessIntent"); String id = "intentId"; @@ -114,18 +109,18 @@ public class IntentControllerTest { Intent intent = new Intent(); intent.setIntentName("cllBussinessIntent"); IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE); - when(intentProcessService.intentProcess(any())).thenThrow(new CommonException("MSG", ResponseConsts.RET_UPDATE_DATA_FAIL)); intentController.removeIntentById("intentId"); Assert.assertTrue(true); } @Test - public void testGetIntentListByIntentGenerateType(){ + public void testGetIntentListByIntentGenerateType() { intentController.getIntentListByIntentGenerateType(anyString()); verify(intentService, times(1)).getIntentListByUserInput(anyString()); } + @Test - public void testGetIntentListByIntentGenerateTypeCommoExcption(){ + public void testGetIntentListByIntentGenerateTypeCommoExcption() { when(intentService.getIntentListByUserInput(any())).thenThrow(new CommonException("MSG", ResponseConsts.RET_UPDATE_DATA_FAIL)); intentController.getIntentListByIntentGenerateType(anyString()); Assert.assertTrue(true); diff --git a/intentanalysis/src/test/resources/intentdb-test-init.sql b/intentanalysis/src/test/resources/intentdb-test-init.sql index b3b9e71..d53f04c 100644 --- a/intentanalysis/src/test/resources/intentdb-test-init.sql +++ b/intentanalysis/src/test/resources/intentdb-test-init.sql @@ -94,5 +94,6 @@ create table if not exists intent_Event_Record( intentId varchar(255), intentName varchar(255), intentStatus varchar (225), - operateType varchar (225) + operateType varchar (225), + parent_id varchar(255) ); |