Example #1
0
 private void btnNuevoAction() {
   entity = new Discapacidad();
   SwingUtil.resetJComponets(abmPanel.getComponents());
   abmPanel.getCbInstitucion().requestFocusInWindow();
   @SuppressWarnings("unchecked")
   ComboBoxWrapper<UsuarioSector> cbw =
       (ComboBoxWrapper<UsuarioSector>) abmPanel.getCbInstitucion().getSelectedItem();
   UsuarioSector us = cbw.getEntity();
   abmPanel
       .getjBarcodeBean1()
       .setCode(
           us.getInstitucion().getId() + "-" + us.getSector().getSectorUI().getCode() + "-xxxxxx");
   customABMJDialog.setPanelComponentsEnabled(true);
   customABMJDialog.setEnabledBottomButtons(true);
 }
Example #2
0
 private void setEntity(boolean cerrarYPrecintar) throws MessageException {
   if (entity.getDetalle() == null || entity.getDetalle().isEmpty()) {
     throw new MessageException(
         "Debe contener al menos un detalle (No vas a mandar la caja vacía..)");
   }
   if (cerrarYPrecintar) {
     List<String> codigoPrecintos = SGDUtilities.initPrecintosUI(customABMJDialog);
     if (codigoPrecintos.isEmpty()) {
       throw new MessageException(SGD.getResources().getString("cargaprecintoscancelada"));
     }
     for (String codigo : codigoPrecintos) {
       entity.getPrecintos().add(new DiscapacidadPrecinto(codigo, entity));
     }
   }
   if (entity.getId() == null) {
     @SuppressWarnings("unchecked")
     ComboBoxWrapper<UsuarioSector> cb =
         (ComboBoxWrapper<UsuarioSector>) abmPanel.getCbInstitucion().getSelectedItem();
     entity.setInstitucion(cb.getEntity().getInstitucion());
     entity.setSector(cb.getEntity().getSector());
     entity.setUsuario(UsuarioController.getCurrentUser());
   }
 }
Example #3
0
 private String armarQuery() {
   StringBuilder sb =
       new StringBuilder(
           "SELECT o FROM "
               + DiscapacidadDetalle.class.getSimpleName()
               + " o "
               + " WHERE o.id is not null ");
   Map<String, Object> data = buscadorPanel.getData();
   sb.append("AND o.discapacidad.baja = ").append(data.get("baja"));
   if (data.get("i") != null) {
     @SuppressWarnings("unchecked")
     ComboBoxWrapper<UsuarioSector> cb = (ComboBoxWrapper<UsuarioSector>) data.get("i");
     sb.append(" AND o.discapacidad.institucion.id = ")
         .append(cb.getEntity().getInstitucion().getId());
   } else {
     List<Institucion> institucionesList =
         new UsuarioSectorJPAController().findInstituciones(UsuarioController.getCurrentUser());
     Iterator<Institucion> it = institucionesList.iterator();
     sb.append(" AND (");
     while (it.hasNext()) {
       Institucion institucion = it.next();
       sb.append(" o.discapacidad.institucion.id = ").append(institucion.getId());
       if (it.hasNext()) {
         sb.append(" OR ");
       }
     }
     sb.append(") ");
   }
   if (data.get("td") != null) {
     @SuppressWarnings("unchecked")
     ComboBoxWrapper<TipoDocumento> cb = (ComboBoxWrapper<TipoDocumento>) data.get("td");
     sb.append(" AND o.tipoDocumento.id = ").append(cb.getEntity().getId());
   }
   if (data.get("std") != null) {
     @SuppressWarnings("unchecked")
     ComboBoxWrapper<SubTipoDocumento> cb = (ComboBoxWrapper<SubTipoDocumento>) data.get("std");
     sb.append(" AND o.subTipoDocumento.id = ").append(cb.getEntity().getId());
   }
   if (data.get("desde") != null) {
     sb.append(" AND o.")
         .append(DiscapacidadDetalle_.documentoFecha.getName())
         .append(">='")
         .append(UTIL.yyyy_MM_dd.format((Date) data.get("desde")))
         .append("'");
   }
   if (data.get("hasta") != null) {
     sb.append(" AND o.documentoFecha <='")
         .append(UTIL.yyyy_MM_dd.format(data.get("hasta")))
         .append("'");
   }
   if (data.get("apenom").toString().length() > 0) {
     String[] split = data.get("apenom").toString().toUpperCase().split(" ");
     sb.append(" AND ( UPPER(CONCAT(o.apellido, o.nombre)) like '%").append(split[0]).append("%'");
     if (split.length > 1) {
       split = Arrays.copyOfRange(split, 1, split.length);
       for (String c : split) {
         sb.append(" AND (UPPER(CONCAT(o.apellido, o.nombre)) like '%").append(c).append("%') ");
       }
     }
     sb.append(")");
   }
   if (data.get("documentonumero").toString().length() > 0) {
     Long nf = Long.valueOf(data.get("documentonumero").toString());
     sb.append(" AND o.")
         .append(DiscapacidadDetalle_.documentoNumero.getName())
         .append(" = ")
         .append(nf);
   }
   if (!data.get("periodo").toString().isEmpty()) {
     try {
       Integer nf = Integer.valueOf(data.get("periodo").toString());
       sb.append(" AND o.")
           .append(DiscapacidadDetalle_.periodoYear.getName())
           .append(" = ")
           .append(nf);
     } catch (NumberFormatException ex) {
       // que se joda por poner cualquier cosa..
     }
   }
   if (!data.get("observacion").toString().isEmpty()) {
     sb.append(" AND UPPER(o.")
         .append(DiscapacidadDetalle_.observacion.getName())
         .append(") like '%")
         .append(data.get("observacion").toString().toUpperCase())
         .append("%'");
   }
   if (!data.get("caja").toString().isEmpty()) {
     sb.append(" AND o.discapacidad.codigo=").append(data.get("caja"));
   }
   Logger.getLogger(this.getClass()).trace(sb.toString());
   return sb.toString();
 }
