AlarmCategoryDaoImpl.java
package com.mycim.server.alarm.dao.impl;
import com.mycim.framework.jdbc.JdbcTemplate;
import com.mycim.framework.jdbc.mapper.RowMapper;
import com.mycim.framework.utils.MiscUtils;
import com.mycim.server.alarm.dao.AlarmCategoryDao;
import com.mycim.valueobject.alm.AlarmCategory;
import com.mycim.valueobject.consts.DataBaseNames;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* AlarmCategoryDaoImpl
*
* @author pinyan.song
* @version 6.0.0
* @date 2019-11-8
**/
@Repository
public class AlarmCategoryDaoImpl implements AlarmCategoryDao {
@Autowired
JdbcTemplate jdbcTemplate;
@Override
public AlarmCategory getAlarmCategory(long alarmCategoryRrn) {
String sql = "SELECT ENABLE_FLAG,SEVERITY,PRIORITY,AUTO_CLEAR_FLAG, " + " IGNORE_REPEAT_PERIOD," +
"REMINDER_WFL_RRN,WAIT_TIME_FOR_REMINDER,TRIGGER_WFL_RRN," + " ACKNOWLEDGE_WFL_RRN,CLEAR_WFL_RRN FROM" +
" " + DataBaseNames.ALARM_CATEGORY_KEY + " WHERE ALARM_CATEGORY_RRN = ? ";
return jdbcTemplate.queryForObjectWithNull(sql, new RowMapper<AlarmCategory>() {
@Override
public AlarmCategory mapRow(ResultSet rs, int rowNum) throws SQLException {
AlarmCategory alarmCategory = new AlarmCategory();
alarmCategory.setInstanceRrn(alarmCategoryRrn);
alarmCategory.setEnableFlag(rs.getString("ENABLE_FLAG"));
alarmCategory.setSeverity(rs.getString("SEVERITY"));
alarmCategory.setPriority(rs.getString("PRIORITY"));
alarmCategory
.setAutoClearFlag(MiscUtils.parseCheckBoxValueFromDatabase(rs.getString("AUTO_CLEAR_FLAG")));
alarmCategory.setIgnoreRepeatPeriod(rs.getLong("IGNORE_REPEAT_PERIOD"));
alarmCategory.setRemindWflRrn(rs.getLong("REMINDER_WFL_RRN"));
alarmCategory.setWaitTimeForRemind(rs.getLong("WAIT_TIME_FOR_REMINDER"));
alarmCategory.setTriggerWflRrn(rs.getLong("TRIGGER_WFL_RRN"));
alarmCategory.setAcknowledgeWflRrn(rs.getLong("ACKNOWLEDGE_WFL_RRN"));
alarmCategory.setClearWflRrn(rs.getLong("CLEAR_WFL_RRN"));
return alarmCategory;
}
}, alarmCategoryRrn);
}
@Override
public String getAlarmCategoryByWflRrn(Long workflowRrn) {
String sql = "select no.instance_id from alarm_category ac, named_object no where ac" + ".alarm_category_rrn" +
"=no.instance_rrn and ac.trigger_wfl_rrn=?";
return jdbcTemplate.queryForObject(sql, new Object[]{workflowRrn}, String.class);
}
}