public List<NetbookReparadasAnualmente> verNetbooksReparadasAnualmente(
      @Named("Año a Mostrar") int anio) {
    List<NetbookReparadasAnualmente> reparadas = new ArrayList<NetbookReparadasAnualmente>();
    List<SolicitudServicioTecnico> listaNetbooksReparadas =
        container.allMatches(
            QueryDefault.create(
                SolicitudServicioTecnico.class,
                "traerSolicitudesReparadas",
                "institucion",
                repositorioPersona.verMisDatos().getEstablecimiento()));
    int[] cantidadDeNetbooksReparadas = new int[13];
    // todas las pociciones del array en 0
    for (int i = 0; i < cantidadDeNetbooksReparadas.length; i++) {
      cantidadDeNetbooksReparadas[i] = 0;
    }
    // contamos cuantas netbooks se repararon en cada mes
    for (SolicitudServicioTecnico solicitud : listaNetbooksReparadas) {
      if (solicitud.isReparada() && solicitud.getFechaDeSolucion().getYear() == anio) {
        cantidadDeNetbooksReparadas[solicitud.getFechaDeSolicitud().getMonthOfYear() - 1]++;
      }
    }
    // Recorremos todos los meses y asignamos cuantas netbooks se repararon al web view
    for (Mes mes : Mes.values()) {
      Memento m = mementoService.create();
      BigDecimal variableTemporal = new BigDecimal(cantidadDeNetbooksReparadas[mes.ordinal()]);
      m.set("mes", mes);
      m.set("cantidadNetbookReparadas", variableTemporal);
      reparadas.add(container.newViewModelInstance(NetbookReparadasAnualmente.class, m.asString()));
    }

    return reparadas;
  }
Example #2
0
 public void hintsToPageParameters(Map<String, String> hints, PageParameters pageParameters) {
   if (hints.isEmpty()) {
     return;
   }
   MementoServiceDefault vms = new MementoServiceDefault();
   Memento memento = vms.create();
   Set<String> hintKeys = hints.keySet();
   for (String key : hintKeys) {
     String safeKey = key.replace(':', '_');
     Serializable value = hints.get(key);
     memento.set(safeKey, value);
   }
   String serializedHints = memento.asString();
   PageParameterNames.ANCHOR.addStringTo(pageParameters, serializedHints);
 }
Example #3
0
 public void pageParametersToHints(
     final PageParameters pageParameters, Map<String, String> hints) {
   String hintsStr = PageParameterNames.ANCHOR.getStringFrom(pageParameters);
   if (hintsStr != null) {
     try {
       Memento memento = new MementoServiceDefault().parse(hintsStr);
       Set<String> keys = memento.keySet();
       for (String safeKey : keys) {
         String value = memento.get(safeKey, String.class);
         String key = safeKey.replace('_', ':');
         hints.put(key, value);
       }
     } catch (RuntimeException ex) {
       // fail gracefully, ie ignore.
       System.err.println(ex);
     }
   }
 }