package nc.impl.bd.bgy_esbinfo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import nc.bs.bd.baseservice.md.BatchBaseService;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.itf.bd.bgy_esbinfo.IBgy_esbinfoQryService;
import nc.itf.bd.bgy_esbinfo.IBgy_esbinfoService;
import nc.itf.bd.defdoc.IDefdocConst;
import nc.itf.bd.pub.IBDMetaDataIDConstBasic;
import nc.jdbc.framework.processor.ColumnListProcessor;
import nc.md.persist.framework.IMDPersistenceQueryService;
import nc.vo.ws.esb.EsbinfoVO;
import nc.vo.bd.meta.BatchOperateVO;
import nc.vo.pub.BusinessException;

/**
* <b>   </b>
*
* <p>
    *
    * </p>
*
* Create at 2009-12-25 上午09:31:57
*
* @author bq
* @since V6.0
*/

public class Bgy_esbinfoServiceImpl extends BatchBaseService<EsbinfoVO> implements IBgy_esbinfoService, IBgy_esbinfoQryService {

    private IMDPersistenceQueryService queryService=null;
    public Bgy_esbinfoServiceImpl() {
        super("b8c5198f-1e3f-4ec6-bc0a-988f8ea79f1d");
    }

    @Override
    public BatchOperateVO batchSaveCurrtype(BatchOperateVO vo) throws BusinessException {
        return batchSave(vo);
    }

    @Override
    public EsbinfoVO findByPK(String key) throws BusinessException {
        EsbinfoVO esbinfoVO = null;
        try {
            Object vo = new BaseDAO().retrieveByPK(EsbinfoVO.class, key);
            esbinfoVO = (vo == null ? null : (EsbinfoVO) vo);
        } catch (Exception e) {
            Logger.error(e.getMessage(), e);
            throw new BusinessException(e);
        }

        return esbinfoVO;
    }

    @SuppressWarnings("unchecked")
    @Override
    public EsbinfoVO[] queryAll() throws BusinessException {
        Collection<EsbinfoVO> col=getQueryService().queryBillOfVOByCondWithOrder(EsbinfoVO.class, "1=1", true, false, new String[]{});
        return col.toArray(new EsbinfoVO[0]);
    }

        @SuppressWarnings("unchecked")
        @Override
        public EsbinfoVO[] query(String where) throws BusinessException {
        Collection<EsbinfoVO> col=getQueryService().queryBillOfVOByCondWithOrder(EsbinfoVO.class, where, true, false, new String[]{});

            return col.toArray(new EsbinfoVO[0]);
            }
            private IMDPersistenceQueryService getQueryService()
            {
            if(queryService==null)
            queryService=NCLocator.getInstance().lookup(IMDPersistenceQueryService.class);
            return queryService;

            }

            @Override
            public String[] queryPKs(String where) throws BusinessException {
            String[] pks = null;
            StringBuilder querySQL = new StringBuilder("select ");
            querySQL.append(" pk_esbinfo ");
            querySQL.append(" from ");
            querySQL.append(" bgy_esbinfo ");
            querySQL.append(" where ");
            querySQL.append(where);
            querySQL.append(" order by ");
            querySQL.append(" ts ");

            List<String> pkList = (ArrayList<String>) new BaseDAO().executeQuery(
                    querySQL.toString(), new ColumnListProcessor());
                    if (pkList != null && pkList.size() > 0) {
                    pks = pkList.toArray(new String[pkList.size()]);
                    }

                    return pks;
                    }
        }
