summaryrefslogtreecommitdiffstats
path: root/intentanalysis
diff options
context:
space:
mode:
Diffstat (limited to 'intentanalysis')
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ContextMapper.java11
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java12
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java10
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationTargetMapper.java7
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/FulfilmentInfoMapper.java6
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java13
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java8
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ContextService.java7
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectService.java5
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java10
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetService.java6
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ConditionServiceImpl.java8
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ContextServiceImpl.java45
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java39
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java93
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationTargetServiceImpl.java57
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfilmentInfoServiceImpl.java24
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java44
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java17
-rw-r--r--intentanalysis/src/main/resources/intent-analysis-init.sql21
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml24
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml26
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml28
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ExpectationObjectMapper.xml20
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ExpectationTargetMapper.xml16
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/FulfilmentInfoMapper.xml11
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml13
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml25
30 files changed, 342 insertions, 268 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ContextMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ContextMapper.java
index 4e5acea..5878f81 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ContextMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ContextMapper.java
@@ -20,18 +20,15 @@ package org.onap.usecaseui.intentanalysis.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
-import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
@Mapper
public interface ContextMapper {
- void insertContextList(@Param(value = "contextList") List<Context> contextList);
+ int insertContextList(@Param(value = "contextList") List<Context> contextList,
+ @Param(value = "parentId") String parentId);
- void insertContextParentList(@Param(value = "contextList") List<Context> contextList,
- @Param(value = "parentType") ContextParentType contextParentType,
- @Param(value = "parentId") String parentId);
-
- List<Context> selectContextByParentId(String parentId);
+ List<Context> selectContextByParentId(@Param(value = "parentId") String parentId);
}
+
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java
index 8f8eea1..72d96a3 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java
@@ -26,17 +26,17 @@ import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
@Mapper
public interface ExpectationMapper {
- int insertIntentExpectations(@Param(value = "intentExpectations") List<Expectation> intentExpectations,
- @Param(value = "intentId") String intentId);
+ int insertIntentExpectationList(@Param(value = "intentExpectationList") List<Expectation> intentExpectationList,
+ @Param(value = "intentId") String intentId);
int insertIntentExpectation(@Param(value = "expectation") Expectation expectation,
@Param(value = "intentId") String intentId);
- int deleteIntentExpectationsByIntentId(String intentId);
+ int deleteIntentExpectationListByIntentId(@Param(value = "intentId") String intentId);
- int updateIntentExpectation(Expectation expectation);
+ int updateIntentExpectation(@Param(value = "expectation") Expectation expectation);
- int deleteIntentExpectationById(String expectationId);
+ int deleteIntentExpectationById(@Param(value = "expectationId") String expectationId);
- List<Expectation> selectIntentExpectationsByIntentId(String intentId);
+ List<Expectation> selectIntentExpectationListByIntentId(@Param(value = "intentId") String intentId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java
index 5b5a70f..57f2bd3 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java
@@ -17,16 +17,18 @@
package org.onap.usecaseui.intentanalysis.mapper;
-import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
-import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
@Mapper
public interface ExpectationObjectMapper {
- void insertExpectationObject(@Param(value = "expectationObject") ExpectationObject expectationObject,
- @Param(value = "expectationId") String expectationId);
+ int insertExpectationObject(@Param(value = "expectationObject") ExpectationObject expectationObject,
+ @Param(value = "expectationId") String expectationId);
+
+ ExpectationObject selectExpectationObjectByExpectationId(@Param(value = "expectationId") String expectationId);
+
+ String selectExpectationObjectId(@Param(value = "expectationId") String expectationId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationTargetMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationTargetMapper.java
index 945795e..c418ff4 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationTargetMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationTargetMapper.java
@@ -26,6 +26,9 @@ import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget;
@Mapper
public interface ExpectationTargetMapper {
- void insertExpectationTarget(@Param(value = "expectationTarget") ExpectationTarget expectationTarget,
- @Param(value = "expectationId") String expectationId);
+ int insertExpectationTarget(@Param(value = "expectationTarget") ExpectationTarget expectationTarget,
+ @Param(value = "expectationId") String expectationId);
+
+ List<ExpectationTarget> selectExpectationTargetListByExpectationId(
+ @Param(value = "expectationId") String expectationId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/FulfilmentInfoMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/FulfilmentInfoMapper.java
index 2b7cd9a..9e3819f 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/FulfilmentInfoMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/FulfilmentInfoMapper.java
@@ -25,8 +25,8 @@ import org.onap.usecaseui.intentanalysis.bean.models.FulfilmentInfo;
@Mapper
public interface FulfilmentInfoMapper {
- void insertFulfilmentInfo(@Param(value = "fulfilmentInfo") FulfilmentInfo fulfilmentInfo,
- @Param(value = "parentId") String parentId);
+ int insertFulfilmentInfo(@Param(value = "fulfilmentInfo") FulfilmentInfo fulfilmentInfo,
+ @Param(value = "parentId") String parentId);
- FulfilmentInfo selectFulfilmentInfoById(String parentId);
+ FulfilmentInfo selectFulfilmentInfoById(@Param(value = "parentId") String parentId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java
index 867f315..c051e68 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java
@@ -19,21 +19,22 @@ package org.onap.usecaseui.intentanalysis.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
@Mapper
public interface IntentMapper {
- int insertIntent(Intent intent);
+ int insertIntent(@Param(value = "intent") Intent intent);
- int updateIntent(Intent intent);
+ int updateIntent(@Param(value = "intent") Intent intent);
- Intent selectIntentById(String intentId);
+ Intent selectIntentById(@Param(value = "intentId") String intentId);
- List<Intent> selectIntents();
+ List<Intent> selectIntentList();
- int deleteIntentById(String intentId);
+ int deleteIntentById(@Param(value = "intentId") String intentId);
- List<Intent> getIntentByName(String name);
+ List<Intent> getIntentByName(@Param(value = "name") String name);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java
index ce261a1..10538c4 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java
@@ -31,13 +31,13 @@ public interface StateMapper {
int insertStateList(@Param(value = "stateList") List<State> state,
@Param(value = "expectationId") String expectationId);
- List<State> selectStateByExpectation(String expectationId);
+ List<State> selectStateByExpectation(@Param(value = "expectationId") String expectationId);
- int deleteStateByExpectationId(String expectationId);
+ int deleteStateByExpectationId(@Param(value = "expectationId") String expectationId);
- int updateState(State state);
+ int updateState(@Param(value = "state") State state);
int insertState(@Param(value = "state") State state, @Param(value = "expectationId") String expectationId);
- int deleteStateById(String stateId);
+ int deleteStateById(@Param(value = "stateId") String stateId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ContextService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ContextService.java
index 2cabbf6..502cdc2 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ContextService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ContextService.java
@@ -18,17 +18,14 @@ package org.onap.usecaseui.intentanalysis.service;
import java.util.List;
-import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
public interface ContextService {
- void createContextList(List<Context> contextList, ContextParentType contextParentType, String parentId);
+ void createContextList(List<Context> contextList, String parentId);
- void insertContext(Context context, String parentId);
-
- void deleteContextListByParentId(String parentId);
+ void createContext(Context context, String parentId);
void deleteContextById(String contextId);
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectService.java
index a5e2462..4cf6bd5 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectService.java
@@ -22,5 +22,8 @@ import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
public interface ExpectationObjectService {
- void createObject(ExpectationObject expectationObject, String expectationId);
+ void createExpectationObject(ExpectationObject expectationObject, String expectationId);
+
+ ExpectationObject getExpectationObjectByExpectationId(String expectationId);
+
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java
index baee400..a4f47ac 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java
@@ -23,15 +23,15 @@ import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
public interface ExpectationService {
- void createIntentExpectations(List<Expectation> intentExpectations, String intentId);
+ void createIntentExpectationList(List<Expectation> intentExpectationList, String intentId);
- void insertIntentExpectation(Expectation expectation, String intentId);
+ void createIntentExpectation(Expectation expectation, String intentId);
- void deleteIntentExpectationsByIntentId(String intentId);
+ void deleteIntentExpectationListByIntentId(String intentId);
void deleteIntentExpectationById(String expectationId);
- void updateIntentExpectationsByIntentId(List<Expectation> intentExpectations, String intentId);
+ void updateIntentExpectationListByIntentId(List<Expectation> intentExpectationList, String intentId);
- List<Expectation> getIntentExpectationsByIntentId(String intentId);
+ List<Expectation> getIntentExpectationListByIntentId(String intentId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetService.java
index 255e4c5..7521e59 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetService.java
@@ -23,7 +23,9 @@ import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget;
public interface ExpectationTargetService {
- void createTarget(ExpectationTarget expectationTarget, String expectationId);
+ void createExpectationTarget(ExpectationTarget expectationTarget, String expectationId);
- void createTargets(List<ExpectationTarget> expectationTargets, String expectationId);
+ void createExpectationTargetList(List<ExpectationTarget> expectationTargetList, String expectationId);
+
+ List<ExpectationTarget> getExpectationTargetListByExpectationId(String expectationId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java
index fd34c77..d2d66c7 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java
@@ -31,7 +31,7 @@ public interface StateService {
List<State> getStateListByExpectationId(String expectationId);
- void insertState(State state, String expectationId);
+ void createState(State state, String expectationId);
void deleteStateById(String stateId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ConditionServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ConditionServiceImpl.java
index a553b90..10864f1 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ConditionServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ConditionServiceImpl.java
@@ -15,12 +15,11 @@
*/
package org.onap.usecaseui.intentanalysis.service.impl;
+import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.bean.enums.ConditionParentType;
import org.onap.usecaseui.intentanalysis.bean.models.Condition;
import org.onap.usecaseui.intentanalysis.mapper.ConditionMapper;
import org.onap.usecaseui.intentanalysis.service.ConditionService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -28,10 +27,9 @@ import java.util.List;
@Service
+@Slf4j
public class ConditionServiceImpl implements ConditionService {
- private static Logger LOGGER = LoggerFactory.getLogger(ContextServiceImpl.class);
-
@Autowired
private ConditionMapper conditionMapper;
@@ -41,7 +39,7 @@ public class ConditionServiceImpl implements ConditionService {
@Override
public void createConditionList(List<Condition> conditionList, ConditionParentType conditionParentType, String parentId) {
conditionMapper.insertConditionList(conditionList);
- conditionMapper.insertConditionParentList(conditionList,conditionParentType,parentId);
+ conditionMapper.insertConditionParentList(conditionList, conditionParentType, parentId);
}
@Override
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ContextServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ContextServiceImpl.java
index c0f472d..ef75755 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ContextServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ContextServiceImpl.java
@@ -17,14 +17,17 @@
package org.onap.usecaseui.intentanalysis.service.impl;
+import java.util.ArrayList;
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.bean.enums.ConditionParentType;
-import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
+import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
+import org.springframework.stereotype.Service;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
import org.onap.usecaseui.intentanalysis.mapper.ContextMapper;
import org.onap.usecaseui.intentanalysis.service.ConditionService;
import org.onap.usecaseui.intentanalysis.service.ContextService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -32,11 +35,11 @@ import java.util.List;
@Service
+@Slf4j
public class ContextServiceImpl implements ContextService {
- static Logger LOGGER = LoggerFactory.getLogger(ContextServiceImpl.class);
-
private ConditionParentType conditionParentType;
+
@Autowired
private ContextMapper contextMapper;
@@ -47,22 +50,20 @@ public class ContextServiceImpl implements ContextService {
private ConditionService conditionService;
@Override
- public void createContextList(List<Context> contextList, ContextParentType contextParentType, String parentId) {
- contextMapper.insertContextList(contextList);
-
- for (Context context: contextList) {
- conditionService.createConditionList(context.getContextConditions(),conditionParentType.CONTEXT,context.getContextId());
+ public void createContextList(List<Context> contextList, String parentId) {
+ if (contextMapper.insertContextList(contextList, parentId) < 1) {
+ String msg = "Create context list to database failed.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
+ for (Context context : contextList) {
+ conditionService.createConditionList(context.getContextConditions(), conditionParentType.CONTEXT,
+ context.getContextId());
}
-
- contextMapper.insertContextParentList(contextList, contextParentType, parentId);
- }
-
- @Override
- public void insertContext(Context context, String parentId) {
}
@Override
- public void deleteContextListByParentId(String parentId) {
+ public void createContext(Context context, String parentId) {
}
@Override
@@ -75,6 +76,12 @@ public class ContextServiceImpl implements ContextService {
@Override
public List<Context> getContextListByParentId(String parentId) {
- return contextMapper.selectContextByParentId(parentId);
+ List<Context> contextList = contextMapper.selectContextByParentId(parentId);
+ if (contextList == null) {
+ String msg = String.format("Context: Intent id %s doesn't exist in database.", parentId);
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ return contextList;
}
-}
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java
index 32ae35c..d94dfdc 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java
@@ -17,14 +17,11 @@
package org.onap.usecaseui.intentanalysis.service.impl;
-import java.util.ArrayList;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
+import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
-import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
import org.onap.usecaseui.intentanalysis.mapper.ExpectationObjectMapper;
import org.onap.usecaseui.intentanalysis.service.ContextService;
@@ -32,12 +29,9 @@ import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
@Service
+@Slf4j
public class ExpectationObjectServiceImpl implements ExpectationObjectService {
- private static Logger LOGGER = LoggerFactory.getLogger(ExpectationObjectServiceImpl.class);
-
- private ContextParentType contextParentType;
-
@Autowired
private ExpectationObjectMapper expectationObjectMapper;
@@ -48,9 +42,26 @@ public class ExpectationObjectServiceImpl implements ExpectationObjectService {
private ContextService contextService;
@Override
- public void createObject(ExpectationObject expectationObject, String expectationId) {
- expectationObjectMapper.insertExpectationObject(expectationObject, expectationId);
+ public void createExpectationObject(ExpectationObject expectationObject, String expectationId) {
+ if (expectationObjectMapper.insertExpectationObject(expectationObject, expectationId) < 1) {
+ String msg = "Create expectation object to database failed.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
contextService.createContextList(expectationObject.getObjectContexts(),
- contextParentType.EXPECTATION_OBJECT, expectationId);
+ expectationObjectMapper.selectExpectationObjectId(expectationId));
+ }
+
+ @Override
+ public ExpectationObject getExpectationObjectByExpectationId(String expectationId) {
+ ExpectationObject expectationObject = expectationObjectMapper.selectExpectationObjectByExpectationId(expectationId);
+ if (expectationObject == null) {
+ String msg = String.format("ExpectationObject: expectation id %s doesn't exist in database.", expectationId);
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ expectationObject.setObjectContexts(contextService.getContextListByParentId(expectationObjectMapper.selectExpectationObjectId(expectationId)));
+
+ return expectationObject;
}
-}
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java
index d5db0ca..76911e9 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java
@@ -23,9 +23,7 @@ import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
-import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget;
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.onap.usecaseui.intentanalysis.mapper.ExpectationMapper;
@@ -54,35 +52,28 @@ public class ExpectationServiceImpl implements ExpectationService {
@Autowired
private FulfilmentInfoService fulfilmentInfoService;
- private ContextParentType contextParentType;
-
@Override
- public void createIntentExpectations(List<Expectation> intentExpectations, String intentId) {
- for (Expectation expectation : intentExpectations) {
- if (null != expectation) {
- expectationObjectService.createObject(expectation.getExpectationObject(),
- expectation.getExpectationId());
- expectationTargetService.createTargets(expectation.getExpectationTargets(),
- expectation.getExpectationId());
- contextService.createContextList(expectation.getExpectationContexts(),
- contextParentType.EXPECTATION,
- expectation.getExpectationId());
- fulfilmentInfoService.createFulfilmentInfo(expectation.getExpectationFulfilmentInfo(),
- expectation.getExpectationId());
- }
- }
- int res = expectationMapper.insertIntentExpectations(intentExpectations, intentId);
- if (res < 1) {
+ public void createIntentExpectationList(List<Expectation> intentExpectationList, String intentId) {
+ if (expectationMapper.insertIntentExpectationList(intentExpectationList, intentId) < 1) {
String msg = "Create expectation to database failed.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
+ for (Expectation expectation : intentExpectationList) {
+ String expectationId = expectation.getExpectationId();
+ expectationObjectService.createExpectationObject(expectation.getExpectationObject(),
+ expectationId);
+ expectationTargetService.createExpectationTargetList(expectation.getExpectationTargets(),
+ expectationId);
+ contextService.createContextList(expectation.getExpectationContexts(), expectationId);
+ fulfilmentInfoService.createFulfilmentInfo(expectation.getExpectationFulfilmentInfo(),
+ expectationId);
+ }
}
@Override
- public void insertIntentExpectation(Expectation expectation, String intentId) {
- int res = expectationMapper.insertIntentExpectation(expectation, intentId);
- if (res < 1) {
+ public void createIntentExpectation(Expectation expectation, String intentId) {
+ if (expectationMapper.insertIntentExpectation(expectation, intentId) < 1) {
String msg = "Create expectation to database failed.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
@@ -90,49 +81,51 @@ public class ExpectationServiceImpl implements ExpectationService {
}
@Override
- public List<Expectation> getIntentExpectationsByIntentId(String intentId) {
- List<Expectation> expectationList = expectationMapper.selectIntentExpectationsByIntentId(intentId);
+ public List<Expectation> getIntentExpectationListByIntentId(String intentId) {
+ List<Expectation> expectationList = expectationMapper.selectIntentExpectationListByIntentId(intentId);
if (expectationList == null) {
- String msg = String.format("Intent id %s doesn't exist in database.", intentId);
+ String msg = String.format("Expectation: Intent id %s doesn't exist in database.", intentId);
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
- int res = expectationMapper.deleteIntentExpectationsByIntentId(intentId);
- if (res < 1) {
- String msg = "Delete expectation in database failed.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ for (Expectation expectation : expectationList) {
+ if (expectation != null) {
+ String expectationId = expectation.getExpectationId();
+ expectation.setExpectationObject(expectationObjectService.getExpectationObjectByExpectationId(expectationId));
+ expectation.setExpectationTargets(expectationTargetService.getExpectationTargetListByExpectationId(expectationId));
+ expectation.setExpectationContexts(contextService.getContextListByParentId(expectationId));
+ expectation.setExpectationFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfoByParentId(expectationId));
+ }
}
return expectationList;
}
@Override
- public void updateIntentExpectationsByIntentId(List<Expectation> intentExpectations, String intentId) {
- List<Expectation> expectationDBList = expectationMapper.selectIntentExpectationsByIntentId(intentId);
- if (expectationDBList == null) {
+ public void updateIntentExpectationListByIntentId(List<Expectation> intentExpectationList, String intentId) {
+ List<Expectation> expectationList = expectationMapper.selectIntentExpectationListByIntentId(intentId);
+ if (expectationList == null) {
String msg = String.format("Intent id %s doesn't exist in database.", intentId);
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
- List<String> expectationDBIdList = new ArrayList<>();
- for (Expectation expectationDB : expectationDBList) {
- expectationDBIdList.add(expectationDB.getExpectationId());
+ List<String> expectationIdList = new ArrayList<>();
+ for (Expectation expectationDB : expectationList) {
+ expectationIdList.add(expectationDB.getExpectationId());
}
- for (Expectation expectation : intentExpectations) {
- if (expectationDBIdList.contains(expectation.getExpectationId())) {
- int res = expectationMapper.updateIntentExpectation(expectation);
- if (res < 1) {
+ for (Expectation expectation : intentExpectationList) {
+ if (expectationIdList.contains(expectation.getExpectationId())) {
+ if (expectationMapper.updateIntentExpectation(expectation) < 1) {
String msg = "Update expectation in database failed.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
}
- expectationDBIdList.remove(expectation.getExpectationId());
+ expectationIdList.remove(expectation.getExpectationId());
} else {
- expectationService.insertIntentExpectation(expectation, intentId);
+ expectationService.createIntentExpectation(expectation, intentId);
}
}
- for (String expectationDBId : expectationDBIdList) {
+ for (String expectationDBId : expectationIdList) {
expectationService.deleteIntentExpectationById(expectationDBId);
}
log.info("Expectations are successfully updated.");
@@ -140,8 +133,7 @@ public class ExpectationServiceImpl implements ExpectationService {
@Override
public void deleteIntentExpectationById(String expectationId) {
- int res = expectationMapper.deleteIntentExpectationById(expectationId);
- if (res < 1) {
+ if (expectationMapper.deleteIntentExpectationById(expectationId) < 1) {
String msg = "Delete expectation in database failed.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
@@ -149,18 +141,17 @@ public class ExpectationServiceImpl implements ExpectationService {
}
@Override
- public void deleteIntentExpectationsByIntentId(String intentId) {
- List<Expectation> expectationList = expectationMapper.selectIntentExpectationsByIntentId(intentId);
+ public void deleteIntentExpectationListByIntentId(String intentId) {
+ List<Expectation> expectationList = expectationMapper.selectIntentExpectationListByIntentId(intentId);
if (expectationList == null) {
String msg = String.format("Intent id %s doesn't exist in database.", intentId);
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
- int res = expectationMapper.deleteIntentExpectationsByIntentId(intentId);
- if (res < 1) {
+ if (expectationMapper.deleteIntentExpectationListByIntentId(intentId) < 1) {
String msg = "Delete expectation in database failed.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
}
}
-}
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationTargetServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationTargetServiceImpl.java
index 87e8435..a6de3da 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationTargetServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationTargetServiceImpl.java
@@ -17,16 +17,15 @@
package org.onap.usecaseui.intentanalysis.service.impl;
-import java.util.ArrayList;
import java.util.List;
import org.onap.usecaseui.intentanalysis.bean.enums.ConditionParentType;
import org.onap.usecaseui.intentanalysis.service.ConditionService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
+import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget;
import org.onap.usecaseui.intentanalysis.mapper.ExpectationTargetMapper;
import org.onap.usecaseui.intentanalysis.service.ContextService;
@@ -35,13 +34,11 @@ import org.onap.usecaseui.intentanalysis.service.FulfilmentInfoService;
@Service
+@Slf4j
public class ExpectationTargetServiceImpl implements ExpectationTargetService {
- private static Logger LOGGER = LoggerFactory.getLogger(ExpectationTargetServiceImpl.class);
-
- private ContextParentType contextParentType;
-
private ConditionParentType conditionParentType;
+
@Autowired
private ExpectationTargetMapper expectationTargetMapper;
@@ -57,23 +54,45 @@ public class ExpectationTargetServiceImpl implements ExpectationTargetService {
@Autowired
private ConditionService conditionService;
+
@Override
- public void createTarget(ExpectationTarget expectationTarget, String expectationId) {
- expectationTargetMapper.insertExpectationTarget(expectationTarget, expectationId);
- contextService.createContextList(expectationTarget.getTargetContexts(),
- contextParentType.EXPECTATION_TARGET,
- expectationTarget.getTargetId());
+ public void createExpectationTarget(ExpectationTarget expectationTarget, String expectationId) {
+ if (expectationTargetMapper.insertExpectationTarget(expectationTarget, expectationId) < 1) {
+ String msg = "Create expectation to database failed.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
+ contextService.createContextList(expectationTarget.getTargetContexts(), expectationTarget.getTargetId());
fulfilmentInfoService.createFulfilmentInfo(expectationTarget.getTargetFulfilmentInfo(),
expectationTarget.getTargetId());
- conditionService.createConditionList(expectationTarget.getTargetConditions(),conditionParentType.EXPECTATION_TARGET,expectationId);
+ conditionService.createConditionList(expectationTarget.getTargetConditions(),
+ conditionParentType.EXPECTATION_TARGET, expectationId);
}
@Override
- public void createTargets(List<ExpectationTarget> expectationTargets, String expectationId) {
- for (ExpectationTarget expectationTarget : expectationTargets) {
- if (null != expectationTarget) {
- expectationTargetService.createTarget(expectationTarget, expectationId);
+ public void createExpectationTargetList(List<ExpectationTarget> expectationTargetList, String expectationId) {
+ for (ExpectationTarget expectationTarget : expectationTargetList) {
+ if (expectationTarget != null) {
+ expectationTargetService.createExpectationTarget(expectationTarget, expectationId);
+ }
+ }
+ }
+
+ @Override
+ public List<ExpectationTarget> getExpectationTargetListByExpectationId(String expectationId) {
+ List<ExpectationTarget> expectationTargetList = expectationTargetMapper.selectExpectationTargetListByExpectationId(expectationId);
+ if (expectationTargetList == null) {
+ String msg = String.format("Target: Expectation id %s doesn't exist in database.", expectationId);
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ for (ExpectationTarget expectationTarget : expectationTargetList) {
+ if (expectationTarget != null) {
+ String targetId = expectationTarget.getTargetId();
+ expectationTarget.setTargetContexts(contextService.getContextListByParentId(targetId));
+ expectationTarget.setTargetFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfoByParentId(targetId));
}
}
+ return expectationTargetList;
}
-}
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfilmentInfoServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfilmentInfoServiceImpl.java
index 3f7947d..f42b87d 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfilmentInfoServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfilmentInfoServiceImpl.java
@@ -17,8 +17,9 @@
package org.onap.usecaseui.intentanalysis.service.impl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
+import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.onap.usecaseui.intentanalysis.bean.models.FulfilmentInfo;
@@ -27,10 +28,9 @@ import org.onap.usecaseui.intentanalysis.service.FulfilmentInfoService;
@Service
+@Slf4j
public class FulfilmentInfoServiceImpl implements FulfilmentInfoService {
- private static Logger LOGGER = LoggerFactory.getLogger(FulfilmentInfoServiceImpl.class);
-
@Autowired
private FulfilmentInfoMapper fulfilmentInfoMapper;
@@ -39,7 +39,11 @@ public class FulfilmentInfoServiceImpl implements FulfilmentInfoService {
@Override
public void createFulfilmentInfo(FulfilmentInfo fulfilmentInfo, String parentId) {
- fulfilmentInfoMapper.insertFulfilmentInfo(fulfilmentInfo, parentId);
+ if (fulfilmentInfoMapper.insertFulfilmentInfo(fulfilmentInfo, parentId) < 1) {
+ String msg = "Create fulfilmentInfoMapper to database failed.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
}
@Override
@@ -52,6 +56,12 @@ public class FulfilmentInfoServiceImpl implements FulfilmentInfoService {
@Override
public FulfilmentInfo getFulfilmentInfoByParentId(String parentId) {
- return fulfilmentInfoMapper.selectFulfilmentInfoById(parentId);
+ FulfilmentInfo fulfilmentInfo = fulfilmentInfoMapper.selectFulfilmentInfoById(parentId);
+ if (fulfilmentInfo == null) {
+ String msg = String.format("FulfilmentInfo: Parent id %s doesn't exist in database.", parentId);
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ return fulfilmentInfo;
}
-}
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java
index 85ae90e..9fdc3ba 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java
@@ -39,4 +39,4 @@ public class ImfRegInfoServiceImpl implements ImfRegInfoService {
public List<IntentManagementFunctionRegInfo> getImfRegInfoList() {
return imfRegInfoMapper.getImfRegInfoList();
}
-}
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
index dd3b9fe..02a85f8 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
@@ -17,14 +17,12 @@
package org.onap.usecaseui.intentanalysis.service.impl;
-import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
@@ -48,22 +46,19 @@ public class IntentServiceImpl implements IntentService {
@Autowired
private ContextService contextService;
- private ContextParentType contextParentType;
-
@Autowired
private FulfilmentInfoService fulfilmentInfoService;
@Transactional(rollbackFor = RuntimeException.class)
@Override
public Intent createIntent(Intent intent) {
- int res = intentMapper.insertIntent(intent);
- if (res < 1) {
+ if (intentMapper.insertIntent(intent) < 1) {
String msg = "Create intent to database failed.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
- expectationService.createIntentExpectations(intent.getIntentExpectations(), intent.getIntentId());
- contextService.createContextList(intent.getIntentContexts(), contextParentType.INTENT, intent.getIntentId());
+ expectationService.createIntentExpectationList(intent.getIntentExpectations(), intent.getIntentId());
+ contextService.createContextList(intent.getIntentContexts(), intent.getIntentId());
fulfilmentInfoService.createFulfilmentInfo(intent.getIntentFulfilmentInfo(), intent.getIntentId());
log.debug("Intent was successfully created.");
return intent;
@@ -71,14 +66,20 @@ public class IntentServiceImpl implements IntentService {
@Override
public List<Intent> getIntentList() {
- List<Intent> intentList = intentMapper.selectIntents();
+ List<Intent> intentList = intentMapper.selectIntentList();
if (intentList == null || intentList.size() <= 0) {
String msg = "Intent list doesn't exist in the intent database.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
for (Intent intent : intentList) {
- intent.setIntentExpectations(expectationService.getIntentExpectationsByIntentId(intent.getIntentId()));
+ if (null != intent) {
+ String intentId = intent.getIntentId();
+ intent.setIntentExpectations(expectationService.getIntentExpectationListByIntentId(intentId));
+ intent.setIntentContexts(contextService.getContextListByParentId(intentId));
+ intent.setIntentFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfoByParentId(intentId));
+ log.debug("Intent %s was successfully found", intentId);
+ }
}
return intentList;
}
@@ -86,14 +87,16 @@ public class IntentServiceImpl implements IntentService {
@Override
public Intent getIntentById(String intentId) {
Intent intent = intentMapper.selectIntentById(intentId);
- if (intent != null) {
- intent.setIntentExpectations(expectationService.getIntentExpectationsByIntentId(intent.getIntentId()));
- return intent;
- } else {
+ if (intent == null) {
String msg = String.format("Intent id %s doesn't exist in database.", intentId);
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
+ intent.setIntentExpectations(expectationService.getIntentExpectationListByIntentId(intentId));
+ intent.setIntentContexts(contextService.getContextListByParentId(intentId));
+ intent.setIntentFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfoByParentId(intentId));
+ log.debug("Intent was successfully found");
+ return intent;
}
@Override
@@ -104,7 +107,7 @@ public class IntentServiceImpl implements IntentService {
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
- expectationService.updateIntentExpectationsByIntentId(intent.getIntentExpectations(), intent.getIntentId());
+ expectationService.updateIntentExpectationListByIntentId(intent.getIntentExpectations(), intent.getIntentId());
int res = intentMapper.updateIntent(intent);
if (res < 1) {
String msg = "Update intent in database failed.";
@@ -117,13 +120,12 @@ public class IntentServiceImpl implements IntentService {
@Override
public void deleteIntentById(String intentId) {
- int res = intentMapper.deleteIntentById(intentId);
- if (res < 1) {
+ if (intentMapper.deleteIntentById(intentId) < 1) {
String msg = "Delete intent in database failed.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
}
- expectationService.deleteIntentExpectationsByIntentId(intentId);
+ expectationService.deleteIntentExpectationListByIntentId(intentId);
log.debug("Intent has been deleted successfully.");
}
@@ -132,9 +134,9 @@ public class IntentServiceImpl implements IntentService {
List<Intent> intentList = intentMapper.getIntentByName(name);
if (CollectionUtils.isNotEmpty(intentList)) {
for (Intent intent:intentList) {
- intent.setIntentExpectations(expectationService.getIntentExpectationsByIntentId(intent.getIntentId()));
- // intent.setIntentContexts();
+ // intent.setIntentContexts();
//
+ intent.setIntentExpectations(expectationService.getIntentExpectationListByIntentId(intent.getIntentId()));
}
return intentList;
} else {
@@ -143,4 +145,4 @@ public class IntentServiceImpl implements IntentService {
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
}
-}
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java
index 11b31a5..c2b8354 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java
@@ -53,7 +53,7 @@ public class StateServiceImpl implements StateService {
public List<State> getStateListByExpectationId(String expectationId) {
List<State> stateList = stateMapper.selectStateByExpectation(expectationId);
if (stateList == null) {
- String msg = String.format("Expectation id %s doesn't exist in database.", expectationId);
+ String msg = String.format("State: Expectation id %s doesn't exist in database.", expectationId);
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
@@ -62,8 +62,7 @@ public class StateServiceImpl implements StateService {
@Override
public void deleteStateListByExpectationId(String expectationId) {
- int res = stateMapper.deleteStateByExpectationId(expectationId);
- if (res < 1) {
+ if (stateMapper.deleteStateByExpectationId(expectationId) < 1) {
String msg = "Delete state in database failed.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
@@ -92,7 +91,7 @@ public class StateServiceImpl implements StateService {
}
stateDBIdList.remove(state.getStateId());
} else {
- stateService.insertState(state, expectationId);
+ stateService.createState(state, expectationId);
}
}
for (String stateDBId : stateDBIdList) {
@@ -102,9 +101,8 @@ public class StateServiceImpl implements StateService {
}
@Override
- public void insertState(State state, String expectationId) {
- int res = stateMapper.insertState(state, expectationId);
- if (res < 1) {
+ public void createState(State state, String expectationId) {
+ if (stateMapper.insertState(state, expectationId) < 1) {
String msg = "Create state to database failed.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
@@ -113,11 +111,10 @@ public class StateServiceImpl implements StateService {
@Override
public void deleteStateById(String stateId) {
- int res = stateMapper.deleteStateById(stateId);
- if (res < 1) {
+ if (stateMapper.deleteStateById(stateId) < 1) {
String msg = "Delete state in database failed.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
}
}
-}
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/resources/intent-analysis-init.sql b/intentanalysis/src/main/resources/intent-analysis-init.sql
index 727e0c6..d777077 100644
--- a/intentanalysis/src/main/resources/intent-analysis-init.sql
+++ b/intentanalysis/src/main/resources/intent-analysis-init.sql
@@ -1,3 +1,5 @@
+CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
+
create table if not exists intent(
intent_id varchar(255) primary key,
intent_name varchar(255)
@@ -11,25 +13,24 @@ create table if not exists expectation(
);
create table if not exists expectation_object(
- expectation_id varchar(255) primary key,
+ object_id varchar(255) DEFAULT uuid_generate_v4 (),
+ primary key(object_id),
object_type varchar(255),
- object_instance varchar(255)
+ object_instance varchar(255),
+ expectation_id varchar(255)
);
create table if not exists expectation_target(
target_id varchar(255) primary key,
target_name varchar(255),
+ target_condition varchar(255),
expectation_id varchar(255)
);
create table if not exists context(
context_id varchar(255) primary key,
- context_name varchar(255)
-);
-
-create table if not exists context_mapping(
- context_id varchar(255) primary key,
- parent_type varchar(255),
+ context_name varchar(255),
+ context_condition varchar(255),
parent_id varchar(255)
);
@@ -61,10 +62,10 @@ create table if not exists condition_mapping(
parent_id varchar(255)
);
-create table if not exists intent_management_function_reg_info{
+create table if not exists intent_management_function_reg_info(
imfr_info_id varchar(255) primary key,
imfr_info_description varchar(255),
support_model varchar(255),
handle_name varchar(255),
intent_function_type varchar(255)
- }; \ No newline at end of file
+ ); \ No newline at end of file
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml
index 8a39762..7f4b24a 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml
@@ -5,19 +5,23 @@
<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.ConditionMapper">
<insert id="insertConditionList">
- insert into condition(condition_id, condition_name, operator_type, condition_value)
- values
- <foreach collection="contextList" index="index" item="item" separator=",">
- (#{item.conditionId}, #{item.conditionName}, #{item.operatorType}, #{item.conditionValue})
- </foreach>
+ <if test="conditionList != null">
+ insert into condition(condition_id, condition_name, operator_type, condition_value)
+ values
+ <foreach collection="conditionList" index="index" item="item" separator=",">
+ (#{item.conditionId}, #{item.conditionName}, #{item.operatorType}, #{item.conditionValue})
+ </foreach>
+ </if>
</insert>
<insert id="insertConditionParentList">
- insert into condition_mapping(condition_id, parent_type, parent_id)
- values
- <foreach collection="conditionList" index="index" item="item" separator=",">
- (#{item.conditionId}, #{parentType}, #{parentId})
- </foreach>
+ <if test="conditionList != null">
+ insert into condition_mapping(condition_id, parent_type, parent_id)
+ values
+ <foreach collection="conditionList" index="index" item="item" separator=",">
+ (#{item.conditionId}, #{parentType}, #{parentId})
+ </foreach>
+ </if>
</insert>
<!-- 这里的查询有问题-->
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml
index 56569e4..975bd03 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml
@@ -6,25 +6,19 @@
<insert id="insertContextList">
- insert into context(context_id, context_name)
- values
- <foreach collection="contextList" index="index" item="item" separator=",">
- (#{item.contextId}, #{item.contextName})
- </foreach>
- </insert>
-
- <insert id="insertContextParentList">
- insert into context_mapping(context_id, parent_type, parent_id)
- values
- <foreach collection="contextList" index="index" item="item" separator=",">
- (#{item.contextId}, #{parentType}, #{parentId})
- </foreach>
+ <if test="contextList != null">
+ insert into context(context_id, context_name, parent_id)
+ values
+ <foreach collection="contextList" index="index" item="item" separator=",">
+ (#{item.contextId}, #{item.contextName}, #{parentId})
+ </foreach>
+ </if>
</insert>
<select id="selectContextByParentId" resultType="org.onap.usecaseui.intentanalysis.bean.models.Context">
- select context_id contextId, context_name contextName
+ select context_id contextId, context_name contextName, context_condition contextCondition
from context
- where intent_id = #{parentId}
+ where parent_id = #{parentId}
</select>
-</mapper>
+</mapper> \ No newline at end of file
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
index 98aa3dd..24d574b 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
@@ -5,12 +5,14 @@
<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.ExpectationMapper">
- <insert id="insertIntentExpectations">
- insert into expectation(expectation_id, expectation_name, expectation_type, intent_id)
- values
- <foreach collection="intentExpectations" index="index" item="item" separator=",">
- (#{item.expectationId}, #{item.expectationName}, #{item.expectationType}, #{intentId})
- </foreach>
+ <insert id="insertIntentExpectationList">
+ <if test="intentExpectationList != null">
+ insert into expectation(expectation_id, expectation_name, expectation_type, intent_id)
+ values
+ <foreach collection="intentExpectationList" index="index" item="item" separator=",">
+ (#{item.expectationId}, #{item.expectationName}, #{item.expectationType}, #{intentId})
+ </foreach>
+ </if>
</insert>
<insert id="insertIntentExpectation">
@@ -18,9 +20,9 @@
values (#{expectation.expectationId}, #{expectation.expectationName}, #{expectation.expectationType}, #{intentId})
</insert>
- <select id="selectIntentExpectationsByIntentId" resultType="org.onap.usecaseui.intentanalysis.bean.models.Expectation">
- select expectation_id expectationId, expectation_name expectationName,
- target_moi targetMOI, intent_id intentId
+ <select id="selectIntentExpectationListByIntentId" resultType="org.onap.usecaseui.intentanalysis.bean.models.Expectation">
+ select expectation_id expectationId, expectation_name expectationName, expectation_type expectationType,
+ intent_id intentId
from expectation
where intent_id = #{intentId}
</select>
@@ -29,13 +31,13 @@
update expectation
<trim prefix="set" suffixOverrides=",">
<if test="expectationName != null">expectation_name = #{expectationName},</if>
- <if test="targetMOI != null">target_moi = #{targetMOI},</if>
</trim>
where expectation_id = #{expectationId}
</update>
- <delete id="deleteIntentExpectationsByIntentId">
- delete from expectation
+ <delete id="deleteIntentExpectationListByIntentId">
+ delete
+ from expectation
where intent_id = #{intentId}
</delete>
@@ -45,4 +47,4 @@
where expectation_id = #{expectationId}
</delete>
-</mapper>
+</mapper> \ No newline at end of file
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ExpectationObjectMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ExpectationObjectMapper.xml
index d67b9bf..b158eb2 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ExpectationObjectMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ExpectationObjectMapper.xml
@@ -6,9 +6,23 @@
<insert id="insertExpectationObject">
- insert into expectation_object(expectation_id, object_type, object_instance)
- values
- (#{expectationId}, #{expectationObject.objectType}, #{expectationObject.objectInstance})
+ <if test="expectationObject != null">
+ insert into expectation_object(object_type, object_instance, expectation_id)
+ values
+ (#{expectationObject.objectType}, #{expectationObject.objectInstance}, #{expectationId})
+ </if>
</insert>
+ <select id="selectIntentExpectationObjectByExpectationId" resultType="org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject">
+ select object_type objectType, object_instance objectInstance
+ from expectation_object
+ where expectation_id = #{expectationId}
+ </select>
+
+ <select id="selectExpectationObjectId" resultType="java.lang.String">
+ select object_id
+ from expectation_object
+ where expectation_id = #{expectationId}
+ </select>
+
</mapper>
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ExpectationTargetMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ExpectationTargetMapper.xml
index 89648b5..1910912 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ExpectationTargetMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ExpectationTargetMapper.xml
@@ -6,9 +6,17 @@
<insert id="insertExpectationTarget">
- insert into expectation_target(target_id, target_name, expectation_id)
- values
- (#{expectationTarget.targetId}, #{expectationTarget.targetName}, #{expectationId})
+ <if test="expectationTarget != null">
+ insert into expectation_target(target_id, target_name, target_condition, expectation_id)
+ values
+ (#{expectationTarget.targetId}, #{expectationTarget.targetName}, #{expectationTarget.targetCondition}, #{expectationId})
+ </if>
</insert>
-</mapper>
+ <select id="selectIntentExpectationTargetListByExpectationId" resultType="org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget">
+ select target_id targetId, target_name targetName, target_condition targetCondition
+ from expectation_target
+ where expectation_id = #{expectationId}
+ </select>
+
+</mapper> \ No newline at end of file
diff --git a/intentanalysis/src/main/resources/mybatis/sql/FulfilmentInfoMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/FulfilmentInfoMapper.xml
index e5a9668..2290703 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/FulfilmentInfoMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/FulfilmentInfoMapper.xml
@@ -6,14 +6,17 @@
<insert id="insertFulfilmentInfo">
- insert into fulfilment_info(fulfilment_info_id, fulfilment_info_status, not_fulfilled_state, not_fulfilled_reason)
- values (#{parentId}, #{fulfilmentInfo.fulfilmentStatus}, #{fulfilmentInfo.notFulfilledState}, #{fulfilmentInfo.notFulfilledReason})
+ <if test="fulfilmentInfo != null">
+ insert into fulfilment_info(fulfilment_info_id, fulfilment_info_status, not_fulfilled_state, not_fulfilled_reason)
+ values (#{parentId}, #{fulfilmentInfo.fulfilmentStatus}, #{fulfilmentInfo.notFulfilledState}, #{fulfilmentInfo.notFulfilledReason})
+ </if>
</insert>
<select id="selectFulfilmentInfoById" resultType="org.onap.usecaseui.intentanalysis.bean.models.FulfilmentInfo">
select fulfilment_info_status fulfilmentStatus, not_fulfilled_state notFulfilledState,
- not_fulfilled_reason notFulfilledReason from fulfilment_info
- where parent_id = #{parentId}
+ not_fulfilled_reason notFulfilledReason
+ from fulfilment_info
+ where fulfilment_info_id = #{parentId}
</select>
</mapper>
diff --git a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
index 9d6029f..643c193 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
@@ -5,17 +5,19 @@
<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.IntentMapper">
<select id="selectIntentById" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
- select intent_id intentId, intent_name intentName from intent
+ select intent_id intentId, intent_name intentName
+ from intent
where intent_id = #{intentId}
</select>
- <select id="selectIntents" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
- select intent_id intentId, intent_name intentName from intent
+ <select id="selectIntentList" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
+ select intent_id intentId, intent_name intentName
+ from intent
</select>
<insert id="insertIntent" >
insert into Intent(intent_id, intent_name)
- values(#{intentId}, #{intentName})
+ values(#{intent.intentId}, #{intent.intentName})
</insert>
<update id="updateIntent" parameterType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
@@ -27,7 +29,8 @@
</update>
<delete id="deleteIntentById" parameterType="string">
- delete from intent
+ delete
+ from intent
where intent_id = #{intentId}
</delete>
diff --git a/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml
index 9e30981..d103015 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml
@@ -5,28 +5,33 @@
<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.StateMapper">
<select id="selectStateByExpectation" resultType="org.onap.usecaseui.intentanalysis.bean.models.State">
- select state_id stateId, state_name stateName, expectation_id expectationId,
- is_satisfied isSatisfied, condition
+ select state_id stateId, state_name stateName, condition,
+ is_satisfied isSatisfied
from state
where expectation_id = #{expectationId}
</select>
<insert id="insertStateList" parameterType="java.util.ArrayList">
- insert into state(state_id, state_name, expectation_id, is_satisfied, condition)
- values
- <foreach collection="stateList" index="index" item="item" separator=",">
- (#{item.stateId}, #{item.stateName}, #{expectationId}, #{item.isSatisfied}, #{item.condition})
- </foreach>
+ <if test="stateList != null">
+ insert into state(state_id, state_name, expectation_id, is_satisfied, condition)
+ values
+ <foreach collection="stateList" index="index" item="item" separator=",">
+ (#{item.stateId}, #{item.stateName}, #{expectationId}, #{item.isSatisfied}, #{item.condition})
+ </foreach>
+ </if>
</insert>
<delete id="deleteStateByExpectationId">
- delete from state
+ delete
+ from state
where expectation_id = #{expectationId}
</delete>
<insert id="insertState">
- insert into state(state_id, state_name, expectation_id, is_satisfied, condition)
- values (#{state.stateId}, #{state.stateName}, #{expectationId}, #{state.isSatisfied}, #{state.condition})
+ <if test="state != null">
+ insert into state(state_id, state_name, expectation_id, is_satisfied, condition)
+ values (#{state.stateId}, #{state.stateName}, #{expectationId}, #{state.isSatisfied}, #{state.condition})
+ </if>
</insert>
<update id="updateState" parameterType="java.util.List">