net.gdface.facelog.db.mysql.LogManager Maven / Gradle / Ivy
// ______________________________________________________
// Generated by sql2java - https://github.com/10km/sql2java-2-6-7 (custom branch)
// modified by guyadong from
// sql2java original version https://sourceforge.net/projects/sql2java/
// JDBC driver used at code generation time: com.mysql.jdbc.Driver
// template: manager.java.vm
// ______________________________________________________
package net.gdface.facelog.db.mysql;
import java.util.concurrent.Callable;
import net.gdface.facelog.db.Constant;
import net.gdface.facelog.db.LogBean;
import net.gdface.facelog.db.IBeanConverter;
import net.gdface.facelog.db.IDbConverter;
import net.gdface.facelog.db.TableManager;
import net.gdface.facelog.db.ILogManager;
import net.gdface.facelog.db.DeviceBean;
import net.gdface.facelog.db.FaceBean;
import net.gdface.facelog.db.FeatureBean;
import net.gdface.facelog.db.PersonBean;
import net.gdface.facelog.db.TableListener;
import net.gdface.facelog.db.exception.RuntimeDaoException;
import net.gdface.facelog.db.exception.ObjectRetrievalException;
import net.gdface.facelog.dborm.exception.DaoException;
/**
* Handles database calls (save, load, count, etc...) for the fl_log table.
* all {@link DaoException} be wrapped as {@link RuntimeDaoException} to throw.
* Remarks: 人脸验证日志,记录所有通过验证的人员
* @author guyadong
*/
public class LogManager extends TableManager.BaseAdapter implements ILogManager
{
private net.gdface.facelog.dborm.log.FlLogManager nativeManager = net.gdface.facelog.dborm.log.FlLogManager.getInstance();
private IDbConverter<
net.gdface.facelog.dborm.device.FlDeviceBean,
net.gdface.facelog.dborm.device.FlDeviceGroupBean,
net.gdface.facelog.dborm.face.FlFaceBean,
net.gdface.facelog.dborm.face.FlFeatureBean,
net.gdface.facelog.dborm.image.FlImageBean,
net.gdface.facelog.dborm.log.FlLogBean,
net.gdface.facelog.dborm.permit.FlPermitBean,
net.gdface.facelog.dborm.person.FlPersonBean,
net.gdface.facelog.dborm.person.FlPersonGroupBean,
net.gdface.facelog.dborm.image.FlStoreBean,
net.gdface.facelog.dborm.log.FlLogLightBean> dbConverter = DbConverter.INSTANCE;
private IBeanConverter beanConverter = dbConverter.getLogBeanConverter();
private static LogManager singleton = new LogManager();
protected LogManager(){}
protected DeviceManager instanceOfDeviceManager(){
return DeviceManager.getInstance();
}
protected FaceManager instanceOfFaceManager(){
return FaceManager.getInstance();
}
protected FeatureManager instanceOfFeatureManager(){
return FeatureManager.getInstance();
}
protected PersonManager instanceOfPersonManager(){
return PersonManager.getInstance();
}
@Override
public String getTableName() {
return this.nativeManager.getTableName();
}
@Override
public String getFields() {
return this.nativeManager.getFields();
}
@Override
public String getFullFields() {
return this.nativeManager.getFullFields();
}
@Override
public String[] getPrimarykeyNames() {
return this.nativeManager.getPrimarykeyNames();
}
/**
* Get the {@link LogManager} singleton.
*
* @return {@link LogManager}
*/
public static LogManager getInstance()
{
return singleton;
}
@Override
protected Class beanType(){
return LogBean.class;
}
//////////////////////////////////////
// PRIMARY KEY METHODS
//////////////////////////////////////
//1 override ILogManager
@Override
public LogBean loadByPrimaryKey(Integer id)
{
try{
return loadByPrimaryKeyChecked(id);
}catch(ObjectRetrievalException e){
// not found
return null;
}
}
//1.1 override ILogManager
@Override
public LogBean loadByPrimaryKeyChecked(Integer id) throws ObjectRetrievalException
{
try{
return this.beanConverter.fromRight(nativeManager.loadByPrimaryKeyChecked(id));
}catch(net.gdface.facelog.dborm.exception.ObjectRetrievalException e){
throw new ObjectRetrievalException();
}catch(DaoException e){
throw new RuntimeDaoException(e);
}
}
//1.2
@Override
public LogBean loadByPrimaryKey(LogBean bean)
{
return bean==null?null:loadByPrimaryKey(bean.getId());
}
//1.2.2
@Override
public LogBean loadByPrimaryKeyChecked(LogBean bean) throws ObjectRetrievalException
{
if(null == bean){
throw new NullPointerException();
}
return loadByPrimaryKeyChecked(bean.getId());
}
//1.3
@Override
public LogBean loadByPrimaryKey(Object ...keys){
try{
return loadByPrimaryKeyChecked(keys);
}catch(ObjectRetrievalException e){
// not found
return null;
}
}
//1.3.2
@Override
public LogBean loadByPrimaryKeyChecked(Object ...keys) throws ObjectRetrievalException{
if(null == keys){
throw new NullPointerException();
}
if(keys.length != FL_LOG_PK_COUNT){
throw new IllegalArgumentException("argument number mismatch with primary key number");
}
if(! (keys[0] instanceof Integer)){
throw new IllegalArgumentException("invalid type for the No.1 argument,expected type:Integer");
}
return loadByPrimaryKeyChecked((Integer)keys[0]);
}
//1.4 override ILogManager
@Override
public boolean existsPrimaryKey(Integer id)
{
try{
return nativeManager.existsPrimaryKey(id);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//1.6
@Override
public boolean existsByPrimaryKey(LogBean bean)
{
return null == bean ? false : existsPrimaryKey(bean.getId());
}
//1.7
@Override
public LogBean checkDuplicate(LogBean bean)throws ObjectRetrievalException{
if(null != bean){
checkDuplicate(bean.getId());
}
return bean;
}
//1.4.1 override ILogManager
@Override
public Integer checkDuplicate(Integer id)throws ObjectRetrievalException{
try{
return this.nativeManager.checkDuplicate(id);
}catch(net.gdface.facelog.dborm.exception.ObjectRetrievalException e){
throw new ObjectRetrievalException(e);
}catch(DaoException e){
throw new RuntimeDaoException(e);
}
}
//1.8 override ILogManager
@Override
public java.util.List loadByPrimaryKey(int... keys){
if(null == keys){
return new java.util.ArrayList();
}
java.util.ArrayList list = new java.util.ArrayList(keys.length);
for(int i = 0 ;i< keys.length;++i){
list.add(loadByPrimaryKey(keys[i]));
}
return list;
}
//1.9 override ILogManager
@Override
public java.util.List loadByPrimaryKey(java.util.Collection keys){
if(null == keys ){
return new java.util.ArrayList();
}
java.util.ArrayList list = new java.util.ArrayList(keys.size());
if(keys instanceof java.util.List){
for(Integer key: keys){
list.add(loadByPrimaryKey(key));
}
}else{
LogBean bean;
for(Integer key: keys){
if(null != (bean = loadByPrimaryKey(key))){
list.add(bean);
}
}
}
return list;
}
//2 override ILogManager
@Override
public int deleteByPrimaryKey(Integer id)
{
try
{
return nativeManager.deleteByPrimaryKey(id);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//2
@Override
public int delete(LogBean bean){
try
{
return nativeManager.delete(this.beanConverter.toRight(bean));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//2.1
@Override
public int deleteByPrimaryKey(Object ...keys){
if(null == keys){
throw new NullPointerException();
}
if(keys.length != FL_LOG_PK_COUNT){
throw new IllegalArgumentException("argument number mismatch with primary key number");
}
if(! (keys[0] instanceof Integer)){
throw new IllegalArgumentException("invalid type for the No.1 argument,expected type:Integer");
}
return deleteByPrimaryKey((Integer)keys[0]);
}
//2.2 override ILogManager
@Override
public int deleteByPrimaryKey(int... keys){
int count = 0;
if(null != keys){
for(int key:keys){
count += deleteByPrimaryKey(key);
}
}
return count;
}
//2.3 override ILogManager
@Override
public int deleteByPrimaryKey(java.util.Collection keys){
int count = 0;
if(null != keys){
for(Integer key :keys){
count += deleteByPrimaryKey(key);
}
}
return count;
}
//2.4 override ILogManager
@Override
public int delete(LogBean... beans){
int count = 0;
if(null != beans){
for(LogBean bean :beans){
count += delete(bean);
}
}
return count;
}
//2.5 override ILogManager
@Override
public int delete(java.util.Collection beans){
int count = 0;
if(null != beans){
for(LogBean bean :beans){
count += delete(bean);
}
}
return count;
}
//3.5 SYNC SAVE override ILogManager
@Override
public LogBean save(LogBean bean
, DeviceBean refDeviceByDeviceId , FaceBean refFaceByCompareFace , FeatureBean refFeatureByVerifyFeature , PersonBean refPersonByPersonId
)
{
if(null == bean){
return null;
}
if(null != refDeviceByDeviceId){
this.setReferencedByDeviceId(bean,refDeviceByDeviceId);
}
if(null != refFaceByCompareFace){
this.setReferencedByCompareFace(bean,refFaceByCompareFace);
}
if(null != refFeatureByVerifyFeature){
this.setReferencedByVerifyFeature(bean,refFeatureByVerifyFeature);
}
if(null != refPersonByPersonId){
this.setReferencedByPersonId(bean,refPersonByPersonId);
}
bean = this.save( bean );
return bean;
}
//3.6 SYNC SAVE AS TRANSACTION override ILogManager
@Override
public LogBean saveAsTransaction(final LogBean bean
,final DeviceBean refDeviceByDeviceId ,final FaceBean refFaceByCompareFace ,final FeatureBean refFeatureByVerifyFeature ,final PersonBean refPersonByPersonId
)
{
return this.runAsTransaction(new Callable(){
@Override
public LogBean call() throws Exception {
return save(bean , refDeviceByDeviceId , refFaceByCompareFace , refFeatureByVerifyFeature , refPersonByPersonId );
}});
}
private static final int SYNC_SAVE_ARG_LEN = 4;
private static final int SYNC_SAVE_ARG_0 = 0;
private static final int SYNC_SAVE_ARG_1 = 1;
private static final int SYNC_SAVE_ARG_2 = 2;
private static final int SYNC_SAVE_ARG_3 = 3;
//3.9 SYNC SAVE
/**
* Save the {@link LogBean} bean and referenced beans and imported beans into the database.
*
* @param bean the {@link LogBean} bean to be saved
* @param inputs referenced beans or imported beans
* see also {@link #save(LogBean , DeviceBean , FaceBean , FeatureBean , PersonBean )}
* @return the inserted or updated {@link LogBean} bean
*/
@Override
public LogBean save(LogBean bean,Object ...inputs)
{
if(null == inputs){
return save(bean);
}
if(inputs.length > SYNC_SAVE_ARG_LEN){
throw new IllegalArgumentException("too many dynamic arguments,max dynamic arguments number: 4");
}
Object[] args = new Object[SYNC_SAVE_ARG_LEN];
System.arraycopy(inputs, 0, args, 0, inputs.length);
if( null != args[SYNC_SAVE_ARG_0] && !(args[SYNC_SAVE_ARG_0] instanceof DeviceBean)){
throw new IllegalArgumentException("invalid type for the No.1 dynamic argument,expected type:DeviceBean");
}
if( null != args[SYNC_SAVE_ARG_1] && !(args[SYNC_SAVE_ARG_1] instanceof FaceBean)){
throw new IllegalArgumentException("invalid type for the No.2 dynamic argument,expected type:FaceBean");
}
if( null != args[SYNC_SAVE_ARG_2] && !(args[SYNC_SAVE_ARG_2] instanceof FeatureBean)){
throw new IllegalArgumentException("invalid type for the No.3 dynamic argument,expected type:FeatureBean");
}
if( null != args[SYNC_SAVE_ARG_3] && !(args[SYNC_SAVE_ARG_3] instanceof PersonBean)){
throw new IllegalArgumentException("invalid type for the No.4 dynamic argument,expected type:PersonBean");
}
return save(bean,
(DeviceBean)args[SYNC_SAVE_ARG_0],
(FaceBean)args[SYNC_SAVE_ARG_1],
(FeatureBean)args[SYNC_SAVE_ARG_2],
(PersonBean)args[SYNC_SAVE_ARG_3]);
}
//3.10 SYNC SAVE
/**
* Save the {@link LogBean} bean and referenced beans and imported beans into the database.
*
* @param bean the {@link LogBean} bean to be saved
* @param inputs referenced beans or imported beans
* see also {@link #save(LogBean , DeviceBean , FaceBean , FeatureBean , PersonBean )}
* @return the inserted or updated {@link LogBean} bean
*/
@SuppressWarnings("unchecked")
@Override
public LogBean saveCollection(LogBean bean,Object ...inputs)
{
if(null == inputs){
return save(bean);
}
if(inputs.length > SYNC_SAVE_ARG_LEN){
throw new IllegalArgumentException("too many dynamic arguments,max dynamic arguments number: 4");
}
Object[] args = new Object[SYNC_SAVE_ARG_LEN];
System.arraycopy(inputs, 0, args, 0, inputs.length);
if( null != args[SYNC_SAVE_ARG_0] && !(args[SYNC_SAVE_ARG_0] instanceof DeviceBean)){
throw new IllegalArgumentException("invalid type for the No.1 dynamic argument,expected type:DeviceBean");
}
if( null != args[SYNC_SAVE_ARG_1] && !(args[SYNC_SAVE_ARG_1] instanceof FaceBean)){
throw new IllegalArgumentException("invalid type for the No.2 dynamic argument,expected type:FaceBean");
}
if( null != args[SYNC_SAVE_ARG_2] && !(args[SYNC_SAVE_ARG_2] instanceof FeatureBean)){
throw new IllegalArgumentException("invalid type for the No.3 dynamic argument,expected type:FeatureBean");
}
if( null != args[SYNC_SAVE_ARG_3] && !(args[SYNC_SAVE_ARG_3] instanceof PersonBean)){
throw new IllegalArgumentException("invalid type for the No.4 dynamic argument,expected type:PersonBean");
}
return save(bean,
(DeviceBean)args[SYNC_SAVE_ARG_0],
(FaceBean)args[SYNC_SAVE_ARG_1],
(FeatureBean)args[SYNC_SAVE_ARG_2],
(PersonBean)args[SYNC_SAVE_ARG_3]);
}
//////////////////////////////////////
// FOREIGN KEY GENERIC METHOD
//////////////////////////////////////
/**
* Retrieves the bean object referenced by fkIndex.
* @param
*
* - {@link Constant#FL_LOG_FK_DEVICE_ID} TO {@link DeviceBean}
* - {@link Constant#FL_LOG_FK_COMPARE_FACE} TO {@link FaceBean}
* - {@link Constant#FL_LOG_FK_VERIFY_FEATURE} TO {@link FeatureBean}
* - {@link Constant#FL_LOG_FK_PERSON_ID} TO {@link PersonBean}
*
* @param bean the {@link LogBean} object to use
* @param fkIndex valid values:
* {@link Constant#FL_LOG_FK_DEVICE_ID},{@link Constant#FL_LOG_FK_COMPARE_FACE},{@link Constant#FL_LOG_FK_VERIFY_FEATURE},{@link Constant#FL_LOG_FK_PERSON_ID}
* @return the associated T bean or {@code null} if {@code bean} or {@code beanToSet} is {@code null}
*/
@SuppressWarnings("unchecked")
@Override
public > T getReferencedBean(LogBean bean,int fkIndex){
switch(fkIndex){
case FL_LOG_FK_DEVICE_ID:
return (T)this.getReferencedByDeviceId(bean);
case FL_LOG_FK_COMPARE_FACE:
return (T)this.getReferencedByCompareFace(bean);
case FL_LOG_FK_VERIFY_FEATURE:
return (T)this.getReferencedByVerifyFeature(bean);
case FL_LOG_FK_PERSON_ID:
return (T)this.getReferencedByPersonId(bean);
default:
throw new IllegalArgumentException(String.format("invalid fkIndex %d", fkIndex));
}
}
/**
* Associates the {@link LogBean} object to the bean object by fkIndex field.
*
* @param see also {@link #getReferencedBean(LogBean,int)}
* @param bean the {@link LogBean} object to use
* @param beanToSet the T object to associate to the {@link LogBean}
* @param fkIndex valid values: see also {@link #getReferencedBean(LogBean,int)}
* @return always beanToSet saved
*/
@SuppressWarnings("unchecked")
@Override
public > T setReferencedBean(LogBean bean,T beanToSet,int fkIndex){
switch(fkIndex){
case FL_LOG_FK_DEVICE_ID:
return (T)this.setReferencedByDeviceId(bean, (DeviceBean)beanToSet);
case FL_LOG_FK_COMPARE_FACE:
return (T)this.setReferencedByCompareFace(bean, (FaceBean)beanToSet);
case FL_LOG_FK_VERIFY_FEATURE:
return (T)this.setReferencedByVerifyFeature(bean, (FeatureBean)beanToSet);
case FL_LOG_FK_PERSON_ID:
return (T)this.setReferencedByPersonId(bean, (PersonBean)beanToSet);
default:
throw new IllegalArgumentException(String.format("invalid fkIndex %d", fkIndex));
}
}
//////////////////////////////////////
// GET/SET FOREIGN KEY BEAN METHOD
//////////////////////////////////////
//5.1 GET REFERENCED VALUE override ILogManager
@Override
public DeviceBean getReferencedByDeviceId(LogBean bean)
{
if(null == bean){
return null;
}
bean.setReferencedByDeviceId(instanceOfDeviceManager().loadByPrimaryKey(bean.getDeviceId()));
return bean.getReferencedByDeviceId();
}
//5.2 SET REFERENCED override ILogManager
@Override
public DeviceBean setReferencedByDeviceId(LogBean bean, DeviceBean beanToSet)
{
try{
net.gdface.facelog.dborm.log.FlLogBean nativeBean = this.beanConverter.toRight(bean);
IBeanConverter foreignConverter = this.dbConverter.getDeviceBeanConverter();
net.gdface.facelog.dborm.device.FlDeviceBean foreignNativeBean = foreignConverter.toRight(beanToSet);
this.nativeManager.setReferencedByDeviceId(nativeBean,foreignNativeBean);
this.beanConverter.fromRight(bean, nativeBean);
foreignConverter.fromRight(beanToSet,foreignNativeBean);
return beanToSet;
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//5.1 GET REFERENCED VALUE override ILogManager
@Override
public FaceBean getReferencedByCompareFace(LogBean bean)
{
if(null == bean){
return null;
}
bean.setReferencedByCompareFace(instanceOfFaceManager().loadByPrimaryKey(bean.getCompareFace()));
return bean.getReferencedByCompareFace();
}
//5.2 SET REFERENCED override ILogManager
@Override
public FaceBean setReferencedByCompareFace(LogBean bean, FaceBean beanToSet)
{
try{
net.gdface.facelog.dborm.log.FlLogBean nativeBean = this.beanConverter.toRight(bean);
IBeanConverter foreignConverter = this.dbConverter.getFaceBeanConverter();
net.gdface.facelog.dborm.face.FlFaceBean foreignNativeBean = foreignConverter.toRight(beanToSet);
this.nativeManager.setReferencedByCompareFace(nativeBean,foreignNativeBean);
this.beanConverter.fromRight(bean, nativeBean);
foreignConverter.fromRight(beanToSet,foreignNativeBean);
return beanToSet;
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//5.1 GET REFERENCED VALUE override ILogManager
@Override
public FeatureBean getReferencedByVerifyFeature(LogBean bean)
{
if(null == bean){
return null;
}
bean.setReferencedByVerifyFeature(instanceOfFeatureManager().loadByPrimaryKey(bean.getVerifyFeature()));
return bean.getReferencedByVerifyFeature();
}
//5.2 SET REFERENCED override ILogManager
@Override
public FeatureBean setReferencedByVerifyFeature(LogBean bean, FeatureBean beanToSet)
{
try{
net.gdface.facelog.dborm.log.FlLogBean nativeBean = this.beanConverter.toRight(bean);
IBeanConverter foreignConverter = this.dbConverter.getFeatureBeanConverter();
net.gdface.facelog.dborm.face.FlFeatureBean foreignNativeBean = foreignConverter.toRight(beanToSet);
this.nativeManager.setReferencedByVerifyFeature(nativeBean,foreignNativeBean);
this.beanConverter.fromRight(bean, nativeBean);
foreignConverter.fromRight(beanToSet,foreignNativeBean);
return beanToSet;
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//5.1 GET REFERENCED VALUE override ILogManager
@Override
public PersonBean getReferencedByPersonId(LogBean bean)
{
if(null == bean){
return null;
}
bean.setReferencedByPersonId(instanceOfPersonManager().loadByPrimaryKey(bean.getPersonId()));
return bean.getReferencedByPersonId();
}
//5.2 SET REFERENCED override ILogManager
@Override
public PersonBean setReferencedByPersonId(LogBean bean, PersonBean beanToSet)
{
try{
net.gdface.facelog.dborm.log.FlLogBean nativeBean = this.beanConverter.toRight(bean);
IBeanConverter foreignConverter = this.dbConverter.getPersonBeanConverter();
net.gdface.facelog.dborm.person.FlPersonBean foreignNativeBean = foreignConverter.toRight(beanToSet);
this.nativeManager.setReferencedByPersonId(nativeBean,foreignNativeBean);
this.beanConverter.fromRight(bean, nativeBean);
foreignConverter.fromRight(beanToSet,foreignNativeBean);
return beanToSet;
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//////////////////////////////////////
// SQL 'WHERE' METHOD
//////////////////////////////////////
//11
@Override
public int deleteByWhere(String where)
{
try{
return this.nativeManager.deleteByWhere(where);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//_____________________________________________________________________
//
// SAVE
//_____________________________________________________________________
//13
@Override
protected LogBean insert(LogBean bean)
{
try{
return this.beanConverter.fromRight(bean,this.nativeManager.insert(this.beanConverter.toRight(bean)));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//14
@Override
protected LogBean update(LogBean bean)
{
try{
return this.beanConverter.fromRight(bean,this.nativeManager.update(this.beanConverter.toRight(bean)));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//_____________________________________________________________________
//
// USING TEMPLATE
//_____________________________________________________________________
//18
@Override
public LogBean loadUniqueUsingTemplate(LogBean bean)
{
try{
return this.beanConverter.fromRight(this.nativeManager.loadUniqueUsingTemplate(this.beanConverter.toRight(bean)));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//18-1
@Override
public LogBean loadUniqueUsingTemplateChecked(LogBean bean) throws ObjectRetrievalException
{
try{
return this.beanConverter.fromRight(this.nativeManager.loadUniqueUsingTemplateChecked(this.beanConverter.toRight(bean)));
}
catch(net.gdface.facelog.dborm.exception.ObjectRetrievalException e)
{
throw new ObjectRetrievalException();
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//20-5
@Override
public int loadUsingTemplate(LogBean bean, int[] fieldList, int startRow, int numRows,int searchType, Action action)
{
try {
return this.nativeManager.loadUsingTemplate(this.beanConverter.toRight(bean),fieldList,startRow,numRows,searchType,this.toNative(action));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//21
@Override
public int deleteUsingTemplate(LogBean bean)
{
try{
return this.nativeManager.deleteUsingTemplate(this.beanConverter.toRight(bean));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//_____________________________________________________________________
//
// USING INDICES
//_____________________________________________________________________
// override ILogManager
@Override
public LogBean[] loadByIndexCompareFace(Integer compareFace)
{
return this.loadByIndexCompareFaceAsList(compareFace).toArray(new LogBean[0]);
}
// override ILogManager
@Override
public java.util.List loadByIndexCompareFaceAsList(Integer compareFace)
{
try{
return this.beanConverter.fromRight(this.nativeManager.loadByIndexCompareFaceAsList(compareFace));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
// override ILogManager
@Override
public int deleteByIndexCompareFace(Integer compareFace)
{
try{
return this.nativeManager.deleteByIndexCompareFace(compareFace);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
// override ILogManager
@Override
public LogBean[] loadByIndexDeviceId(Integer deviceId)
{
return this.loadByIndexDeviceIdAsList(deviceId).toArray(new LogBean[0]);
}
// override ILogManager
@Override
public java.util.List loadByIndexDeviceIdAsList(Integer deviceId)
{
try{
return this.beanConverter.fromRight(this.nativeManager.loadByIndexDeviceIdAsList(deviceId));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
// override ILogManager
@Override
public int deleteByIndexDeviceId(Integer deviceId)
{
try{
return this.nativeManager.deleteByIndexDeviceId(deviceId);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
// override ILogManager
@Override
public LogBean[] loadByIndexPersonId(Integer personId)
{
return this.loadByIndexPersonIdAsList(personId).toArray(new LogBean[0]);
}
// override ILogManager
@Override
public java.util.List loadByIndexPersonIdAsList(Integer personId)
{
try{
return this.beanConverter.fromRight(this.nativeManager.loadByIndexPersonIdAsList(personId));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
// override ILogManager
@Override
public int deleteByIndexPersonId(Integer personId)
{
try{
return this.nativeManager.deleteByIndexPersonId(personId);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
// override ILogManager
@Override
public LogBean[] loadByIndexVerifyFeature(String verifyFeature)
{
return this.loadByIndexVerifyFeatureAsList(verifyFeature).toArray(new LogBean[0]);
}
// override ILogManager
@Override
public java.util.List loadByIndexVerifyFeatureAsList(String verifyFeature)
{
try{
return this.beanConverter.fromRight(this.nativeManager.loadByIndexVerifyFeatureAsList(verifyFeature));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
// override ILogManager
@Override
public int deleteByIndexVerifyFeature(String verifyFeature)
{
try{
return this.nativeManager.deleteByIndexVerifyFeature(verifyFeature);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
/**
* Retrieves a list of LogBean using the index specified by keyIndex.
* @param keyIndex valid values:
* {@link Constant#FL_LOG_INDEX_COMPARE_FACE},{@link Constant#FL_LOG_INDEX_DEVICE_ID},{@link Constant#FL_LOG_INDEX_PERSON_ID},{@link Constant#FL_LOG_INDEX_VERIFY_FEATURE}
* @param keys key values of index
* @return a list of LogBean
*/
@Override
public java.util.List loadByIndexAsList(int keyIndex,Object ...keys)
{
try{
return this.beanConverter.fromRight(this.nativeManager.loadByIndexAsList(keyIndex,keys));
}catch(DaoException e){
throw new RuntimeDaoException(e);
}
}
/**
* Deletes rows using key.
* @param keyIndex valid values:
* {@link Constant#FL_LOG_INDEX_COMPARE_FACE},{@link Constant#FL_LOG_INDEX_DEVICE_ID},{@link Constant#FL_LOG_INDEX_PERSON_ID},{@link Constant#FL_LOG_INDEX_VERIFY_FEATURE}
* @param keys key values of index
* @return the number of deleted objects
*/
@Override
public int deleteByIndex(int keyIndex,Object ...keys)
{
try{
return this.nativeManager.deleteByIndex(keyIndex,keys);
}catch(DaoException e){
throw new RuntimeDaoException(e);
}
}
//_____________________________________________________________________
//
// COUNT
//_____________________________________________________________________
//25
@Override
public int countWhere(String where)
{
try{
return this.nativeManager.countWhere(where);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//20
@Override
public int countUsingTemplate(LogBean bean, int searchType)
{
try{
return this.nativeManager.countUsingTemplate(this.beanConverter.toRight(bean),searchType);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//_____________________________________________________________________
//
// LISTENER
//_____________________________________________________________________
//35
/**
* @return {@link WrapListener} instance
*/
@Override
public TableListener registerListener(TableListener listener)
{
WrapListener wrapListener;
if(listener instanceof WrapListener){
wrapListener = (WrapListener)listener;
this.nativeManager.registerListener(wrapListener.nativeListener);
}else{
wrapListener = new WrapListener(listener);
this.nativeManager.registerListener(wrapListener.nativeListener);
}
return wrapListener;
}
//36
@Override
public void unregisterListener(TableListener listener)
{
if(!(listener instanceof WrapListener)){
throw new IllegalArgumentException("invalid listener type: " + WrapListener.class.getName() +" required");
}
this.nativeManager.unregisterListener(((WrapListener)listener).nativeListener);
}
//37
@Override
public void fire(TableListener.Event event, LogBean bean){
fire(event.ordinal(), bean);
}
//37-1
@Override
public void fire(int event, LogBean bean){
try{
this.nativeManager.fire(event, this.beanConverter.toRight(bean));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
//37-2
/**
* bind foreign key listener to foreign table for DELETE RULE
*/
void bindForeignKeyListenerForDeleteRule(){
this.nativeManager.bindForeignKeyListenerForDeleteRule();
}
//37-3
/**
* unbind foreign key listener from all of foreign tables
* @see #bindForeignKeyListenerForDeleteRule()
*/
void unbindForeignKeyListenerForDeleteRule(){
this.nativeManager.unbindForeignKeyListenerForDeleteRule();
}
/**
* wrap {@code TableListener} as native listener
*/
public class WrapListener implements TableListener{
private final TableListener listener;
private final net.gdface.facelog.dborm.TableListener nativeListener;
private WrapListener(final TableListener listener) {
if(null == listener){
throw new NullPointerException();
}
this.listener = listener;
this.nativeListener = new net.gdface.facelog.dborm.TableListener (){
@Override
public void beforeInsert(net.gdface.facelog.dborm.log.FlLogBean bean) throws DaoException {
listener.beforeInsert(LogManager.this.beanConverter.fromRight(bean));
}
@Override
public void afterInsert(net.gdface.facelog.dborm.log.FlLogBean bean) throws DaoException {
listener.afterInsert(LogManager.this.beanConverter.fromRight(bean));
}
@Override
public void beforeUpdate(net.gdface.facelog.dborm.log.FlLogBean bean) throws DaoException {
listener.beforeUpdate(LogManager.this.beanConverter.fromRight(bean));
}
@Override
public void afterUpdate(net.gdface.facelog.dborm.log.FlLogBean bean) throws DaoException {
listener.afterUpdate(LogManager.this.beanConverter.fromRight(bean));
}
@Override
public void beforeDelete(net.gdface.facelog.dborm.log.FlLogBean bean) throws DaoException {
listener.beforeDelete(LogManager.this.beanConverter.fromRight(bean));
}
@Override
public void afterDelete(net.gdface.facelog.dborm.log.FlLogBean bean) throws DaoException {
listener.afterDelete(LogManager.this.beanConverter.fromRight(bean));
}
@Override
public void done() throws DaoException {
listener.done();
}};
}
@Override
public void beforeInsert(LogBean bean) {
listener.beforeInsert(bean);
}
@Override
public void afterInsert(LogBean bean) {
listener.afterInsert(bean);
}
@Override
public void beforeUpdate(LogBean bean) {
listener.beforeUpdate(bean);
}
@Override
public void afterUpdate(LogBean bean) {
listener.afterUpdate(bean);
}
@Override
public void beforeDelete(LogBean bean) {
listener.beforeDelete(bean);
}
@Override
public void afterDelete(LogBean bean) {
listener.afterDelete(bean);
}
@Override
public void done() {
listener.done();
}
}
//_____________________________________________________________________
//
// UTILS
//_____________________________________________________________________
//43
@Override
public boolean isPrimaryKey(String column){
return this.nativeManager.isPrimaryKey(column);
}
@Override
public int loadBySqlForAction(String sql, Object[] argList, int[] fieldList,int startRow, int numRows,Action action){
try{
return this.nativeManager.loadBySqlForAction(sql,argList,fieldList,startRow,numRows,this.toNative(action));
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
@Override
public T runAsTransaction(Callable fun) {
try{
return this.nativeManager.runAsTransaction(fun);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
@Override
public void runAsTransaction(Runnable fun) {
try{
this.nativeManager.runAsTransaction(fun);
}
catch(DaoException e)
{
throw new RuntimeDaoException(e);
}
}
private net.gdface.facelog.dborm.TableManager.Action toNative(final Action action){
if(null == action){
throw new NullPointerException();
}
return new net.gdface.facelog.dborm.TableManager.Action(){
@Override
public void call(net.gdface.facelog.dborm.log.FlLogBean bean) {
action.call(LogManager.this.beanConverter.fromRight(bean));
}
@Override
public net.gdface.facelog.dborm.log.FlLogBean getBean() {
return LogManager.this.beanConverter.toRight(action.getBean());
}};
}
//45 override ILogManager
@Override
public java.util.List toPrimaryKeyList(LogBean... beans){
if(null == beans){
return new java.util.ArrayList();
}
java.util.ArrayList list = new java.util.ArrayList(beans.length);
for(LogBean bean:beans){
list.add(null == bean ? null : bean.getId());
}
return list;
}
//46 override ILogManager
@Override
public java.util.List toPrimaryKeyList(java.util.Collection beans){
if(null == beans){
return new java.util.ArrayList();
}
java.util.ArrayList list = new java.util.ArrayList(beans.size());
for(LogBean bean:beans){
list.add(null == bean ? null : bean.getId());
}
return list;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy