package com.vci.server.framework.systemConfig.stafforgmanage.combination; import java.util.List; import org.hibernate.HibernateException; import com.vci.server.base.persistence.dao.BaseService; import com.vci.server.base.persistence.dao.HibernateCallback; import com.vci.server.base.persistence.dao.HibernateTemplate; import com.vci.server.framework.systemConfig.stafforgmanage.passwordStrategy.PasswordStrategyDaoImpl; public class CombinationValueService extends BaseService { /** * 根据父Id获取密码组合方式取值范围 *

Description:

* * @author wangxl * @time 2013-1-3 * @param parentId * @return */ public List getCombinationValuesByParentId(final String parentId) { return (List)new HibernateTemplate().run(new HibernateCallback() { public Object execute() throws HibernateException { CombinationValueDAOImpl impl = new CombinationValueDAOImpl(); String hsql = "from CombinationValue cv where PLPARENTID = '" + parentId + "' order by cv.value"; if(parentId.equals("")){ hsql = "from CombinationValue cv order by cv.value"; } return impl.findEntities(hsql); } }); } @SuppressWarnings("unchecked") public List getCombValByClsfIdAndVal(final String parentId, final String value) { return (List)new HibernateTemplate().run(new HibernateCallback() { public Object execute() throws HibernateException { CombinationValueDAOImpl impl = new CombinationValueDAOImpl(); String hsql = "from CombinationValue cv where cv.parentId = ? and cv.value = ? order by cv.value"; String[] values = new String[2]; values[0] = parentId; values[1] = value; return impl.findEntites(hsql, values); } }); } public List getCombinationValueObjById(final String id) { return (List)new HibernateTemplate().run(new HibernateCallback() { public Object execute() throws HibernateException { PasswordStrategyDaoImpl impl = new PasswordStrategyDaoImpl(); String hsql = "from CombinationValue cv where id = '" + id + "'"; return impl.findEntities(hsql); } }); } /** * 添加密码组合方式 *

Description:

* * @author wangxl * @time 2013-1-3 * @param comb */ public void saveCombinationValue(final CombinationValue[] combValue){ new HibernateTemplate().run(new HibernateCallback() { public Object execute() throws HibernateException { CombinationValueDAOImpl impl = new CombinationValueDAOImpl(); for (CombinationValue val : combValue){ val.setUserEntity(userEntity); impl.save(val); } return combValue; } }); } public boolean updateCombinationValue(final CombinationValue combVal){ return (Boolean)new HibernateTemplate().run(new HibernateCallback() { public Object execute() throws HibernateException { CombinationValueDAOImpl impl = new CombinationValueDAOImpl(); CombinationValue cCombVal = impl.getById(combVal.getId()); if (cCombVal == null) { combVal.setUserEntity(userEntity); impl.saveOrUpdate(combVal); } else { cCombVal.setId(combVal.getId()); cCombVal.setParentId(combVal.getParentId()); cCombVal.setValue(combVal.getValue()); cCombVal.setUserEntity(userEntity); impl.saveOrUpdate(cCombVal); } return true; } }); } public boolean deleteCombinationValueByMQL(final String[] ids) { return (Boolean)new HibernateTemplate().run(new HibernateCallback() { public Object execute() throws HibernateException { int len = ids.length; String inStr = ""; for (int i = 0; i < len; i++) { inStr += "?"; if (i != len - 1) { inStr += ","; } } CombinationValueDAOImpl impl = new CombinationValueDAOImpl(); String hql = "delete CombinationValue cv where cv.id in (" + inStr + ")"; impl.deleteQueryObject(hql, ids, userEntity); return true; } }); } }