Advertisement
Guest User

Untitled

a guest
Jun 8th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.23 KB | None | 0 0
  1.             cod match{
  2.                 case x: Int if(x != 200) => {Ok(views.html.forecastIndex(usuario, Left("Cidade não encontrada")))}
  3.                 case 200 => {
  4.                     val cidadeEncontrada: String = (jsonResp \ "city" \ "name").as[String]
  5.                     val paisEncontrado: String = (jsonResp \ "city" \ "country").as[String]
  6.                     val lista = (jsonResp \ "list").asInstanceOf[JsArray].value.tail
  7.                     val arrayPrevisoes = for(previsao <- lista)    
  8.                     yield{
  9.                         val weather = (previsao \ "weather").asInstanceOf[JsArray](0)
  10.                         val icon = (weather \ "icon").as[String]
  11.                         val url_icon = s"http://openweathermap.org/img/w/$icon.png"
  12.                         val data = formato.format(new java.util.Date(1000L * (previsao \ "dt").as[Long]))
  13.                         val descricao = (weather \ "description").as[String]
  14.                         val temperaturaMinima = (previsao \ "temp" \ "min").as[Float]
  15.                         val temperaturaMaxima = (previsao \ "temp" \ "max").as[Float]
  16.                         val umidade = (previsao \ "clouds").as[Float]
  17.                         new Previsao(url_icon, data, descricao, temperaturaMinima, temperaturaMaxima, umidade)
  18.                     }
  19.                     val resultadoPrevisao = new ResultadoPrevisao(cidadeEncontrada, paisEncontrado, arrayPrevisoes)
  20.                     Ok(views.html.forecastIndex(usuario, Right(resultadoPrevisao)))
  21.                 }                    
  22.             }
  23.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement