update intent execute process 67/133867/1
authorkaixiliu <liukaixi@chinamobile.com>
Tue, 28 Mar 2023 08:40:53 +0000 (16:40 +0800)
committerkaixiliu <liukaixi@chinamobile.com>
Tue, 28 Mar 2023 08:41:17 +0000 (16:41 +0800)
Issue-ID: USECASEUI-785
Signed-off-by: kaixiliu <liukaixi@chinamobile.com>
Change-Id: Ib38d171e9a1c389a093bb9c46fdb9050e2b8423e

22 files changed:
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/Thread/CreateCallable.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/CLLBusinessIntentManagementFunction.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessActuationModule.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/CLLAssuranceIntentManagementFunction.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceDecisionModule.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceKnowledgeModule.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/CLLDeliveryIntentManagementFunction.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryDecisionModule.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/clldeliveryIntentmgt/clldeliverymodule/CLLDeliveryKnowledgeModule.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/FormatIntentInputManagementFunction.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/contextService/IntentContextService.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/ActuationModule.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/IntentInterfaceService.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentinterfaceservice/impl/IntentInterfaceServiceImpl.java
intentanalysis/src/main/resources/intent-analysis-init.sql
intentanalysis/src/test/resources/intentdb-test-init.sql

index 573749d..5403490 100644 (file)
@@ -19,11 +19,13 @@ package org.onap.usecaseui.intentanalysis;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 @MapperScan("org.onap.usecaseui.intentanalysis.mapper")
 @SpringBootApplication
 @EnableTransactionManagement
