All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.gdface.facelog.BaseDao Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
// ______________________________________________________
// Generated by sql2java - https://github.com/10km/sql2java 
// JDBC driver used at code generation time: com.mysql.jdbc.Driver
// template: base.dao.java.vm
// ______________________________________________________
package net.gdface.facelog;

import static com.google.common.base.Preconditions.*;
import static gu.sql2java.Managers.*;

import com.google.common.base.Throwables;

import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

import gu.sql2java.TableManager;
import gu.sql2java.BaseBean;
import gu.sql2java.Managers;
import net.gdface.facelog.db.Constant;

import net.gdface.facelog.db.*;
import gu.sql2java.exception.ObjectRetrievalException;
import gu.sql2java.exception.RuntimeDaoException;

/**
 * 数据库访问基础方法
 * @author guyadong
 *
 */
class BaseDao implements CommonConstant,Constant {
    static{
        TableManagerInitializer.INSTANCE.init();
    }
    /** 生成 SQL where 语句,example: {@code WHERE create_time >'2017-09-02 12:12:12'} */
    static private String makeWhere(Date timestamp,String field){
        SimpleDateFormat formatter = new SimpleDateFormat(TIMESTAMP_FORMATTER_STR);
        return String.format(
                "WHERE %s > '%s'", 
                field,
                formatter.format(checkNotNull(timestamp)));    
    }
    /** 
     * 事务执行 
     * @throws RuntimeDaoException
     */
    protected static  T daoRunAsTransaction(Callable fun)
                    throws RuntimeDaoException{
        return Managers.getSqlRunner().runAsTransaction(checkNotNull(fun));
    }
    /** 
     * 事务执行 
     * @throws RuntimeDaoException
     */
    protected static void daoRunAsTransaction(Runnable fun)
                    throws RuntimeDaoException{
        Managers.getSqlRunner().runAsTransaction(checkNotNull(fun));
    }
    /**
     * 查询 {@code table}表的{@code column}字段的数据
     * @param table 数据库表名
     * @param column 有效的table表字段名或table对应java类的字段名
     * @param distinct 为{@code true}只返回不重复记录
     * @param where 'where'起始的SQL 查询条件语句,可为{@code null}
     * @param startRow 返回记录的起始行(首行=1,尾行=-1)
     * @param numRows 返回记录条数(小于0时返回所有记录)
     * @return {@code column}字段记录
     * @see TableManager#loadColumnAsList(String,boolean,String,int,int)
     * @throws RuntimeDaoException
     */
    protectedList daoLoadColumnAsList(String table,String column,boolean distinct,String where,int startRow, int numRows)
                    throws RuntimeDaoException{
        return managerOf(table).loadColumnAsList(column, distinct, where, startRow, numRows);
    }
    /**
     * 查询 {@code table}表的{@code column}字段的数据
     * @param table 数据库表名
     * @param column 有效的table表字段名或table对应java类的字段名
     * @param distinct 为{@code true}只返回不重复记录
     * @param where 'where'起始的SQL 查询条件语句,可为{@code null}
     * @return {@code column}字段记录
     * @see TableManager#loadColumnAsList(String,boolean,String,int,int)
     * @throws RuntimeDaoException
     */
    protectedList daoLoadColumnAsList(String table,String column,boolean distinct,String where)
                    throws RuntimeDaoException{
        return managerOf(table).loadColumnAsList(column, distinct, where, 1, -1);
    }

