# PmScheduleRowMapper.java

    package com.mycim.server.pms.dao.mapper;

    import com.mycim.framework.jdbc.mapper.RowMapper;
    import com.mycim.framework.utils.MiscUtils;
    import com.mycim.framework.utils.lang.time.DateUtils;
    import com.mycim.valueobject.ems.PmSchedule;

    import java.sql.ResultSet;
    import java.sql.SQLException;

    public class PmScheduleRowMapper implements RowMapper<PmSchedule> {

        @Override
        public PmSchedule mapRow(ResultSet rs, int rowNum) throws SQLException {
            PmSchedule pmSchedule = new PmSchedule();

            pmSchedule.setEntityRrn(rs.getLong("ENTITY_RRN"));
            pmSchedule.setSequenceNumber(rs.getLong("SEQUENCE_NUMBER"));
            pmSchedule.setScheduleId(rs.getString("SCHEDULE_ID"));
            pmSchedule.setScheduleDescription(rs.getString("SCHEDULE_DESCRIPTION"));
            pmSchedule.setChecklistRrn(rs.getLong("CHECKLIST_RRN"));
            pmSchedule.setFrequence(rs.getString("FREQUENCE"));
            pmSchedule.setUnit(rs.getString("UNIT"));
            pmSchedule.setNextEventTime(DateUtils.formatDate(rs.getTimestamp("NEXT_EVENT_TIME")));
            pmSchedule.setEstimatedDuration(rs.getLong("ESTIMATED_DURATION"));
            pmSchedule.setBasedOnPmFlag(rs.getString("BASED_ON_PM_FLAG"));
            pmSchedule.setAlarmIdWhenDue(rs.getString("ALARM_ID_WHEN_DUE"));
            pmSchedule.setAlarmEnableFlag(rs.getString("ALARM_ENABLE_FLAG"));
            pmSchedule.setRepeatInFrequence(rs.getLong("REPEAT_IN_FREQUENCE"));
            pmSchedule.setRepeatInUnit(rs.getString("REPEAT_IN_UNIT"));
            pmSchedule.setNotifyBefore(rs.getLong("NOTIFY_BEFORE"));
            pmSchedule.setNotifyAlarmId(rs.getString("NOTIFY_ALARM_ID"));
            pmSchedule.setCancelIfScheduleId(rs.getString("CANCEL_IF_SCHEDULE_ID"));
            pmSchedule.setCancelWithin(rs.getLong("CANCEL_WITHIN"));
            pmSchedule.setOffset(rs.getLong("OFF_SET"));
            pmSchedule.setAlarmIdWhenRepeat(rs.getString("ALARM_REPEAT"));
            pmSchedule.setNextEventTime4Show(pmSchedule.getNextEventTime());
            if ((pmSchedule.getEstimatedDuration() != null) &&
                    (MiscUtils.parseSQL(pmSchedule.getEstimatedDuration()) > 0)) {
                pmSchedule.setEstimatedDuration4Show(
                        DateUtils.formatDateForSeconds(MiscUtils.parseSQL(pmSchedule.getEstimatedDuration())));
            }
            pmSchedule.setEquipmentDesc(rs.getString("INSTANCE_DESC"));
            pmSchedule.setActualEventTime(DateUtils.formatDate(rs.getTimestamp("ACTUAL_EVENT_TIME")));

            return pmSchedule;
        }

    }