Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.inkubator.sms.gateway.service.impl; import com.inkubator.common.notification.model.SMSSend; import com.inkubator.common.util.JsonConverter; import com.inkubator.datacore.service.impl.IServiceImpl; import com.inkubator.sms.gateway.dao.ModemDefinitionDao; import com.inkubator.sms.gateway.dao.SmsActivityDao; import com.inkubator.sms.gateway.entity.ModemDefinition; import com.inkubator.sms.gateway.entity.SmsActivity; import com.inkubator.sms.gateway.service.SmsActivityService; import com.inkubator.sms.gateway.web.model.SmsSendModel; import java.util.Date; import java.util.List; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Session; import org.hibernate.criterion.Order; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.MessageCreator; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; /** * * @author Deni Husni FR */ @Service(value = "smsActivityService") @Lazy public class SmsActivityServiceImpl extends IServiceImpl implements SmsActivityService { @Autowired private SmsActivityDao smsActivityDao; @Autowired private ModemDefinitionDao modemDefinitionDao; @Autowired private JmsTemplate jmsTemplateSMS; @Autowired private JsonConverter jsonConverter; @Override public SmsActivity getEntiyByPK(String id) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntiyByPK(Integer id) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntiyByPK(Long id) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void save(SmsActivity entity) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void update(SmsActivity entity) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void saveOrUpdate(SmsActivity enntity) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity saveData(SmsActivity entity) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity updateData(SmsActivity entity) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity saveOrUpdateData(SmsActivity entity) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntityByPkIsActive(String id, Integer isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntityByPkIsActive(String id, Byte isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntityByPkIsActive(String id, Boolean isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntityByPkIsActive(Integer id, Integer isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntityByPkIsActive(Integer id, Byte isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntityByPkIsActive(Integer id, Boolean isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntityByPkIsActive(Long id, Integer isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntityByPkIsActive(Long id, Byte isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public SmsActivity getEntityByPkIsActive(Long id, Boolean isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void delete(SmsActivity entity) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void softDelete(SmsActivity entity) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public Long getTotalData() throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public Long getTotalDataIsActive(Boolean isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public Long getTotalDataIsActive(Integer isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public Long getTotalDataIsActive(Byte isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override @Transactional(readOnly = true, isolation = Isolation.REPEATABLE_READ, propagation = Propagation.SUPPORTS, timeout = 50) public List<SmsActivity> getAllData() throws Exception { return this.smsActivityDao.getAllData(); } @Override public List<SmsActivity> getAllData(Boolean isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<SmsActivity> getAllData(Integer isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<SmsActivity> getAllData(Byte isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<SmsActivity> getAllDataPageAble(int firstResult, int maxResults, Order order) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<SmsActivity> getAllDataPageAbleIsActive(int firstResult, int maxResults, Order order, Boolean isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<SmsActivity> getAllDataPageAbleIsActive(int firstResult, int maxResults, Order order, Integer isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public List<SmsActivity> getAllDataPageAbleIsActive(int firstResult, int maxResults, Order order, Byte isActive) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override @Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void sendSms(SmsSendModel ssm) throws Exception { ModemDefinition modemDefinition = this.modemDefinitionDao.getEntiyByPK(ssm.getModemId()); double hargaPerSms = modemDefinition.getPricePerSms(); List<String> toLoop = ssm.getListPhone(); for (String toLoop1 : toLoop) { final SMSSend smss = new SMSSend(); smss.setPricePerSms(hargaPerSms); smss.setContent(ssm.getSmsContent()); smss.setFrom("System"); smss.setDestination(toLoop1); smss.setModemId(modemDefinition.getModemId()); this.jmsTemplateSMS.send(new MessageCreator() { @Override public Message createMessage(Session session) throws JMSException { return session.createTextMessage(jsonConverter.getJson(smss)); } }); // OutboundMessage msg = new OutboundMessage(toLoop1, ssm.getSmsContent()); // org.smslib.Service.getInstance().sendMessage(msg, modemDefinition.getModemId()); } // OutboundMessage msg = new OutboundMessage("+6287887051607", "Test UP"); // org.smslib.Service.getInstance().sendMessage(msg); } @Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS, isolation = Isolation.REPEATABLE_READ, timeout = 50) public List<SmsActivity> getListBySendDate(Date date) throws Exception { // return this.smsActivityDao.getListBySendDate(date); return this.smsActivityDao.getAllByLucenSendDate(date); } @Override @Transactional(readOnly = false, isolation = Isolation.REPEATABLE_READ, propagation = Propagation.SUPPORTS, timeout = 50) public List<SmsActivity> getAllByFullTextService(String parameter, int minResult, int maxResult, Order order) throws Exception { return this.smsActivityDao.getAllByFullTextService(parameter, minResult, maxResult, order); } @Override @Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, timeout = 30) public Integer getTotalByFullTextService(String parameter) throws Exception { return this.smsActivityDao.getTotalByFullTextService(parameter); } }