Example #4
0
  private DiscapacidadDetalle getDetalle(Map<String, Object> data) throws MessageException {
    TipoDocumento td;
    SubTipoDocumento std;
    Long numeroDocumento = null;
    Integer periodoYear;
    String apellido;
    String nombre;
    Date documentoFecha;
    String observacion;

    try {
      @SuppressWarnings("unchecked")
      ComboBoxWrapper<TipoDocumento> cb = (ComboBoxWrapper<TipoDocumento>) data.get("td");
      td = cb.getEntity();
    } catch (Exception e) {
      throw new MessageException("Tipo de Documento no válido");
    }
    try {
      @SuppressWarnings("unchecked")
      ComboBoxWrapper<SubTipoDocumento> cbs = (ComboBoxWrapper<SubTipoDocumento>) data.get("std");
      std = cbs.getEntity();
    } catch (ClassCastException e) {
      std = null;
    }

    try {
      if (!data.get("documentonumero").toString().isEmpty()) {
        numeroDocumento = Long.valueOf(data.get("documentonumero").toString());
      }
    } catch (NumberFormatException numberFormatException) {
      throw new MessageException("Número de documento no válido (ingrese solo números)");
    }
    try {
      periodoYear = Integer.valueOf(data.get("periodo").toString());
    } catch (NumberFormatException numberFormatException) {
      throw new MessageException("Número de carpeta no válido (ingrese solo números)");
    }
    apellido = (String) data.get("apellido");
    if (apellido.isEmpty()) {
      apellido = null;
    }
    nombre = (String) data.get("nombre");
    if (nombre.isEmpty()) {
      nombre = null;
    }
    documentoFecha = (Date) data.get("documentofecha");
    observacion = (String) data.get("observacion");
    if (observacion.isEmpty()) {
      observacion = null;
    }
    DiscapacidadDetalle detalle =
        new DiscapacidadDetalle(
            entity.getNextOrderIndex(),
            td,
            std,
            entity,
            numeroDocumento,
            documentoFecha,
            periodoYear,
            apellido,
            nombre,
            observacion);
    return detalle;
  }