|
@@ -54,13 +54,17 @@ public class LogParsingServiceImpl implements LogParsingService {
|
|
|
return JsonUtil.toObject(log, SimpleLog.class);
|
|
return JsonUtil.toObject(log, SimpleLog.class);
|
|
|
} catch (JSONException e) {
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
- throw new ParsingException(e.toString(), 0);
|
|
|
|
|
|
|
+ throw new ParsingException(e.toString(), 0, log);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
|
public <T> T parseLogData(SimpleLog simpleLog, boolean save) throws ParsingException{
|
|
public <T> T parseLogData(SimpleLog simpleLog, boolean save) throws ParsingException{
|
|
|
|
|
+ if (simpleLog == null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
String className = parseOpType(simpleLog.getOpType());
|
|
String className = parseOpType(simpleLog.getOpType());
|
|
|
Class clazz = Class.forName(className);
|
|
Class clazz = Class.forName(className);
|
|
@@ -72,10 +76,10 @@ public class LogParsingServiceImpl implements LogParsingService {
|
|
|
return (T) data;
|
|
return (T) data;
|
|
|
} catch (ClassNotFoundException|ClassCastException e){
|
|
} catch (ClassNotFoundException|ClassCastException e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
- return null;
|
|
|
|
|
|
|
+ throw new ParsingException(e.toString(), 4, simpleLog.getData());
|
|
|
} catch (JSONException e) {
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
- throw new ParsingException(e.toString(), 1);
|
|
|
|
|
|
|
+ throw new ParsingException(e.toString(), 1, simpleLog.getData());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -120,40 +124,37 @@ public class LogParsingServiceImpl implements LogParsingService {
|
|
|
BugInfo info = LogConvertor.convertToBugInfoEntity(bugInfoDTO);
|
|
BugInfo info = LogConvertor.convertToBugInfoEntity(bugInfoDTO);
|
|
|
|
|
|
|
|
Optional<DevcloudInfo> devcloudInfo = devcloudInfoDao.findById(bugInfoDTO.getProjectId());
|
|
Optional<DevcloudInfo> devcloudInfo = devcloudInfoDao.findById(bugInfoDTO.getProjectId());
|
|
|
- if (devcloudInfo.isPresent()) {
|
|
|
|
|
- devcloudInfo.get().getBugList().add(info);
|
|
|
|
|
- devcloudInfoDao.save(devcloudInfo.get());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ DevcloudInfo devcloudInfoEntity = devcloudInfo.orElseGet(() -> createDevCloudInfo(bugInfoDTO.getProjectId()));
|
|
|
|
|
+ devcloudInfoEntity.getBugList().add(info);
|
|
|
|
|
+ devcloudInfoDao.save(devcloudInfoEntity);
|
|
|
|
|
|
|
|
} else if (className.equals(CommitInfoDTO.class.getName())) {
|
|
} else if (className.equals(CommitInfoDTO.class.getName())) {
|
|
|
CommitInfoDTO commitInfoDTO = (CommitInfoDTO) data;
|
|
CommitInfoDTO commitInfoDTO = (CommitInfoDTO) data;
|
|
|
CommitInfo info = LogConvertor.convertToCommitInfoEntity(commitInfoDTO);
|
|
CommitInfo info = LogConvertor.convertToCommitInfoEntity(commitInfoDTO);
|
|
|
|
|
|
|
|
Optional<DevcloudInfo> devcloudInfo = devcloudInfoDao.findById(commitInfoDTO.getProjectId());
|
|
Optional<DevcloudInfo> devcloudInfo = devcloudInfoDao.findById(commitInfoDTO.getProjectId());
|
|
|
- if (devcloudInfo.isPresent()) {
|
|
|
|
|
- devcloudInfo.get().getCommitList().add(info);
|
|
|
|
|
- devcloudInfoDao.save(devcloudInfo.get());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ DevcloudInfo devcloudInfoEntity = devcloudInfo.orElseGet(() -> createDevCloudInfo(commitInfoDTO.getProjectId()));
|
|
|
|
|
+ devcloudInfoEntity.getCommitList().add(info);
|
|
|
|
|
+ devcloudInfoDao.save(devcloudInfoEntity);
|
|
|
|
|
|
|
|
} else if (className.equals(TestInfoDTO.class.getName())) {
|
|
} else if (className.equals(TestInfoDTO.class.getName())) {
|
|
|
TestInfoDTO testInfoDTO = (TestInfoDTO) data;
|
|
TestInfoDTO testInfoDTO = (TestInfoDTO) data;
|
|
|
TestInfo info = LogConvertor.convertToTestInfoEntity(testInfoDTO);
|
|
TestInfo info = LogConvertor.convertToTestInfoEntity(testInfoDTO);
|
|
|
|
|
|
|
|
Optional<DevcloudInfo> devcloudInfo = devcloudInfoDao.findById(testInfoDTO.getProjectId());
|
|
Optional<DevcloudInfo> devcloudInfo = devcloudInfoDao.findById(testInfoDTO.getProjectId());
|
|
|
- if (devcloudInfo.isPresent()) {
|
|
|
|
|
- devcloudInfo.get().getTestList().add(info);
|
|
|
|
|
- devcloudInfoDao.save(devcloudInfo.get());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ DevcloudInfo devcloudInfoEntity = devcloudInfo.orElseGet(() -> createDevCloudInfo(testInfoDTO.getProjectId()));
|
|
|
|
|
+ devcloudInfoEntity.getTestList().add(info);
|
|
|
|
|
+ devcloudInfoDao.save(devcloudInfoEntity);
|
|
|
|
|
|
|
|
} else if (className.equals(PipelineCreationDTO.class.getName())) {
|
|
} else if (className.equals(PipelineCreationDTO.class.getName())) {
|
|
|
PipelineCreationDTO creationDTO = (PipelineCreationDTO) data;
|
|
PipelineCreationDTO creationDTO = (PipelineCreationDTO) data;
|
|
|
Optional<DevcloudInfo> devcloudInfo = devcloudInfoDao.findById(creationDTO.getProjectId());
|
|
Optional<DevcloudInfo> devcloudInfo = devcloudInfoDao.findById(creationDTO.getProjectId());
|
|
|
- if (devcloudInfo.isPresent()) {
|
|
|
|
|
- PipelineInfo pipelineInfo = new PipelineInfo();
|
|
|
|
|
- pipelineInfo.setPipelineId(creationDTO.getPipelineId());
|
|
|
|
|
- devcloudInfo.get().getPipelineList().add(pipelineInfo);
|
|
|
|
|
- devcloudInfoDao.save(devcloudInfo.get());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ DevcloudInfo devcloudInfoEntity = devcloudInfo.orElseGet(() -> createDevCloudInfo(creationDTO.getProjectId()));
|
|
|
|
|
+
|
|
|
|
|
+ PipelineInfo pipelineInfo = new PipelineInfo();
|
|
|
|
|
+ pipelineInfo.setPipelineId(creationDTO.getPipelineId());
|
|
|
|
|
+ devcloudInfoEntity.getPipelineList().add(pipelineInfo);
|
|
|
|
|
+ devcloudInfoDao.save(devcloudInfoEntity);
|
|
|
|
|
|
|
|
} else if (className.equals(PipelineDeletionDTO.class.getName())) {
|
|
} else if (className.equals(PipelineDeletionDTO.class.getName())) {
|
|
|
PipelineDeletionDTO deletionDTO = (PipelineDeletionDTO) data;
|
|
PipelineDeletionDTO deletionDTO = (PipelineDeletionDTO) data;
|
|
@@ -187,10 +188,9 @@ public class LogParsingServiceImpl implements LogParsingService {
|
|
|
TreeNodeInfo info = LogConvertor.convertToTreeNodeInfoEntity(nodeInfoDTO);
|
|
TreeNodeInfo info = LogConvertor.convertToTreeNodeInfoEntity(nodeInfoDTO);
|
|
|
|
|
|
|
|
Optional<DevcloudInfo> devcloudInfo = devcloudInfoDao.findById(nodeInfoDTO.getProjectId());
|
|
Optional<DevcloudInfo> devcloudInfo = devcloudInfoDao.findById(nodeInfoDTO.getProjectId());
|
|
|
- if (devcloudInfo.isPresent()) {
|
|
|
|
|
- devcloudInfo.get().getTreeNodeList().add(info);
|
|
|
|
|
- devcloudInfoDao.save(devcloudInfo.get());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ DevcloudInfo devcloudInfoEntity = devcloudInfo.orElseGet(() -> createDevCloudInfo(nodeInfoDTO.getProjectId()));
|
|
|
|
|
+ devcloudInfoEntity.getTreeNodeList().add(info);
|
|
|
|
|
+ devcloudInfoDao.save(devcloudInfoEntity);
|
|
|
|
|
|
|
|
} else if (className.equals(TreeNodeDeletionDTO.class.getName())) {
|
|
} else if (className.equals(TreeNodeDeletionDTO.class.getName())) {
|
|
|
TreeNodeDeletionDTO deletionDTO = (TreeNodeDeletionDTO) data;
|
|
TreeNodeDeletionDTO deletionDTO = (TreeNodeDeletionDTO) data;
|
|
@@ -212,4 +212,11 @@ public class LogParsingServiceImpl implements LogParsingService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private DevcloudInfo createDevCloudInfo(Integer projectId) {
|
|
|
|
|
+ DevcloudInfo devcloudInfo = new DevcloudInfo(projectId, new ArrayList<>(), new ArrayList<>(),
|
|
|
|
|
+ new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
|
|
|
|
+ this.devcloudInfoDao.save(devcloudInfo);
|
|
|
|
|
+ return devcloudInfo;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|