Package systole.persistence.brokersDB

Source Code of systole.persistence.brokersDB.RawSignalBrokerDB

/**
*
*/
package systole.persistence.brokersDB;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import systole.domain.signals.RawSignal;
import systole.exceptions.ExceptionDAO;
import systole.persistence.FacadeDB;
import systole.persistence.brokersInterface.RawSignalBroker;
import systole.view.messages.ErrorMessages;

/**
* @author jmj
*
*/
public class RawSignalBrokerDB extends BrokerDB implements RawSignalBroker {

    /**
     *
     */
    public RawSignalBrokerDB() {
        super();
    }

    /* (non-Javadoc)
     * @see systole.persistence.brokersInterface.RawSignalBroker#getRawSignalById(long)
     */
    @Override
    public RawSignal getRawSignalById(Integer id) throws ExceptionDAO {
        try {
            this.logger.logDebug("getting rawSignal instance");
            Session currentSession = FacadeDB.getInstance().getCurrentSession();
            RawSignal instance = (RawSignal) currentSession.get(RawSignal.class, id);
            this.logger.logDebug("get rawSignal successfully");
            return instance;
        } catch (HibernateException e) {
            this.logger.logError("error on get rawSignal by id, msg: " + e.getMessage());
            throw new ExceptionDAO("No se pudo obtener la Señal", e.fillInStackTrace());
        }
    }

    /* (non-Javadoc)
     * @see systole.persistence.brokersInterface.RawSignalBroker#insert(systole.domain.signals.RawSignal)
     */
    @Override
    public void insert(RawSignal rawSignal) throws ExceptionDAO {
        try {
            this.logger.logDebug("save rawSignal ");
            Session currentSession = FacadeDB.getInstance().getCurrentSession();
            currentSession.save(rawSignal);
            this.logger.logDebug("save rawSignal successfully");
        } catch (HibernateException e) {
            this.logger.logError("error on save rawSignal, msg: " + e.getMessage());
            throw new ExceptionDAO(ErrorMessages.CHANGES_NOT_SAVE, e.fillInStackTrace());
        }

    }

    /* (non-Javadoc)
     * @see systole.persistence.brokersInterface.RawSignalBroker#update(systole.domain.signals.RawSignal)
     */
    @Override
    public void update(RawSignal rawSignal) throws ExceptionDAO {
        try {
            this.logger.logDebug("Updating rawSignal");
            Session currentSession = FacadeDB.getInstance().getCurrentSession();
            currentSession.update(rawSignal);
            this.logger.logDebug("rawSignal updated");
        } catch (HibernateException e) {
            this.logger.logError("error on update rawSignal, msg: " + e.getMessage());
            throw new ExceptionDAO(ErrorMessages.CHANGES_NOT_SAVE, e.fillInStackTrace());
        }
    }
}
TOP

Related Classes of systole.persistence.brokersDB.RawSignalBrokerDB

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.