Package org.magicbox.ibatis

Source Code of org.magicbox.ibatis.GruppiDaoImpl

/*
* Copyright Massimiliano Dess� (desmax74@yahoo.it)
*
* Licensed under Apache License Version 2.0
* (http://www.apache.org/licenses/LICENSE-2.0),
*
* for commercial use, under
* GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*/
package org.magicbox.ibatis;

import java.util.List;
import java.util.Map;

import javolution.util.FastMap;

import org.magicbox.dao.GruppiDao;
import org.magicbox.domain.GruppoImpl;
import org.magicbox.domain.Gruppo;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
* Implementazione per l'accesso al repository dei propri gruppi da parte di un centro
*
* @author Massimiliano Dess�; (desmax74@yahoo.it)
* @since jdk 1.6.0
* @version 3.0
*/
@SuppressWarnings("unchecked")
public class GruppiDaoImpl extends SqlMapClientDaoSupport implements GruppiDao {

    public List<String> getMailgruppi(String listeWithSeparator) {
        return getSqlMapClientTemplate().queryForList("selectMailGruppo", listeWithSeparator);
    }

    public boolean deleteAllGruppiCentro(long idCentro) {
        return getSqlMapClientTemplate().delete("deleteAllGruppiCentro", idCentro) > 0 ? true : false;
    }

    public boolean deleteGruppo(long id, long idCentro) {
        return getSqlMapClientTemplate().delete("deleteGruppo", prepareParams(id, idCentro)) == 1 ? true : false;
    }

    public List<Gruppo> getGruppiCentro(long idCentro) {
        return getSqlMapClientTemplate().queryForList("getGruppiCentro", idCentro);
    }

    public Gruppo getGruppo(long id, long idCentro) {
        return (Gruppo) getSqlMapClientTemplate().queryForObject("getGruppo", prepareParams(id, idCentro));
    }

    public long insertGruppo(Gruppo gruppo, long idCentro) {
        return (Long) getSqlMapClientTemplate().insert("insertGruppo", new GruppoImpl(gruppo, idCentro));
    }

    public int updateGruppo(Gruppo gruppo, long idCentro) {
        return getSqlMapClientTemplate().update("updateGruppo", new GruppoImpl(gruppo, idCentro));
    }

    private Map prepareParams(long id, long idCentro) {
        Map params = new FastMap();
        params.put("id", id);
        params.put("idCentro", idCentro);
        return params;
    }
}
TOP

Related Classes of org.magicbox.ibatis.GruppiDaoImpl

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.