package com.fitbank.migrationdb.term; import java.util.List; import com.fitbank.common.Helper; import com.fitbank.common.RequestData; import com.fitbank.common.conectivity.HbSession; import com.fitbank.common.hb.UtilHB; import com.fitbank.common.logger.FitbankLogger; import com.fitbank.dto.GeneralRequest; import com.fitbank.dto.management.Detail; import com.fitbank.hb.persistence.acco.Taccount; import com.fitbank.migrationdb.common.MonitorThreads; public class MigrationCommand extends Thread { /** * Referencia a la petición de Ejecución */ private GeneralRequest request; public MigrationCommand(Detail pDetail) throws Exception { request = pDetail; } @Override public void run() { try { RequestData.setSession((Detail) request); Helper.setSession(HbSession.getInstance().openSession()); Helper.beginTransaction(); this.process(); Helper.commitTransaction(); } catch (Exception e) { FitbankLogger.getLogger().error(e.getMessage()); } finally { try { Helper.rollbackTransaction(); } catch (Exception e) { FitbankLogger.getLogger().error(e); } Helper.closeSession(); } } private void process() throws Exception { MonitorThreads mh = new MonitorThreads(); List listTaccount = getAccounts(); FitbankLogger.getLogger().error( "CUENTAS A PROCESAR: " + listTaccount.size()); if (listTaccount != null) { for (Taccount taccount : listTaccount) { try { mh.addCounter(); Provision provision = new Provision(request, taccount, mh); provision.start(); } catch (Exception e) { FitbankLogger.getLogger().error(e.getMessage()); } } } } private static final String HQL_ACCOUNTS = "from Taccount t where t.pk.fhasta = fncfhasta and t.csubsistema = '05' " + "and t.cestatuscuenta = '002' "; @SuppressWarnings("unchecked") private List getAccounts() throws Exception { UtilHB utilHB = new UtilHB(HQL_ACCOUNTS); return utilHB.getList(); } }