# CheckListItemManagerImpl.java

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

    import com.mycim.server.base.manager.NamedObjectManager;
    import com.mycim.server.base.manager.TransactionLogManager;
    import com.mycim.server.pms.dao.CheckListItemDao;
    import com.mycim.server.pms.manager.CheckListItemManager;
    import com.mycim.valueobject.bas.TransactionLog;
    import com.mycim.valueobject.ems.ChecklistItem;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    import java.util.List;

    /**
     * ChecklistItem ManagerImpl
     *
     * @author pinyan.song
     * @version 6.0.0
     * @date 2019-11-5
     **/
    @Service
    @Transactional
    public class CheckListItemManagerImpl implements CheckListItemManager {
        @Autowired
        CheckListItemDao checkListItemDao;

        @Autowired
        NamedObjectManager namedObjectManager;

        @Autowired
        TransactionLogManager transactionLogManager;

        @Override
        public List<ChecklistItem> getChecklistItems(long checklistRrn) {
            return paddingData(checkListItemDao.getChecklistItems(checklistRrn));
        }

        @Override
        public List<ChecklistItem> getChecklistItems(long entityRrn, long checklistRrn) {
            return paddingData(checkListItemDao.getChecklistItems(entityRrn, checklistRrn));
        }

        @Override
        public void insertChecklistItem(ChecklistItem checklistItem) {
            TransactionLog transactionLog = transactionLogManager
                    .startTransactionLog(checklistItem.getTransPerformedby(), checklistItem.getTransId());
            checkListItemDao.insertChecklistItem(checklistItem, transactionLog);
            transactionLogManager.markTransactionLog(transactionLog);
        }

        @Override
        public void deleteChecklistItem(ChecklistItem checklistItem) {
            TransactionLog transactionLog = transactionLogManager
                    .startTransactionLog(checklistItem.getTransPerformedby(), checklistItem.getTransId());
            checkListItemDao.deleteChecklistItem(checklistItem, transactionLog);
            transactionLogManager.markTransactionLog(transactionLog);
        }

        @Override
        public void updateChecklistItem(ChecklistItem checklistItem) {
            TransactionLog transactionLog = transactionLogManager
                    .startTransactionLog(checklistItem.getTransPerformedby(), checklistItem.getTransId());
            checkListItemDao.updateChecklistItem(checklistItem, transactionLog);
            transactionLogManager.markTransactionLog(transactionLog);
        }

        @Override
        public void changeChecklistItemSeq(long checklistRrn, long aSeq, long bSeq) {
            checkListItemDao.changeChecklistItemSeq(checklistRrn, aSeq, bSeq);
        }

        @Override
        public List<ChecklistItem> getChecklistJobItems(long checklistJobRrn, Long checklistRrn) {
            return paddingData(checkListItemDao.getChecklistJobItems(checklistJobRrn, checklistRrn));
        }

        private List<ChecklistItem> paddingData(List<ChecklistItem> list) {
            for (ChecklistItem item : list) {
                if (item.getParameterSetRrn() > 0) {
                    item.setParameterSetId(namedObjectManager.getInstanceId(item.getParameterSetRrn()));
                }
            }
            return list;
        }

    }