Search in sources :

Example 1 with LogRecordDO

use of com.alibaba.otter.manager.biz.config.record.dal.dataobject.LogRecordDO in project otter by alibaba.

the class LogRecordServiceImpl method modelToDo.

/*----------------------DO <-> MODEL 组装方法--------------------------*/
/**
 * <pre>
 * 用于Model对象转化为DO对象
 * 优化:
 *      无SQL交互,只是简单进行字段组装,暂时无须优化
 * </pre>
 *
 * @param channel
 * @return ChannelDO
 */
private LogRecordDO modelToDo(LogRecord entityObj) {
    LogRecordDO logRecordDo = new LogRecordDO();
    try {
        if (entityObj.getPipeline() != null && entityObj.getPipeline().getId() > 0) {
            Channel channel = channelService.findByPipelineId(entityObj.getPipeline().getId());
            logRecordDo.setChannelId(channel.getId());
            logRecordDo.setPipelineId(entityObj.getPipeline().getId());
        } else {
            logRecordDo.setChannelId(-1l);
            logRecordDo.setPipelineId(-1l);
        }
        logRecordDo.setNid(entityObj.getNid());
        logRecordDo.setTitle(entityObj.getTitle());
        String message = entityObj.getMessage();
        if (message != null && message.length() > 65535 / 3) {
            message = message.substring(0, 65535 / 3);
        }
        logRecordDo.setMessage(message);
        logRecordDo.setGmtCreate(entityObj.getGmtCreate());
        logRecordDo.setGmtModified(entityObj.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## has an error where write log to db");
        throw new ManagerException(e);
    }
    return logRecordDo;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) LogRecordDO(com.alibaba.otter.manager.biz.config.record.dal.dataobject.LogRecordDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Aggregations

ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)1 LogRecordDO (com.alibaba.otter.manager.biz.config.record.dal.dataobject.LogRecordDO)1 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)1