# AlarmCategoryManagerImpl.java

    package com.mycim.server.alarm.manager.impl;

    import com.fa.sesa.exception.Assert;
    import com.fa.sesa.exception.Errors;
    import com.mycim.server.alarm.dao.AlarmCategoryDao;
    import com.mycim.server.alarm.manager.AlarmCategoryManager;
    import com.mycim.server.base.manager.NamedObjectManager;
    import com.mycim.valueobject.alm.AlarmCategory;
    import com.mycim.valueobject.bas.NamedObject;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    /**
     * AlarmCategoryManager
     *
     * @author pinyan.song
     * @version 6.0.0
     * @date 2019-11-8
     **/
    @Service
    @Transactional
    public class AlarmCategoryManagerImpl implements AlarmCategoryManager {
        @Autowired
        AlarmCategoryDao categoryDao;

        @Autowired
        NamedObjectManager namedObjectManager;

        @Override
        public AlarmCategory getAlarmCategory(AlarmCategory alarmCategory) {
            NamedObject instance = namedObjectManager.getNamedObject(alarmCategory);

            if (instance == null) {
                return null;
            }

            alarmCategory = categoryDao.getAlarmCategory(instance.getInstanceRrn());

            Assert.state(null != alarmCategory,
                         Errors.create().content("Orphan data found in Alarm Category table.").build());

            alarmCategory.copyNamedObject(instance);

            // get the id use the rrn.
            if ((alarmCategory.getAcknowledgeWflRrn() != null) && (alarmCategory.getAcknowledgeWflRrn() > 0)) {
                alarmCategory
                        .setAcknowledgeWflId(namedObjectManager.getNamedObjectId(alarmCategory.getAcknowledgeWflRrn()));
            }

            if ((alarmCategory.getRemindWflRrn() != null) && (alarmCategory.getRemindWflRrn() > 0)) {
                alarmCategory.setRemindWflId(namedObjectManager.getNamedObjectId(alarmCategory.getRemindWflRrn()));
            }

            if ((alarmCategory.getClearWflRrn() != null) && (alarmCategory.getClearWflRrn() > 0)) {
                alarmCategory.setClearWflId(namedObjectManager.getNamedObjectId(alarmCategory.getClearWflRrn()));
            }

            if ((alarmCategory.getTriggerWflRrn() != null) && (alarmCategory.getTriggerWflRrn() > 0)) {
                alarmCategory.setTriggerWflId(namedObjectManager.getNamedObjectId(alarmCategory.getTriggerWflRrn()));
            }

            return alarmCategory;
        }

        @Override
        public String getAlarmCategoryByWflRrn(Long workflowRrn) {
            return categoryDao.getAlarmCategoryByWflRrn(workflowRrn);
        }

    }