+@EnableAsync
 public class IntentAnalysisApplication {
 
     public static void main(String[] args) {
index b91eb63..2d548f2 100644 (file)
@@ -18,6 +18,7 @@ package org.onap.usecaseui.intentanalysis.Thread;
 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.eventAndPublish.event.IntentCreateEvent;
 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
 import org.springframework.context.ApplicationContext;
@@ -53,6 +54,10 @@ public class CreateCallable implements Callable<String> {
         actuationModule.fulfillIntent(intentGoalBean, handler);
         //update origin intent if need
         actuationModule.updateIntentOperationInfo(originalIntent, intentGoalBean);
+
+        String intentStatus = "success";
+        IntentCreateEvent intentCreateEvent = new IntentCreateEvent(this, originalIntent, intentGoalBean, handler, intentStatus);
+        applicationContext.publishEvent(intentCreateEvent);
         return  intentGoalBean.getIntent().getIntentName() +" Intent operate finished";
     }
 }
index 80ff29e..1203508 100644 (file)
@@ -17,32 +17,171 @@ package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt;
 
 
 import lombok.Data;
-import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessActuationModule;
-import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessDecisionModule;
-import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule.CLLBusinessKnowledgeModule;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
+import org.onap.usecaseui.intentanalysis.bean.models.Context;
+import org.onap.usecaseui.intentanalysis.bean.models.Intent;
+import org.onap.usecaseui.intentanalysis.bean.models.IntentEventRecord;
+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.intentEventRecord.IntentEventRecordService;
 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
+import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
+import org.onap.usecaseui.intentanalysis.service.ContextService;
+import org.onap.usecaseui.intentanalysis.service.IntentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
+@Slf4j
 @Data
 @Component("CLLBusinessIntentManagementFunction")
 public class CLLBusinessIntentManagementFunction extends IntentManagementFunction {
 
-    @Resource(name= "CLLBusinessActuationModule")
+    @Resource(name = "CLLBusinessActuationModule")
     public void setActuationModule(ActuationModule actuationModule) {
-        this.actuationModule=actuationModule;
+        this.actuationModule = actuationModule;
     }
-    @Resource(name= "CLLBusinessKnowledgeModule")
+
+    @Resource(name = "CLLBusinessKnowledgeModule")
     public void setKnowledgeModule(KnowledgeModule knowledgeModule) {
-        this.knowledgeModule=knowledgeModule;
+        this.knowledgeModule = knowledgeModule;
     }
-    @Resource(name= "CLLBusinessDecisionModule")
+
+    @Resource(name = "CLLBusinessDecisionModule")
     public void setDecisionModule(DecisionModule decisionModule) {
-        this.decisionModule=decisionModule;
+        this.decisionModule = decisionModule;
+    }
+
+    @Autowired
+    public IntentContextService intentContextService;
+    @Autowired
+    IntentInterfaceService intentInterfaceService;
+    @Autowired
+    ApplicationContext applicationContext;
+    @Autowired
+    ContextService contextService;
+    @Autowired
+    IntentService intentService;
+    @Autowired
+    IntentEventRecordService intentEventRecordService;
+
+    @Resource(name = "intentTaskExecutor")
+    ThreadPoolTaskExecutor executor;
+
+    @Override
+    public void receiveIntentAsOwner(IntentGoalBean intentGoalBean) {
+        IntentGoalBean originIntentGoalBean = detection(intentGoalBean);
+        LinkedHashMap<IntentGoalBean, IntentManagementFunction> linkedMap = investigation(originIntentGoalBean);
+        implementIntent(intentGoalBean.getIntent(), linkedMap);
+        if (intentGoalBean.getIntentGoalType() == IntentGoalType.DELETE) {
+            List<Context> parentInfo = intentGoalBean.getIntent().getIntentContexts().stream().filter(a ->
+                    StringUtils.equalsIgnoreCase(a.getContextName(), "parentIntent info")).collect(Collectors.toList());
+
+            String userInputId = parentInfo.get(0).getContextConditions().get(0).getConditionValue();
+            intentService.deleteIntent(intentGoalBean.getIntent().getIntentId());
+            intentService.deleteIntent(userInputId);
+        }
+    }
+
+    @Override
+    public void receiveIntentAsHandler(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
+        ActuationModule actuationModule = handler.getActuationModule();
+        IntentGoalType type = intentGoalBean.getIntentGoalType();
+        if (type == IntentGoalType.CREATE) {
+            actuationModule.saveIntentToDb(intentGoalBean.getIntent());
+        } else if (type == IntentGoalType.UPDATE) {
+            actuationModule.updateIntentToDb(intentGoalBean.getIntent());
+        } else if (type == IntentGoalType.DELETE) {
+            actuationModule.deleteIntentToDb(intentGoalBean.getIntent());
+        }
+        //update origin intent if need
+        actuationModule.updateIntentOperationInfo(originalIntent, intentGoalBean);
+        handler.receiveIntentAsOwner(intentGoalBean);
+
+    }
+
+    public IntentGoalBean detection(IntentGoalBean intentGoalBean) {
+        Intent originIntent = intentGoalBean.getIntent();
+        IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
+        if (intentGoalType == IntentGoalType.CREATE) {
+            //return knowledgeModule.intentCognition(originIntent);
+            return intentGoalBean;
+        } else if (intentGoalType == IntentGoalType.UPDATE) {
+            return new IntentGoalBean(intentGoalBean.getIntent(), IntentGoalType.UPDATE);
+        } else {
+            return new IntentGoalBean(intentGoalBean.getIntent(), IntentGoalType.DELETE);
+        }
+    }
+
+    public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigation(IntentGoalBean intentGoalBean) {
+        IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
+        if (intentGoalType == IntentGoalType.CREATE) {
+            return decisionModule.investigationCreateProcess(intentGoalBean);
+        } else if (intentGoalType == IntentGoalType.UPDATE) {
+            return decisionModule.investigationUpdateProcess(intentGoalBean);
+        } else {
+            return decisionModule.investigationDeleteProcess(intentGoalBean);
+        }
+    }
+
+    @SneakyThrows
+    public boolean implementIntent(Intent originIntent, LinkedHashMap<IntentGoalBean, IntentManagementFunction> linkedIntentMap) {
+        Iterator<Map.Entry<IntentGoalBean, IntentManagementFunction>> iterator = linkedIntentMap.entrySet().iterator();
+        while (iterator.hasNext()) {
+            Map.Entry<IntentGoalBean, IntentManagementFunction> next = iterator.next();
+            IntentGoalBean newIntentGoalBean = next.getKey();
+            IntentGoalType intentGoalType = newIntentGoalBean.getIntentGoalType();
+            IntentManagementFunction handler = next.getValue();
+            if (intentGoalType == IntentGoalType.CREATE) {
+                Intent newIdIntent = decisionModule.intentObjectDefine(originIntent, next.getKey().getIntent());
+                intentContextService.updateIntentOwnerHandlerContext(newIdIntent, this, next.getValue());
+                intentContextService.updateParentIntentContext(originIntent, newIdIntent);
+                intentContextService.updateChindIntentContext(originIntent, newIdIntent);
+                contextService.updateContextList(originIntent.getIntentContexts(), originIntent.getIntentId());
+                //intent-Distribution-create
+                boolean isAcceptCreate = intentInterfaceService.createInterface(originIntent,
+                        new IntentGoalBean(newIdIntent, IntentGoalType.CREATE), next.getValue());
+                // TODO: 2023/3/27  isParallel status need deal before distribution
+                boolean isParallel = false;
+                if (!isParallel) {
+                    //Block and regularly query whether the event is published
+                    boolean isPublish = false;
+                    while (isPublish) {
+                        Thread.sleep(1000);
+                        IntentEventRecord record = intentEventRecordService.getIntentEventRecordByntentId(newIdIntent.getIntentId(), "create");
+                        if (null != record) {
+                            isPublish = true;
+                        }
+                    }
+                }
+                // return isAcceptCreate;
+            } else if (intentGoalType == IntentGoalType.UPDATE) {
+                //define process  just send probe interface
+                // intent-Distribution-update
+                boolean isAcceptupdate = intentInterfaceService.updateInterface(originIntent,
+                        next.getKey(), next.getValue());
+            } else {
+                // actuationModule.deleteIntentToDb(next.getKey().getIntent());
+                // intent-Distribution-delete
+                boolean isAcceptDelete = intentInterfaceService.deleteInterface(originIntent,
+                        next.getKey(), next.getValue());
+            }
+        }
+        return false;
     }
 
 }
index 62626bc..aa82ee9 100644 (file)
@@ -64,7 +64,8 @@ public class CLLBusinessActuationModule extends ActuationModule {
 
     @Override
     public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) {
-        toNextIntentHandler(intentGoalBean, intentHandler);
+        //toNextIntentHandler(intentGoalBean, intentHandler);
+        intentHandler.receiveIntentAsOwner(intentGoalBean);
     }
        
     @Override
index d2c984d..c57c707 100644 (file)
@@ -46,17 +46,17 @@ public class CLLBusinessKnowledgeModule extends KnowledgeModule {
 
     @Override
     public boolean recieveCreateIntent() {
-        return false;
+        return true;
     }
 
     @Override
     public boolean recieveUpdateIntent() {
-        return false;
+        return true;
     }
 
     @Override
     public boolean recieveDeleteIntent() {
-        return false;
+        return true;
     }
 
     void intentReportResolution() {
index 7947edb..88c1264 100644 (file)
 package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt;
 
 import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.usecaseui.intentanalysis.Thread.CreateCallable;
+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.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.concurrent.FutureTask;
+
+@Slf4j
 @Data
 @Component("CLLAssuranceIntentManagementFunction")
 public class CLLAssuranceIntentManagementFunction extends IntentManagementFunction {
@@ -40,4 +51,29 @@ public class CLLAssuranceIntentManagementFunction extends IntentManagementFuncti
     public void setDecisionModule(DecisionModule decisionModule) {
         this.decisionModule = decisionModule;
     }
+
+    @Autowired
+    ApplicationContext applicationContext;
+    @Resource(name = "intentTaskExecutor")
+    ThreadPoolTaskExecutor executor;
+
+    @Override
+    public void receiveIntentAsOwner(IntentGoalBean intentGoalBean) {
+    }
+
+    @Override
+    public void receiveIntentAsHandler(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
+        //ask  knowledgeModole of handler imf for permision and operate
+        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);
+            executor.submit(futureTask);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+
+    }
+
 }
index abd10fd..3ea832d 100644 (file)
@@ -15,9 +15,6 @@
  */
 package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.cllassurancemodule;
 
-import java.util.List;
-import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
-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.DecisionModule;
index dd560ff..44fb9f8 100644 (file)
@@ -57,17 +57,17 @@ public class CLLAssuranceKnowledgeModule extends KnowledgeModule {
 
     @Override
     public boolean recieveCreateIntent() {
-        return false;
+        return true;
     }
 
     @Override
     public boolean recieveUpdateIntent() {
-        return false;
+        return true;
     }
 
     @Override
     public boolean recieveDeleteIntent() {
-        return false;
+        return true;
     }
 
     /**
index fe37f95..4e358cb 100644 (file)
 package org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt;
 
 import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.usecaseui.intentanalysis.Thread.CreateCallable;
+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.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.concurrent.FutureTask;
+
+@Slf4j
 @Data
 @Component("CLLDeliveryIntentManagementFunction")
 public class CLLDeliveryIntentManagementFunction extends IntentManagementFunction {
@@ -40,4 +51,26 @@ public class CLLDeliveryIntentManagementFunction extends IntentManagementFunctio
     public void setDecisionModule(DecisionModule decisionModule) {
         this.decisionModule = decisionModule;
     }
+
+    @Autowired
+    ApplicationContext applicationContext;
+    @Resource(name = "intentTaskExecutor")
+    ThreadPoolTaskExecutor executor;
+
+    @Override
+    public void receiveIntentAsOwner(IntentGoalBean intentGoalBean) {
+    }
+
+    @Override
+    public void receiveIntentAsHandler(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
+        //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);
+            executor.submit(futureTask);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
 }
index c18cb16..9e344e8 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt.clldeliverymodule;
 
-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.DecisionModule;
index 1222d4d..051c01c 100644 (file)
@@ -29,16 +29,16 @@ public class CLLDeliveryKnowledgeModule extends KnowledgeModule {
 
     @Override
     public boolean recieveCreateIntent() {
-        return false;
+        return true;
     }
 
     @Override
     public boolean recieveUpdateIntent() {
-        return false;
+        return true;
     }
 
     @Override
     public boolean recieveDeleteIntent() {
-        return false;
+        return true;
     }
 }
index 2e80c88..4d16d92 100644 (file)
 package org.onap.usecaseui.intentanalysis.formatintentinputMgt;
 
 import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.usecaseui.intentanalysis.bean.enums.IntentGenerateType;
+import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
+import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
+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.intentBaseService.intentModule.KnowledgeModule;
+import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
+import org.onap.usecaseui.intentanalysis.service.IntentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.util.*;
 
+@Slf4j
 @Data
 @Component("formatIntentInputManagementFunction")
 public class FormatIntentInputManagementFunction extends IntentManagementFunction {
+    @Autowired
+    public IntentContextService intentContextService;
 
-    @Resource(name= "formatIntentInputKnowledgeModule")
+    @Resource(name = "formatIntentInputKnowledgeModule")
     public void setKnowledgeModule(KnowledgeModule knowledgeModule) {
-        this.knowledgeModule=knowledgeModule;
+        this.knowledgeModule = knowledgeModule;
     }
-    @Resource(name= "formatIntentInputActuationModule")
+
+    @Resource(name = "formatIntentInputActuationModule")
     public void setActuationModule(ActuationModule actuationModule) {
 
-        this.actuationModule=actuationModule;
+        this.actuationModule = actuationModule;
     }
-    @Resource(name= "formatIntentInputDecisionModule")
+
+    @Resource(name = "formatIntentInputDecisionModule")
     public void setDecisionModule(DecisionModule decisionModule) {
 
-        this.decisionModule=decisionModule;
+        this.decisionModule = decisionModule;
+    }
+
+    @Autowired
+    IntentInterfaceService intentInterfaceService;
+    @Autowired
+    ApplicationContext applicationContext;
+    @Autowired
+    IntentService intentService;
+
+    @Override
+    public void receiveIntentAsOwner(IntentGoalBean intentGoalBean) {
+
+        IntentGoalBean originIntentGoalBean = detection(intentGoalBean);
+        LinkedHashMap<IntentGoalBean, IntentManagementFunction> linkedMap = investigation(originIntentGoalBean);
+        implementIntent(intentGoalBean.getIntent(), linkedMap);
+    }
+
+    @Override
+    public void receiveIntentAsHandler(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
+    }
+
+    public IntentGoalBean detection(IntentGoalBean intentGoalBean) {
+        Intent originIntent = intentGoalBean.getIntent();
+        IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
+        if (intentGoalType == IntentGoalType.CREATE) {
+            return knowledgeModule.intentCognition(originIntent);
+        } else if (intentGoalType == IntentGoalType.UPDATE) {
+            return new IntentGoalBean(intentGoalBean.getIntent(), IntentGoalType.UPDATE);
+        } else {
+            return new IntentGoalBean(intentGoalBean.getIntent(), IntentGoalType.DELETE);
+        }
+    }
+
+    public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigation(IntentGoalBean intentGoalBean) {
+        IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
+        if (intentGoalType == IntentGoalType.CREATE) {
+            return decisionModule.investigationCreateProcess(intentGoalBean);
+        } else if (intentGoalType == IntentGoalType.UPDATE) {
+            return decisionModule.investigationUpdateProcess(intentGoalBean);
+        } else {
+            return decisionModule.investigationDeleteProcess(intentGoalBean);
+        }
+    }
+
+    public boolean implementIntent(Intent originIntent, LinkedHashMap<IntentGoalBean, IntentManagementFunction> linkedIntentMap) {
+        Iterator<Map.Entry<IntentGoalBean, IntentManagementFunction>> iterator = linkedIntentMap.entrySet().iterator();
+        while (iterator.hasNext()) {
+            Map.Entry<IntentGoalBean, IntentManagementFunction> next = iterator.next();
+            IntentGoalBean newIntentGoalBean = next.getKey();
+            IntentGoalType intentGoalType = newIntentGoalBean.getIntentGoalType();
+            if (intentGoalType == IntentGoalType.CREATE) {
+                Intent newIdIntent = decisionModule.intentObjectDefine(originIntent, next.getKey().getIntent());
+                intentContextService.updateIntentOwnerHandlerContext(newIdIntent, this, next.getValue());
+                intentContextService.updateParentIntentContext(originIntent, newIdIntent);
+                intentContextService.updateChindIntentContext(originIntent, newIdIntent);
+                //intent-Distribution-create
+                boolean isAcceptCreate = intentInterfaceService.createInterface(originIntent,
+                        new IntentGoalBean(newIdIntent, IntentGoalType.CREATE), next.getValue());
+                originIntent.setIntentGenerateType(IntentGenerateType.USERINPUT);
+                //save user input intent
+                intentService.createIntent(originIntent);
+                return isAcceptCreate;
+            } else if (intentGoalType == IntentGoalType.UPDATE) {
+                log.info("formatIntentInputIMF UPDATE");
+                //update cllBusinessIntent's expectation
+                Intent subIntent = newIntentGoalBean.getIntent();
+                updateIntentInfo(originIntent, subIntent);
+                // 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 {
+                // intent-Distribution-delete
+                boolean isAcceptDelete = intentInterfaceService.deleteInterface(originIntent, next.getKey(), next.getValue());
+            }
+        }
+        return true;
+    }
+
+    public void updateIntentInfo(Intent originIntent, Intent intent) {
+
+        List<Expectation> originIntentExpectationList = originIntent.getIntentExpectations();
+        List<Expectation> intentExpectationList = intent.getIntentExpectations();
+        int newIntentExpectationNum = originIntentExpectationList.size();
+        int oldIntentExpectationNum = intentExpectationList.size();
+
+        List<Expectation> changeList = new ArrayList<>();
+        if (newIntentExpectationNum != oldIntentExpectationNum) {
+            if (newIntentExpectationNum < oldIntentExpectationNum) {
+
+                for (Expectation oldExpectation : intentExpectationList) {//search
+                    boolean bFindExpectation = false;
+                    for (Expectation newExpectation : originIntentExpectationList) {//param
+                        if (oldExpectation.getExpectationName().equals(newExpectation.getExpectationName())) {
+                            bFindExpectation = true;
+                            break;
+                        }
+                    }
+                    if (bFindExpectation) {
+                        changeList.add(oldExpectation);
+                    }
+                }
+            }
+        }
+        intent.setIntentExpectations(changeList);
     }
 }
index be6d9ef..efd09a2 100644 (file)
@@ -121,7 +121,7 @@ public class FormatIntentInputDecisionModule extends DecisionModule {
         List<Intent> subIntentList = intentContextService.getSubIntentInfoFromContext(intentGoalBean.getIntent());
         for (Intent intent : subIntentList) {
             IntentManagementFunction intentHandlerInfo = intentContextService.getHandlerInfo(intent);
-            UpdateIntentInfo(intentGoalBean.getIntent(), intent);
+           // UpdateIntentInfo(intentGoalBean.getIntent(), intent);//new process move  to defineProcess
             IntentGoalBean subIntentGoalBean = new IntentGoalBean(intent, IntentGoalType.UPDATE);
             intentMap.put(subIntentGoalBean, intentHandlerInfo);
         }
index 387d728..453a1cd 100644 (file)
@@ -17,6 +17,8 @@ package org.onap.usecaseui.intentanalysis.intentBaseService;
 
 
 import lombok.Data;
+import org.onap.usecaseui.intentanalysis.bean.models.Intent;
+import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
@@ -30,4 +32,7 @@ public class IntentManagementFunction {
     protected ActuationModule actuationModule;
     protected DecisionModule decisionModule;
     protected KnowledgeModule knowledgeModule;
+
+    public void receiveIntentAsOwner(IntentGoalBean intentGoalBean){};
+    public void receiveIntentAsHandler(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler){};
 }
index 76ff2d2..4d2ee3e 100644 (file)
@@ -41,6 +41,12 @@ public class IntentContextService {
     @Autowired
     ApplicationContext applicationContext;
 
+    public void updateIntentContext(Intent newIdIntent,Intent originIntent,IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){
+        updateIntentOwnerHandlerContext(newIdIntent, intentOwner, intentHandler);
+        updateParentIntentContext(originIntent, newIdIntent);
+        updateChindIntentContext(originIntent, newIdIntent);
+    }
+
     public void updateChindIntentContext(Intent originIntent, Intent intent){
         List<Context> contextList = intent.getIntentContexts();
         if (CollectionUtils.isEmpty(contextList)) {
index 9b4c248..f41c5ee 100644 (file)
@@ -65,11 +65,11 @@ public abstract class ActuationModule {
     public boolean distrubuteIntentToHandler(Map.Entry<IntentGoalBean, IntentManagementFunction> entry) {
         IntentGoalType intentGoalType = entry.getKey().getIntentGoalType();
         if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) {
-            return intentInterfaceService.createInterface(entry.getKey().getIntent(), entry.getValue());
+            return intentInterfaceService.createInterface(entry.getKey(), entry.getValue());
         } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) {
-            return intentInterfaceService.updateInterface(entry.getKey().getIntent(), entry.getValue());
+            return intentInterfaceService.updateInterface(entry.getKey(), entry.getValue());
         } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) {
-            return intentInterfaceService.deleteInterface(entry.getKey().getIntent(), entry.getValue());
+            return intentInterfaceService.deleteInterface(entry.getKey(), entry.getValue());
         }
         return false;
     }
index 51d50d4..549672c 100644 (file)
@@ -35,7 +35,7 @@ public abstract class DecisionModule {
     // find intentManageFunction
     public abstract IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean);
 
-    public Intent intentDefinition(Intent originIntent, Intent intent) {
+    public Intent intentObjectDefine(Intent originIntent, Intent intent) {
         log.debug("definition create process start to define intent:" + intent.getIntentName());
         Intent newIntent = new Intent();
         newIntent.setIntentId(CommonUtil.getUUid());
index c2a48ff..64ab8c4 100644 (file)
@@ -56,7 +56,7 @@ public class IntentDefinitionService {
 
         IntentGoalBean newIntentGoalBean = entry.getKey();
         if (newIntentGoalBean.getIntentGoalType() == IntentGoalType.CREATE){
-            Intent newIdIntent = intentDecisionModule.intentDefinition(originIntent, entry.getKey().getIntent());
+            Intent newIdIntent = intentDecisionModule.intentObjectDefine(originIntent, entry.getKey().getIntent());
             intentContextService.updateIntentOwnerHandlerContext(newIdIntent, intentOwner, intentHandler);
             intentContextService.updateParentIntentContext(originIntent, newIdIntent);
             intentContextService.updateChindIntentContext(originIntent, newIdIntent);
index 4470d05..bbb09f4 100644 (file)
 package org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice;
 
 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
+import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
 
 public interface IntentInterfaceService {
-    public boolean createInterface(Intent intent, IntentManagementFunction imf);
+    public boolean createInterface(IntentGoalBean intentGoalBean, IntentManagementFunction imf);
+    public boolean createInterface(Intent originalIntent,IntentGoalBean intentGoalBean, IntentManagementFunction imf);
 
-    public boolean updateInterface(Intent intent, IntentManagementFunction imf);
+    public boolean updateInterface(IntentGoalBean intentGoalBean, IntentManagementFunction imf);
+    public boolean updateInterface(Intent originalIntent,IntentGoalBean intentGoalBean, IntentManagementFunction imf);
+
+    public boolean deleteInterface(IntentGoalBean intentGoalBean, IntentManagementFunction imf);
+    public boolean deleteInterface(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction imf);
 
-    public boolean deleteInterface(Intent intent, IntentManagementFunction imf);
 }
index 1c6d853..a9410c6 100644 (file)
 package org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.impl;
 
 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.intentinterfaceservice.IntentInterfaceService;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
+
 @Service
 public class IntentInterfaceServiceImpl implements IntentInterfaceService {
     @Override
-    public boolean createInterface(Intent intent, IntentManagementFunction imf) {
-        //ask  knowledgeModole of handler imf for permision
-        imf.getKnowledgeModule().recieveCreateIntent();
+    public boolean createInterface(IntentGoalBean intentGoalBean, IntentManagementFunction imf) {
         return false;
     }
 
     @Override
-    public boolean updateInterface(Intent intent, IntentManagementFunction imf) {
-        imf.getKnowledgeModule().recieveUpdateIntent();
-        return false;
+    public boolean createInterface(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
+        //ask  knowledgeModole of handler imf for permision
+        boolean receive = handler.getKnowledgeModule().recieveCreateIntent();
+        LocalDateTime now = LocalDateTime.now();
+        if (receive) {
+                handler.receiveIntentAsHandler(originalIntent, intentGoalBean, handler);
+        }
+        return receive;
+
     }
 
     @Override
-    public boolean deleteInterface(Intent intent, IntentManagementFunction imf) {
-        imf.getKnowledgeModule().recieveDeleteIntent();
+    public boolean updateInterface(IntentGoalBean intentGoalBean, IntentManagementFunction imf) {
         return false;
     }
+
+    @Override
+    public boolean updateInterface(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
+        boolean receive = handler.getKnowledgeModule().recieveUpdateIntent();
+        if (receive) {
+            handler.receiveIntentAsHandler(originalIntent, intentGoalBean, handler);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean deleteInterface(IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
+        handler.getKnowledgeModule().recieveDeleteIntent();
+        return true;
+    }
+
+    @Override
+    public boolean deleteInterface(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
+        boolean receive = handler.getKnowledgeModule().recieveDeleteIntent();
+        if (receive) {
+            handler.receiveIntentAsHandler(originalIntent, intentGoalBean, handler);
+        }
+        return true;
+    }
 }
index 682c976..a3834f9 100644 (file)
@@ -70,4 +70,12 @@ create table if not exists intent_management_function_reg_info(
     support_interfaces varchar(255),
     handle_name varchar(255),
     intent_function_type varchar(255)
+    );
+
+create table if not exists intent_Event_Record(
+    id varchar(255) DEFAULT uuid_generate_v4 (),
+    intentId varchar(255),
+    intentName varchar(255),
+    intentStatus varchar (225),
+    operateType varchar (225)
     );
\ No newline at end of file
index 855d5dd..b3b9e71 100644 (file)
@@ -88,3 +88,11 @@ create table if not exists intent_management_function_reg_info(
     handle_name varchar(255),
     intent_function_type varchar(255)
     );
+
+create table if not exists intent_Event_Record(
+    id varchar(255) DEFAULT random_uuid(),
+    intentId varchar(255),
+    intentName varchar(255),
+    intentStatus varchar (225),
+    operateType varchar (225)
+    );