Exemple #1
0
  private Notificacion armarNotificacion(ResultSet rs) {
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Notificacion n = new Notificacion();
    try {
      n.setId(rs.getInt("id"));
      n.setFecha_envio(format.parse(rs.getString("fecha_envio")));
      n.setFecha_recepcion(format.parse(rs.getString("fecha_recepcion")));
      n.setContenido(rs.getString("contenido"));
      n.setContexto(rs.getString("contexto"));
      n.setNinio(rs.getString("ninio"));
      n.setCategoria(rs.getString("categoria"));

      // agregar etiquetas
      Statement st2 = connect.createStatement();
      ResultSet rs2;
      ArrayList<String> etiquetas = new ArrayList<String>();
      rs2 =
          st2.executeQuery(
              "SELECT * FROM notificacion_etiqueta, etiquetas WHERE notificacion_id = "
                  + n.getId()
                  + " AND notificacion_etiqueta.etiqueta_id = etiquetas.id");
      while (rs2.next()) {
        etiquetas.add(rs2.getString("texto"));
      }

      n.setEtiquetas(etiquetas);

    } catch (SQLException | ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return n;
  };