- Validação na remoção/adição de tramos
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@21839 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
c2427f4950
commit
60c3414325
|
@ -36,12 +36,12 @@ import com.rjconsultores.ventaboletos.entidad.CoeficienteTarifa;
|
|||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoTramo;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
||||
import com.rjconsultores.ventaboletos.entidad.TramoKm;
|
||||
import com.rjconsultores.ventaboletos.entidad.TramoServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.TramoTiempo;
|
||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
import com.rjconsultores.ventaboletos.service.ClaseServicioService;
|
||||
import com.rjconsultores.ventaboletos.service.CoeficienteTarifaService;
|
||||
import com.rjconsultores.ventaboletos.service.EmpresaService;
|
||||
|
@ -70,7 +70,10 @@ import com.rjconsultores.ventaboletos.web.utilerias.render.RenderTramoTiempo;
|
|||
@Scope("prototype")
|
||||
public class EditarTramosController extends MyGenericForwardComposer {
|
||||
|
||||
private static Logger log = Logger.getLogger(EditarTramosController.class);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
private TramoService tramoService;
|
||||
@Autowired
|
||||
|
@ -135,7 +138,8 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|||
private Button btnApagar;
|
||||
private ConstraintNumberBD constraintTarifa;
|
||||
private Tab tabExcepcionesKm;
|
||||
private static Logger log = Logger.getLogger(EditarTramosController.class);
|
||||
|
||||
private boolean existeRutaOcupaTramo;
|
||||
|
||||
public Tramo getTramo() {
|
||||
return tramo;
|
||||
|
@ -219,6 +223,7 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
existeRutaOcupaTramo = false;
|
||||
lsVias = viaService.obtenerTodos();
|
||||
lsEmpresa = empresaService.obtenerTodos();
|
||||
lsClaseServicio = claseServicioService.buscarTodosExceto(-1);
|
||||
|
@ -239,6 +244,7 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|||
|
||||
tramo = (Tramo) Executions.getCurrent().getArg().get("tramo");
|
||||
if (tramo.getTramoId() != null) {
|
||||
existeRutaOcupaTramo = rutaCombinacionService.existeTramo(tramo);
|
||||
tramo = tramoService.obtenerID(tramo.getTramoId());
|
||||
|
||||
for (TramoServicio ta : tramo.getTramoServicioList()) {
|
||||
|
@ -513,8 +519,7 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|||
cmbParadaDestino.getValue(true);
|
||||
|
||||
if (listaTramoServicio.isEmpty()) {
|
||||
Messagebox.show(Labels.getLabel("editarTramosController.MSG.obligatorioTramoTiempo"),
|
||||
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
||||
Messagebox.show(Labels.getLabel("editarTramosController.MSG.obligatorioTramoTiempo"), Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
||||
Messagebox.INFORMATION);
|
||||
|
||||
return;
|
||||
|
@ -522,70 +527,21 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|||
|
||||
try {
|
||||
tramo.setLsOrgaoTramo(lsOrgamoTramo);
|
||||
|
||||
tramo.setActivo(Boolean.TRUE);
|
||||
tramo.setFecmodif(Calendar.getInstance().getTime());
|
||||
tramo.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
|
||||
Parada origem = tramo.getOrigem();
|
||||
Parada destino = tramo.getDestino();
|
||||
|
||||
tramo.setVia((Via) cmbVia.getSelectedItem().getValue());
|
||||
tramo.setLsTramoTiempo(listaTramosTiempo);
|
||||
tramo.setTramoServicioList(listaTramoServicio);
|
||||
tramo.setTramoKms(listaTramosKm);
|
||||
|
||||
if (!origem.getParadaId().equals(destino.getParadaId())) {
|
||||
Tramo tramoConsulta = tramoService.buscar(tramo.getOrigem(), tramo.getDestino(), tramo.getVia());
|
||||
|
||||
boolean podeSalvar = false;
|
||||
if (tramoConsulta == null) {
|
||||
podeSalvar = true;
|
||||
} else {
|
||||
if (tramoConsulta.getTramoId().equals(tramo.getTramoId())) {
|
||||
podeSalvar = true;
|
||||
}
|
||||
}
|
||||
if (podeSalvar) {
|
||||
if (tramo.getTramoId() == null) {
|
||||
|
||||
tramoService.suscribir(tramo);
|
||||
tramosList.addItem(tramo);
|
||||
|
||||
Messagebox.show(Labels.getLabel("editarTramosController.MSG.suscribirOK"),
|
||||
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
||||
Messagebox.INFORMATION);
|
||||
|
||||
closeWindow();
|
||||
|
||||
} else {
|
||||
tramoService.actualizacion(tramo);
|
||||
tramo = tramoService.suscribirActualizar(tramo);
|
||||
tramosList.updateItem(tramo);
|
||||
|
||||
Messagebox.show(Labels.getLabel("editarTramosController.MSG.suscribirOK"),
|
||||
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
||||
Messagebox.show(Labels.getLabel("editarTramosController.MSG.suscribirOK"), Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
||||
Messagebox.INFORMATION);
|
||||
|
||||
closeWindow();
|
||||
}
|
||||
} else {
|
||||
Messagebox.show(Labels.getLabel("MSG.Registro.Existe.Origem.Destino.Via"),
|
||||
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
||||
Messagebox.EXCLAMATION);
|
||||
}
|
||||
} else {
|
||||
Messagebox.show(Labels.getLabel("editarTramosController.MSG.OrigemDestinoIguais"),
|
||||
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK,
|
||||
Messagebox.EXCLAMATION);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof WrongValueException) {
|
||||
throw (WrongValueException) ex;
|
||||
}
|
||||
|
||||
log.error(ex);
|
||||
Messagebox.show(Labels.getLabel("MSG.Error"), Labels.getLabel("editarTramosController.window.title"),
|
||||
Messagebox.OK, Messagebox.ERROR);
|
||||
} catch (BusinessException ex) {
|
||||
Messagebox.show(ex.getLocalizedMessage(), Labels.getLabel("editarTramosController.window.title"), Messagebox.OK, Messagebox.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -676,13 +632,10 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|||
orgaoConcedente = (OrgaoConcedente) cbiOrgaoConcedente.getValue();
|
||||
claseServicio = (ClaseServicio) cbiClaseServicio.getValue();
|
||||
|
||||
|
||||
Integer kmCoeficiente1 = txtKMCoeficiente1.getValue();
|
||||
Integer kmCoeficiente2 = txtKMCoeficiente2.getValue();
|
||||
Integer kmCoeficiente3 = txtKMCoeficiente3.getValue();
|
||||
|
||||
|
||||
|
||||
if ((coeficienteTarifa1 == null) && (kmCoeficiente1 == null)) {
|
||||
|
||||
Messagebox.show(Labels.getLabel("editarTramosController.msg.coeficiente1Obligatorio"),
|
||||
|
@ -721,7 +674,6 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
if (orgaoClaseJahInformado) {
|
||||
Messagebox.show(Labels.getLabel("editarTramosController.msg.orgaoJahInformado"),
|
||||
Labels.getLabel("editarTramosController.window.title"), Messagebox.OK, Messagebox.EXCLAMATION);
|
||||
|
@ -756,4 +708,9 @@ public class EditarTramosController extends MyGenericForwardComposer {
|
|||
txtKMCoeficiente2.setValue(null);
|
||||
txtKMCoeficiente3.setValue(null);
|
||||
}
|
||||
|
||||
public boolean isExisteRutaOcupaTramo() {
|
||||
return existeRutaOcupaTramo;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ public class TarifaEscalaContorller extends MyGenericForwardComposer {
|
|||
log.debug("Inicio carga de combiaciones");
|
||||
for (RutaCombinacion rc : lsRutaCombinacion) {
|
||||
Tramo tramo = rc.getTramo();
|
||||
Tarifa tarifa = tarifaService.buscar(tramo, marca, claseServicio, vigenciaTarifa, moneda);
|
||||
Tarifa tarifa = tarifaService.buscar(tramo, marca, claseServicio, vigenciaTarifa, moneda, null);
|
||||
|
||||
if (tarifa == null) {
|
||||
tarifa = new Tarifa();
|
||||
|
|
|
@ -112,14 +112,19 @@ public class MyComboboxParada extends Combobox {
|
|||
this.setText(initialValue.getDescparada());
|
||||
}
|
||||
|
||||
public void getValue(boolean checaBusqueda) throws WrongValueException {
|
||||
/**
|
||||
*
|
||||
* @param checaBusqueda
|
||||
* @throws WrongValueException
|
||||
*/
|
||||
public String getValue(boolean checaBusqueda) throws WrongValueException {
|
||||
if (checaBusqueda) {
|
||||
if (this.getSelectedItem() == null) {
|
||||
throw new WrongValueException(this, Labels.getLabel("MSG.Error.combobox.hacerBusqueda"));
|
||||
}
|
||||
} else {
|
||||
super.getValue();
|
||||
}
|
||||
|
||||
return super.getValue();
|
||||
}
|
||||
|
||||
public boolean isSinTodos() {
|
||||
|
|
|
@ -3788,3 +3788,10 @@ configLayoutImpressaoBoletoController.layout.label = Layout
|
|||
configLayoutImpressaoBoletoController.campo.label = Campo
|
||||
configLayoutImpressaoBoletoController.coluna.label = Coluna
|
||||
configLayoutImpressaoBoletoController.linha.label = Linha
|
||||
|
||||
#TramoService
|
||||
tramoServiceImpl.msg.validacionVia=A via não pode ser alterada
|
||||
TramoServiceImpl.msg.validacionOrigen=A origem do trecho não pode ser alterada
|
||||
TramoServiceImpl.msg.validacionDestino=O destino do trecho não pode ser alterado
|
||||
TramoServiceImpl.msg.validacionTramoServicio=Não pode ser apagado o Tempo Geral de um Tipo de Classe que é usado em uma ruta
|
||||
TramoServiceImpl.msg.validacionTramoTiempo=Não pode ser apagado a Exceção de Tempo de um Tipo de Classe que é usado em uma ruta
|
|
@ -38,17 +38,17 @@
|
|||
</row>
|
||||
<row>
|
||||
<label value="${c:l('editarTramosController.labelOrigen.value')}" />
|
||||
<combobox id="cmbParadaOrigem" constraint="no empty" use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada" mold="rounded"
|
||||
<combobox id="cmbParadaOrigem" constraint="no empty" use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada" mold="rounded" disabled="@{winEditarTramos$composer.existeRutaOcupaTramo}"
|
||||
buttonVisible="true" width="80%" initialValue="@{winEditarTramos$composer.tramo.origem}" selectedItem="@{winEditarTramos$composer.tramo.origem}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${c:l('editarTramosController.labelDestino.value')}" />
|
||||
<combobox id="cmbParadaDestino" constraint="no empty" use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada" mold="rounded"
|
||||
<combobox id="cmbParadaDestino" constraint="no empty" use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada" mold="rounded" disabled="@{winEditarTramos$composer.existeRutaOcupaTramo}"
|
||||
buttonVisible="true" width="80%" initialValue="@{winEditarTramos$composer.tramo.destino}" selectedItem="@{winEditarTramos$composer.tramo.destino}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${c:l('editarTramosController.labelVia.value')}" />
|
||||
<combobox id="cmbVia" use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar" constraint="no empty" mold="rounded"
|
||||
<combobox id="cmbVia" use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar" constraint="no empty" mold="rounded" disabled="@{winEditarTramos$composer.existeRutaOcupaTramo}"
|
||||
buttonVisible="true" width="80%" model="@{winEditarTramos$composer.lsVias}" selectedItem="@{winEditarTramos$composer.tramo.via}" />
|
||||
</row>
|
||||
<!--row>
|
||||
|
|
Loading…
Reference in New Issue