diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/GerarConexionPorRutaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/GerarConexionPorRutaController.java index 7ba71c755..4ecc6d57b 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/GerarConexionPorRutaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/GerarConexionPorRutaController.java @@ -125,12 +125,6 @@ public class GerarConexionPorRutaController extends MyGenericForwardComposer { conexionRutaConf = (ConexionRutaConf) Executions.getCurrent().getArg().get("conexionRutaConf"); conexionRutaConfList = (MyListbox) Executions.getCurrent().getArg().get("conexionRutaConfList"); - Set lsParadasOrigemA = new HashSet(); - Set lsParadasTodasOrigemA = new HashSet(); - Set lsParadasDestinoB = new HashSet(); - Set lsParadasTodasDestinoB = new HashSet(); - Set lsParadasDestinoC = new HashSet(); - Set lsParadasTodasDestinoC = new HashSet(); if (conexionRutaConf != null) { @@ -141,46 +135,23 @@ public class GerarConexionPorRutaController extends MyGenericForwardComposer { txtTiempoMin.setValue(conexionRutaConf.getTiempoMin()); txtTiempoMax.setValue(conexionRutaConf.getTiempoMax()); - for (ConexionRutaExcepcionPtoVta conexionRutaExcepcionPtoVta : conexionRutaRestricaoPtoVtaService.buscarPorConexionConf(conexionRutaConf)) { - listPuntoVenta.addItemNovo(conexionRutaExcepcionPtoVta.getPuntoVenta()); - } - for (ConexionRutaExcepcionTipoPtoVta conexionRutaExcepcionTipoPtoVta: conexionRutaExcepcionTipoPtoVtaService.buscarPorConexionConf(conexionRutaConf)) { - listEspCanal.addItemNovo(conexionRutaExcepcionTipoPtoVta.getTipoPtovta()); - } - - List> rutas = conexionRutaConfService.buscarRutasPorConexionConf(conexionRutaConf.getConexionRutaConfId()); - List lsRutaA = rutas.get(0); - List lsRutaB = rutas.get(1); - List lsRutaC = rutas.get(2); + configuraExcecaoPorPontoVenda(); - lsParadasOrigemA.addAll(conexionRutaTramoCtrlService.buscarLocalidadesOrigem(conexionRutaConf.getConexionRutaConfId())); - lsParadasDestinoB.addAll(conexionRutaTramoCtrlService.buscarLocalidadesDestino(conexionRutaConf.getConexionRutaConfId())); - lsParadasDestinoC.addAll(conexionRutaTramoCtrlService.buscarLocalidadesDestinoC(conexionRutaConf.getConexionRutaConfId())); + configuraExcecaoPorTipoVenda(); - lsParadasTodasOrigemA.addAll(conexionRutaTramoCtrlService.buscarTodasLocalidadesOrigem(conexionRutaConf.getConexionRutaConfId())); - lsParadasTodasOrigemA.removeAll(lsParadasOrigemA); - - lsParadasTodasDestinoB.addAll(conexionRutaTramoCtrlService.buscarTodasLocalidadesDestino(conexionRutaConf.getConexionRutaConfId())); - lsParadasTodasDestinoB.removeAll(lsParadasDestinoB); - - lsParadasTodasDestinoC.addAll(conexionRutaTramoCtrlService.buscarTodasLocalidadesDestinoC(conexionRutaConf.getConexionRutaConfId())); - lsParadasTodasDestinoC.removeAll(lsParadasDestinoC); - - localidadesLinhaASelecionadaList.setData(new ArrayList(lsParadasOrigemA)); - localidadesOrigemlList.setData(new ArrayList(lsParadasTodasOrigemA)); - localidadesLinhaBSelecionadaList.setData(new ArrayList(lsParadasDestinoB)); - localidadesDestinoList.setData(new ArrayList(lsParadasTodasDestinoB)); - localidadesLinhaCSelecionadaList.setData(new ArrayList(lsParadasDestinoC)); - localidadesDestinoLinhaCList.setData(new ArrayList(lsParadasTodasDestinoC)); + configuraRutasPorEixo(); + + //Eixo A + configuraLocalidadesEixoA(); + + //Eixo B + configuraLocalidadesEixoB(); + + //Eixo C + configuraLocalidadesEixoC(); - executarPesquisaLocalidadesOrigen(); - executarPesquisaLocalidadesDestino(); - executarPesquisaLocalidadesDestinoLinhasC(); - rutasAList.setData(lsRutaA); - rutasBList.setData(lsRutaB); - rutasCList.setData(lsRutaC); gerarCombinacao(true); }else{ @@ -188,23 +159,37 @@ public class GerarConexionPorRutaController extends MyGenericForwardComposer { btnApagar.setDisabled(true); } - localidadesLinhaASelecionadaList.setItemRenderer(new RenderConexionRutaRemoveSelecionada(new EventListener() { + configuraRendererListaLocalidadesSelecionadasEixoA(); + + configuraRendererListaLocalidadesSelecionadasEixoB(); + + configuraRendererListaLocalidadesSelecionadasEixoC(); + + resultadoCombinacao.setSelected(false); + + } + + private void configuraRendererListaLocalidadesSelecionadasEixoC() { + localidadesLinhaCSelecionadaList.setItemRenderer(new RenderConexionRutaRemoveSelecionada(new EventListener() { @Override public void onEvent(Event arg0) throws Exception { Parada conexionRutaVO = (Parada) arg0.getTarget().getAttribute("data"); - for (Object objectParada : localidadesLinhaASelecionadaList.getListData()) { + for (Object objectParada : localidadesLinhaCSelecionadaList.getListData()) { if (((Parada) objectParada).equals(conexionRutaVO)) { - localidadesLinhaASelecionadaList.removeItem(conexionRutaVO); - if(!localidadesOrigemlList.getListData().contains(conexionRutaVO)) { - localidadesOrigemlList.addItemNovo(conexionRutaVO); + localidadesLinhaCSelecionadaList.removeItem(conexionRutaVO); + if(!localidadesDestinoLinhaCList.getListData().contains(conexionRutaVO)) { + localidadesDestinoLinhaCList.addItemNovo(conexionRutaVO); } break; } } } })); + } + + private void configuraRendererListaLocalidadesSelecionadasEixoB() { localidadesLinhaBSelecionadaList.setItemRenderer(new RenderConexionRutaRemoveSelecionada(new EventListener() { @Override @@ -223,26 +208,107 @@ public class GerarConexionPorRutaController extends MyGenericForwardComposer { gerarLocalidadesComunsBC(); } })); - localidadesLinhaCSelecionadaList.setItemRenderer(new RenderConexionRutaRemoveSelecionada(new EventListener() { + } + + private void configuraRendererListaLocalidadesSelecionadasEixoA() { + localidadesLinhaASelecionadaList.setItemRenderer(new RenderConexionRutaRemoveSelecionada(new EventListener() { @Override public void onEvent(Event arg0) throws Exception { Parada conexionRutaVO = (Parada) arg0.getTarget().getAttribute("data"); - for (Object objectParada : localidadesLinhaCSelecionadaList.getListData()) { + for (Object objectParada : localidadesLinhaASelecionadaList.getListData()) { if (((Parada) objectParada).equals(conexionRutaVO)) { - localidadesLinhaCSelecionadaList.removeItem(conexionRutaVO); - if(!localidadesDestinoLinhaCList.getListData().contains(conexionRutaVO)) { - localidadesDestinoLinhaCList.addItemNovo(conexionRutaVO); + localidadesLinhaASelecionadaList.removeItem(conexionRutaVO); + if(!localidadesOrigemlList.getListData().contains(conexionRutaVO)) { + localidadesOrigemlList.addItemNovo(conexionRutaVO); } break; } } } })); - - resultadoCombinacao.setSelected(false); - + } + + /** + * Configura localidades eixo C + * @throws InterruptedException + */ + private void configuraLocalidadesEixoC() throws InterruptedException { + Set lsParadasTodasPossiveisEixoC = new HashSet(); + Set lsParadasCadastradasEixoC = new HashSet(); + lsParadasCadastradasEixoC.addAll(conexionRutaTramoCtrlService.buscarLocalidadesEixoC(conexionRutaConf.getConexionRutaConfId())); + lsParadasTodasPossiveisEixoC.addAll(conexionRutaTramoCtrlService.buscarTodasLocalidadesDestinoC(conexionRutaConf.getConexionRutaConfId())); + lsParadasTodasPossiveisEixoC.removeAll(lsParadasCadastradasEixoC); + localidadesLinhaCSelecionadaList.setData(new ArrayList(lsParadasCadastradasEixoC)); + localidadesDestinoLinhaCList.setData(new ArrayList(lsParadasTodasPossiveisEixoC)); + executarPesquisaLocalidadesDestinoLinhasC(); + } + + /** + * Configura localidades eixo B + * @throws InterruptedException + */ + private void configuraLocalidadesEixoB() throws InterruptedException { + Set lsParadasTodasPossiveisEixoB = new HashSet(); + Set lsParadasCadastradasEixoB = new HashSet(); + lsParadasCadastradasEixoB.addAll(conexionRutaTramoCtrlService.buscarLocalidadeEixoB(conexionRutaConf.getConexionRutaConfId())); + lsParadasTodasPossiveisEixoB.addAll(conexionRutaTramoCtrlService.buscarTodasLocalidadesDestino(conexionRutaConf.getConexionRutaConfId())); + lsParadasTodasPossiveisEixoB.removeAll(lsParadasCadastradasEixoB); + localidadesLinhaBSelecionadaList.setData(new ArrayList(lsParadasCadastradasEixoB)); + localidadesDestinoList.setData(new ArrayList(lsParadasTodasPossiveisEixoB)); + executarPesquisaLocalidadesDestino(); + } + + /** + * Configura localidades eixo A + * @throws InterruptedException + */ + private void configuraLocalidadesEixoA() throws InterruptedException { + Set lsParadasTodasPossiveisEixoA = new HashSet(); + Set lsParadasCadastradasEixoA = new HashSet(); + lsParadasCadastradasEixoA.addAll(conexionRutaTramoCtrlService.buscarLocalidadesEixoA(conexionRutaConf.getConexionRutaConfId())); + lsParadasTodasPossiveisEixoA.addAll(conexionRutaTramoCtrlService.buscarTodasLocalidadesOrigem(conexionRutaConf.getConexionRutaConfId())); + lsParadasTodasPossiveisEixoA.removeAll(lsParadasCadastradasEixoA); + localidadesLinhaASelecionadaList.setData(new ArrayList(lsParadasCadastradasEixoA)); + localidadesOrigemlList.setData(new ArrayList(lsParadasTodasPossiveisEixoA)); + executarPesquisaLocalidadesOrigen(); + } + + /** + * Configura as rutas (linhas) para cada eixo + */ + private void configuraRutasPorEixo() { + //Busca uma lista de linhas (rutas), esta lista contem 3 sub-listas (1 para cada eixo de conexão A, B e C) + List> rutas = conexionRutaConfService.buscarRutasPorConexionConf(conexionRutaConf.getConexionRutaConfId()); + List lsRutaA = rutas.get(0); + List lsRutaB = rutas.get(1); + List lsRutaC = rutas.get(2); + rutasAList.setData(lsRutaA); + rutasBList.setData(lsRutaB); + rutasCList.setData(lsRutaC); + } + + /** + * Configura a lista de exceções por tipo de venda (canal de venda) + */ + private void configuraExcecaoPorTipoVenda() { + //Busca a lista de exceções por tipo de venda (canal de venda) + List conexionRutaExcepcionTipoPtoVtaList = conexionRutaExcepcionTipoPtoVtaService.buscarPorConexionConf(conexionRutaConf); + for (ConexionRutaExcepcionTipoPtoVta conexionRutaExcepcionTipoPtoVta:conexionRutaExcepcionTipoPtoVtaList ) { + listEspCanal.addItemNovo(conexionRutaExcepcionTipoPtoVta.getTipoPtovta()); + } + } + + /** + * Configura a lista de exceções por ponto de venda + */ + private void configuraExcecaoPorPontoVenda() { + //Busca a lista de exceções por ponto de venda + List conexionRutaExcepcionPtoVtaList = conexionRutaRestricaoPtoVtaService.buscarPorConexionConf(conexionRutaConf); + for (ConexionRutaExcepcionPtoVta conexionRutaExcepcionPtoVta : conexionRutaExcepcionPtoVtaList) { + listPuntoVenta.addItemNovo(conexionRutaExcepcionPtoVta.getPuntoVenta()); + } } @SuppressWarnings("unchecked") @@ -311,6 +377,7 @@ public class GerarConexionPorRutaController extends MyGenericForwardComposer { public void onClick$btnPesquisaLocalidadesDestino(Event ev) throws InterruptedException { executarPesquisaLocalidadesDestino(); } + public void renderizarLinhasAB() { localidadesComunsList.setItemRenderer(new RenderEixoConexionRutaRemoveSelecionada(new EventListener() { @@ -687,6 +754,7 @@ public class GerarConexionPorRutaController extends MyGenericForwardComposer { } } + @SuppressWarnings("unchecked") public void onClick$btnNovoRutaB(Event ev) throws InterruptedException { if (!validarLinhaJaSelecionada()) { @@ -710,7 +778,6 @@ public class GerarConexionPorRutaController extends MyGenericForwardComposer { if(rutaB.getRutaId() == -1){ rutasBList.clear(); }else { - @SuppressWarnings("unchecked") List canaisVenta = rutasBList.getListData(); for (Ruta rutaAux : canaisVenta) { if(rutaB.getRutaId() == -1){ @@ -761,6 +828,7 @@ public class GerarConexionPorRutaController extends MyGenericForwardComposer { } } } + @SuppressWarnings("unchecked") public void onClick$btnNovoRutaC(Event ev) throws InterruptedException { @@ -785,7 +853,6 @@ public class GerarConexionPorRutaController extends MyGenericForwardComposer { if(rutaC.getRutaId() == -1){ rutasCList.clear(); }else { - @SuppressWarnings("unchecked") List canaisVenta = rutasCList.getListData(); for (Ruta rutaAux : canaisVenta) { if(rutaC.getRutaId() == -1){