EntityCounterTypeManagerImpl.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.EntityCounterTypeDao;
import com.mycim.server.pms.manager.EntityCounterTypeManager;
import com.mycim.valueobject.bas.TransactionLog;
import com.mycim.valueobject.consts.TransactionNames;
import com.mycim.valueobject.ems.EntityCounterType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* EntityCounterTypeManager Impl
*
* @author pinyan.song
* @version 6.0.0
* @date 2019-11-15
**/
@Service
@Transactional
public class EntityCounterTypeManagerImpl implements EntityCounterTypeManager {
@Autowired
EntityCounterTypeDao entityCounterTypeDao;
@Autowired
private NamedObjectManager namedObjectManager;
@Autowired
private TransactionLogManager transactionLogManager;
@Override
public List<EntityCounterType> getEntityCounterTypesOfEntity(long entityRrn) {
List<EntityCounterType> data = entityCounterTypeDao.getEntityCounterTypesOfEntity(entityRrn);
for (EntityCounterType e : data) {
e.setEventId(namedObjectManager.getInstanceId(e.getEventRrn()));
e.setRecipeId(namedObjectManager.getInstanceId(e.getRecipeRrn()));
}
return data;
}
@Override
public long insertEntityCounterType(EntityCounterType entityCounterType) {
TransactionLog transactionLog = transactionLogManager
.startTransactionLog(entityCounterType.getTransPerformedBy(), TransactionNames.CREATE_KEY);
long instanceRrn = entityCounterTypeDao.insertEntityCounterType(entityCounterType, transactionLog);
transactionLogManager.markTransactionLog(transactionLog);
return instanceRrn;
}
@Override
public void updateEntityCounterType(EntityCounterType entityCounterType) {
TransactionLog transactionLog = transactionLogManager
.startTransactionLog(entityCounterType.getTransPerformedBy(), TransactionNames.MODIFY_KEY);
entityCounterTypeDao.updateEntityCounterType(entityCounterType, transactionLog);
transactionLogManager.markTransactionLog(transactionLog);
}
@Override
public void deleteEntityCounterType(EntityCounterType entityCounterType) {
TransactionLog transactionLog = transactionLogManager
.startTransactionLog(entityCounterType.getTransPerformedBy(), TransactionNames.DELETE_KEY);
entityCounterTypeDao.deleteEntityCounterType(entityCounterType, transactionLog);
transactionLogManager.markTransactionLog(transactionLog);
}
}