    protected static final  void throwCauseIfInstanceOf(Exception error,Class expType) throws T {
        if(null != error.getCause()){
            Throwables.throwIfInstanceOf(error.getCause(),expType);
        }
    }
    /**
     * 数据库写操作类型
     * @author guyadong
     *
     */
    protected enum WriteOp{
        /** 增加记录 */insert,
        /** 更新记录 */update,
        /** 删除记录 */delete
    }
    //////////// FL_DEVICE /////////
    final IDeviceManager deviceManager = instanceOf(IDeviceManager.class);
    //1
    /** 
     * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param id 设备id * @return DeviceBean 对象 * @see IDeviceManager#loadByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected DeviceBean daoGetDevice(Integer id)throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).loadByPrimaryKey(id); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param id 设备id * @return DeviceBean 对象 * @see IDeviceManager#loadByPrimaryKeyChecked(Integer) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected DeviceBean daoGetDeviceChecked(Integer id)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IDeviceManager.class).loadByPrimaryKeyChecked(id); } //2 /** * 根据主键从数据库读取记录 * @return 返回与输入参数下标对应的 DeviceBean 列表,没有查到记录的返回{@code null} * @see IDeviceManager#loadByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected List daoGetDevices(Collection idCollection) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).loadByPrimaryKey(idCollection); } //3 /** * 删除主键列表({@code idCollection})指定的记录 * @return 返回删除的记录条数 * @see IDeviceManager#deleteByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected int daoDeleteDevicesByPrimaryKey(Collection idCollection) throws RuntimeDaoException{ int count =0; if(null != idCollection){ for(Integer id:idCollection){ count += daoDeleteDevice(id); } } return count; } //3-5 /** transformer : DeviceBean to fl_device.id */ protected final Function daoCastDeviceToPk = new Function(){ @Override public Integer apply(DeviceBean input) { return null == input ? null : input.getId(); }}; //3-6 /** transformer : fl_device.id to DeviceBean */ protected final Function daoCastDeviceFromPk = new Function(){ @Override public DeviceBean apply(Integer input) { return daoGetDevice(input); }}; //3-8 /** * unwrap primary key from {@link DeviceBean}
* if {@code beans} is {@code null},return a empty list(immutable) * * @param beans {@link DeviceBean} collection * @return primary key list * @see IDeviceManager#toPrimaryKeyList(Collection) */ protected List daoToPrimaryKeyListFromDevices(Collection beans){ if (null == beans){ return ImmutableList.of(); }else{ return instanceOf(IDeviceManager.class).toPrimaryKeyList(beans); } } //3-9 /** * unwrap primary key from {@link DeviceBean}
* * the returned list is a transformed view of {@code beans}; * changes to {@code beans} will be reflected in the returned list and vice versa. * * if {@code beans} is {@code null},return a empty list(immutable) * @param beans {@link DeviceBean} list * @return primary key list * @see Lists#transform(List, Function) */ protected List daoToPrimaryKeyListFromDevices(List beans){ if(null == beans){ return ImmutableList.of(); }else{ return Lists.transform(beans,daoCastDeviceToPk); } } //4 /** * 判断主键指定的记录是否存在 * * @param id 设备id * @see IDeviceManager#existsPrimaryKey(Integer) * @throws RuntimeDaoException */ protected boolean daoExistsDevice(Integer id) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).existsPrimaryKey(id); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsDevice(DeviceBean bean) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param id 设备id * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see IDeviceManager#deleteByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected int daoDeleteDevice(Integer id) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).deleteByPrimaryKey(id); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeleteDevice(Integer) * @throws RuntimeDaoException */ protected int daoDeleteDevice(DeviceBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeleteDevice(bean.getId()); } //5-3 /** * 删除唯一键指定的记录 * * @param mac 6字节MAC地址(HEX) * @return 返回删除的记录条数(1),输入参数为{@code null}或记录不存在返回0 * @see #daoDeleteDevice(Integer) * @throws RuntimeDaoException */ protected int daoDeleteDeviceByIndexMac(String mac) throws RuntimeDaoException{ return (null == mac) ? 0 : instanceOf(IDeviceManager.class).deleteByIndexMac(mac); } //5-3 /** * 删除唯一键指定的记录 * * @param serialNo 设备序列号 * @return 返回删除的记录条数(1),输入参数为{@code null}或记录不存在返回0 * @see #daoDeleteDevice(Integer) * @throws RuntimeDaoException */ protected int daoDeleteDeviceByIndexSerialNo(String serialNo) throws RuntimeDaoException{ return (null == serialNo) ? 0 : instanceOf(IDeviceManager.class).deleteByIndexSerialNo(serialNo); } //6 /** * 删除{@code deviceBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeleteDevice(Integer) * @throws RuntimeDaoException */ protected int daoDeleteDevices(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(DeviceBean bean:beans){ count += daoDeleteDevice(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected DeviceBean daoCheckDuplicate(DeviceBean deviceBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(IDeviceManager.class).checkDuplicate(deviceBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param id 设备id * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * @return always {@code idOfDevice} * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected Integer daoCheckDuplicateDevice(Integer id) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(IDeviceManager.class).existsPrimaryKey(id)){ throw new DuplicateRecordException(); } return id; } //8 /** * 返回外键(fl_error_log.device_id)引用指定记录(fl_device.id)的所有{@code fl_error_log}记录 * * @param idOfDevice 设备id * @see IDeviceManager#getErrorLogBeansByDeviceIdAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetErrorLogBeansByDeviceIdOnDevice(Integer idOfDevice) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).getErrorLogBeansByDeviceIdAsList(idOfDevice); } //8-2 /** * 删除外键(idOfDevice))引用指定记录(fl_device.id)的所有{@code fl_error_log}记录 * * @param idOfDevice 设备id * @see IDeviceManager#deleteErrorLogBeansByDeviceId(Integer) * @throws RuntimeDaoException */ protected int daoDeleteErrorLogBeansByDeviceIdOnDevice(Integer idOfDevice) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).deleteErrorLogBeansByDeviceId(idOfDevice); } //8 /** * 返回外键(fl_image.device_id)引用指定记录(fl_device.id)的所有{@code fl_image}记录 * * @param idOfDevice 设备id * @see IDeviceManager#getImageBeansByDeviceIdAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetImageBeansByDeviceIdOnDevice(Integer idOfDevice) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).getImageBeansByDeviceIdAsList(idOfDevice); } //8-2 /** * 删除外键(idOfDevice))引用指定记录(fl_device.id)的所有{@code fl_image}记录 * * @param idOfDevice 设备id * @see IDeviceManager#deleteImageBeansByDeviceId(Integer) * @throws RuntimeDaoException */ protected int daoDeleteImageBeansByDeviceIdOnDevice(Integer idOfDevice) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).deleteImageBeansByDeviceId(idOfDevice); } //8 /** * 返回外键(fl_log.device_id)引用指定记录(fl_device.id)的所有{@code fl_log}记录 * * @param idOfDevice 设备id * @see IDeviceManager#getLogBeansByDeviceIdAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetLogBeansByDeviceIdOnDevice(Integer idOfDevice) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).getLogBeansByDeviceIdAsList(idOfDevice); } //8-2 /** * 删除外键(idOfDevice))引用指定记录(fl_device.id)的所有{@code fl_log}记录 * * @param idOfDevice 设备id * @see IDeviceManager#deleteLogBeansByDeviceId(Integer) * @throws RuntimeDaoException */ protected int daoDeleteLogBeansByDeviceIdOnDevice(Integer idOfDevice) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).deleteLogBeansByDeviceId(idOfDevice); } //8-3 /** * 返回外键(fl_device.group_id)引用的 fl_device_group 记录 * @param bean * @see IDeviceManager#getReferencedByGroupId(DeviceBean) * @throws RuntimeDaoException */ protected DeviceGroupBean daoGetReferencedByGroupIdOnDevice(DeviceBean bean) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).getReferencedByGroupId(bean); } //8-4 /** * 设置外键fl_device(group_id)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IDeviceManager#setReferencedByGroupId(DeviceBean,DeviceGroupBean) * @throws RuntimeDaoException */ protected DeviceGroupBean daoSetReferencedByGroupIdOnDevice(DeviceBean bean,DeviceGroupBean beanToSet) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).setReferencedByGroupId(bean,beanToSet); } //8-6 /** transformer : DeviceBean to fl_device.group_id */ protected final Function daoCastDeviceToGroupId = new Function(){ @Override public Integer apply(DeviceBean input) { return null == input ? null : input.getGroupId(); }}; //8-8 /** transformer : fl_device.id to fl_device.group_id */ protected final Function daoCastDevicePkToGroupId = new Function(){ @Override public Integer apply(Integer input) { return null == input ? null : daoCastDeviceToGroupId.apply(daoGetDevice(input)); }}; //14 /** * 参见 {@link TableManager#save(BaseBean)} * @throws RuntimeDaoException */ protected DeviceBean daoSaveDevice(DeviceBean deviceBean) throws RuntimeDaoException{ daoCheckGroup(deviceBean); return instanceOf(IDeviceManager.class).save(deviceBean); } //15 /** 同步保存
* see also {@link IDeviceManager#save(DeviceBean , DeviceGroupBean , Collection, Collection, Collection )} * @throws RuntimeDaoException */ protected DeviceBean daoSaveDevice(DeviceBean deviceBean , DeviceGroupBean refDevicegroupByGroupId , Collection impErrorlogByDeviceId , Collection impImageByDeviceId , Collection impLogByDeviceId )throws RuntimeDaoException{ daoCheckGroup(deviceBean); return instanceOf(IDeviceManager.class).save(deviceBean , refDevicegroupByGroupId , impErrorlogByDeviceId , impImageByDeviceId , impLogByDeviceId ); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoSaveDevice(DeviceBean) * @throws RuntimeDaoException */ protected Collection daoSaveDevices(Collection beans) throws RuntimeDaoException { if(null != beans){ for(DeviceBean bean : beans){ daoSaveDevice(bean); } } return beans; } //12-3-5 /** * {@link #daoSaveDevices(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoSaveDevicesAsTransaction(final Collection beans) throws RuntimeDaoException { try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoSaveDevices(beans); }}); }catch(RuntimeException e){ throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_device 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IDeviceManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadDeviceByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_device 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadDeviceUsingTemplate(DeviceBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_device 的{@code column}字段的数据 * @param column 有效的fl_device表字段名或{@link DeviceBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IDeviceManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfDeviceAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_device 表的所有记录 * @see IDeviceManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadDeviceAll() throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_device 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountDeviceByWhere(String where) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).countWhere(where); } //18 /** * 查询{@code where}条件指定的记录 * @return 返回查询结果记录的主键 * @see #daoLoadDeviceByWhere(String,int,int) * @throws RuntimeDaoException */ protected List daoLoadDeviceIdByWhere(String where) throws RuntimeDaoException{ return daoToPrimaryKeyListFromDevices(daoLoadDeviceByWhere(where,1,-1)); } //18-5 /** * 索引(fl_device.mac)查询,没有找到记录返回{@code null}
* * @param mac 6字节MAC地址(HEX) * @see IDeviceManager#loadByIndexMac(String) * @throws RuntimeDaoException */ protected DeviceBean daoGetDeviceByIndexMac(String mac) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).loadByIndexMac(mac); } //18-7 /** * 索引(fl_device.mac)查询,没有找到记录抛出异常
* * @param mac 6字节MAC地址(HEX) * @see IDeviceManager#loadByIndexMacChecked(String) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected DeviceBean daoGetDeviceByIndexMacChecked(String mac) throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IDeviceManager.class).loadByIndexMacChecked(mac); } //18-8 /** * 检查数据库中是否有(唯一键)相同的记录,如果有则抛出异常 * * @param mac 6字节MAC地址(HEX) * @throws DuplicateRecordException if exists duplicated row * @throws RuntimeDaoException */ protected String daoCheckDuplicateDeviceByIndexMac(String mac) throws RuntimeDaoException,DuplicateRecordException{ if(null != daoGetDeviceByIndexMac(mac)){ throw new DuplicateRecordException(); } return mac; } //18-5 /** * 索引(fl_device.serial_no)查询,没有找到记录返回{@code null}
* * @param serialNo 设备序列号 * @see IDeviceManager#loadByIndexSerialNo(String) * @throws RuntimeDaoException */ protected DeviceBean daoGetDeviceByIndexSerialNo(String serialNo) throws RuntimeDaoException{ return instanceOf(IDeviceManager.class).loadByIndexSerialNo(serialNo); } //18-7 /** * 索引(fl_device.serial_no)查询,没有找到记录抛出异常
* * @param serialNo 设备序列号 * @see IDeviceManager#loadByIndexSerialNoChecked(String) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected DeviceBean daoGetDeviceByIndexSerialNoChecked(String serialNo) throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IDeviceManager.class).loadByIndexSerialNoChecked(serialNo); } //18-8 /** * 检查数据库中是否有(唯一键)相同的记录,如果有则抛出异常 * * @param serialNo 设备序列号 * @throws DuplicateRecordException if exists duplicated row * @throws RuntimeDaoException */ protected String daoCheckDuplicateDeviceByIndexSerialNo(String serialNo) throws RuntimeDaoException,DuplicateRecordException{ if(null != daoGetDeviceByIndexSerialNo(serialNo)){ throw new DuplicateRecordException(); } return serialNo; } //19 /** * (主动更新机制实现)
* 返回 fl_device.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadDeviceByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadDeviceByCreateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadDeviceByWhere(makeWhere(timestamp,"create_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadDeviceByCreateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadDeviceByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadDeviceByCreateTime(timestamp,1,-1); } //20-5 /** * 返回fl_device.create_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountDeviceByWhere(String) * @throws RuntimeDaoException */ protected int daoCountDeviceByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoCountDeviceByWhere(makeWhere(timestamp,"create_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_device.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadDeviceIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadDeviceIdByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadDeviceIdByWhere(makeWhere(timestamp,"create_time")); } //19 /** * (主动更新机制实现)
* 返回 fl_device.update_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadDeviceByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadDeviceByUpdateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadDeviceByWhere(makeWhere(timestamp,"update_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadDeviceByUpdateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadDeviceByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadDeviceByUpdateTime(timestamp,1,-1); } //20-5 /** * 返回fl_device.update_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountDeviceByWhere(String) * @throws RuntimeDaoException */ protected int daoCountDeviceByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoCountDeviceByWhere(makeWhere(timestamp,"update_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_device.update_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadDeviceIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadDeviceIdByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadDeviceIdByWhere(makeWhere(timestamp,"update_time")); } //////////// FL_DEVICE_GROUP ///////// final IDeviceGroupManager deviceGroupManager = instanceOf(IDeviceGroupManager.class); //1 /** * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param id 设备组id * @return DeviceGroupBean 对象 * @see IDeviceGroupManager#loadByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected DeviceGroupBean daoGetDeviceGroup(Integer id)throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).loadByPrimaryKey(id); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param id 设备组id * @return DeviceGroupBean 对象 * @see IDeviceGroupManager#loadByPrimaryKeyChecked(Integer) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected DeviceGroupBean daoGetDeviceGroupChecked(Integer id)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IDeviceGroupManager.class).loadByPrimaryKeyChecked(id); } //2 /** * 根据主键从数据库读取记录 * @return 返回与输入参数下标对应的 DeviceGroupBean 列表,没有查到记录的返回{@code null} * @see IDeviceGroupManager#loadByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected List daoGetDeviceGroups(Collection idCollection) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).loadByPrimaryKey(idCollection); } //3 /** * 删除主键列表({@code idCollection})指定的记录 * @return 返回删除的记录条数 * @see IDeviceGroupManager#deleteByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected int daoDeleteDeviceGroupsByPrimaryKey(Collection idCollection) throws RuntimeDaoException{ int count =0; if(null != idCollection){ for(Integer id:idCollection){ count += daoDeleteDeviceGroup(id); } } return count; } //3-5 /** transformer : DeviceGroupBean to fl_device_group.id */ protected final Function daoCastDeviceGroupToPk = new Function(){ @Override public Integer apply(DeviceGroupBean input) { return null == input ? null : input.getId(); }}; //3-6 /** transformer : fl_device_group.id to DeviceGroupBean */ protected final Function daoCastDeviceGroupFromPk = new Function(){ @Override public DeviceGroupBean apply(Integer input) { return daoGetDeviceGroup(input); }}; //3-8 /** * unwrap primary key from {@link DeviceGroupBean}
* if {@code beans} is {@code null},return a empty list(immutable) * * @param beans {@link DeviceGroupBean} collection * @return primary key list * @see IDeviceGroupManager#toPrimaryKeyList(Collection) */ protected List daoToPrimaryKeyListFromDeviceGroups(Collection beans){ if (null == beans){ return ImmutableList.of(); }else{ return instanceOf(IDeviceGroupManager.class).toPrimaryKeyList(beans); } } //3-9 /** * unwrap primary key from {@link DeviceGroupBean}
* * the returned list is a transformed view of {@code beans}; * changes to {@code beans} will be reflected in the returned list and vice versa. * * if {@code beans} is {@code null},return a empty list(immutable) * @param beans {@link DeviceGroupBean} list * @return primary key list * @see Lists#transform(List, Function) */ protected List daoToPrimaryKeyListFromDeviceGroups(List beans){ if(null == beans){ return ImmutableList.of(); }else{ return Lists.transform(beans,daoCastDeviceGroupToPk); } } //4 /** * 判断主键指定的记录是否存在 * * @param id 设备组id * @see IDeviceGroupManager#existsPrimaryKey(Integer) * @throws RuntimeDaoException */ protected boolean daoExistsDeviceGroup(Integer id) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).existsPrimaryKey(id); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsDeviceGroup(DeviceGroupBean bean) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param id 设备组id * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see IDeviceGroupManager#deleteByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected int daoDeleteDeviceGroup(Integer id) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).deleteByPrimaryKey(id); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeleteDeviceGroup(Integer) * @throws RuntimeDaoException */ protected int daoDeleteDeviceGroup(DeviceGroupBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeleteDeviceGroup(bean.getId()); } //6 /** * 删除{@code deviceGroupBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeleteDeviceGroup(Integer) * @throws RuntimeDaoException */ protected int daoDeleteDeviceGroups(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(DeviceGroupBean bean:beans){ count += daoDeleteDeviceGroup(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected DeviceGroupBean daoCheckDuplicate(DeviceGroupBean deviceGroupBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(IDeviceGroupManager.class).checkDuplicate(deviceGroupBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param id 设备组id * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * @return always {@code idOfDeviceGroup} * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected Integer daoCheckDuplicateDeviceGroup(Integer id) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(IDeviceGroupManager.class).existsPrimaryKey(id)){ throw new DuplicateRecordException(); } return id; } //8 /** * 返回属于{@code idOfDeviceGroup}指定组的所有{@code fl_device}记录 * * @param idOfDeviceGroup 设备组id * @see IDeviceGroupManager#getDeviceBeansByGroupIdAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetDevicesOfGroup(Integer idOfDeviceGroup) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).getDeviceBeansByGroupIdAsList(idOfDeviceGroup); } //8-2 /** * 删除外键(idOfDeviceGroup))引用指定记录(fl_device_group.id)的所有{@code fl_device}记录 * * @param idOfDeviceGroup 设备组id * @see IDeviceGroupManager#deleteDeviceBeansByGroupId(Integer) * @throws RuntimeDaoException */ protected int daoDeleteDeviceBeansByGroupIdOnDeviceGroup(Integer idOfDeviceGroup) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).deleteDeviceBeansByGroupId(idOfDeviceGroup); } //8 /** * 返回{@code idOfDeviceGroup)}指定的组下的所有子节点,如果没有子节点则返回空表 * * @param idOfDeviceGroup 设备组id * @see IDeviceGroupManager#getDeviceGroupBeansByParentAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetSubDeviceGroup(Integer idOfDeviceGroup) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).getDeviceGroupBeansByParentAsList(idOfDeviceGroup); } //8-2 /** * 删除外键(idOfDeviceGroup))引用指定记录(fl_device_group.id)的所有{@code fl_device_group}记录 * * @param idOfDeviceGroup 设备组id * @see IDeviceGroupManager#deleteDeviceGroupBeansByParent(Integer) * @throws RuntimeDaoException */ protected int daoDeleteDeviceGroupBeansByParentOnDeviceGroup(Integer idOfDeviceGroup) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).deleteDeviceGroupBeansByParent(idOfDeviceGroup); } //8 /** * 返回外键(fl_permit.device_group_id)引用指定记录(fl_device_group.id)的所有{@code fl_permit}记录 * * @param idOfDeviceGroup 设备组id * @see IDeviceGroupManager#getPermitBeansByDeviceGroupIdAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetPermitBeansByDeviceGroupIdOnDeviceGroup(Integer idOfDeviceGroup) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).getPermitBeansByDeviceGroupIdAsList(idOfDeviceGroup); } //8-2 /** * 删除外键(idOfDeviceGroup))引用指定记录(fl_device_group.id)的所有{@code fl_permit}记录 * * @param idOfDeviceGroup 设备组id * @see IDeviceGroupManager#deletePermitBeansByDeviceGroupId(Integer) * @throws RuntimeDaoException */ protected int daoDeletePermitBeansByDeviceGroupIdOnDeviceGroup(Integer idOfDeviceGroup) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).deletePermitBeansByDeviceGroupId(idOfDeviceGroup); } //8-3 /** * 返回外键(fl_device_group.parent)引用的 fl_device_group 记录 * @param bean * @see IDeviceGroupManager#getReferencedByParent(DeviceGroupBean) * @throws RuntimeDaoException */ protected DeviceGroupBean daoGetReferencedByParentOnDeviceGroup(DeviceGroupBean bean) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).getReferencedByParent(bean); } //8-4 /** * 设置外键fl_device_group(parent)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IDeviceGroupManager#setReferencedByParent(DeviceGroupBean,DeviceGroupBean) * @throws RuntimeDaoException */ protected DeviceGroupBean daoSetReferencedByParentOnDeviceGroup(DeviceGroupBean bean,DeviceGroupBean beanToSet) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).setReferencedByParent(bean,beanToSet); } //9 /** * 返回(idOfDeviceGroup))指定的fl_device_group记录的所有的父节点(包括自己)
* 自引用字段:fl_device_group(parent) * @see IDeviceGroupManager#listOfParent(Integer) * @throws RuntimeDaoException */ protected java.util.List daoListOfParentForDeviceGroup(Integer idOfDeviceGroup) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).listOfParent(idOfDeviceGroup); } //9-2 /** * 返回{@code deviceGroupBean}指定的fl_device_group记录的所有的父节点(包括自己)
* 自引用字段:fl_device_group(parent) * @see IDeviceGroupManager#listOfParent(DeviceGroupBean) * @throws RuntimeDaoException */ protected java.util.List daoListOfParentForDeviceGroup(DeviceGroupBean deviceGroupBean) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).listOfParent(deviceGroupBean); } //9-3 /** * 返回(idOfDeviceGroup))指定的fl_device_group记录的所有的子节点(包括自己)
* 自引用字段:fl_device_group(parent) * @see IDeviceGroupManager#childListByParent(Integer) * @throws RuntimeDaoException */ protected java.util.List daoChildListByParentForDeviceGroup(Integer idOfDeviceGroup) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).childListByParent(idOfDeviceGroup); } //9-4 /** * 返回{@code deviceGroupBean}指定的fl_device_group记录的所有的子节点(包括自己)
* 自引用字段:fl_device_group(parent) * @see IDeviceGroupManager#listOfParent(DeviceGroupBean) * @throws RuntimeDaoException */ protected java.util.List daoChildListByParentForDeviceGroup(DeviceGroupBean deviceGroupBean) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).childListByParent(deviceGroupBean); } //10 /** * 如果没有默认组则向 fl_device_group 表中增加默认组,失败则抛出异常 * * @throws IllegalStateException 创建失败 * @throws RuntimeDaoException */ protected void daoSaveDefaultDeviceGroupIfAbsent() throws RuntimeDaoException{ if(!daoExistsDeviceGroup(DEFAULT_GROUP_ID)){ try{ DeviceGroupBean bean = new DeviceGroupBean(DEFAULT_GROUP_ID); bean.setName(DEFAULT_GROUP_NAME); daoSaveDeviceGroup(bean); }catch(RuntimeDaoException e){ // do nothing } if(!daoExistsDeviceGroup(DEFAULT_GROUP_ID)){ throw new IllegalStateException("can't create default group for device_group"); } } } //11 /** * 检查{@link DeviceBean}的'group_id'字段是否为默认组{@link CommonConstant#DEFAULT_GROUP_ID}, * 如果是,且默认组记录不存在则创建默认组 * @return {@code deviceBean} * @see #daoSaveDefaultDeviceGroupIfAbsent() * @throws RuntimeDaoException */ protected DeviceBean daoCheckGroup(DeviceBean deviceBean) throws RuntimeDaoException{ if(null != deviceBean && Objects.equals(deviceBean.getGroupId(), DEFAULT_GROUP_ID)){ daoSaveDefaultDeviceGroupIfAbsent(); } return deviceBean; } //14 /** * 参见 {@link TableManager#save(BaseBean)} * @throws RuntimeDaoException */ protected DeviceGroupBean daoSaveDeviceGroup(DeviceGroupBean deviceGroupBean) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).save(deviceGroupBean); } //15 /** 同步保存
* see also {@link IDeviceGroupManager#save(DeviceGroupBean , DeviceGroupBean , Collection, Collection, Collection )} * @throws RuntimeDaoException */ protected DeviceGroupBean daoSaveDeviceGroup(DeviceGroupBean deviceGroupBean , DeviceGroupBean refDevicegroupByParent , Collection impDeviceByGroupId , Collection impDevicegroupByParent , Collection impPermitByDeviceGroupId )throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).save(deviceGroupBean , refDevicegroupByParent , impDeviceByGroupId , impDevicegroupByParent , impPermitByDeviceGroupId ); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoSaveDeviceGroup(DeviceGroupBean) * @throws RuntimeDaoException */ protected Collection daoSaveDeviceGroups(Collection beans) throws RuntimeDaoException { if(null != beans){ for(DeviceGroupBean bean : beans){ daoSaveDeviceGroup(bean); } } return beans; } //12-3-5 /** * {@link #daoSaveDeviceGroups(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoSaveDeviceGroupsAsTransaction(final Collection beans) throws RuntimeDaoException { try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoSaveDeviceGroups(beans); }}); }catch(RuntimeException e){ throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_device_group 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IDeviceGroupManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadDeviceGroupByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_device_group 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadDeviceGroupUsingTemplate(DeviceGroupBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_device_group 的{@code column}字段的数据 * @param column 有效的fl_device_group表字段名或{@link DeviceGroupBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IDeviceGroupManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfDeviceGroupAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_device_group 表的所有记录 * @see IDeviceGroupManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadDeviceGroupAll() throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_device_group 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountDeviceGroupByWhere(String where) throws RuntimeDaoException{ return instanceOf(IDeviceGroupManager.class).countWhere(where); } //18 /** * 查询{@code where}条件指定的记录 * @return 返回查询结果记录的主键 * @see #daoLoadDeviceGroupByWhere(String,int,int) * @throws RuntimeDaoException */ protected List daoLoadDeviceGroupIdByWhere(String where) throws RuntimeDaoException{ return daoToPrimaryKeyListFromDeviceGroups(daoLoadDeviceGroupByWhere(where,1,-1)); } //19 /** * (主动更新机制实现)
* 返回 fl_device_group.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadDeviceGroupByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadDeviceGroupByCreateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadDeviceGroupByWhere(makeWhere(timestamp,"create_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadDeviceGroupByCreateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadDeviceGroupByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadDeviceGroupByCreateTime(timestamp,1,-1); } //20-5 /** * 返回fl_device_group.create_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountDeviceGroupByWhere(String) * @throws RuntimeDaoException */ protected int daoCountDeviceGroupByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoCountDeviceGroupByWhere(makeWhere(timestamp,"create_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_device_group.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadDeviceGroupIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadDeviceGroupIdByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadDeviceGroupIdByWhere(makeWhere(timestamp,"create_time")); } //19 /** * (主动更新机制实现)
* 返回 fl_device_group.update_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadDeviceGroupByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadDeviceGroupByUpdateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadDeviceGroupByWhere(makeWhere(timestamp,"update_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadDeviceGroupByUpdateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadDeviceGroupByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadDeviceGroupByUpdateTime(timestamp,1,-1); } //20-5 /** * 返回fl_device_group.update_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountDeviceGroupByWhere(String) * @throws RuntimeDaoException */ protected int daoCountDeviceGroupByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoCountDeviceGroupByWhere(makeWhere(timestamp,"update_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_device_group.update_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadDeviceGroupIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadDeviceGroupIdByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadDeviceGroupIdByWhere(makeWhere(timestamp,"update_time")); } //////////// FL_PERSON ///////// final IPersonManager personManager = instanceOf(IPersonManager.class); //1 /** * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param id 用户id * @return PersonBean 对象 * @see IPersonManager#loadByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected PersonBean daoGetPerson(Integer id)throws RuntimeDaoException{ return instanceOf(IPersonManager.class).loadByPrimaryKey(id); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param id 用户id * @return PersonBean 对象 * @see IPersonManager#loadByPrimaryKeyChecked(Integer) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected PersonBean daoGetPersonChecked(Integer id)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IPersonManager.class).loadByPrimaryKeyChecked(id); } //2 /** * 根据主键从数据库读取记录 * @return 返回与输入参数下标对应的 PersonBean 列表,没有查到记录的返回{@code null} * @see IPersonManager#loadByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected List daoGetPersons(Collection idCollection) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).loadByPrimaryKey(idCollection); } //3 /** * 删除主键列表({@code idCollection})指定的记录 * @return 返回删除的记录条数 * @see IPersonManager#deleteByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected int daoDeletePersonsByPrimaryKey(Collection idCollection) throws RuntimeDaoException{ int count =0; if(null != idCollection){ for(Integer id:idCollection){ count += daoDeletePerson(id); } } return count; } //3-5 /** transformer : PersonBean to fl_person.id */ protected final Function daoCastPersonToPk = new Function(){ @Override public Integer apply(PersonBean input) { return null == input ? null : input.getId(); }}; //3-6 /** transformer : fl_person.id to PersonBean */ protected final Function daoCastPersonFromPk = new Function(){ @Override public PersonBean apply(Integer input) { return daoGetPerson(input); }}; //3-8 /** * unwrap primary key from {@link PersonBean}
* if {@code beans} is {@code null},return a empty list(immutable) * * @param beans {@link PersonBean} collection * @return primary key list * @see IPersonManager#toPrimaryKeyList(Collection) */ protected List daoToPrimaryKeyListFromPersons(Collection beans){ if (null == beans){ return ImmutableList.of(); }else{ return instanceOf(IPersonManager.class).toPrimaryKeyList(beans); } } //3-9 /** * unwrap primary key from {@link PersonBean}
* * the returned list is a transformed view of {@code beans}; * changes to {@code beans} will be reflected in the returned list and vice versa. * * if {@code beans} is {@code null},return a empty list(immutable) * @param beans {@link PersonBean} list * @return primary key list * @see Lists#transform(List, Function) */ protected List daoToPrimaryKeyListFromPersons(List beans){ if(null == beans){ return ImmutableList.of(); }else{ return Lists.transform(beans,daoCastPersonToPk); } } //4 /** * 判断主键指定的记录是否存在 * * @param id 用户id * @see IPersonManager#existsPrimaryKey(Integer) * @throws RuntimeDaoException */ protected boolean daoExistsPerson(Integer id) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).existsPrimaryKey(id); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsPerson(PersonBean bean) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param id 用户id * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see IPersonManager#deleteByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected int daoDeletePerson(Integer id) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).deleteByPrimaryKey(id); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeletePerson(Integer) * @throws RuntimeDaoException */ protected int daoDeletePerson(PersonBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeletePerson(bean.getId()); } //5-3 /** * 删除唯一键指定的记录 * * @param imageMd5 用户默认照片(证件照,标准照)的md5校验码,外键 * @return 返回删除的记录条数(1),输入参数为{@code null}或记录不存在返回0 * @see #daoDeletePerson(Integer) * @throws RuntimeDaoException */ protected int daoDeletePersonByIndexImageMd5(String imageMd5) throws RuntimeDaoException{ return (null == imageMd5) ? 0 : instanceOf(IPersonManager.class).deleteByIndexImageMd5(imageMd5); } //5-3 /** * 删除唯一键指定的记录 * * @param mobilePhone 手机号码 * @return 返回删除的记录条数(1),输入参数为{@code null}或记录不存在返回0 * @see #daoDeletePerson(Integer) * @throws RuntimeDaoException */ protected int daoDeletePersonByIndexMobilePhone(String mobilePhone) throws RuntimeDaoException{ return (null == mobilePhone) ? 0 : instanceOf(IPersonManager.class).deleteByIndexMobilePhone(mobilePhone); } //5-3 /** * 删除唯一键指定的记录 * * @param papersNum 证件号码 * @return 返回删除的记录条数(1),输入参数为{@code null}或记录不存在返回0 * @see #daoDeletePerson(Integer) * @throws RuntimeDaoException */ protected int daoDeletePersonByIndexPapersNum(String papersNum) throws RuntimeDaoException{ return (null == papersNum) ? 0 : instanceOf(IPersonManager.class).deleteByIndexPapersNum(papersNum); } //6 /** * 删除{@code personBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeletePerson(Integer) * @throws RuntimeDaoException */ protected int daoDeletePersons(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(PersonBean bean:beans){ count += daoDeletePerson(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected PersonBean daoCheckDuplicate(PersonBean personBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(IPersonManager.class).checkDuplicate(personBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param id 用户id * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * @return always {@code idOfPerson} * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected Integer daoCheckDuplicatePerson(Integer id) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(IPersonManager.class).existsPrimaryKey(id)){ throw new DuplicateRecordException(); } return id; } //8 /** * 返回外键(fl_error_log.person_id)引用指定记录(fl_person.id)的所有{@code fl_error_log}记录 * * @param idOfPerson 用户id * @see IPersonManager#getErrorLogBeansByPersonIdAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetErrorLogBeansByPersonIdOnPerson(Integer idOfPerson) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).getErrorLogBeansByPersonIdAsList(idOfPerson); } //8-2 /** * 删除外键(idOfPerson))引用指定记录(fl_person.id)的所有{@code fl_error_log}记录 * * @param idOfPerson 用户id * @see IPersonManager#deleteErrorLogBeansByPersonId(Integer) * @throws RuntimeDaoException */ protected int daoDeleteErrorLogBeansByPersonIdOnPerson(Integer idOfPerson) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).deleteErrorLogBeansByPersonId(idOfPerson); } //8 /** * 返回外键(fl_feature.person_id)引用指定记录(fl_person.id)的所有{@code fl_feature}记录 * * @param idOfPerson 用户id * @see IPersonManager#getFeatureBeansByPersonIdAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetFeatureBeansByPersonIdOnPerson(Integer idOfPerson) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).getFeatureBeansByPersonIdAsList(idOfPerson); } //8-2 /** * 删除外键(idOfPerson))引用指定记录(fl_person.id)的所有{@code fl_feature}记录 * * @param idOfPerson 用户id * @see IPersonManager#deleteFeatureBeansByPersonId(Integer) * @throws RuntimeDaoException */ protected int daoDeleteFeatureBeansByPersonIdOnPerson(Integer idOfPerson) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).deleteFeatureBeansByPersonId(idOfPerson); } //8 /** * 返回外键(fl_log.person_id)引用指定记录(fl_person.id)的所有{@code fl_log}记录 * * @param idOfPerson 用户id * @see IPersonManager#getLogBeansByPersonIdAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetLogBeansByPersonIdOnPerson(Integer idOfPerson) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).getLogBeansByPersonIdAsList(idOfPerson); } //8-2 /** * 删除外键(idOfPerson))引用指定记录(fl_person.id)的所有{@code fl_log}记录 * * @param idOfPerson 用户id * @see IPersonManager#deleteLogBeansByPersonId(Integer) * @throws RuntimeDaoException */ protected int daoDeleteLogBeansByPersonIdOnPerson(Integer idOfPerson) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).deleteLogBeansByPersonId(idOfPerson); } //8-3 /** * 返回外键(fl_person.image_md5)引用的 fl_image 记录 * @param bean * @see IPersonManager#getReferencedByImageMd5(PersonBean) * @throws RuntimeDaoException */ protected ImageBean daoGetReferencedByImageMd5OnPerson(PersonBean bean) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).getReferencedByImageMd5(bean); } //8-4 /** * 设置外键fl_person(image_md5)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IPersonManager#setReferencedByImageMd5(PersonBean,ImageBean) * @throws RuntimeDaoException */ protected ImageBean daoSetReferencedByImageMd5OnPerson(PersonBean bean,ImageBean beanToSet) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).setReferencedByImageMd5(bean,beanToSet); } //8-6 /** transformer : PersonBean to fl_person.image_md5 */ protected final Function daoCastPersonToImageMd5 = new Function(){ @Override public String apply(PersonBean input) { return null == input ? null : input.getImageMd5(); }}; //8-8 /** transformer : fl_person.id to fl_person.image_md5 */ protected final Function daoCastPersonPkToImageMd5 = new Function(){ @Override public String apply(Integer input) { return null == input ? null : daoCastPersonToImageMd5.apply(daoGetPerson(input)); }}; //8-3 /** * 返回外键(fl_person.group_id)引用的 fl_person_group 记录 * @param bean * @see IPersonManager#getReferencedByGroupId(PersonBean) * @throws RuntimeDaoException */ protected PersonGroupBean daoGetReferencedByGroupIdOnPerson(PersonBean bean) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).getReferencedByGroupId(bean); } //8-4 /** * 设置外键fl_person(group_id)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IPersonManager#setReferencedByGroupId(PersonBean,PersonGroupBean) * @throws RuntimeDaoException */ protected PersonGroupBean daoSetReferencedByGroupIdOnPerson(PersonBean bean,PersonGroupBean beanToSet) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).setReferencedByGroupId(bean,beanToSet); } //8-6 /** transformer : PersonBean to fl_person.group_id */ protected final Function daoCastPersonToGroupId = new Function(){ @Override public Integer apply(PersonBean input) { return null == input ? null : input.getGroupId(); }}; //8-8 /** transformer : fl_person.id to fl_person.group_id */ protected final Function daoCastPersonPkToGroupId = new Function(){ @Override public Integer apply(Integer input) { return null == input ? null : daoCastPersonToGroupId.apply(daoGetPerson(input)); }}; //14 /** * 参见 {@link TableManager#save(BaseBean)} * @throws RuntimeDaoException */ protected PersonBean daoSavePerson(PersonBean personBean) throws RuntimeDaoException{ daoCheckGroup(personBean); return instanceOf(IPersonManager.class).save(personBean); } //15 /** 同步保存
* see also {@link IPersonManager#save(PersonBean , ImageBean, PersonGroupBean , Collection, Collection, Collection )} * @throws RuntimeDaoException */ protected PersonBean daoSavePerson(PersonBean personBean , ImageBean refImageByImageMd5 , PersonGroupBean refPersongroupByGroupId , Collection impErrorlogByPersonId , Collection impFeatureByPersonId , Collection impLogByPersonId )throws RuntimeDaoException{ daoCheckGroup(personBean); return instanceOf(IPersonManager.class).save(personBean , refImageByImageMd5 , refPersongroupByGroupId , impErrorlogByPersonId , impFeatureByPersonId , impLogByPersonId ); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoSavePerson(PersonBean) * @throws RuntimeDaoException */ protected Collection daoSavePersons(Collection beans) throws RuntimeDaoException { if(null != beans){ for(PersonBean bean : beans){ daoSavePerson(bean); } } return beans; } //12-3-5 /** * {@link #daoSavePersons(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoSavePersonsAsTransaction(final Collection beans) throws RuntimeDaoException { try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoSavePersons(beans); }}); }catch(RuntimeException e){ throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_person 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IPersonManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadPersonByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_person 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadPersonUsingTemplate(PersonBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_person 的{@code column}字段的数据 * @param column 有效的fl_person表字段名或{@link PersonBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IPersonManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfPersonAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_person 表的所有记录 * @see IPersonManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadPersonAll() throws RuntimeDaoException{ return instanceOf(IPersonManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_person 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountPersonByWhere(String where) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).countWhere(where); } //18 /** * 查询{@code where}条件指定的记录 * @return 返回查询结果记录的主键 * @see #daoLoadPersonByWhere(String,int,int) * @throws RuntimeDaoException */ protected List daoLoadPersonIdByWhere(String where) throws RuntimeDaoException{ return daoToPrimaryKeyListFromPersons(daoLoadPersonByWhere(where,1,-1)); } //18-5 /** * 索引(fl_person.image_md5)查询,没有找到记录返回{@code null}
* * @param imageMd5 用户默认照片(证件照,标准照)的md5校验码,外键 * @see IPersonManager#loadByIndexImageMd5(String) * @throws RuntimeDaoException */ protected PersonBean daoGetPersonByIndexImageMd5(String imageMd5) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).loadByIndexImageMd5(imageMd5); } //18-7 /** * 索引(fl_person.image_md5)查询,没有找到记录抛出异常
* * @param imageMd5 用户默认照片(证件照,标准照)的md5校验码,外键 * @see IPersonManager#loadByIndexImageMd5Checked(String) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected PersonBean daoGetPersonByIndexImageMd5Checked(String imageMd5) throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IPersonManager.class).loadByIndexImageMd5Checked(imageMd5); } //18-8 /** * 检查数据库中是否有(唯一键)相同的记录,如果有则抛出异常 * * @param imageMd5 用户默认照片(证件照,标准照)的md5校验码,外键 * @throws DuplicateRecordException if exists duplicated row * @throws RuntimeDaoException */ protected String daoCheckDuplicatePersonByIndexImageMd5(String imageMd5) throws RuntimeDaoException,DuplicateRecordException{ if(null != daoGetPersonByIndexImageMd5(imageMd5)){ throw new DuplicateRecordException(); } return imageMd5; } //18-5 /** * 索引(fl_person.mobile_phone)查询,没有找到记录返回{@code null}
* * @param mobilePhone 手机号码 * @see IPersonManager#loadByIndexMobilePhone(String) * @throws RuntimeDaoException */ protected PersonBean daoGetPersonByIndexMobilePhone(String mobilePhone) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).loadByIndexMobilePhone(mobilePhone); } //18-7 /** * 索引(fl_person.mobile_phone)查询,没有找到记录抛出异常
* * @param mobilePhone 手机号码 * @see IPersonManager#loadByIndexMobilePhoneChecked(String) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected PersonBean daoGetPersonByIndexMobilePhoneChecked(String mobilePhone) throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IPersonManager.class).loadByIndexMobilePhoneChecked(mobilePhone); } //18-8 /** * 检查数据库中是否有(唯一键)相同的记录,如果有则抛出异常 * * @param mobilePhone 手机号码 * @throws DuplicateRecordException if exists duplicated row * @throws RuntimeDaoException */ protected String daoCheckDuplicatePersonByIndexMobilePhone(String mobilePhone) throws RuntimeDaoException,DuplicateRecordException{ if(null != daoGetPersonByIndexMobilePhone(mobilePhone)){ throw new DuplicateRecordException(); } return mobilePhone; } //18-5 /** * 索引(fl_person.papers_num)查询,没有找到记录返回{@code null}
* * @param papersNum 证件号码 * @see IPersonManager#loadByIndexPapersNum(String) * @throws RuntimeDaoException */ protected PersonBean daoGetPersonByIndexPapersNum(String papersNum) throws RuntimeDaoException{ return instanceOf(IPersonManager.class).loadByIndexPapersNum(papersNum); } //18-7 /** * 索引(fl_person.papers_num)查询,没有找到记录抛出异常
* * @param papersNum 证件号码 * @see IPersonManager#loadByIndexPapersNumChecked(String) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected PersonBean daoGetPersonByIndexPapersNumChecked(String papersNum) throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IPersonManager.class).loadByIndexPapersNumChecked(papersNum); } //18-8 /** * 检查数据库中是否有(唯一键)相同的记录,如果有则抛出异常 * * @param papersNum 证件号码 * @throws DuplicateRecordException if exists duplicated row * @throws RuntimeDaoException */ protected String daoCheckDuplicatePersonByIndexPapersNum(String papersNum) throws RuntimeDaoException,DuplicateRecordException{ if(null != daoGetPersonByIndexPapersNum(papersNum)){ throw new DuplicateRecordException(); } return papersNum; } //19 /** * (主动更新机制实现)
* 返回 fl_person.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadPersonByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadPersonByCreateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadPersonByWhere(makeWhere(timestamp,"create_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadPersonByCreateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadPersonByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadPersonByCreateTime(timestamp,1,-1); } //20-5 /** * 返回fl_person.create_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountPersonByWhere(String) * @throws RuntimeDaoException */ protected int daoCountPersonByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoCountPersonByWhere(makeWhere(timestamp,"create_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_person.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadPersonIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadPersonIdByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadPersonIdByWhere(makeWhere(timestamp,"create_time")); } //19 /** * (主动更新机制实现)
* 返回 fl_person.update_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadPersonByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadPersonByUpdateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadPersonByWhere(makeWhere(timestamp,"update_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadPersonByUpdateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadPersonByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadPersonByUpdateTime(timestamp,1,-1); } //20-5 /** * 返回fl_person.update_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountPersonByWhere(String) * @throws RuntimeDaoException */ protected int daoCountPersonByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoCountPersonByWhere(makeWhere(timestamp,"update_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_person.update_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadPersonIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadPersonIdByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadPersonIdByWhere(makeWhere(timestamp,"update_time")); } //////////// FL_PERSON_GROUP ///////// final IPersonGroupManager personGroupManager = instanceOf(IPersonGroupManager.class); //1 /** * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param id 用户组id * @return PersonGroupBean 对象 * @see IPersonGroupManager#loadByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected PersonGroupBean daoGetPersonGroup(Integer id)throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).loadByPrimaryKey(id); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param id 用户组id * @return PersonGroupBean 对象 * @see IPersonGroupManager#loadByPrimaryKeyChecked(Integer) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected PersonGroupBean daoGetPersonGroupChecked(Integer id)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IPersonGroupManager.class).loadByPrimaryKeyChecked(id); } //2 /** * 根据主键从数据库读取记录 * @return 返回与输入参数下标对应的 PersonGroupBean 列表,没有查到记录的返回{@code null} * @see IPersonGroupManager#loadByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected List daoGetPersonGroups(Collection idCollection) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).loadByPrimaryKey(idCollection); } //3 /** * 删除主键列表({@code idCollection})指定的记录 * @return 返回删除的记录条数 * @see IPersonGroupManager#deleteByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected int daoDeletePersonGroupsByPrimaryKey(Collection idCollection) throws RuntimeDaoException{ int count =0; if(null != idCollection){ for(Integer id:idCollection){ count += daoDeletePersonGroup(id); } } return count; } //3-5 /** transformer : PersonGroupBean to fl_person_group.id */ protected final Function daoCastPersonGroupToPk = new Function(){ @Override public Integer apply(PersonGroupBean input) { return null == input ? null : input.getId(); }}; //3-6 /** transformer : fl_person_group.id to PersonGroupBean */ protected final Function daoCastPersonGroupFromPk = new Function(){ @Override public PersonGroupBean apply(Integer input) { return daoGetPersonGroup(input); }}; //3-8 /** * unwrap primary key from {@link PersonGroupBean}
* if {@code beans} is {@code null},return a empty list(immutable) * * @param beans {@link PersonGroupBean} collection * @return primary key list * @see IPersonGroupManager#toPrimaryKeyList(Collection) */ protected List daoToPrimaryKeyListFromPersonGroups(Collection beans){ if (null == beans){ return ImmutableList.of(); }else{ return instanceOf(IPersonGroupManager.class).toPrimaryKeyList(beans); } } //3-9 /** * unwrap primary key from {@link PersonGroupBean}
* * the returned list is a transformed view of {@code beans}; * changes to {@code beans} will be reflected in the returned list and vice versa. * * if {@code beans} is {@code null},return a empty list(immutable) * @param beans {@link PersonGroupBean} list * @return primary key list * @see Lists#transform(List, Function) */ protected List daoToPrimaryKeyListFromPersonGroups(List beans){ if(null == beans){ return ImmutableList.of(); }else{ return Lists.transform(beans,daoCastPersonGroupToPk); } } //4 /** * 判断主键指定的记录是否存在 * * @param id 用户组id * @see IPersonGroupManager#existsPrimaryKey(Integer) * @throws RuntimeDaoException */ protected boolean daoExistsPersonGroup(Integer id) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).existsPrimaryKey(id); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsPersonGroup(PersonGroupBean bean) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param id 用户组id * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see IPersonGroupManager#deleteByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected int daoDeletePersonGroup(Integer id) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).deleteByPrimaryKey(id); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeletePersonGroup(Integer) * @throws RuntimeDaoException */ protected int daoDeletePersonGroup(PersonGroupBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeletePersonGroup(bean.getId()); } //6 /** * 删除{@code personGroupBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeletePersonGroup(Integer) * @throws RuntimeDaoException */ protected int daoDeletePersonGroups(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(PersonGroupBean bean:beans){ count += daoDeletePersonGroup(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected PersonGroupBean daoCheckDuplicate(PersonGroupBean personGroupBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(IPersonGroupManager.class).checkDuplicate(personGroupBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param id 用户组id * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * @return always {@code idOfPersonGroup} * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected Integer daoCheckDuplicatePersonGroup(Integer id) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(IPersonGroupManager.class).existsPrimaryKey(id)){ throw new DuplicateRecordException(); } return id; } //8 /** * 返回外键(fl_permit.person_group_id)引用指定记录(fl_person_group.id)的所有{@code fl_permit}记录 * * @param idOfPersonGroup 用户组id * @see IPersonGroupManager#getPermitBeansByPersonGroupIdAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetPermitBeansByPersonGroupIdOnPersonGroup(Integer idOfPersonGroup) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).getPermitBeansByPersonGroupIdAsList(idOfPersonGroup); } //8-2 /** * 删除外键(idOfPersonGroup))引用指定记录(fl_person_group.id)的所有{@code fl_permit}记录 * * @param idOfPersonGroup 用户组id * @see IPersonGroupManager#deletePermitBeansByPersonGroupId(Integer) * @throws RuntimeDaoException */ protected int daoDeletePermitBeansByPersonGroupIdOnPersonGroup(Integer idOfPersonGroup) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).deletePermitBeansByPersonGroupId(idOfPersonGroup); } //8 /** * 返回属于{@code idOfPersonGroup}指定组的所有{@code fl_person}记录 * * @param idOfPersonGroup 用户组id * @see IPersonGroupManager#getPersonBeansByGroupIdAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetPersonsOfGroup(Integer idOfPersonGroup) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).getPersonBeansByGroupIdAsList(idOfPersonGroup); } //8-2 /** * 删除外键(idOfPersonGroup))引用指定记录(fl_person_group.id)的所有{@code fl_person}记录 * * @param idOfPersonGroup 用户组id * @see IPersonGroupManager#deletePersonBeansByGroupId(Integer) * @throws RuntimeDaoException */ protected int daoDeletePersonBeansByGroupIdOnPersonGroup(Integer idOfPersonGroup) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).deletePersonBeansByGroupId(idOfPersonGroup); } //8 /** * 返回{@code idOfPersonGroup)}指定的组下的所有子节点,如果没有子节点则返回空表 * * @param idOfPersonGroup 用户组id * @see IPersonGroupManager#getPersonGroupBeansByParentAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetSubPersonGroup(Integer idOfPersonGroup) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).getPersonGroupBeansByParentAsList(idOfPersonGroup); } //8-2 /** * 删除外键(idOfPersonGroup))引用指定记录(fl_person_group.id)的所有{@code fl_person_group}记录 * * @param idOfPersonGroup 用户组id * @see IPersonGroupManager#deletePersonGroupBeansByParent(Integer) * @throws RuntimeDaoException */ protected int daoDeletePersonGroupBeansByParentOnPersonGroup(Integer idOfPersonGroup) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).deletePersonGroupBeansByParent(idOfPersonGroup); } //8-3 /** * 返回外键(fl_person_group.parent)引用的 fl_person_group 记录 * @param bean * @see IPersonGroupManager#getReferencedByParent(PersonGroupBean) * @throws RuntimeDaoException */ protected PersonGroupBean daoGetReferencedByParentOnPersonGroup(PersonGroupBean bean) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).getReferencedByParent(bean); } //8-4 /** * 设置外键fl_person_group(parent)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IPersonGroupManager#setReferencedByParent(PersonGroupBean,PersonGroupBean) * @throws RuntimeDaoException */ protected PersonGroupBean daoSetReferencedByParentOnPersonGroup(PersonGroupBean bean,PersonGroupBean beanToSet) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).setReferencedByParent(bean,beanToSet); } //9 /** * 返回(idOfPersonGroup))指定的fl_person_group记录的所有的父节点(包括自己)
* 自引用字段:fl_person_group(parent) * @see IPersonGroupManager#listOfParent(Integer) * @throws RuntimeDaoException */ protected java.util.List daoListOfParentForPersonGroup(Integer idOfPersonGroup) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).listOfParent(idOfPersonGroup); } //9-2 /** * 返回{@code personGroupBean}指定的fl_person_group记录的所有的父节点(包括自己)
* 自引用字段:fl_person_group(parent) * @see IPersonGroupManager#listOfParent(PersonGroupBean) * @throws RuntimeDaoException */ protected java.util.List daoListOfParentForPersonGroup(PersonGroupBean personGroupBean) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).listOfParent(personGroupBean); } //9-3 /** * 返回(idOfPersonGroup))指定的fl_person_group记录的所有的子节点(包括自己)
* 自引用字段:fl_person_group(parent) * @see IPersonGroupManager#childListByParent(Integer) * @throws RuntimeDaoException */ protected java.util.List daoChildListByParentForPersonGroup(Integer idOfPersonGroup) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).childListByParent(idOfPersonGroup); } //9-4 /** * 返回{@code personGroupBean}指定的fl_person_group记录的所有的子节点(包括自己)
* 自引用字段:fl_person_group(parent) * @see IPersonGroupManager#listOfParent(PersonGroupBean) * @throws RuntimeDaoException */ protected java.util.List daoChildListByParentForPersonGroup(PersonGroupBean personGroupBean) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).childListByParent(personGroupBean); } //10 /** * 如果没有默认组则向 fl_person_group 表中增加默认组,失败则抛出异常 * * @throws IllegalStateException 创建失败 * @throws RuntimeDaoException */ protected void daoSaveDefaultPersonGroupIfAbsent() throws RuntimeDaoException{ if(!daoExistsPersonGroup(DEFAULT_GROUP_ID)){ try{ PersonGroupBean bean = new PersonGroupBean(DEFAULT_GROUP_ID); bean.setName(DEFAULT_GROUP_NAME); daoSavePersonGroup(bean); }catch(RuntimeDaoException e){ // do nothing } if(!daoExistsPersonGroup(DEFAULT_GROUP_ID)){ throw new IllegalStateException("can't create default group for person_group"); } } } //11 /** * 检查{@link PersonBean}的'group_id'字段是否为默认组{@link CommonConstant#DEFAULT_GROUP_ID}, * 如果是,且默认组记录不存在则创建默认组 * @return {@code personBean} * @see #daoSaveDefaultPersonGroupIfAbsent() * @throws RuntimeDaoException */ protected PersonBean daoCheckGroup(PersonBean personBean) throws RuntimeDaoException{ if(null != personBean && Objects.equals(personBean.getGroupId(), DEFAULT_GROUP_ID)){ daoSaveDefaultPersonGroupIfAbsent(); } return personBean; } //14 /** * 参见 {@link TableManager#save(BaseBean)} * @throws RuntimeDaoException */ protected PersonGroupBean daoSavePersonGroup(PersonGroupBean personGroupBean) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).save(personGroupBean); } //15 /** 同步保存
* see also {@link IPersonGroupManager#save(PersonGroupBean , PersonGroupBean , Collection, Collection, Collection )} * @throws RuntimeDaoException */ protected PersonGroupBean daoSavePersonGroup(PersonGroupBean personGroupBean , PersonGroupBean refPersongroupByParent , Collection impPermitByPersonGroupId , Collection impPersonByGroupId , Collection impPersongroupByParent )throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).save(personGroupBean , refPersongroupByParent , impPermitByPersonGroupId , impPersonByGroupId , impPersongroupByParent ); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoSavePersonGroup(PersonGroupBean) * @throws RuntimeDaoException */ protected Collection daoSavePersonGroups(Collection beans) throws RuntimeDaoException { if(null != beans){ for(PersonGroupBean bean : beans){ daoSavePersonGroup(bean); } } return beans; } //12-3-5 /** * {@link #daoSavePersonGroups(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoSavePersonGroupsAsTransaction(final Collection beans) throws RuntimeDaoException { try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoSavePersonGroups(beans); }}); }catch(RuntimeException e){ throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_person_group 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IPersonGroupManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadPersonGroupByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_person_group 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadPersonGroupUsingTemplate(PersonGroupBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_person_group 的{@code column}字段的数据 * @param column 有效的fl_person_group表字段名或{@link PersonGroupBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IPersonGroupManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfPersonGroupAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_person_group 表的所有记录 * @see IPersonGroupManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadPersonGroupAll() throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_person_group 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountPersonGroupByWhere(String where) throws RuntimeDaoException{ return instanceOf(IPersonGroupManager.class).countWhere(where); } //18 /** * 查询{@code where}条件指定的记录 * @return 返回查询结果记录的主键 * @see #daoLoadPersonGroupByWhere(String,int,int) * @throws RuntimeDaoException */ protected List daoLoadPersonGroupIdByWhere(String where) throws RuntimeDaoException{ return daoToPrimaryKeyListFromPersonGroups(daoLoadPersonGroupByWhere(where,1,-1)); } //19 /** * (主动更新机制实现)
* 返回 fl_person_group.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadPersonGroupByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadPersonGroupByCreateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadPersonGroupByWhere(makeWhere(timestamp,"create_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadPersonGroupByCreateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadPersonGroupByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadPersonGroupByCreateTime(timestamp,1,-1); } //20-5 /** * 返回fl_person_group.create_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountPersonGroupByWhere(String) * @throws RuntimeDaoException */ protected int daoCountPersonGroupByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoCountPersonGroupByWhere(makeWhere(timestamp,"create_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_person_group.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadPersonGroupIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadPersonGroupIdByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadPersonGroupIdByWhere(makeWhere(timestamp,"create_time")); } //19 /** * (主动更新机制实现)
* 返回 fl_person_group.update_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadPersonGroupByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadPersonGroupByUpdateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadPersonGroupByWhere(makeWhere(timestamp,"update_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadPersonGroupByUpdateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadPersonGroupByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadPersonGroupByUpdateTime(timestamp,1,-1); } //20-5 /** * 返回fl_person_group.update_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountPersonGroupByWhere(String) * @throws RuntimeDaoException */ protected int daoCountPersonGroupByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoCountPersonGroupByWhere(makeWhere(timestamp,"update_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_person_group.update_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadPersonGroupIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadPersonGroupIdByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadPersonGroupIdByWhere(makeWhere(timestamp,"update_time")); } //////////// FL_PERMIT ///////// final IPermitManager permitManager = instanceOf(IPermitManager.class); //1 /** * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param deviceGroupId 外键,设备组id * @param personGroupId 外键,人员组id * @return PermitBean 对象 * @see IPermitManager#loadByPrimaryKey(Integer,Integer) * @throws RuntimeDaoException */ protected PermitBean daoGetPermit(Integer deviceGroupId,Integer personGroupId)throws RuntimeDaoException{ return instanceOf(IPermitManager.class).loadByPrimaryKey(deviceGroupId,personGroupId); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param deviceGroupId 外键,设备组id * @param personGroupId 外键,人员组id * @return PermitBean 对象 * @see IPermitManager#loadByPrimaryKeyChecked(Integer,Integer) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected PermitBean daoGetPermitChecked(Integer deviceGroupId,Integer personGroupId)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IPermitManager.class).loadByPrimaryKeyChecked(deviceGroupId,personGroupId); } //4 /** * 判断主键指定的记录是否存在 * * @param deviceGroupId 外键,设备组id * @param personGroupId 外键,人员组id * @see IPermitManager#existsPrimaryKey(Integer,Integer) * @throws RuntimeDaoException */ protected boolean daoExistsPermit(Integer deviceGroupId,Integer personGroupId) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).existsPrimaryKey(deviceGroupId,personGroupId); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsPermit(PermitBean bean) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param deviceGroupId 外键,设备组id * @param personGroupId 外键,人员组id * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see IPermitManager#deleteByPrimaryKey(Integer,Integer) * @throws RuntimeDaoException */ protected int daoDeletePermit(Integer deviceGroupId,Integer personGroupId) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).deleteByPrimaryKey(deviceGroupId,personGroupId); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeletePermit(Integer,Integer) * @throws RuntimeDaoException */ protected int daoDeletePermit(PermitBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeletePermit(bean.getDeviceGroupId(),bean.getPersonGroupId()); } //6 /** * 删除{@code permitBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeletePermit(Integer,Integer) * @throws RuntimeDaoException */ protected int daoDeletePermits(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(PermitBean bean:beans){ count += daoDeletePermit(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected PermitBean daoCheckDuplicate(PermitBean permitBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(IPermitManager.class).checkDuplicate(permitBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param deviceGroupId 外键,设备组id * @param personGroupId 外键,人员组id * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected void daoCheckDuplicatePermit(Integer deviceGroupId,Integer personGroupId) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(IPermitManager.class).existsPrimaryKey(deviceGroupId,personGroupId)){ throw new DuplicateRecordException(); } } //8-3 /** * 返回外键(fl_permit.device_group_id)引用的 fl_device_group 记录 * @param bean * @see IPermitManager#getReferencedByDeviceGroupId(PermitBean) * @throws RuntimeDaoException */ protected DeviceGroupBean daoGetReferencedByDeviceGroupIdOnPermit(PermitBean bean) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).getReferencedByDeviceGroupId(bean); } //8-4 /** * 设置外键fl_permit(device_group_id)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IPermitManager#setReferencedByDeviceGroupId(PermitBean,DeviceGroupBean) * @throws RuntimeDaoException */ protected DeviceGroupBean daoSetReferencedByDeviceGroupIdOnPermit(PermitBean bean,DeviceGroupBean beanToSet) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).setReferencedByDeviceGroupId(bean,beanToSet); } //8-6 /** transformer : PermitBean to fl_permit.device_group_id */ protected final Function daoCastPermitToDeviceGroupId = new Function(){ @Override public Integer apply(PermitBean input) { return null == input ? null : input.getDeviceGroupId(); }}; //8-3 /** * 返回外键(fl_permit.person_group_id)引用的 fl_person_group 记录 * @param bean * @see IPermitManager#getReferencedByPersonGroupId(PermitBean) * @throws RuntimeDaoException */ protected PersonGroupBean daoGetReferencedByPersonGroupIdOnPermit(PermitBean bean) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).getReferencedByPersonGroupId(bean); } //8-4 /** * 设置外键fl_permit(person_group_id)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IPermitManager#setReferencedByPersonGroupId(PermitBean,PersonGroupBean) * @throws RuntimeDaoException */ protected PersonGroupBean daoSetReferencedByPersonGroupIdOnPermit(PermitBean bean,PersonGroupBean beanToSet) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).setReferencedByPersonGroupId(bean,beanToSet); } //8-6 /** transformer : PermitBean to fl_permit.person_group_id */ protected final Function daoCastPermitToPersonGroupId = new Function(){ @Override public Integer apply(PermitBean input) { return null == input ? null : input.getPersonGroupId(); }}; //14 /** * 参见 {@link TableManager#save(BaseBean)} * @throws RuntimeDaoException */ protected PermitBean daoSavePermit(PermitBean permitBean) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).save(permitBean); } //15 /** 同步保存
* see also {@link IPermitManager#save(PermitBean , DeviceGroupBean, PersonGroupBean )} * @throws RuntimeDaoException */ protected PermitBean daoSavePermit(PermitBean permitBean , DeviceGroupBean refDevicegroupByDeviceGroupId , PersonGroupBean refPersongroupByPersonGroupId )throws RuntimeDaoException{ return instanceOf(IPermitManager.class).save(permitBean , refDevicegroupByDeviceGroupId , refPersongroupByPersonGroupId ); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoSavePermit(PermitBean) * @throws RuntimeDaoException */ protected Collection daoSavePermits(Collection beans) throws RuntimeDaoException { if(null != beans){ for(PermitBean bean : beans){ daoSavePermit(bean); } } return beans; } //12-3-5 /** * {@link #daoSavePermits(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoSavePermitsAsTransaction(final Collection beans) throws RuntimeDaoException { try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoSavePermits(beans); }}); }catch(RuntimeException e){ throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_permit 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IPermitManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadPermitByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_permit 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadPermitUsingTemplate(PermitBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_permit 的{@code column}字段的数据 * @param column 有效的fl_permit表字段名或{@link PermitBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IPermitManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfPermitAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_permit 表的所有记录 * @see IPermitManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadPermitAll() throws RuntimeDaoException{ return instanceOf(IPermitManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_permit 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountPermitByWhere(String where) throws RuntimeDaoException{ return instanceOf(IPermitManager.class).countWhere(where); } //19 /** * (主动更新机制实现)
* 返回 fl_permit.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadPermitByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadPermitByCreateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadPermitByWhere(makeWhere(timestamp,"create_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadPermitByCreateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadPermitByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadPermitByCreateTime(timestamp,1,-1); } //20-5 /** * 返回fl_permit.create_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountPermitByWhere(String) * @throws RuntimeDaoException */ protected int daoCountPermitByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoCountPermitByWhere(makeWhere(timestamp,"create_time")); } //////////// FL_FACE ///////// final IFaceManager faceManager = instanceOf(IFaceManager.class); //1 /** * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param id 主键 * @return FaceBean 对象 * @see IFaceManager#loadByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected FaceBean daoGetFace(Integer id)throws RuntimeDaoException{ return instanceOf(IFaceManager.class).loadByPrimaryKey(id); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param id 主键 * @return FaceBean 对象 * @see IFaceManager#loadByPrimaryKeyChecked(Integer) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected FaceBean daoGetFaceChecked(Integer id)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IFaceManager.class).loadByPrimaryKeyChecked(id); } //2 /** * 根据主键从数据库读取记录 * @return 返回与输入参数下标对应的 FaceBean 列表,没有查到记录的返回{@code null} * @see IFaceManager#loadByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected List daoGetFaces(Collection idCollection) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).loadByPrimaryKey(idCollection); } //3 /** * 删除主键列表({@code idCollection})指定的记录 * @return 返回删除的记录条数 * @see IFaceManager#deleteByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected int daoDeleteFacesByPrimaryKey(Collection idCollection) throws RuntimeDaoException{ int count =0; if(null != idCollection){ for(Integer id:idCollection){ count += daoDeleteFace(id); } } return count; } //3-5 /** transformer : FaceBean to fl_face.id */ protected final Function daoCastFaceToPk = new Function(){ @Override public Integer apply(FaceBean input) { return null == input ? null : input.getId(); }}; //3-6 /** transformer : fl_face.id to FaceBean */ protected final Function daoCastFaceFromPk = new Function(){ @Override public FaceBean apply(Integer input) { return daoGetFace(input); }}; //3-8 /** * unwrap primary key from {@link FaceBean}
* if {@code beans} is {@code null},return a empty list(immutable) * * @param beans {@link FaceBean} collection * @return primary key list * @see IFaceManager#toPrimaryKeyList(Collection) */ protected List daoToPrimaryKeyListFromFaces(Collection beans){ if (null == beans){ return ImmutableList.of(); }else{ return instanceOf(IFaceManager.class).toPrimaryKeyList(beans); } } //3-9 /** * unwrap primary key from {@link FaceBean}
* * the returned list is a transformed view of {@code beans}; * changes to {@code beans} will be reflected in the returned list and vice versa. * * if {@code beans} is {@code null},return a empty list(immutable) * @param beans {@link FaceBean} list * @return primary key list * @see Lists#transform(List, Function) */ protected List daoToPrimaryKeyListFromFaces(List beans){ if(null == beans){ return ImmutableList.of(); }else{ return Lists.transform(beans,daoCastFaceToPk); } } //4 /** * 判断主键指定的记录是否存在 * * @param id 主键 * @see IFaceManager#existsPrimaryKey(Integer) * @throws RuntimeDaoException */ protected boolean daoExistsFace(Integer id) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).existsPrimaryKey(id); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsFace(FaceBean bean) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param id 主键 * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see IFaceManager#deleteByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected int daoDeleteFace(Integer id) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).deleteByPrimaryKey(id); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeleteFace(Integer) * @throws RuntimeDaoException */ protected int daoDeleteFace(FaceBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeleteFace(bean.getId()); } //6 /** * 删除{@code faceBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeleteFace(Integer) * @throws RuntimeDaoException */ protected int daoDeleteFaces(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(FaceBean bean:beans){ count += daoDeleteFace(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected FaceBean daoCheckDuplicate(FaceBean faceBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(IFaceManager.class).checkDuplicate(faceBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param id 主键 * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * @return always {@code idOfFace} * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected Integer daoCheckDuplicateFace(Integer id) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(IFaceManager.class).existsPrimaryKey(id)){ throw new DuplicateRecordException(); } return id; } //8 /** * 返回外键(fl_log.compare_face)引用指定记录(fl_face.id)的所有{@code fl_log}记录 * * @param idOfFace 主键 * @see IFaceManager#getLogBeansByCompareFaceAsList(Integer) * @throws RuntimeDaoException */ protected List daoGetLogBeansByCompareFaceOnFace(Integer idOfFace) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).getLogBeansByCompareFaceAsList(idOfFace); } //8-2 /** * 删除外键(idOfFace))引用指定记录(fl_face.id)的所有{@code fl_log}记录 * * @param idOfFace 主键 * @see IFaceManager#deleteLogBeansByCompareFace(Integer) * @throws RuntimeDaoException */ protected int daoDeleteLogBeansByCompareFaceOnFace(Integer idOfFace) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).deleteLogBeansByCompareFace(idOfFace); } //8-3 /** * 返回外键(fl_face.feature_md5)引用的 fl_feature 记录 * @param bean * @see IFaceManager#getReferencedByFeatureMd5(FaceBean) * @throws RuntimeDaoException */ protected FeatureBean daoGetReferencedByFeatureMd5OnFace(FaceBean bean) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).getReferencedByFeatureMd5(bean); } //8-4 /** * 设置外键fl_face(feature_md5)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IFaceManager#setReferencedByFeatureMd5(FaceBean,FeatureBean) * @throws RuntimeDaoException */ protected FeatureBean daoSetReferencedByFeatureMd5OnFace(FaceBean bean,FeatureBean beanToSet) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).setReferencedByFeatureMd5(bean,beanToSet); } //8-6 /** transformer : FaceBean to fl_face.feature_md5 */ protected final Function daoCastFaceToFeatureMd5 = new Function(){ @Override public String apply(FaceBean input) { return null == input ? null : input.getFeatureMd5(); }}; //8-8 /** transformer : fl_face.id to fl_face.feature_md5 */ protected final Function daoCastFacePkToFeatureMd5 = new Function(){ @Override public String apply(Integer input) { return null == input ? null : daoCastFaceToFeatureMd5.apply(daoGetFace(input)); }}; //8-3 /** * 返回外键(fl_face.image_md5)引用的 fl_image 记录 * @param bean * @see IFaceManager#getReferencedByImageMd5(FaceBean) * @throws RuntimeDaoException */ protected ImageBean daoGetReferencedByImageMd5OnFace(FaceBean bean) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).getReferencedByImageMd5(bean); } //8-4 /** * 设置外键fl_face(image_md5)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IFaceManager#setReferencedByImageMd5(FaceBean,ImageBean) * @throws RuntimeDaoException */ protected ImageBean daoSetReferencedByImageMd5OnFace(FaceBean bean,ImageBean beanToSet) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).setReferencedByImageMd5(bean,beanToSet); } //8-6 /** transformer : FaceBean to fl_face.image_md5 */ protected final Function daoCastFaceToImageMd5 = new Function(){ @Override public String apply(FaceBean input) { return null == input ? null : input.getImageMd5(); }}; //8-8 /** transformer : fl_face.id to fl_face.image_md5 */ protected final Function daoCastFacePkToImageMd5 = new Function(){ @Override public String apply(Integer input) { return null == input ? null : daoCastFaceToImageMd5.apply(daoGetFace(input)); }}; //12 /** * 添加新记录
* fl_face 表只支持添加删除,不支持修改,所以如果数据库中已经存在相同记录或{@link FaceBean#isNew()}返回{@code false},则抛出异常 * @param faceBean 要添加的新记录 * @see TableManager#save(BaseBean) * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code faceBean.isNew()} is {@code false} */ protected FaceBean daoAddFace(FaceBean faceBean) throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == faceBean || faceBean.isNew(),"can be add,delete,but modify record for fl_face,so the _isNew field must be true"); return instanceOf(IFaceManager.class).save(daoCheckDuplicate(faceBean)); } //13 /** * 添加新记录(同步保存)
* fl_face 表只允许添加删除,不允许修改,所以如果数据库中已经存在相同记录或{@link FaceBean#isNew()}返回{@code false},则抛出异常 * see also {@link IFaceManager#save(FaceBean , FeatureBean, ImageBean , Collection )}
* @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code faceBean.isNew()} is {@code false} */ protected FaceBean daoAddFace(FaceBean faceBean , FeatureBean refFeatureByFeatureMd5 , ImageBean refImageByImageMd5 , Collection impLogByCompareFace )throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == faceBean || faceBean.isNew(),"can be add,delete,but modify record for fl_face,so the _isNew field must be true"); daoCheckDuplicate(faceBean); return instanceOf(IFaceManager.class).save(faceBean , refFeatureByFeatureMd5 , refImageByImageMd5 , impLogByCompareFace ); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoAddFace(FaceBean) * @throws RuntimeDaoException */ protected Collection daoAddFaces(Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ if(null != beans){ for(FaceBean bean : beans){ daoAddFace(bean); } } return beans; } //12-3-5 /** * {@link #daoAddFaces(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoAddFacesAsTransaction(final Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoAddFaces(beans); }}); }catch(RuntimeException e){ throwCauseIfInstanceOf(e,DuplicateRecordException.class); throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_face 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IFaceManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadFaceByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_face 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadFaceUsingTemplate(FaceBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_face 的{@code column}字段的数据 * @param column 有效的fl_face表字段名或{@link FaceBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IFaceManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfFaceAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_face 表的所有记录 * @see IFaceManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadFaceAll() throws RuntimeDaoException{ return instanceOf(IFaceManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_face 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountFaceByWhere(String where) throws RuntimeDaoException{ return instanceOf(IFaceManager.class).countWhere(where); } //18 /** * 查询{@code where}条件指定的记录 * @return 返回查询结果记录的主键 * @see #daoLoadFaceByWhere(String,int,int) * @throws RuntimeDaoException */ protected List daoLoadFaceIdByWhere(String where) throws RuntimeDaoException{ return daoToPrimaryKeyListFromFaces(daoLoadFaceByWhere(where,1,-1)); } //////////// FL_FEATURE ///////// final IFeatureManager featureManager = instanceOf(IFeatureManager.class); //1 /** * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param md5 主键,特征码md5校验码 * @return FeatureBean 对象 * @see IFeatureManager#loadByPrimaryKey(String) * @throws RuntimeDaoException */ protected FeatureBean daoGetFeature(String md5)throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).loadByPrimaryKey(md5); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param md5 主键,特征码md5校验码 * @return FeatureBean 对象 * @see IFeatureManager#loadByPrimaryKeyChecked(String) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected FeatureBean daoGetFeatureChecked(String md5)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IFeatureManager.class).loadByPrimaryKeyChecked(md5); } //2 /** * 根据主键从数据库读取记录 * @return 返回与输入参数下标对应的 FeatureBean 列表,没有查到记录的返回{@code null} * @see IFeatureManager#loadByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected List daoGetFeatures(Collection md5Collection) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).loadByPrimaryKey(md5Collection); } //3 /** * 删除主键列表({@code md5Collection})指定的记录 * @return 返回删除的记录条数 * @see IFeatureManager#deleteByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected int daoDeleteFeaturesByPrimaryKey(Collection md5Collection) throws RuntimeDaoException{ int count =0; if(null != md5Collection){ for(String md5:md5Collection){ count += daoDeleteFeature(md5); } } return count; } //3-5 /** transformer : FeatureBean to fl_feature.md5 */ protected final Function daoCastFeatureToPk = new Function(){ @Override public String apply(FeatureBean input) { return null == input ? null : input.getMd5(); }}; //3-6 /** transformer : fl_feature.md5 to FeatureBean */ protected final Function daoCastFeatureFromPk = new Function(){ @Override public FeatureBean apply(String input) { return daoGetFeature(input); }}; //3-8 /** * unwrap primary key from {@link FeatureBean}
* if {@code beans} is {@code null},return a empty list(immutable) * * @param beans {@link FeatureBean} collection * @return primary key list * @see IFeatureManager#toPrimaryKeyList(Collection) */ protected List daoToPrimaryKeyListFromFeatures(Collection beans){ if (null == beans){ return ImmutableList.of(); }else{ return instanceOf(IFeatureManager.class).toPrimaryKeyList(beans); } } //3-9 /** * unwrap primary key from {@link FeatureBean}
* * the returned list is a transformed view of {@code beans}; * changes to {@code beans} will be reflected in the returned list and vice versa. * * if {@code beans} is {@code null},return a empty list(immutable) * @param beans {@link FeatureBean} list * @return primary key list * @see Lists#transform(List, Function) */ protected List daoToPrimaryKeyListFromFeatures(List beans){ if(null == beans){ return ImmutableList.of(); }else{ return Lists.transform(beans,daoCastFeatureToPk); } } //4 /** * 判断主键指定的记录是否存在 * * @param md5 主键,特征码md5校验码 * @see IFeatureManager#existsPrimaryKey(String) * @throws RuntimeDaoException */ protected boolean daoExistsFeature(String md5) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).existsPrimaryKey(md5); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsFeature(FeatureBean bean) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param md5 主键,特征码md5校验码 * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see IFeatureManager#deleteByPrimaryKey(String) * @throws RuntimeDaoException */ protected int daoDeleteFeature(String md5) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).deleteByPrimaryKey(md5); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeleteFeature(String) * @throws RuntimeDaoException */ protected int daoDeleteFeature(FeatureBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeleteFeature(bean.getMd5()); } //6 /** * 删除{@code featureBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeleteFeature(String) * @throws RuntimeDaoException */ protected int daoDeleteFeatures(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(FeatureBean bean:beans){ count += daoDeleteFeature(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected FeatureBean daoCheckDuplicate(FeatureBean featureBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(IFeatureManager.class).checkDuplicate(featureBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param md5 主键,特征码md5校验码 * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * @return always {@code md5OfFeature} * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected String daoCheckDuplicateFeature(String md5) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(IFeatureManager.class).existsPrimaryKey(md5)){ throw new DuplicateRecordException(); } return md5; } //8 /** * 返回外键(fl_face.feature_md5)引用指定记录(fl_feature.md5)的所有{@code fl_face}记录 * * @param md5OfFeature 主键,特征码md5校验码 * @see IFeatureManager#getFaceBeansByFeatureMd5AsList(String) * @throws RuntimeDaoException */ protected List daoGetFaceBeansByFeatureMd5OnFeature(String md5OfFeature) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).getFaceBeansByFeatureMd5AsList(md5OfFeature); } //8-2 /** * 删除外键(md5OfFeature))引用指定记录(fl_feature.md5)的所有{@code fl_face}记录 * * @param md5OfFeature 主键,特征码md5校验码 * @see IFeatureManager#deleteFaceBeansByFeatureMd5(String) * @throws RuntimeDaoException */ protected int daoDeleteFaceBeansByFeatureMd5OnFeature(String md5OfFeature) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).deleteFaceBeansByFeatureMd5(md5OfFeature); } //8 /** * 返回外键(fl_log.verify_feature)引用指定记录(fl_feature.md5)的所有{@code fl_log}记录 * * @param md5OfFeature 主键,特征码md5校验码 * @see IFeatureManager#getLogBeansByVerifyFeatureAsList(String) * @throws RuntimeDaoException */ protected List daoGetLogBeansByVerifyFeatureOnFeature(String md5OfFeature) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).getLogBeansByVerifyFeatureAsList(md5OfFeature); } //8-2 /** * 删除外键(md5OfFeature))引用指定记录(fl_feature.md5)的所有{@code fl_log}记录 * * @param md5OfFeature 主键,特征码md5校验码 * @see IFeatureManager#deleteLogBeansByVerifyFeature(String) * @throws RuntimeDaoException */ protected int daoDeleteLogBeansByVerifyFeatureOnFeature(String md5OfFeature) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).deleteLogBeansByVerifyFeature(md5OfFeature); } //8-3 /** * 返回外键(fl_feature.person_id)引用的 fl_person 记录 * @param bean * @see IFeatureManager#getReferencedByPersonId(FeatureBean) * @throws RuntimeDaoException */ protected PersonBean daoGetReferencedByPersonIdOnFeature(FeatureBean bean) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).getReferencedByPersonId(bean); } //8-4 /** * 设置外键fl_feature(person_id)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IFeatureManager#setReferencedByPersonId(FeatureBean,PersonBean) * @throws RuntimeDaoException */ protected PersonBean daoSetReferencedByPersonIdOnFeature(FeatureBean bean,PersonBean beanToSet) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).setReferencedByPersonId(bean,beanToSet); } //8-6 /** transformer : FeatureBean to fl_feature.person_id */ protected final Function daoCastFeatureToPersonId = new Function(){ @Override public Integer apply(FeatureBean input) { return null == input ? null : input.getPersonId(); }}; //8-8 /** transformer : fl_feature.md5 to fl_feature.person_id */ protected final Function daoCastFeaturePkToPersonId = new Function(){ @Override public Integer apply(String input) { return null == input ? null : daoCastFeatureToPersonId.apply(daoGetFeature(input)); }}; //12 /** * 添加新记录
* fl_feature 表只支持添加删除,不支持修改,所以如果数据库中已经存在相同记录或{@link FeatureBean#isNew()}返回{@code false},则抛出异常 * @param featureBean 要添加的新记录 * @see TableManager#save(BaseBean) * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code featureBean.isNew()} is {@code false} */ protected FeatureBean daoAddFeature(FeatureBean featureBean) throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == featureBean || featureBean.isNew(),"can be add,delete,but modify record for fl_feature,so the _isNew field must be true"); return instanceOf(IFeatureManager.class).save(daoCheckDuplicate(featureBean)); } //13 /** * 添加新记录(同步保存)
* fl_feature 表只允许添加删除,不允许修改,所以如果数据库中已经存在相同记录或{@link FeatureBean#isNew()}返回{@code false},则抛出异常 * see also {@link IFeatureManager#save(FeatureBean , PersonBean , Collection, Collection )}
* @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code featureBean.isNew()} is {@code false} */ protected FeatureBean daoAddFeature(FeatureBean featureBean , PersonBean refPersonByPersonId , Collection impFaceByFeatureMd5 , Collection impLogByVerifyFeature )throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == featureBean || featureBean.isNew(),"can be add,delete,but modify record for fl_feature,so the _isNew field must be true"); daoCheckDuplicate(featureBean); return instanceOf(IFeatureManager.class).save(featureBean , refPersonByPersonId , impFaceByFeatureMd5 , impLogByVerifyFeature ); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoAddFeature(FeatureBean) * @throws RuntimeDaoException */ protected Collection daoAddFeatures(Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ if(null != beans){ for(FeatureBean bean : beans){ daoAddFeature(bean); } } return beans; } //12-3-5 /** * {@link #daoAddFeatures(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoAddFeaturesAsTransaction(final Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoAddFeatures(beans); }}); }catch(RuntimeException e){ throwCauseIfInstanceOf(e,DuplicateRecordException.class); throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_feature 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IFeatureManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadFeatureByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_feature 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadFeatureUsingTemplate(FeatureBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_feature 的{@code column}字段的数据 * @param column 有效的fl_feature表字段名或{@link FeatureBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IFeatureManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfFeatureAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_feature 表的所有记录 * @see IFeatureManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadFeatureAll() throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_feature 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountFeatureByWhere(String where) throws RuntimeDaoException{ return instanceOf(IFeatureManager.class).countWhere(where); } //18 /** * 查询{@code where}条件指定的记录 * @return 返回查询结果记录的主键 * @see #daoLoadFeatureByWhere(String,int,int) * @throws RuntimeDaoException */ protected List daoLoadFeatureMd5ByWhere(String where) throws RuntimeDaoException{ return daoToPrimaryKeyListFromFeatures(daoLoadFeatureByWhere(where,1,-1)); } //19 /** * (主动更新机制实现)
* 返回 fl_feature.update_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadFeatureByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadFeatureByUpdateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadFeatureByWhere(makeWhere(timestamp,"update_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadFeatureByUpdateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadFeatureByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadFeatureByUpdateTime(timestamp,1,-1); } //20-5 /** * 返回fl_feature.update_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountFeatureByWhere(String) * @throws RuntimeDaoException */ protected int daoCountFeatureByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoCountFeatureByWhere(makeWhere(timestamp,"update_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_feature.update_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadFeatureMd5ByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadFeatureMd5ByUpdateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadFeatureMd5ByWhere(makeWhere(timestamp,"update_time")); } //////////// FL_IMAGE ///////// final IImageManager imageManager = instanceOf(IImageManager.class); //1 /** * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param md5 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @return ImageBean 对象 * @see IImageManager#loadByPrimaryKey(String) * @throws RuntimeDaoException */ protected ImageBean daoGetImage(String md5)throws RuntimeDaoException{ return instanceOf(IImageManager.class).loadByPrimaryKey(md5); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param md5 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @return ImageBean 对象 * @see IImageManager#loadByPrimaryKeyChecked(String) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected ImageBean daoGetImageChecked(String md5)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IImageManager.class).loadByPrimaryKeyChecked(md5); } //2 /** * 根据主键从数据库读取记录 * @return 返回与输入参数下标对应的 ImageBean 列表,没有查到记录的返回{@code null} * @see IImageManager#loadByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected List daoGetImages(Collection md5Collection) throws RuntimeDaoException{ return instanceOf(IImageManager.class).loadByPrimaryKey(md5Collection); } //3 /** * 删除主键列表({@code md5Collection})指定的记录 * @return 返回删除的记录条数 * @see IImageManager#deleteByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected int daoDeleteImagesByPrimaryKey(Collection md5Collection) throws RuntimeDaoException{ int count =0; if(null != md5Collection){ for(String md5:md5Collection){ count += daoDeleteImage(md5); } } return count; } //3-5 /** transformer : ImageBean to fl_image.md5 */ protected final Function daoCastImageToPk = new Function(){ @Override public String apply(ImageBean input) { return null == input ? null : input.getMd5(); }}; //3-6 /** transformer : fl_image.md5 to ImageBean */ protected final Function daoCastImageFromPk = new Function(){ @Override public ImageBean apply(String input) { return daoGetImage(input); }}; //3-8 /** * unwrap primary key from {@link ImageBean}
* if {@code beans} is {@code null},return a empty list(immutable) * * @param beans {@link ImageBean} collection * @return primary key list * @see IImageManager#toPrimaryKeyList(Collection) */ protected List daoToPrimaryKeyListFromImages(Collection beans){ if (null == beans){ return ImmutableList.of(); }else{ return instanceOf(IImageManager.class).toPrimaryKeyList(beans); } } //3-9 /** * unwrap primary key from {@link ImageBean}
* * the returned list is a transformed view of {@code beans}; * changes to {@code beans} will be reflected in the returned list and vice versa. * * if {@code beans} is {@code null},return a empty list(immutable) * @param beans {@link ImageBean} list * @return primary key list * @see Lists#transform(List, Function) */ protected List daoToPrimaryKeyListFromImages(List beans){ if(null == beans){ return ImmutableList.of(); }else{ return Lists.transform(beans,daoCastImageToPk); } } //4 /** * 判断主键指定的记录是否存在 * * @param md5 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @see IImageManager#existsPrimaryKey(String) * @throws RuntimeDaoException */ protected boolean daoExistsImage(String md5) throws RuntimeDaoException{ return instanceOf(IImageManager.class).existsPrimaryKey(md5); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsImage(ImageBean bean) throws RuntimeDaoException{ return instanceOf(IImageManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param md5 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see IImageManager#deleteByPrimaryKey(String) * @throws RuntimeDaoException */ protected int daoDeleteImage(String md5) throws RuntimeDaoException{ return instanceOf(IImageManager.class).deleteByPrimaryKey(md5); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeleteImage(String) * @throws RuntimeDaoException */ protected int daoDeleteImage(ImageBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeleteImage(bean.getMd5()); } //6 /** * 删除{@code imageBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeleteImage(String) * @throws RuntimeDaoException */ protected int daoDeleteImages(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(ImageBean bean:beans){ count += daoDeleteImage(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected ImageBean daoCheckDuplicate(ImageBean imageBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(IImageManager.class).checkDuplicate(imageBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param md5 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * @return always {@code md5OfImage} * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected String daoCheckDuplicateImage(String md5) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(IImageManager.class).existsPrimaryKey(md5)){ throw new DuplicateRecordException(); } return md5; } //8 /** * 返回外键(fl_face.image_md5)引用指定记录(fl_image.md5)的所有{@code fl_face}记录 * * @param md5OfImage 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @see IImageManager#getFaceBeansByImageMd5AsList(String) * @throws RuntimeDaoException */ protected List daoGetFaceBeansByImageMd5OnImage(String md5OfImage) throws RuntimeDaoException{ return instanceOf(IImageManager.class).getFaceBeansByImageMd5AsList(md5OfImage); } //8-2 /** * 删除外键(md5OfImage))引用指定记录(fl_image.md5)的所有{@code fl_face}记录 * * @param md5OfImage 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @see IImageManager#deleteFaceBeansByImageMd5(String) * @throws RuntimeDaoException */ protected int daoDeleteFaceBeansByImageMd5OnImage(String md5OfImage) throws RuntimeDaoException{ return instanceOf(IImageManager.class).deleteFaceBeansByImageMd5(md5OfImage); } //8 /** * 返回外键(fl_log.image_md5)引用指定记录(fl_image.md5)的所有{@code fl_log}记录 * * @param md5OfImage 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @see IImageManager#getLogBeansByImageMd5AsList(String) * @throws RuntimeDaoException */ protected List daoGetLogBeansByImageMd5OnImage(String md5OfImage) throws RuntimeDaoException{ return instanceOf(IImageManager.class).getLogBeansByImageMd5AsList(md5OfImage); } //8-2 /** * 删除外键(md5OfImage))引用指定记录(fl_image.md5)的所有{@code fl_log}记录 * * @param md5OfImage 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @see IImageManager#deleteLogBeansByImageMd5(String) * @throws RuntimeDaoException */ protected int daoDeleteLogBeansByImageMd5OnImage(String md5OfImage) throws RuntimeDaoException{ return instanceOf(IImageManager.class).deleteLogBeansByImageMd5(md5OfImage); } //8 /** * 返回外键(fl_person.image_md5)引用指定记录(fl_image.md5)的所有{@code fl_person}记录 * * @param md5OfImage 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @see IImageManager#getPersonBeansByImageMd5AsList(String) * @throws RuntimeDaoException */ protected List daoGetPersonBeansByImageMd5OnImage(String md5OfImage) throws RuntimeDaoException{ return instanceOf(IImageManager.class).getPersonBeansByImageMd5AsList(md5OfImage); } //8-2 /** * 删除外键(md5OfImage))引用指定记录(fl_image.md5)的所有{@code fl_person}记录 * * @param md5OfImage 主键,图像md5检验码,同时也是从 fl_store 获取图像数据的key * @see IImageManager#deletePersonBeansByImageMd5(String) * @throws RuntimeDaoException */ protected int daoDeletePersonBeansByImageMd5OnImage(String md5OfImage) throws RuntimeDaoException{ return instanceOf(IImageManager.class).deletePersonBeansByImageMd5(md5OfImage); } //8-3 /** * 返回外键(fl_image.device_id)引用的 fl_device 记录 * @param bean * @see IImageManager#getReferencedByDeviceId(ImageBean) * @throws RuntimeDaoException */ protected DeviceBean daoGetReferencedByDeviceIdOnImage(ImageBean bean) throws RuntimeDaoException{ return instanceOf(IImageManager.class).getReferencedByDeviceId(bean); } //8-4 /** * 设置外键fl_image(device_id)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IImageManager#setReferencedByDeviceId(ImageBean,DeviceBean) * @throws RuntimeDaoException */ protected DeviceBean daoSetReferencedByDeviceIdOnImage(ImageBean bean,DeviceBean beanToSet) throws RuntimeDaoException{ return instanceOf(IImageManager.class).setReferencedByDeviceId(bean,beanToSet); } //8-6 /** transformer : ImageBean to fl_image.device_id */ protected final Function daoCastImageToDeviceId = new Function(){ @Override public Integer apply(ImageBean input) { return null == input ? null : input.getDeviceId(); }}; //8-8 /** transformer : fl_image.md5 to fl_image.device_id */ protected final Function daoCastImagePkToDeviceId = new Function(){ @Override public Integer apply(String input) { return null == input ? null : daoCastImageToDeviceId.apply(daoGetImage(input)); }}; //12 /** * 添加新记录
* fl_image 表只支持添加删除,不支持修改,所以如果数据库中已经存在相同记录或{@link ImageBean#isNew()}返回{@code false},则抛出异常 * @param imageBean 要添加的新记录 * @see TableManager#save(BaseBean) * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code imageBean.isNew()} is {@code false} */ protected ImageBean daoAddImage(ImageBean imageBean) throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == imageBean || imageBean.isNew(),"can be add,delete,but modify record for fl_image,so the _isNew field must be true"); return instanceOf(IImageManager.class).save(daoCheckDuplicate(imageBean)); } //13 /** * 添加新记录(同步保存)
* fl_image 表只允许添加删除,不允许修改,所以如果数据库中已经存在相同记录或{@link ImageBean#isNew()}返回{@code false},则抛出异常 * see also {@link IImageManager#save(ImageBean , DeviceBean , Collection, Collection, Collection )}
* @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code imageBean.isNew()} is {@code false} */ protected ImageBean daoAddImage(ImageBean imageBean , DeviceBean refDeviceByDeviceId , Collection impFaceByImageMd5 , Collection impLogByImageMd5 , Collection impPersonByImageMd5 )throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == imageBean || imageBean.isNew(),"can be add,delete,but modify record for fl_image,so the _isNew field must be true"); daoCheckDuplicate(imageBean); return instanceOf(IImageManager.class).save(imageBean , refDeviceByDeviceId , impFaceByImageMd5 , impLogByImageMd5 , impPersonByImageMd5 ); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoAddImage(ImageBean) * @throws RuntimeDaoException */ protected Collection daoAddImages(Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ if(null != beans){ for(ImageBean bean : beans){ daoAddImage(bean); } } return beans; } //12-3-5 /** * {@link #daoAddImages(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoAddImagesAsTransaction(final Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoAddImages(beans); }}); }catch(RuntimeException e){ throwCauseIfInstanceOf(e,DuplicateRecordException.class); throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_image 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IImageManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadImageByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IImageManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_image 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadImageUsingTemplate(ImageBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IImageManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_image 的{@code column}字段的数据 * @param column 有效的fl_image表字段名或{@link ImageBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IImageManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfImageAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IImageManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_image 表的所有记录 * @see IImageManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadImageAll() throws RuntimeDaoException{ return instanceOf(IImageManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_image 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountImageByWhere(String where) throws RuntimeDaoException{ return instanceOf(IImageManager.class).countWhere(where); } //18 /** * 查询{@code where}条件指定的记录 * @return 返回查询结果记录的主键 * @see #daoLoadImageByWhere(String,int,int) * @throws RuntimeDaoException */ protected List daoLoadImageMd5ByWhere(String where) throws RuntimeDaoException{ return daoToPrimaryKeyListFromImages(daoLoadImageByWhere(where,1,-1)); } //////////// FL_LOG ///////// final ILogManager logManager = instanceOf(ILogManager.class); //1 /** * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param id 日志id * @return LogBean 对象 * @see ILogManager#loadByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected LogBean daoGetLog(Integer id)throws RuntimeDaoException{ return instanceOf(ILogManager.class).loadByPrimaryKey(id); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param id 日志id * @return LogBean 对象 * @see ILogManager#loadByPrimaryKeyChecked(Integer) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected LogBean daoGetLogChecked(Integer id)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(ILogManager.class).loadByPrimaryKeyChecked(id); } //2 /** * 根据主键从数据库读取记录 * @return 返回与输入参数下标对应的 LogBean 列表,没有查到记录的返回{@code null} * @see ILogManager#loadByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected List daoGetLogs(Collection idCollection) throws RuntimeDaoException{ return instanceOf(ILogManager.class).loadByPrimaryKey(idCollection); } //3 /** * 删除主键列表({@code idCollection})指定的记录 * @return 返回删除的记录条数 * @see ILogManager#deleteByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected int daoDeleteLogsByPrimaryKey(Collection idCollection) throws RuntimeDaoException{ int count =0; if(null != idCollection){ for(Integer id:idCollection){ count += daoDeleteLog(id); } } return count; } //3-5 /** transformer : LogBean to fl_log.id */ protected final Function daoCastLogToPk = new Function(){ @Override public Integer apply(LogBean input) { return null == input ? null : input.getId(); }}; //3-6 /** transformer : fl_log.id to LogBean */ protected final Function daoCastLogFromPk = new Function(){ @Override public LogBean apply(Integer input) { return daoGetLog(input); }}; //3-8 /** * unwrap primary key from {@link LogBean}
* if {@code beans} is {@code null},return a empty list(immutable) * * @param beans {@link LogBean} collection * @return primary key list * @see ILogManager#toPrimaryKeyList(Collection) */ protected List daoToPrimaryKeyListFromLogs(Collection beans){ if (null == beans){ return ImmutableList.of(); }else{ return instanceOf(ILogManager.class).toPrimaryKeyList(beans); } } //3-9 /** * unwrap primary key from {@link LogBean}
* * the returned list is a transformed view of {@code beans}; * changes to {@code beans} will be reflected in the returned list and vice versa. * * if {@code beans} is {@code null},return a empty list(immutable) * @param beans {@link LogBean} list * @return primary key list * @see Lists#transform(List, Function) */ protected List daoToPrimaryKeyListFromLogs(List beans){ if(null == beans){ return ImmutableList.of(); }else{ return Lists.transform(beans,daoCastLogToPk); } } //4 /** * 判断主键指定的记录是否存在 * * @param id 日志id * @see ILogManager#existsPrimaryKey(Integer) * @throws RuntimeDaoException */ protected boolean daoExistsLog(Integer id) throws RuntimeDaoException{ return instanceOf(ILogManager.class).existsPrimaryKey(id); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsLog(LogBean bean) throws RuntimeDaoException{ return instanceOf(ILogManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param id 日志id * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see ILogManager#deleteByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected int daoDeleteLog(Integer id) throws RuntimeDaoException{ return instanceOf(ILogManager.class).deleteByPrimaryKey(id); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeleteLog(Integer) * @throws RuntimeDaoException */ protected int daoDeleteLog(LogBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeleteLog(bean.getId()); } //6 /** * 删除{@code logBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeleteLog(Integer) * @throws RuntimeDaoException */ protected int daoDeleteLogs(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(LogBean bean:beans){ count += daoDeleteLog(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected LogBean daoCheckDuplicate(LogBean logBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(ILogManager.class).checkDuplicate(logBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param id 日志id * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * @return always {@code idOfLog} * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected Integer daoCheckDuplicateLog(Integer id) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(ILogManager.class).existsPrimaryKey(id)){ throw new DuplicateRecordException(); } return id; } //8-3 /** * 返回外键(fl_log.device_id)引用的 fl_device 记录 * @param bean * @see ILogManager#getReferencedByDeviceId(LogBean) * @throws RuntimeDaoException */ protected DeviceBean daoGetReferencedByDeviceIdOnLog(LogBean bean) throws RuntimeDaoException{ return instanceOf(ILogManager.class).getReferencedByDeviceId(bean); } //8-4 /** * 设置外键fl_log(device_id)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see ILogManager#setReferencedByDeviceId(LogBean,DeviceBean) * @throws RuntimeDaoException */ protected DeviceBean daoSetReferencedByDeviceIdOnLog(LogBean bean,DeviceBean beanToSet) throws RuntimeDaoException{ return instanceOf(ILogManager.class).setReferencedByDeviceId(bean,beanToSet); } //8-6 /** transformer : LogBean to fl_log.device_id */ protected final Function daoCastLogToDeviceId = new Function(){ @Override public Integer apply(LogBean input) { return null == input ? null : input.getDeviceId(); }}; //8-8 /** transformer : fl_log.id to fl_log.device_id */ protected final Function daoCastLogPkToDeviceId = new Function(){ @Override public Integer apply(Integer input) { return null == input ? null : daoCastLogToDeviceId.apply(daoGetLog(input)); }}; //8-3 /** * 返回外键(fl_log.compare_face)引用的 fl_face 记录 * @param bean * @see ILogManager#getReferencedByCompareFace(LogBean) * @throws RuntimeDaoException */ protected FaceBean daoGetReferencedByCompareFaceOnLog(LogBean bean) throws RuntimeDaoException{ return instanceOf(ILogManager.class).getReferencedByCompareFace(bean); } //8-4 /** * 设置外键fl_log(compare_face)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see ILogManager#setReferencedByCompareFace(LogBean,FaceBean) * @throws RuntimeDaoException */ protected FaceBean daoSetReferencedByCompareFaceOnLog(LogBean bean,FaceBean beanToSet) throws RuntimeDaoException{ return instanceOf(ILogManager.class).setReferencedByCompareFace(bean,beanToSet); } //8-6 /** transformer : LogBean to fl_log.compare_face */ protected final Function daoCastLogToCompareFace = new Function(){ @Override public Integer apply(LogBean input) { return null == input ? null : input.getCompareFace(); }}; //8-8 /** transformer : fl_log.id to fl_log.compare_face */ protected final Function daoCastLogPkToCompareFace = new Function(){ @Override public Integer apply(Integer input) { return null == input ? null : daoCastLogToCompareFace.apply(daoGetLog(input)); }}; //8-3 /** * 返回外键(fl_log.verify_feature)引用的 fl_feature 记录 * @param bean * @see ILogManager#getReferencedByVerifyFeature(LogBean) * @throws RuntimeDaoException */ protected FeatureBean daoGetReferencedByVerifyFeatureOnLog(LogBean bean) throws RuntimeDaoException{ return instanceOf(ILogManager.class).getReferencedByVerifyFeature(bean); } //8-4 /** * 设置外键fl_log(verify_feature)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see ILogManager#setReferencedByVerifyFeature(LogBean,FeatureBean) * @throws RuntimeDaoException */ protected FeatureBean daoSetReferencedByVerifyFeatureOnLog(LogBean bean,FeatureBean beanToSet) throws RuntimeDaoException{ return instanceOf(ILogManager.class).setReferencedByVerifyFeature(bean,beanToSet); } //8-6 /** transformer : LogBean to fl_log.verify_feature */ protected final Function daoCastLogToVerifyFeature = new Function(){ @Override public String apply(LogBean input) { return null == input ? null : input.getVerifyFeature(); }}; //8-8 /** transformer : fl_log.id to fl_log.verify_feature */ protected final Function daoCastLogPkToVerifyFeature = new Function(){ @Override public String apply(Integer input) { return null == input ? null : daoCastLogToVerifyFeature.apply(daoGetLog(input)); }}; //8-3 /** * 返回外键(fl_log.image_md5)引用的 fl_image 记录 * @param bean * @see ILogManager#getReferencedByImageMd5(LogBean) * @throws RuntimeDaoException */ protected ImageBean daoGetReferencedByImageMd5OnLog(LogBean bean) throws RuntimeDaoException{ return instanceOf(ILogManager.class).getReferencedByImageMd5(bean); } //8-4 /** * 设置外键fl_log(image_md5)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see ILogManager#setReferencedByImageMd5(LogBean,ImageBean) * @throws RuntimeDaoException */ protected ImageBean daoSetReferencedByImageMd5OnLog(LogBean bean,ImageBean beanToSet) throws RuntimeDaoException{ return instanceOf(ILogManager.class).setReferencedByImageMd5(bean,beanToSet); } //8-6 /** transformer : LogBean to fl_log.image_md5 */ protected final Function daoCastLogToImageMd5 = new Function(){ @Override public String apply(LogBean input) { return null == input ? null : input.getImageMd5(); }}; //8-8 /** transformer : fl_log.id to fl_log.image_md5 */ protected final Function daoCastLogPkToImageMd5 = new Function(){ @Override public String apply(Integer input) { return null == input ? null : daoCastLogToImageMd5.apply(daoGetLog(input)); }}; //8-3 /** * 返回外键(fl_log.person_id)引用的 fl_person 记录 * @param bean * @see ILogManager#getReferencedByPersonId(LogBean) * @throws RuntimeDaoException */ protected PersonBean daoGetReferencedByPersonIdOnLog(LogBean bean) throws RuntimeDaoException{ return instanceOf(ILogManager.class).getReferencedByPersonId(bean); } //8-4 /** * 设置外键fl_log(person_id)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see ILogManager#setReferencedByPersonId(LogBean,PersonBean) * @throws RuntimeDaoException */ protected PersonBean daoSetReferencedByPersonIdOnLog(LogBean bean,PersonBean beanToSet) throws RuntimeDaoException{ return instanceOf(ILogManager.class).setReferencedByPersonId(bean,beanToSet); } //8-6 /** transformer : LogBean to fl_log.person_id */ protected final Function daoCastLogToPersonId = new Function(){ @Override public Integer apply(LogBean input) { return null == input ? null : input.getPersonId(); }}; //8-8 /** transformer : fl_log.id to fl_log.person_id */ protected final Function daoCastLogPkToPersonId = new Function(){ @Override public Integer apply(Integer input) { return null == input ? null : daoCastLogToPersonId.apply(daoGetLog(input)); }}; //12 /** * 添加新记录
* fl_log 表只支持添加删除,不支持修改,所以如果数据库中已经存在相同记录或{@link LogBean#isNew()}返回{@code false},则抛出异常 * @param logBean 要添加的新记录 * @see TableManager#save(BaseBean) * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code logBean.isNew()} is {@code false} */ protected LogBean daoAddLog(LogBean logBean) throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == logBean || logBean.isNew(),"can be add,delete,but modify record for fl_log,so the _isNew field must be true"); return instanceOf(ILogManager.class).save(daoCheckDuplicate(logBean)); } //13 /** * 添加新记录(同步保存)
* fl_log 表只允许添加删除,不允许修改,所以如果数据库中已经存在相同记录或{@link LogBean#isNew()}返回{@code false},则抛出异常 * see also {@link ILogManager#save(LogBean , DeviceBean, FaceBean, FeatureBean, ImageBean, PersonBean )}
* @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code logBean.isNew()} is {@code false} */ protected LogBean daoAddLog(LogBean logBean , DeviceBean refDeviceByDeviceId , FaceBean refFaceByCompareFace , FeatureBean refFeatureByVerifyFeature , ImageBean refImageByImageMd5 , PersonBean refPersonByPersonId )throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == logBean || logBean.isNew(),"can be add,delete,but modify record for fl_log,so the _isNew field must be true"); daoCheckDuplicate(logBean); return instanceOf(ILogManager.class).save(logBean , refDeviceByDeviceId , refFaceByCompareFace , refFeatureByVerifyFeature , refImageByImageMd5 , refPersonByPersonId ); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoAddLog(LogBean) * @throws RuntimeDaoException */ protected Collection daoAddLogs(Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ if(null != beans){ for(LogBean bean : beans){ daoAddLog(bean); } } return beans; } //12-3-5 /** * {@link #daoAddLogs(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoAddLogsAsTransaction(final Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoAddLogs(beans); }}); }catch(RuntimeException e){ throwCauseIfInstanceOf(e,DuplicateRecordException.class); throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_log 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see ILogManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadLogByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(ILogManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_log 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadLogUsingTemplate(LogBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(ILogManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_log 的{@code column}字段的数据 * @param column 有效的fl_log表字段名或{@link LogBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see ILogManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfLogAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(ILogManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_log 表的所有记录 * @see ILogManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadLogAll() throws RuntimeDaoException{ return instanceOf(ILogManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_log 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountLogByWhere(String where) throws RuntimeDaoException{ return instanceOf(ILogManager.class).countWhere(where); } //18 /** * 查询{@code where}条件指定的记录 * @return 返回查询结果记录的主键 * @see #daoLoadLogByWhere(String,int,int) * @throws RuntimeDaoException */ protected List daoLoadLogIdByWhere(String where) throws RuntimeDaoException{ return daoToPrimaryKeyListFromLogs(daoLoadLogByWhere(where,1,-1)); } //19 /** * (主动更新机制实现)
* 返回 fl_log.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadLogByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadLogByCreateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadLogByWhere(makeWhere(timestamp,"create_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadLogByCreateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadLogByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadLogByCreateTime(timestamp,1,-1); } //20-5 /** * 返回fl_log.create_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountLogByWhere(String) * @throws RuntimeDaoException */ protected int daoCountLogByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoCountLogByWhere(makeWhere(timestamp,"create_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_log.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadLogIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadLogIdByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadLogIdByWhere(makeWhere(timestamp,"create_time")); } //19 /** * (主动更新机制实现)
* 返回 fl_log.verify_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadLogByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadLogByVerifyTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadLogByWhere(makeWhere(timestamp,"verify_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadLogByVerifyTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadLogByVerifyTime(Date timestamp) throws RuntimeDaoException{ return daoLoadLogByVerifyTime(timestamp,1,-1); } //20-5 /** * 返回fl_log.verify_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountLogByWhere(String) * @throws RuntimeDaoException */ protected int daoCountLogByVerifyTime(Date timestamp) throws RuntimeDaoException{ return daoCountLogByWhere(makeWhere(timestamp,"verify_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_log.verify_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadLogIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadLogIdByVerifyTime(Date timestamp) throws RuntimeDaoException{ return daoLoadLogIdByWhere(makeWhere(timestamp,"verify_time")); } //////////// FL_STORE ///////// final IStoreManager storeManager = instanceOf(IStoreManager.class); //1 /** * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param md5 主键,md5检验码 * @return StoreBean 对象 * @see IStoreManager#loadByPrimaryKey(String) * @throws RuntimeDaoException */ protected StoreBean daoGetStore(String md5)throws RuntimeDaoException{ return instanceOf(IStoreManager.class).loadByPrimaryKey(md5); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param md5 主键,md5检验码 * @return StoreBean 对象 * @see IStoreManager#loadByPrimaryKeyChecked(String) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected StoreBean daoGetStoreChecked(String md5)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IStoreManager.class).loadByPrimaryKeyChecked(md5); } //2 /** * 根据主键从数据库读取记录 * @return 返回与输入参数下标对应的 StoreBean 列表,没有查到记录的返回{@code null} * @see IStoreManager#loadByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected List daoGetStores(Collection md5Collection) throws RuntimeDaoException{ return instanceOf(IStoreManager.class).loadByPrimaryKey(md5Collection); } //3 /** * 删除主键列表({@code md5Collection})指定的记录 * @return 返回删除的记录条数 * @see IStoreManager#deleteByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected int daoDeleteStoresByPrimaryKey(Collection md5Collection) throws RuntimeDaoException{ int count =0; if(null != md5Collection){ for(String md5:md5Collection){ count += daoDeleteStore(md5); } } return count; } //3-5 /** transformer : StoreBean to fl_store.md5 */ protected final Function daoCastStoreToPk = new Function(){ @Override public String apply(StoreBean input) { return null == input ? null : input.getMd5(); }}; //3-6 /** transformer : fl_store.md5 to StoreBean */ protected final Function daoCastStoreFromPk = new Function(){ @Override public StoreBean apply(String input) { return daoGetStore(input); }}; //3-8 /** * unwrap primary key from {@link StoreBean}
* if {@code beans} is {@code null},return a empty list(immutable) * * @param beans {@link StoreBean} collection * @return primary key list * @see IStoreManager#toPrimaryKeyList(Collection) */ protected List daoToPrimaryKeyListFromStores(Collection beans){ if (null == beans){ return ImmutableList.of(); }else{ return instanceOf(IStoreManager.class).toPrimaryKeyList(beans); } } //3-9 /** * unwrap primary key from {@link StoreBean}
* * the returned list is a transformed view of {@code beans}; * changes to {@code beans} will be reflected in the returned list and vice versa. * * if {@code beans} is {@code null},return a empty list(immutable) * @param beans {@link StoreBean} list * @return primary key list * @see Lists#transform(List, Function) */ protected List daoToPrimaryKeyListFromStores(List beans){ if(null == beans){ return ImmutableList.of(); }else{ return Lists.transform(beans,daoCastStoreToPk); } } //4 /** * 判断主键指定的记录是否存在 * * @param md5 主键,md5检验码 * @see IStoreManager#existsPrimaryKey(String) * @throws RuntimeDaoException */ protected boolean daoExistsStore(String md5) throws RuntimeDaoException{ return instanceOf(IStoreManager.class).existsPrimaryKey(md5); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsStore(StoreBean bean) throws RuntimeDaoException{ return instanceOf(IStoreManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param md5 主键,md5检验码 * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see IStoreManager#deleteByPrimaryKey(String) * @throws RuntimeDaoException */ protected int daoDeleteStore(String md5) throws RuntimeDaoException{ return instanceOf(IStoreManager.class).deleteByPrimaryKey(md5); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeleteStore(String) * @throws RuntimeDaoException */ protected int daoDeleteStore(StoreBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeleteStore(bean.getMd5()); } //6 /** * 删除{@code storeBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeleteStore(String) * @throws RuntimeDaoException */ protected int daoDeleteStores(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(StoreBean bean:beans){ count += daoDeleteStore(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected StoreBean daoCheckDuplicate(StoreBean storeBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(IStoreManager.class).checkDuplicate(storeBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param md5 主键,md5检验码 * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * @return always {@code md5OfStore} * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected String daoCheckDuplicateStore(String md5) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(IStoreManager.class).existsPrimaryKey(md5)){ throw new DuplicateRecordException(); } return md5; } //12 /** * 添加新记录
* fl_store 表只支持添加删除,不支持修改,所以如果数据库中已经存在相同记录或{@link StoreBean#isNew()}返回{@code false},则抛出异常 * @param storeBean 要添加的新记录 * @see TableManager#save(BaseBean) * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code storeBean.isNew()} is {@code false} */ protected StoreBean daoAddStore(StoreBean storeBean) throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == storeBean || storeBean.isNew(),"can be add,delete,but modify record for fl_store,so the _isNew field must be true"); return instanceOf(IStoreManager.class).save(daoCheckDuplicate(storeBean)); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoAddStore(StoreBean) * @throws RuntimeDaoException */ protected Collection daoAddStores(Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ if(null != beans){ for(StoreBean bean : beans){ daoAddStore(bean); } } return beans; } //12-3-5 /** * {@link #daoAddStores(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoAddStoresAsTransaction(final Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoAddStores(beans); }}); }catch(RuntimeException e){ throwCauseIfInstanceOf(e,DuplicateRecordException.class); throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_store 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IStoreManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadStoreByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IStoreManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_store 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadStoreUsingTemplate(StoreBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IStoreManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_store 的{@code column}字段的数据 * @param column 有效的fl_store表字段名或{@link StoreBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IStoreManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfStoreAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IStoreManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_store 表的所有记录 * @see IStoreManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadStoreAll() throws RuntimeDaoException{ return instanceOf(IStoreManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_store 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountStoreByWhere(String where) throws RuntimeDaoException{ return instanceOf(IStoreManager.class).countWhere(where); } //18 /** * 查询{@code where}条件指定的记录 * @return 返回查询结果记录的主键 * @see #daoLoadStoreByWhere(String,int,int) * @throws RuntimeDaoException */ protected List daoLoadStoreMd5ByWhere(String where) throws RuntimeDaoException{ return daoToPrimaryKeyListFromStores(daoLoadStoreByWhere(where,1,-1)); } //////////// FL_LOG_LIGHT ///////// final ILogLightManager logLightManager = instanceOf(ILogLightManager.class); //16 /** * 查询{@code where} SQL条件语句指定的 fl_log_light 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see ILogLightManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadLogLightByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(ILogLightManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_log_light 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadLogLightUsingTemplate(LogLightBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(ILogLightManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_log_light 的{@code column}字段的数据 * @param column 有效的fl_log_light表字段名或{@link LogLightBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see ILogLightManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfLogLightAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(ILogLightManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_log_light 表的所有记录 * @see ILogLightManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadLogLightAll() throws RuntimeDaoException{ return instanceOf(ILogLightManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_log_light 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountLogLightByWhere(String where) throws RuntimeDaoException{ return instanceOf(ILogLightManager.class).countWhere(where); } //19 /** * (主动更新机制实现)
* 返回 fl_log_light.verify_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadLogLightByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadLogLightByVerifyTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadLogLightByWhere(makeWhere(timestamp,"verify_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadLogLightByVerifyTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadLogLightByVerifyTime(Date timestamp) throws RuntimeDaoException{ return daoLoadLogLightByVerifyTime(timestamp,1,-1); } //20-5 /** * 返回fl_log_light.verify_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountLogLightByWhere(String) * @throws RuntimeDaoException */ protected int daoCountLogLightByVerifyTime(Date timestamp) throws RuntimeDaoException{ return daoCountLogLightByWhere(makeWhere(timestamp,"verify_time")); } //////////// FL_ERROR_LOG ///////// final IErrorLogManager errorLogManager = instanceOf(IErrorLogManager.class); //1 /** * 根据主键从数据库读取记录,没有找到记录返回{@code null}
* * @param id 日志id * @return ErrorLogBean 对象 * @see IErrorLogManager#loadByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected ErrorLogBean daoGetErrorLog(Integer id)throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).loadByPrimaryKey(id); } //1-2 /** * 根据主键从数据库读取记录,没有找到记录抛出异常
* * @param id 日志id * @return ErrorLogBean 对象 * @see IErrorLogManager#loadByPrimaryKeyChecked(Integer) * @throws RuntimeDaoException * @throws ObjectRetrievalException 没有找到记录 */ protected ErrorLogBean daoGetErrorLogChecked(Integer id)throws RuntimeDaoException,ObjectRetrievalException{ return instanceOf(IErrorLogManager.class).loadByPrimaryKeyChecked(id); } //2 /** * 根据主键从数据库读取记录 * @return 返回与输入参数下标对应的 ErrorLogBean 列表,没有查到记录的返回{@code null} * @see IErrorLogManager#loadByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected List daoGetErrorLogs(Collection idCollection) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).loadByPrimaryKey(idCollection); } //3 /** * 删除主键列表({@code idCollection})指定的记录 * @return 返回删除的记录条数 * @see IErrorLogManager#deleteByPrimaryKey(Collection) * @throws RuntimeDaoException */ protected int daoDeleteErrorLogsByPrimaryKey(Collection idCollection) throws RuntimeDaoException{ int count =0; if(null != idCollection){ for(Integer id:idCollection){ count += daoDeleteErrorLog(id); } } return count; } //3-5 /** transformer : ErrorLogBean to fl_error_log.id */ protected final Function daoCastErrorLogToPk = new Function(){ @Override public Integer apply(ErrorLogBean input) { return null == input ? null : input.getId(); }}; //3-6 /** transformer : fl_error_log.id to ErrorLogBean */ protected final Function daoCastErrorLogFromPk = new Function(){ @Override public ErrorLogBean apply(Integer input) { return daoGetErrorLog(input); }}; //3-8 /** * unwrap primary key from {@link ErrorLogBean}
* if {@code beans} is {@code null},return a empty list(immutable) * * @param beans {@link ErrorLogBean} collection * @return primary key list * @see IErrorLogManager#toPrimaryKeyList(Collection) */ protected List daoToPrimaryKeyListFromErrorLogs(Collection beans){ if (null == beans){ return ImmutableList.of(); }else{ return instanceOf(IErrorLogManager.class).toPrimaryKeyList(beans); } } //3-9 /** * unwrap primary key from {@link ErrorLogBean}
* * the returned list is a transformed view of {@code beans}; * changes to {@code beans} will be reflected in the returned list and vice versa. * * if {@code beans} is {@code null},return a empty list(immutable) * @param beans {@link ErrorLogBean} list * @return primary key list * @see Lists#transform(List, Function) */ protected List daoToPrimaryKeyListFromErrorLogs(List beans){ if(null == beans){ return ImmutableList.of(); }else{ return Lists.transform(beans,daoCastErrorLogToPk); } } //4 /** * 判断主键指定的记录是否存在 * * @param id 日志id * @see IErrorLogManager#existsPrimaryKey(Integer) * @throws RuntimeDaoException */ protected boolean daoExistsErrorLog(Integer id) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).existsPrimaryKey(id); } //4-2 /** * 判断指定的记录是否存在 * @see TableManager#existsByPrimaryKey(BaseBean) * @throws RuntimeDaoException */ protected boolean daoExistsErrorLog(ErrorLogBean bean) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).existsByPrimaryKey(bean); } //5 /** * 删除主键指定的记录 * * @param id 日志id * @return 返回删除的记录条数(1),如果记录不存在返回0 * @see IErrorLogManager#deleteByPrimaryKey(Integer) * @throws RuntimeDaoException */ protected int daoDeleteErrorLog(Integer id) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).deleteByPrimaryKey(id); } //5-2 /** * 删除指定的记录 * @param bean 要删除的记录 * @return 返回删除的记录条数(1),如果{@code bean}为{@code null}或记录不存在返回0 * @see #daoDeleteErrorLog(Integer) * @throws RuntimeDaoException */ protected int daoDeleteErrorLog(ErrorLogBean bean) throws RuntimeDaoException{ return null == bean ? 0 : daoDeleteErrorLog(bean.getId()); } //6 /** * 删除{@code errorLogBeanCollection}列表指定的记录 * @return 返回删除的记录条数 * @see #daoDeleteErrorLog(Integer) * @throws RuntimeDaoException */ protected int daoDeleteErrorLogs(Collection beans) throws RuntimeDaoException{ int count =0; if(null != beans){ for(ErrorLogBean bean:beans){ count += daoDeleteErrorLog(bean); } } return count; } //7 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row */ protected ErrorLogBean daoCheckDuplicate(ErrorLogBean errorLogBean) throws RuntimeDaoException,DuplicateRecordException{ try{ return instanceOf(IErrorLogManager.class).checkDuplicate(errorLogBean); }catch(ObjectRetrievalException e){ throw new DuplicateRecordException(); } } //7-3 /** * 检查数据库中是否有(主键)相同的记录,如果有则抛出异常 * * @param id 日志id * @see TableManager#checkDuplicate(BaseBean) * @throws DuplicateRecordException if exists duplicated row * @return always {@code idOfErrorLog} * @throws RuntimeDaoException * @throws DuplicateRecordException */ protected Integer daoCheckDuplicateErrorLog(Integer id) throws RuntimeDaoException,DuplicateRecordException{ if(instanceOf(IErrorLogManager.class).existsPrimaryKey(id)){ throw new DuplicateRecordException(); } return id; } //8-3 /** * 返回外键(fl_error_log.device_id)引用的 fl_device 记录 * @param bean * @see IErrorLogManager#getReferencedByDeviceId(ErrorLogBean) * @throws RuntimeDaoException */ protected DeviceBean daoGetReferencedByDeviceIdOnErrorLog(ErrorLogBean bean) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).getReferencedByDeviceId(bean); } //8-4 /** * 设置外键fl_error_log(device_id)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IErrorLogManager#setReferencedByDeviceId(ErrorLogBean,DeviceBean) * @throws RuntimeDaoException */ protected DeviceBean daoSetReferencedByDeviceIdOnErrorLog(ErrorLogBean bean,DeviceBean beanToSet) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).setReferencedByDeviceId(bean,beanToSet); } //8-6 /** transformer : ErrorLogBean to fl_error_log.device_id */ protected final Function daoCastErrorLogToDeviceId = new Function(){ @Override public Integer apply(ErrorLogBean input) { return null == input ? null : input.getDeviceId(); }}; //8-8 /** transformer : fl_error_log.id to fl_error_log.device_id */ protected final Function daoCastErrorLogPkToDeviceId = new Function(){ @Override public Integer apply(Integer input) { return null == input ? null : daoCastErrorLogToDeviceId.apply(daoGetErrorLog(input)); }}; //8-3 /** * 返回外键(fl_error_log.person_id)引用的 fl_person 记录 * @param bean * @see IErrorLogManager#getReferencedByPersonId(ErrorLogBean) * @throws RuntimeDaoException */ protected PersonBean daoGetReferencedByPersonIdOnErrorLog(ErrorLogBean bean) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).getReferencedByPersonId(bean); } //8-4 /** * 设置外键fl_error_log(person_id)引用为{@code beanToSet}指定的记录, * 如果{@code beanToSet}没有保存则先save * @param bean * @param beanToSet 被引用的记录 * @see IErrorLogManager#setReferencedByPersonId(ErrorLogBean,PersonBean) * @throws RuntimeDaoException */ protected PersonBean daoSetReferencedByPersonIdOnErrorLog(ErrorLogBean bean,PersonBean beanToSet) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).setReferencedByPersonId(bean,beanToSet); } //8-6 /** transformer : ErrorLogBean to fl_error_log.person_id */ protected final Function daoCastErrorLogToPersonId = new Function(){ @Override public Integer apply(ErrorLogBean input) { return null == input ? null : input.getPersonId(); }}; //8-8 /** transformer : fl_error_log.id to fl_error_log.person_id */ protected final Function daoCastErrorLogPkToPersonId = new Function(){ @Override public Integer apply(Integer input) { return null == input ? null : daoCastErrorLogToPersonId.apply(daoGetErrorLog(input)); }}; //12 /** * 添加新记录
* fl_error_log 表只支持添加删除,不支持修改,所以如果数据库中已经存在相同记录或{@link ErrorLogBean#isNew()}返回{@code false},则抛出异常 * @param errorLogBean 要添加的新记录 * @see TableManager#save(BaseBean) * @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code errorLogBean.isNew()} is {@code false} */ protected ErrorLogBean daoAddErrorLog(ErrorLogBean errorLogBean) throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == errorLogBean || errorLogBean.isNew(),"can be add,delete,but modify record for fl_error_log,so the _isNew field must be true"); return instanceOf(IErrorLogManager.class).save(daoCheckDuplicate(errorLogBean)); } //13 /** * 添加新记录(同步保存)
* fl_error_log 表只允许添加删除,不允许修改,所以如果数据库中已经存在相同记录或{@link ErrorLogBean#isNew()}返回{@code false},则抛出异常 * see also {@link IErrorLogManager#save(ErrorLogBean , DeviceBean, PersonBean )}
* @see TableManager#checkDuplicate(BaseBean) * @throws RuntimeDaoException * @throws DuplicateRecordException if exists duplicated row * @throws IllegalArgumentException if {@code errorLogBean.isNew()} is {@code false} */ protected ErrorLogBean daoAddErrorLog(ErrorLogBean errorLogBean , DeviceBean refDeviceByDeviceId , PersonBean refPersonByPersonId )throws RuntimeDaoException,DuplicateRecordException{ checkArgument(null == errorLogBean || errorLogBean.isNew(),"can be add,delete,but modify record for fl_error_log,so the _isNew field must be true"); daoCheckDuplicate(errorLogBean); return instanceOf(IErrorLogManager.class).save(errorLogBean , refDeviceByDeviceId , refPersonByPersonId ); } //12-3-3 /** * 添加新记录
* @param beans 要添加的新记录集合 * @return always {@code beans} * @see #daoAddErrorLog(ErrorLogBean) * @throws RuntimeDaoException */ protected Collection daoAddErrorLogs(Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ if(null != beans){ for(ErrorLogBean bean : beans){ daoAddErrorLog(bean); } } return beans; } //12-3-5 /** * {@link #daoAddErrorLogs(Collection)}的事务化版本 * @throws RuntimeDaoException */ protected Collection daoAddErrorLogsAsTransaction(final Collection beans) throws RuntimeDaoException ,DuplicateRecordException{ try{ return daoRunAsTransaction(new Callable>(){ @Override public Collection call() throws Exception { return daoAddErrorLogs(beans); }}); }catch(RuntimeException e){ throwCauseIfInstanceOf(e,DuplicateRecordException.class); throw e; } } //16 /** * 查询{@code where} SQL条件语句指定的 fl_error_log 记录 * @param where SQL 条件语句,为{@code null}或空时加载所有记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IErrorLogManager#loadByWhereAsList(String,int[],int,int) * @throws RuntimeDaoException */ protected List daoLoadErrorLogByWhere(String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).loadByWhereAsList(where,null,startRow,numRows); } //16-2 /** * 以{@code bean} 为模板查询 fl_error_log 记录 * @param bean 模板对象 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see TableManager#loadUsingTemplate(BaseBean,int,int) * @throws RuntimeDaoException */ protected List daoLoadErrorLogUsingTemplate(ErrorLogBean bean,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).loadUsingTemplateAsList(bean,startRow,numRows); } //16-3 /** * 查询 fl_error_log 的{@code column}字段的数据 * @param column 有效的fl_error_log表字段名或{@link ErrorLogBean} 字段名 * @param distinct 只返回不重复记录 * @param where 'where'起始的SQL 查询条件语句,可为{@code null} * @return {@code column}字段记录 * @param startRow 返回记录的起始行(首行=1,尾行=-1) * @param numRows 返回记录条数(小于0时返回所有记录) * @see IErrorLogManager#loadColumnAsList(String,boolean,String,int,int) * @throws RuntimeDaoException */ protected List daoLoadColumnOfErrorLogAsList(String column,boolean distinct,String where,int startRow, int numRows) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).loadColumnAsList(column, distinct, where, startRow, numRows); } //17 /** * 返回 fl_error_log 表的所有记录 * @see IErrorLogManager#loadAllAsList() * @throws RuntimeDaoException */ protected List daoLoadErrorLogAll() throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).loadAllAsList(); } //17-2 /** * 返回满足{@code where} SQL条件语句的 fl_error_log 记录总数 * @see TableManager#countWhere(String) * @throws RuntimeDaoException */ protected int daoCountErrorLogByWhere(String where) throws RuntimeDaoException{ return instanceOf(IErrorLogManager.class).countWhere(where); } //18 /** * 查询{@code where}条件指定的记录 * @return 返回查询结果记录的主键 * @see #daoLoadErrorLogByWhere(String,int,int) * @throws RuntimeDaoException */ protected List daoLoadErrorLogIdByWhere(String where) throws RuntimeDaoException{ return daoToPrimaryKeyListFromErrorLogs(daoLoadErrorLogByWhere(where,1,-1)); } //19 /** * (主动更新机制实现)
* 返回 fl_error_log.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @see #daoLoadErrorLogByWhere(String,int,int) * @throws RuntimeDaoException * @throws IllegalArgumentException {@code timestamp}为{@code null}时 */ protected List daoLoadErrorLogByCreateTime(Date timestamp,int startRow, int numRows) throws RuntimeDaoException{ return daoLoadErrorLogByWhere(makeWhere(timestamp,"create_time"),startRow,numRows); } //20 /** * 参见 {@link #daoLoadErrorLogByCreateTime(Date,int,int)} * @throws RuntimeDaoException */ protected List daoLoadErrorLogByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadErrorLogByCreateTime(timestamp,1,-1); } //20-5 /** * 返回fl_error_log.create_time 字段大于指定时间戳({@code timestamp})的记录总数 * @see #daoCountErrorLogByWhere(String) * @throws RuntimeDaoException */ protected int daoCountErrorLogByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoCountErrorLogByWhere(makeWhere(timestamp,"create_time")); } //21 /** * (主动更新机制实现)
* 返回 fl_error_log.create_time 字段大于指定时间戳({@code timestamp})的所有记录 * @return 返回查询结果记录的主键 * @see #daoLoadErrorLogIdByWhere(String) * @throws RuntimeDaoException */ protected List daoLoadErrorLogIdByCreateTime(Date timestamp) throws RuntimeDaoException{ return daoLoadErrorLogIdByWhere(makeWhere(timestamp,"create_time")); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy