├── 00WeatherApi00 ├── target │ ├── classes │ │ ├── application.properties │ │ ├── com │ │ │ └── example │ │ │ │ └── main │ │ │ │ ├── models │ │ │ │ ├── Date.class │ │ │ │ ├── Main.class │ │ │ │ ├── Time.class │ │ │ │ ├── Today.class │ │ │ │ ├── Example.class │ │ │ │ ├── Weather.class │ │ │ │ ├── TodaysWeather.class │ │ │ │ └── ForecastWeather.class │ │ │ │ ├── services │ │ │ │ └── WeatherService.class │ │ │ │ ├── SpringWeatherApplication.class │ │ │ │ └── controller │ │ │ │ └── WeatherController.class │ │ └── META-INF │ │ │ ├── maven │ │ │ └── pl.kamilbiernacki │ │ │ │ └── springWeather │ │ │ │ ├── pom.properties │ │ │ │ └── pom.xml │ │ │ └── MANIFEST.MF │ └── test-classes │ │ └── com │ │ └── example │ │ └── demo │ │ └── ApplicationTests.class ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── main │ │ │ ├── SpringWeatherApplication.java │ │ │ ├── controller │ │ │ └── WeatherController.java │ │ │ ├── models │ │ │ ├── TodaysWeather.java │ │ │ ├── Date.java │ │ │ ├── Time.java │ │ │ ├── Example.java │ │ │ ├── ForecastWeather.java │ │ │ ├── Weather.java │ │ │ ├── Main.java │ │ │ └── Today.java │ │ │ └── services │ │ │ └── WeatherService.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── demo │ │ └── ApplicationTests.java ├── pom.xml ├── mvnw.cmd └── mvnw └── README.md /00WeatherApi00/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | spring.jackson.serialization.write-dates-as-timestamps:false -------------------------------------------------------------------------------- /00WeatherApi00/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jackson.serialization.write-dates-as-timestamps:false -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/models/Date.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/models/Date.class -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/models/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/models/Main.class -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/models/Time.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/models/Time.class -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/models/Today.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/models/Today.class -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/models/Example.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/models/Example.class -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/models/Weather.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/models/Weather.class -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/models/TodaysWeather.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/models/TodaysWeather.class -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/models/ForecastWeather.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/models/ForecastWeather.class -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/services/WeatherService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/services/WeatherService.class -------------------------------------------------------------------------------- /00WeatherApi00/target/test-classes/com/example/demo/ApplicationTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/test-classes/com/example/demo/ApplicationTests.class -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/SpringWeatherApplication.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/SpringWeatherApplication.class -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/com/example/main/controller/WeatherController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anujpanveli/Spring-Boot-Weather-App/HEAD/00WeatherApi00/target/classes/com/example/main/controller/WeatherController.class -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spring-Boot-Weather-App 2 | A Spring Boot app that consumes weather and forecast data from openwethermap api and displays output in the form of json. 3 | 4 | Please paste your api key in the url of the service class 5 | -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/META-INF/maven/pl.kamilbiernacki/springWeather/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven Integration for Eclipse 2 | #Thu Jan 10 12:24:05 IST 2019 3 | version=0.0.1-SNAPSHOT 4 | groupId=pl.kamilbiernacki 5 | m2e.projectName=00WeatherApi00 6 | m2e.projectLocation=C\:\\Users\\AnujPanveli\\eclipse-workspace\\00WeatherApi00 7 | artifactId=springWeather 8 | -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/SpringWeatherApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.main; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringWeatherApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringWeatherApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Implementation-Title: springWeather 3 | Implementation-Version: 0.0.1-SNAPSHOT 4 | Built-By: AnujPanveli 5 | Implementation-Vendor-Id: pl.kamilbiernacki 6 | Build-Jdk: 1.8.0_191 7 | Implementation-URL: http://projects.spring.io/spring-boot/springWeathe 8 | r/ 9 | Created-By: Maven Integration for Eclipse 10 | Implementation-Vendor: Pivotal Software, Inc. 11 | 12 | -------------------------------------------------------------------------------- /00WeatherApi00/src/test/java/com/example/demo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/controller/WeatherController.java: -------------------------------------------------------------------------------- 1 | package com.example.main.controller; 2 | 3 | import java.text.ParseException; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | 12 | import com.example.main.models.Example; 13 | 14 | import com.example.main.services.WeatherService; 15 | 16 | 17 | @RestController 18 | public class WeatherController { 19 | 20 | private final WeatherService weatherService; 21 | 22 | @Autowired 23 | public WeatherController(WeatherService weatherService) { 24 | this.weatherService = weatherService; 25 | } 26 | 27 | @RequestMapping("/") 28 | String home() { 29 | return "Hello World!"; 30 | } 31 | 32 | @RequestMapping("forecast/{city}") 33 | public List getWeatherForFive( 34 | @PathVariable String city) throws ParseException { 35 | return this.weatherService.getWeatherForFive(city); 36 | } 37 | 38 | @RequestMapping("weather/{city}") 39 | public List getWeather( 40 | @PathVariable String city) { 41 | return this.weatherService.getWeather(city); 42 | } 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/models/TodaysWeather.java: -------------------------------------------------------------------------------- 1 | package com.example.main.models; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 6 | import com.fasterxml.jackson.annotation.JsonAnySetter; 7 | import com.fasterxml.jackson.annotation.JsonIgnore; 8 | import com.fasterxml.jackson.annotation.JsonInclude; 9 | import com.fasterxml.jackson.annotation.JsonProperty; 10 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 11 | 12 | @JsonInclude(JsonInclude.Include.NON_NULL) 13 | @JsonPropertyOrder({ 14 | "today" 15 | }) 16 | public class TodaysWeather { 17 | 18 | @JsonProperty("today") 19 | private Today today; 20 | @JsonIgnore 21 | private Map additionalProperties = new HashMap(); 22 | 23 | @JsonProperty("today") 24 | public Today getToday() { 25 | return today; 26 | } 27 | 28 | @JsonProperty("today") 29 | public void setToday(Today today) { 30 | this.today = today; 31 | } 32 | 33 | @JsonAnyGetter 34 | public Map getAdditionalProperties() { 35 | return this.additionalProperties; 36 | } 37 | 38 | @JsonAnySetter 39 | public void setAdditionalProperty(String name, Object value) { 40 | this.additionalProperties.put(name, value); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/models/Date.java: -------------------------------------------------------------------------------- 1 | package com.example.main.models; 2 | 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 7 | import com.fasterxml.jackson.annotation.JsonAnySetter; 8 | import com.fasterxml.jackson.annotation.JsonIgnore; 9 | import com.fasterxml.jackson.annotation.JsonInclude; 10 | import com.fasterxml.jackson.annotation.JsonProperty; 11 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 12 | 13 | 14 | @JsonInclude(JsonInclude.Include.NON_NULL) 15 | @JsonPropertyOrder({ 16 | "time" 17 | }) 18 | public class Date { 19 | 20 | @JsonProperty("time") 21 | private Time time; 22 | @JsonIgnore 23 | private Map additionalProperties = new HashMap(); 24 | 25 | 26 | @JsonProperty("time") 27 | public Time gettime() { 28 | return time; 29 | } 30 | 31 | @JsonProperty("time") 32 | public void settime(Time time) { 33 | this.time = time; 34 | } 35 | 36 | @JsonAnyGetter 37 | public Map getAdditionalProperties() { 38 | return this.additionalProperties; 39 | } 40 | 41 | @JsonAnySetter 42 | public void setAdditionalProperty(String name, Object value) { 43 | this.additionalProperties.put(name, value); 44 | } 45 | 46 | public String toString() { 47 | StringBuffer buffer = new StringBuffer(); 48 | buffer.append(gettime()); 49 | return buffer.toString(); 50 | } 51 | } -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/models/Time.java: -------------------------------------------------------------------------------- 1 | package com.example.main.models; 2 | 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 7 | import com.fasterxml.jackson.annotation.JsonAnySetter; 8 | import com.fasterxml.jackson.annotation.JsonIgnore; 9 | import com.fasterxml.jackson.annotation.JsonInclude; 10 | import com.fasterxml.jackson.annotation.JsonProperty; 11 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 12 | 13 | @JsonInclude(JsonInclude.Include.NON_NULL) 14 | @JsonPropertyOrder({ 15 | "time", 16 | "main", 17 | "weather" 18 | }) 19 | public class Time { 20 | 21 | 22 | private String time; 23 | public String getTime() { 24 | return time; 25 | } 26 | 27 | public void setTime(String time) { 28 | this.time = time; 29 | } 30 | 31 | @JsonProperty("main") 32 | private Main main; 33 | @JsonProperty("weather") 34 | private Weather weather; 35 | @JsonIgnore 36 | private Map additionalProperties = new HashMap(); 37 | 38 | @JsonProperty("main") 39 | public Main getMain() { 40 | return main; 41 | } 42 | 43 | @JsonProperty("main") 44 | public void setMain(Main main) { 45 | this.main = main; 46 | } 47 | 48 | @JsonProperty("weather") 49 | public Weather getWeather() { 50 | return weather; 51 | } 52 | 53 | @JsonProperty("weather") 54 | public void setWeather(Weather weather) { 55 | this.weather = weather; 56 | } 57 | 58 | @JsonAnyGetter 59 | public Map getAdditionalProperties() { 60 | return this.additionalProperties; 61 | } 62 | 63 | @JsonAnySetter 64 | public void setAdditionalProperty(String name, Object value) { 65 | this.additionalProperties.put(name, value); 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/models/Example.java: -------------------------------------------------------------------------------- 1 | package com.example.main.models; 2 | 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 7 | import com.fasterxml.jackson.annotation.JsonAnySetter; 8 | import com.fasterxml.jackson.annotation.JsonIgnore; 9 | import com.fasterxml.jackson.annotation.JsonInclude; 10 | import com.fasterxml.jackson.annotation.JsonProperty; 11 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 12 | 13 | @JsonInclude(JsonInclude.Include.NON_NULL) 14 | @JsonPropertyOrder({ 15 | "forecast_weather", 16 | "todays_weather" 17 | }) 18 | public class Example { 19 | 20 | @JsonProperty("forecast_weather") 21 | private ForecastWeather forecastWeather; 22 | @JsonProperty("todays_weather") 23 | private TodaysWeather todaysWeather; 24 | @JsonIgnore 25 | private Map additionalProperties = new HashMap(); 26 | 27 | @JsonProperty("forecast_weather") 28 | public ForecastWeather getForecastWeather() { 29 | return forecastWeather; 30 | } 31 | 32 | @JsonProperty("forecast_weather") 33 | public void setForecastWeather(ForecastWeather forecastWeather) { 34 | this.forecastWeather = forecastWeather; 35 | } 36 | 37 | @JsonProperty("todays_weather") 38 | public TodaysWeather getTodaysWeather() { 39 | return todaysWeather; 40 | } 41 | 42 | @JsonProperty("todays_weather") 43 | public void setTodaysWeather(TodaysWeather todaysWeather) { 44 | this.todaysWeather = todaysWeather; 45 | } 46 | 47 | @JsonAnyGetter 48 | public Map getAdditionalProperties() { 49 | return this.additionalProperties; 50 | } 51 | 52 | @JsonAnySetter 53 | public void setAdditionalProperty(String name, Object value) { 54 | this.additionalProperties.put(name, value); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/models/ForecastWeather.java: -------------------------------------------------------------------------------- 1 | package com.example.main.models; 2 | 3 | import java.io.Serializable; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | 9 | 10 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 11 | import com.fasterxml.jackson.annotation.JsonAnySetter; 12 | 13 | import com.fasterxml.jackson.annotation.JsonIgnore; 14 | import com.fasterxml.jackson.annotation.JsonInclude; 15 | import com.fasterxml.jackson.annotation.JsonProperty; 16 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 17 | 18 | @JsonInclude(JsonInclude.Include.NON_NULL) 19 | @JsonPropertyOrder({ 20 | "date", 21 | "time" 22 | }) 23 | 24 | public class ForecastWeather { 25 | 26 | private Time time; 27 | 28 | 29 | public Time getTime() { 30 | return time; 31 | } 32 | 33 | public void setTime(Time time) { 34 | this.time = time; 35 | } 36 | 37 | 38 | @JsonProperty("date") 39 | private String date; 40 | @JsonIgnore 41 | private Serializable additionalProperties = new HashMap(); 42 | 43 | 44 | @JsonProperty("date") 45 | public String getdate() { 46 | return date; 47 | } 48 | 49 | 50 | @JsonProperty("date") 51 | public void setdate(String date) { 52 | this.date= date; 53 | } 54 | 55 | @SuppressWarnings("unchecked") 56 | @JsonAnyGetter 57 | public Map getAdditionalProperties() { 58 | return (Map) this.additionalProperties; 59 | } 60 | 61 | @SuppressWarnings("unchecked") 62 | @JsonAnySetter 63 | public void setAdditionalProperty( Object date, Object time ) { 64 | ((HashMap) this.additionalProperties).put(date,time); 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | StringBuffer buffer = new StringBuffer(); 70 | buffer.append(getdate() ); 71 | return buffer.toString(); 72 | } 73 | 74 | } -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/models/Weather.java: -------------------------------------------------------------------------------- 1 | package com.example.main.models; 2 | import java.util.HashMap; 3 | import java.util.Map; 4 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 5 | import com.fasterxml.jackson.annotation.JsonAnySetter; 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | import com.fasterxml.jackson.annotation.JsonInclude; 8 | import com.fasterxml.jackson.annotation.JsonProperty; 9 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 10 | 11 | @JsonInclude(JsonInclude.Include.NON_NULL) 12 | @JsonPropertyOrder({ 13 | "id", 14 | "main", 15 | "description", 16 | "icon" 17 | }) 18 | public class Weather { 19 | 20 | @JsonProperty("id") 21 | private Integer id; 22 | @JsonProperty("main") 23 | private String main; 24 | @JsonProperty("description") 25 | private String description; 26 | @JsonProperty("icon") 27 | private String icon; 28 | @JsonIgnore 29 | private Map additionalProperties = new HashMap(); 30 | 31 | @JsonProperty("id") 32 | public Integer getId() { 33 | return id; 34 | } 35 | 36 | @JsonProperty("id") 37 | public void setId(Integer id) { 38 | this.id = id; 39 | } 40 | 41 | @JsonProperty("main") 42 | public String getMain() { 43 | return main; 44 | } 45 | 46 | @JsonProperty("main") 47 | public void setMain(String main) { 48 | this.main = main; 49 | } 50 | 51 | @JsonProperty("description") 52 | public String getDescription() { 53 | return description; 54 | } 55 | 56 | @JsonProperty("description") 57 | public void setDescription(String description) { 58 | this.description = description; 59 | } 60 | 61 | @JsonProperty("icon") 62 | public String getIcon() { 63 | return icon; 64 | } 65 | 66 | @JsonProperty("icon") 67 | public void setIcon(String icon) { 68 | this.icon = icon; 69 | } 70 | 71 | @JsonAnyGetter 72 | public Map getAdditionalProperties() { 73 | return this.additionalProperties; 74 | } 75 | 76 | @JsonAnySetter 77 | public void setAdditionalProperty(String name, Object value) { 78 | this.additionalProperties.put(name, value); 79 | } 80 | 81 | } -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/models/Main.java: -------------------------------------------------------------------------------- 1 | package com.example.main.models; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 6 | import com.fasterxml.jackson.annotation.JsonAnySetter; 7 | import com.fasterxml.jackson.annotation.JsonIgnore; 8 | import com.fasterxml.jackson.annotation.JsonInclude; 9 | import com.fasterxml.jackson.annotation.JsonProperty; 10 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 11 | 12 | @JsonInclude(JsonInclude.Include.NON_NULL) 13 | @JsonPropertyOrder({ 14 | "temp", 15 | "temp_min", 16 | "temp_max", 17 | "pressure", 18 | "sea_level", 19 | "grnd_level", 20 | "humidity", 21 | "temp_kf" 22 | }) 23 | public class Main { 24 | 25 | @JsonProperty("temp") 26 | private Double temp; 27 | @JsonProperty("temp_min") 28 | private Double tempMin; 29 | @JsonProperty("temp_max") 30 | private Double tempMax; 31 | @JsonProperty("pressure") 32 | private Double pressure; 33 | @JsonProperty("sea_level") 34 | private Double seaLevel; 35 | @JsonProperty("grnd_level") 36 | private Double grndLevel; 37 | @JsonProperty("humidity") 38 | private Integer humidity; 39 | @JsonProperty("temp_kf") 40 | private Integer tempKf; 41 | @JsonIgnore 42 | private Map additionalProperties = new HashMap(); 43 | 44 | @JsonProperty("temp") 45 | public Double getTemp() { 46 | return temp; 47 | } 48 | 49 | @JsonProperty("temp") 50 | public void setTemp(Double temp) { 51 | this.temp = temp; 52 | } 53 | 54 | @JsonProperty("temp_min") 55 | public Double getTempMin() { 56 | return tempMin; 57 | } 58 | 59 | @JsonProperty("temp_min") 60 | public void setTempMin(int temp_min) { 61 | this.tempMin = (double) temp_min; 62 | } 63 | 64 | @JsonProperty("temp_max") 65 | public Double getTempMax() { 66 | return tempMax; 67 | } 68 | 69 | @JsonProperty("temp_max") 70 | public void setTempMax(int temp_max) { 71 | this.tempMax = (double) temp_max; 72 | } 73 | 74 | @JsonProperty("pressure") 75 | public Double getPressure() { 76 | return pressure; 77 | } 78 | 79 | @JsonProperty("pressure") 80 | public void setPressure(int i) { 81 | this.pressure = (double) i; 82 | } 83 | 84 | @JsonProperty("sea_level") 85 | public Double getSeaLevel() { 86 | return seaLevel; 87 | } 88 | 89 | @JsonProperty("sea_level") 90 | public void setSeaLevel(int sea_level) { 91 | this.seaLevel = (double) sea_level; 92 | } 93 | 94 | @JsonProperty("grnd_level") 95 | public Double getGrndLevel() { 96 | return grndLevel; 97 | } 98 | 99 | @JsonProperty("grnd_level") 100 | public void setGrndLevel(int grnd_level) { 101 | this.grndLevel = (double) grnd_level; 102 | } 103 | 104 | @JsonProperty("humidity") 105 | public Integer getHumidity() { 106 | return humidity; 107 | } 108 | 109 | @JsonProperty("humidity") 110 | public void setHumidity(Integer humidity) { 111 | this.humidity = humidity; 112 | } 113 | 114 | @JsonProperty("temp_kf") 115 | public Integer getTempKf() { 116 | return tempKf; 117 | } 118 | 119 | @JsonProperty("temp_kf") 120 | public void setTempKf(Integer tempKf) { 121 | this.tempKf = tempKf; 122 | } 123 | 124 | @JsonAnyGetter 125 | public Map getAdditionalProperties() { 126 | return this.additionalProperties; 127 | } 128 | 129 | @JsonAnySetter 130 | public void setAdditionalProperty(String name, Object value) { 131 | this.additionalProperties.put(name, value); 132 | } 133 | 134 | } -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/models/Today.java: -------------------------------------------------------------------------------- 1 | package com.example.main.models; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 6 | import com.fasterxml.jackson.annotation.JsonAnySetter; 7 | import com.fasterxml.jackson.annotation.JsonIgnore; 8 | import com.fasterxml.jackson.annotation.JsonInclude; 9 | import com.fasterxml.jackson.annotation.JsonProperty; 10 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 11 | 12 | @JsonInclude(JsonInclude.Include.NON_NULL) 13 | @JsonPropertyOrder({ 14 | "temp", 15 | "pressure", 16 | "humidity", 17 | "temp_min", 18 | "temp_max", 19 | "sea_level", 20 | "grnd_level", 21 | "main", 22 | "description" 23 | }) 24 | public class Today { 25 | 26 | @JsonProperty("temp") 27 | private Double temp; 28 | @JsonProperty("pressure") 29 | private Double pressure; 30 | @JsonProperty("humidity") 31 | private Integer humidity; 32 | @JsonProperty("temp_min") 33 | private Double tempMin; 34 | @JsonProperty("temp_max") 35 | private Double tempMax; 36 | @JsonProperty("sea_level") 37 | private Double seaLevel; 38 | @JsonProperty("grnd_level") 39 | private Double grndLevel; 40 | @JsonProperty("main") 41 | private String main; 42 | @JsonProperty("description") 43 | private String description; 44 | @JsonIgnore 45 | private Map additionalProperties = new HashMap(); 46 | 47 | @JsonProperty("temp") 48 | public Double getTemp() { 49 | return temp; 50 | } 51 | 52 | @JsonProperty("temp") 53 | public void setTemp(Double temp) { 54 | this.temp = temp; 55 | } 56 | 57 | @JsonProperty("pressure") 58 | public Double getPressure() { 59 | return pressure; 60 | } 61 | 62 | @JsonProperty("pressure") 63 | public void setPressure(Double pressure) { 64 | this.pressure = pressure; 65 | } 66 | 67 | @JsonProperty("humidity") 68 | public Integer getHumidity() { 69 | return humidity; 70 | } 71 | 72 | @JsonProperty("humidity") 73 | public void setHumidity(Integer humidity) { 74 | this.humidity = humidity; 75 | } 76 | 77 | @JsonProperty("temp_min") 78 | public Double getTempMin() { 79 | return tempMin; 80 | } 81 | 82 | @JsonProperty("temp_min") 83 | public void setTempMin(Double tempMin) { 84 | this.tempMin = tempMin; 85 | } 86 | 87 | @JsonProperty("temp_max") 88 | public Double getTempMax() { 89 | return tempMax; 90 | } 91 | 92 | @JsonProperty("temp_max") 93 | public void setTempMax(Double tempMax) { 94 | this.tempMax = tempMax; 95 | } 96 | 97 | @JsonProperty("sea_level") 98 | public Double getSeaLevel() { 99 | return seaLevel; 100 | } 101 | 102 | @JsonProperty("sea_level") 103 | public void setSeaLevel(Double seaLevel) { 104 | this.seaLevel = seaLevel; 105 | } 106 | 107 | @JsonProperty("grnd_level") 108 | public Double getGrndLevel() { 109 | return grndLevel; 110 | } 111 | 112 | @JsonProperty("grnd_level") 113 | public void setGrndLevel(Double grndLevel) { 114 | this.grndLevel = grndLevel; 115 | } 116 | 117 | @JsonProperty("main") 118 | public String getMain() { 119 | return main; 120 | } 121 | 122 | @JsonProperty("main") 123 | public void setMain(String main) { 124 | this.main = main; 125 | } 126 | 127 | @JsonProperty("description") 128 | public String getDescription() { 129 | return description; 130 | } 131 | 132 | @JsonProperty("description") 133 | public void setDescription(String description) { 134 | this.description = description; 135 | } 136 | 137 | @JsonAnyGetter 138 | public Map getAdditionalProperties() { 139 | return this.additionalProperties; 140 | } 141 | 142 | @JsonAnySetter 143 | public void setAdditionalProperty(String name, Object value) { 144 | this.additionalProperties.put(name, value); 145 | } 146 | 147 | } -------------------------------------------------------------------------------- /00WeatherApi00/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | pl.kamilbiernacki 8 | springWeather 9 | 0.0.1-SNAPSHOT 10 | jar 11 | springWeather 12 | Demo project for Spring Boot 13 | 14 | org.springframework.boot 15 | spring-boot-starter-parent 16 | 1.5.11.BUILD-SNAPSHOT 17 | 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-thymeleaf 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.projectlombok 38 | lombok 39 | true 40 | 41 | 42 | joda-time 43 | joda-time 44 | 2.10 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-actuator 49 | 50 | 51 | com.sun.jersey 52 | jersey-client 53 | 1.19 54 | 55 | 56 | 57 | 58 | org.codehaus.jackson 59 | jackson-core-asl 60 | 1.9.13 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-starter-mustache 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-starter-cache 69 | 70 | 71 | 72 | com.googlecode.json-simple 73 | json-simple 74 | 1.1.1 75 | 76 | 77 | 78 | 79 | 80 | com.fasterxml.jackson.datatype 81 | jackson-datatype-jsr310 82 | 83 | 84 | com.github.ben-manes.caffeine 85 | caffeine 86 | 87 | 88 | 89 | org.springframework.boot 90 | spring-boot-devtools 91 | true 92 | 93 | 94 | org.springframework.boot 95 | spring-boot-configuration-processor 96 | true 97 | 98 | 99 | 100 | org.springframework.boot 101 | spring-boot-starter-test 102 | test 103 | 104 | 105 | org.springframework.restdocs 106 | spring-restdocs-mockmvc 107 | test 108 | 109 | 110 | org.springframework.boot 111 | spring-boot-starter-test 112 | test 113 | 114 | 115 | net.sourceforge.nekohtml 116 | nekohtml 117 | 1.9.22 118 | 119 | 120 | org.json 121 | json 122 | 20180130 123 | 124 | 125 | 126 | 127 | 128 | org.springframework.boot 129 | spring-boot-maven-plugin 130 | 131 | 132 | 133 | 134 | 135 | spring-snapshots 136 | Spring Snapshots 137 | https://repo.spring.io/snapshot 138 | 139 | true 140 | 141 | 142 | 143 | spring-milestones 144 | Spring Milestones 145 | https://repo.spring.io/milestone 146 | 147 | false 148 | 149 | 150 | 151 | 152 | 153 | spring-snapshots 154 | Spring Snapshots 155 | https://repo.spring.io/snapshot 156 | 157 | true 158 | 159 | 160 | 161 | spring-milestones 162 | Spring Milestones 163 | https://repo.spring.io/milestone 164 | 165 | false 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /00WeatherApi00/target/classes/META-INF/maven/pl.kamilbiernacki/springWeather/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | pl.kamilbiernacki 8 | springWeather 9 | 0.0.1-SNAPSHOT 10 | jar 11 | springWeather 12 | Demo project for Spring Boot 13 | 14 | org.springframework.boot 15 | spring-boot-starter-parent 16 | 1.5.11.BUILD-SNAPSHOT 17 | 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-thymeleaf 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.projectlombok 38 | lombok 39 | true 40 | 41 | 42 | joda-time 43 | joda-time 44 | 2.10 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-actuator 49 | 50 | 51 | com.sun.jersey 52 | jersey-client 53 | 1.19 54 | 55 | 56 | 57 | 58 | org.codehaus.jackson 59 | jackson-core-asl 60 | 1.9.13 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-starter-mustache 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-starter-cache 69 | 70 | 71 | 72 | com.googlecode.json-simple 73 | json-simple 74 | 1.1.1 75 | 76 | 77 | 78 | 79 | 80 | com.fasterxml.jackson.datatype 81 | jackson-datatype-jsr310 82 | 83 | 84 | com.github.ben-manes.caffeine 85 | caffeine 86 | 87 | 88 | 89 | org.springframework.boot 90 | spring-boot-devtools 91 | true 92 | 93 | 94 | org.springframework.boot 95 | spring-boot-configuration-processor 96 | true 97 | 98 | 99 | 100 | org.springframework.boot 101 | spring-boot-starter-test 102 | test 103 | 104 | 105 | org.springframework.restdocs 106 | spring-restdocs-mockmvc 107 | test 108 | 109 | 110 | org.springframework.boot 111 | spring-boot-starter-test 112 | test 113 | 114 | 115 | net.sourceforge.nekohtml 116 | nekohtml 117 | 1.9.22 118 | 119 | 120 | org.json 121 | json 122 | 20180130 123 | 124 | 125 | 126 | 127 | 128 | org.springframework.boot 129 | spring-boot-maven-plugin 130 | 131 | 132 | 133 | 134 | 135 | spring-snapshots 136 | Spring Snapshots 137 | https://repo.spring.io/snapshot 138 | 139 | true 140 | 141 | 142 | 143 | spring-milestones 144 | Spring Milestones 145 | https://repo.spring.io/milestone 146 | 147 | false 148 | 149 | 150 | 151 | 152 | 153 | spring-snapshots 154 | Spring Snapshots 155 | https://repo.spring.io/snapshot 156 | 157 | true 158 | 159 | 160 | 161 | spring-milestones 162 | Spring Milestones 163 | https://repo.spring.io/milestone 164 | 165 | false 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /00WeatherApi00/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /00WeatherApi00/src/main/java/com/example/main/services/WeatherService.java: -------------------------------------------------------------------------------- 1 | package com.example.main.services; 2 | 3 | import org.json.JSONArray; 4 | import org.json.JSONObject; 5 | 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.web.client.RestTemplate; 8 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; 9 | 10 | import com.example.main.models.*; 11 | 12 | 13 | import java.text.ParseException; 14 | import java.text.SimpleDateFormat; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | @Service 20 | public class WeatherService extends MappingJackson2HttpMessageConverter { 21 | 22 | private static WeatherService ourInstance = new WeatherService(); 23 | 24 | public static WeatherService getInstance() { 25 | return ourInstance; 26 | } 27 | 28 | private WeatherService() { 29 | setPrettyPrint(true); 30 | } 31 | 32 | public List getWeatherForFive(String city) throws ParseException { 33 | 34 | String websiteResponse = "http://api.openweathermap.org/data/2.5/forecast?q=" + city + "&mode=json&appid="+Place Your Api Key Here+"&units=metric"; 35 | 36 | RestTemplate restTemplate = new RestTemplate(); 37 | String result = restTemplate.getForObject(websiteResponse, String.class); 38 | 39 | String description = null; 40 | double temp=0; 41 | int pressure=0; 42 | int humidity = 0; 43 | int temp_min=0; 44 | int temp_max=0; 45 | int temp_kf=0; 46 | int sea_level=0; 47 | int grnd_level=0; 48 | 49 | java.util.Date date1 = null; 50 | 51 | String date = null; 52 | 53 | String icon=null; 54 | String WeatherCondition=null; 55 | int id=0; 56 | 57 | List weatherList = new ArrayList<>(); 58 | 59 | JSONObject root = new JSONObject(result); 60 | 61 | SimpleDateFormat dfoutput2 = new SimpleDateFormat("HH"); 62 | SimpleDateFormat dfoutput1 = new SimpleDateFormat("dd-MM-yyyy"); 63 | SimpleDateFormat dfinput = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 64 | 65 | JSONArray weatherObject = root.getJSONArray("list"); 66 | 67 | for(int i = 0; i < weatherObject.length(); i++) { 68 | 69 | JSONObject arrayElement = weatherObject.getJSONObject(i); 70 | 71 | JSONObject main = arrayElement.getJSONObject("main"); 72 | temp = (int) main.getFloat("temp"); 73 | pressure = main.getInt("pressure"); 74 | humidity = main.getInt("humidity"); 75 | temp_min = main.getInt("temp_min"); 76 | temp_max = main.getInt("temp_max"); 77 | temp_kf = main.getInt("temp_kf"); 78 | sea_level = main.getInt("sea_level"); 79 | grnd_level = main.getInt("grnd_level"); 80 | 81 | description = arrayElement.getJSONArray("weather").getJSONObject(0).getString("description"); 82 | icon = arrayElement.getJSONArray("weather").getJSONObject(0).getString("icon"); 83 | WeatherCondition = arrayElement.getJSONArray("weather").getJSONObject(0).getString("main"); 84 | id = arrayElement.getJSONArray("weather").getJSONObject(0).getInt("id"); 85 | 86 | date = arrayElement.getString("dt_txt"); 87 | 88 | date1 = dfinput.parse(date); 89 | 90 | 91 | ForecastWeather fw=new ForecastWeather(); 92 | Date dt=new Date(); 93 | Main mn=new Main(); 94 | Example e = new Example(); 95 | 96 | Time t = new Time(); 97 | Weather w = new Weather(); 98 | 99 | 100 | mn.setTemp(temp); 101 | mn.setPressure((int) pressure/10); 102 | mn.setHumidity(humidity); 103 | mn.setGrndLevel(grnd_level); 104 | mn.setSeaLevel(sea_level); 105 | mn.setTempKf(temp_kf); 106 | 107 | mn.setTempMax(temp_max); 108 | mn.setTempMin(temp_min); 109 | 110 | w.setDescription(description); 111 | w.setIcon(icon); 112 | w.setId(id); 113 | w.setMain(WeatherCondition); 114 | 115 | t.setTime(dfoutput2.format(date1)); 116 | t.setMain(mn); 117 | t.setWeather(w); 118 | 119 | dt.setAdditionalProperty(dfoutput2.format(date1), t); 120 | 121 | fw.setAdditionalProperty(dfoutput1.format(date1), dt); 122 | 123 | e.setForecastWeather(fw); 124 | 125 | weatherList.add(e); 126 | } 127 | 128 | return weatherList; 129 | } 130 | 131 | 132 | public List getWeather(String city) { 133 | 134 | String websiteResponse = "http://api.openweathermap.org/data/2.5/weather?q="+ city + "&mode=json&appid=+"Type your app id here"+&units=metric"; 135 | 136 | RestTemplate restTemplate = new RestTemplate(); 137 | String result = restTemplate.getForObject(websiteResponse, String.class); 138 | 139 | String description = null; 140 | String WeatherCondition = null; 141 | double temp; 142 | double temp_min; 143 | double temp_max; 144 | double pressure; 145 | int humidity; 146 | 147 | 148 | List weatherList = new ArrayList<>(); 149 | 150 | JSONObject root = new JSONObject(result); 151 | 152 | JSONArray weatherObject = root.getJSONArray("weather"); 153 | 154 | for (int i = 0; i < weatherObject.length(); i++) { 155 | JSONObject elementInArray = weatherObject.getJSONObject(i); 156 | description = elementInArray.getString("description"); 157 | WeatherCondition = elementInArray.getString("main"); 158 | } 159 | 160 | JSONObject main = root.getJSONObject("main"); 161 | 162 | temp = (int) main.getFloat("temp"); 163 | pressure = main.getInt("pressure"); 164 | humidity = main.getInt("humidity"); 165 | temp_min= (int) main.getFloat("temp_min"); 166 | temp_max= (int) main.getFloat("temp_max"); 167 | 168 | 169 | 170 | TodaysWeather tw=new TodaysWeather(); 171 | Example e=new Example(); 172 | Today t=new Today(); 173 | 174 | t.setDescription(description); 175 | 176 | t.setHumidity(humidity); 177 | t.setMain(WeatherCondition); 178 | t.setPressure(pressure); 179 | 180 | t.setTemp(temp); 181 | t.setTempMax(temp_max); 182 | t.setTempMin(temp_min); 183 | 184 | tw.setToday(t); 185 | e.setTodaysWeather(tw); 186 | 187 | weatherList.add(e); 188 | return weatherList; 189 | } 190 | 191 | } 192 | -------------------------------------------------------------------------------- /00WeatherApi00/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | ########################################################################################## 204 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 205 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 206 | ########################################################################################## 207 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 208 | if [ "$MVNW_VERBOSE" = true ]; then 209 | echo "Found .mvn/wrapper/maven-wrapper.jar" 210 | fi 211 | else 212 | if [ "$MVNW_VERBOSE" = true ]; then 213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 214 | fi 215 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 216 | while IFS="=" read key value; do 217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 218 | esac 219 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 220 | if [ "$MVNW_VERBOSE" = true ]; then 221 | echo "Downloading from: $jarUrl" 222 | fi 223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 224 | 225 | if command -v wget > /dev/null; then 226 | if [ "$MVNW_VERBOSE" = true ]; then 227 | echo "Found wget ... using wget" 228 | fi 229 | wget "$jarUrl" -O "$wrapperJarPath" 230 | elif command -v curl > /dev/null; then 231 | if [ "$MVNW_VERBOSE" = true ]; then 232 | echo "Found curl ... using curl" 233 | fi 234 | curl -o "$wrapperJarPath" "$jarUrl" 235 | else 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Falling back to using Java to download" 238 | fi 239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 240 | if [ -e "$javaClass" ]; then 241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 242 | if [ "$MVNW_VERBOSE" = true ]; then 243 | echo " - Compiling MavenWrapperDownloader.java ..." 244 | fi 245 | # Compiling the Java class 246 | ("$JAVA_HOME/bin/javac" "$javaClass") 247 | fi 248 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 249 | # Running the downloader 250 | if [ "$MVNW_VERBOSE" = true ]; then 251 | echo " - Running MavenWrapperDownloader.java ..." 252 | fi 253 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 254 | fi 255 | fi 256 | fi 257 | fi 258 | ########################################################################################## 259 | # End of extension 260 | ########################################################################################## 261 | 262 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 263 | if [ "$MVNW_VERBOSE" = true ]; then 264 | echo $MAVEN_PROJECTBASEDIR 265 | fi 266 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 267 | 268 | # For Cygwin, switch paths to Windows format before running java 269 | if $cygwin; then 270 | [ -n "$M2_HOME" ] && 271 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 272 | [ -n "$JAVA_HOME" ] && 273 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 274 | [ -n "$CLASSPATH" ] && 275 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 276 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 278 | fi 279 | 280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 281 | 282 | exec "$JAVACMD" \ 283 | $MAVEN_OPTS \ 284 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 285 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 286 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 287 | --------------------------------------------------------------------------------