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);
}
+
@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);
}
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);
}
@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);
}
@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);
}
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);
}
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);
}
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);
public interface ExpectationObjectService {
- void createObject(ExpectationObject expectationObject, String expectationId);
+ void createExpectationObject(ExpectationObject expectationObject, String expectationId);
+
+ ExpectationObject getExpectationObjectByExpectationId(String expectationId);
+
}
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);
}
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);
}
List<State> getStateListByExpectationId(String expectationId);
- void insertState(State state, String expectationId);
+ void createState(State state, String expectationId);
void deleteStateById(String stateId);
}
*/
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;
@Service
+@Slf4j
public class ConditionServiceImpl implements ConditionService {
- private static Logger LOGGER = LoggerFactory.getLogger(ContextServiceImpl.class);
-
@Autowired
private ConditionMapper conditionMapper;
@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
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;
@Service
+@Slf4j
public class ContextServiceImpl implements ContextService {
- static Logger LOGGER = LoggerFactory.getLogger(ContextServiceImpl.class);
-
private ConditionParentType conditionParentType;
+
@Autowired
private ContextMapper contextMapper;
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
@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
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;
@Service
+@Slf4j
public class ExpectationObjectServiceImpl implements ExpectationObjectService {
- private static Logger LOGGER = LoggerFactory.getLogger(ExpectationObjectServiceImpl.class);
-
- private ContextParentType contextParentType;
-
@Autowired
private ExpectationObjectMapper expectationObjectMapper;
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
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;
@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);
}
@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.");
@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);
}
@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
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;
@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;
@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
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;
@Service
+@Slf4j
public class FulfilmentInfoServiceImpl implements FulfilmentInfoService {
- private static Logger LOGGER = LoggerFactory.getLogger(FulfilmentInfoServiceImpl.class);
-
@Autowired
private FulfilmentInfoMapper fulfilmentInfoMapper;
@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
@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
public List<IntentManagementFunctionRegInfo> getImfRegInfoList() {
return imfRegInfoMapper.getImfRegInfoList();
}
-}
+}
\ No newline at end of file
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;
@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;
@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;
}
@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
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.";
@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.");
}
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 {
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
}
-}
+}
\ No newline at end of file
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);
}
@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);
}
stateDBIdList.remove(state.getStateId());
} else {
- stateService.insertState(state, expectationId);
+ stateService.createState(state, expectationId);
}
}
for (String stateDBId : stateDBIdList) {
}
@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);
@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
+CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
+
create table if not exists intent(
intent_id varchar(255) primary key,
intent_name varchar(255)
);
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)
);
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
<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>
<!-- 这里的查询有问题-->
<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
<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">
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>
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>
where expectation_id = #{expectationId}
</delete>
-</mapper>
+</mapper>
\ No newline at end of file
<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>
<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
<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>
<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">
</update>
<delete id="deleteIntentById" parameterType="string">
- delete from intent
+ delete
+ from intent
where intent_id = #{intentId}
</delete>
<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">