* @param channelDO
* @return Channel
*/
private LogRecord doToModel(LogRecordDO logRecordDo) {
LogRecord logRecord = new LogRecord();
try {
logRecord.setId(logRecordDo.getId());
if (logRecordDo.getPipelineId() > 0 && logRecordDo.getChannelId() > 0) {
try {
Channel channel = channelService.findByPipelineId(logRecordDo.getPipelineId());
logRecord.setChannel(channel);
for (Pipeline pipeline : channel.getPipelines()) {
if (pipeline.getId().equals(logRecordDo.getPipelineId())) {
logRecord.setPipeline(pipeline);
}
}
} catch (Exception e) {
// 可能历史的log记录对应的channel/pipeline已经被删除了,直接忽略吧
Channel channel = new Channel();
channel.setId(0l);
logRecord.setChannel(channel);
Pipeline pipeline = new Pipeline();
pipeline.setId(0l);
logRecord.setPipeline(pipeline);
}
} else {
Channel channel = new Channel();
channel.setId(-1l);
logRecord.setChannel(channel);
Pipeline pipeline = new Pipeline();
pipeline.setId(-1l);
logRecord.setPipeline(pipeline);
}
logRecord.setTitle(logRecordDo.getTitle());
logRecord.setNid(logRecordDo.getNid());
logRecord.setMessage(logRecordDo.getMessage());
logRecord.setGmtCreate(logRecordDo.getGmtCreate());
logRecord.setGmtModified(logRecordDo.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## ");
throw new ManagerException(e);
}