diff --git a/Weather_App.svg b/Weather_App.svg new file mode 100644 index 0000000..832b973 --- /dev/null +++ b/Weather_App.svg @@ -0,0 +1 @@ +Weather AppWeather Appeirbpg203weatherdataapidisplayexceptionsutilsutilsWeatherDataCity cityInstant datefloat tempCondition conditionfloat windSpeedfloat windDirectionAngleWindDirection windDirectionString toString()WeatherDataAPIArrayList<WeatherData> getTemperature(int day, String city)ArrayList<WeatherData> getTemperature(int day, int hour, String city)ArrayList<WeatherData> getTemperatures(int days, String city)String getAPIName()WeatherDataCacheprivate HashMap<String,WeatherDataCache.CacheValue> {final} cacheprivate long {final} cacheTTLboolean has(String cityName, int day)boolean needsUpdate(String cityName, int day)void set(String cityName, int day, WeatherData value, Instant timestamp)JSONArray toJSON(String apiName)void fromJSON(JSONArray data)WeatherCachedAPIWeatherDataCache {final} cacheJSONArray toJSON()void loadCache(JSONArray data)void loadCacheFromFile(String path)void saveCacheToFile(String path)ArrayList<WeatherData> getTemperature(JSONArray data)OpenMeteoString {final} forecastBaseUrlString {final} daylyQueryJSONFetcher JSONFetcherClock clockJSONObject fetchWeather(int days, City city)Condition getConditionFromCode(int WMOCode)WeatherData getWeatherDataFromForecast(JSONObject response, int day, String city)OpenWeatherMapString forecastBaseUrlString APIKeyClock clockJSONFetcher JSONFetcherWeatherData getWeatherDataFromForecast(JSONObject response, int day, String city)JSONObject fetchWeather(City city)WeatherAPIString APIKeyString forecastBaseUrlJSONFetcher JSONFetcherJSONObject fetchWeather(int days, String city)WeatherData.Condition getConditionFromString(String str)WeatherData getWeatherDataFromForecast(JSONObject response, int day, String city)WeatherDisplayBasicArrayList<WeatherDataAPI> apisdouble getColumnSize()void displayHeader(int days, double sourceColumnSize, double dayColumnSize)void displayWeatherDatas(String apiName, ArrayList<WeatherData> weatherDatas, String startColumnSize, double sourceColumnSize, double dayColumnSize)void displaySeparatorLine(int days, double sourceColumnSize, double dayColumnSize)void displayAllWeatherDatas()WeatherDisplayvoid display(int days, String city)void addAPI(WeatherDataAPI w)WeatherFeatchingExceptionWeatherFeatchingExceptionApiWeatherFeatchingExceptionCityCoordsCityString cityNameutils.Coords cityCoordsJSONFetcher JSONFetcherprivate Coords getCoordsFromName(String cityName)public String toString()Coordsfloat latfloat lonJSONFetcherfetch(URL url)private fetchString(URL url)Getters, setters and constructors are not displayedException11 \ No newline at end of file diff --git a/diagram_class.puml b/diagram_class.puml index 910a3fc..a140409 100644 --- a/diagram_class.puml +++ b/diagram_class.puml @@ -1 +1,130 @@ -@startuml title Weather App note "Getters, setters and constructors are not displayed" as N package eirb.pg203 { Interface WeatherDataAPI { + WeatherData getTemperature(int day, String city) + WeatherData getTemperature(int day, int hour, String city) + WeatherData getTemperatures(int days, String city) + String getAPIName() } Interface WeatherDisplay { + void display(int days, String city) + void addAPI(WeatherDataAPI w) } Exception exceptions.WeatherFeatchingException { } Exception exceptions.WeatherFeatchingExceptionApi extends exceptions.WeatherFeatchingException{ } Exception exceptions.WeatherFeatchingExceptionCityCoords extends exceptions.WeatherFeatchingException{ } Class utils.Coords { - float lat - float lon } Class utils.JSONFetcher { + fetch(URL url) - private {static} fetchString(URL url) } Class City { - String cityName - utils.Coords cityCoords ~ JSONFetcher JSONFetcher - private Coords getCoordsFromName(String cityName) + public String toString() } Class WeatherData { - City city - Instant date - float temp - Condition condition - float windSpeed - float windDirectionAngle - WindDirection windDirection + String toString() } Class WeatherDisplayBasic implements WeatherDisplay { - ArrayList apis - double getColumnSize() - void displayHeader(int days, double sourceColumnSize, double dayColumnSize) - void displayWeatherDatas(String apiName, ArrayList weatherDatas, String startColumnSize, double sourceColumnSize, double dayColumnSize) - void displaySeparatorLine(int days, double sourceColumnSize, double dayColumnSize) - void displayAllWeatherDatas() } Class OpenMeteo implements WeatherDataAPI { - String {final} forecastBaseUrl - String {final} daylyQuery ~ JSONFetcher JSONFetcher ~ Clock clock - JSONObject fetchWeather(int days, City city) - Condition {static} getConditionFromCode(int WMOCode) - WeatherData getWeatherDataFromForecast(JSONObject response, int day, String city) } Class OpenWeatherMap implements WeatherDataAPI { - String {static} forecastBaseUrl - String APIKey ~ Clock clock ~ JSONFetcher JSONFetcher - WeatherData getWeatherDataFromForecast(JSONObject response, int day, String city) - JSONObject fetchWeather(City city) } Class WeatherAPI implements WeatherDataAPI { - String APIKey - String {static} forecastBaseUrl ~ JSONFetcher JSONFetcher - JSONObject fetchWeather(int days, String city) - WeatherData.Condition {static} getConditionFromString(String str) - WeatherData {static} getWeatherDataFromForecast(JSONObject response, int day, String city) } } Exception Exception Exception <|-- WeatherFeatchingException @enduml \ No newline at end of file +@startuml + +title Weather App + +note "Getters, setters and constructors are not displayed" as N + +package eirb.pg203.weather { + + package data { + package api { + Interface WeatherDataAPI { + + ArrayList getTemperature(int day, String city) + + ArrayList getTemperature(int day, int hour, String city) + + ArrayList getTemperatures(int days, String city) + + String getAPIName() + } + + class WeatherDataCache { + + private HashMap {final} cache + + private long {static} {final} cacheTTL + + boolean has(String cityName, int day) + + boolean needsUpdate(String cityName, int day) + + void set(String cityName, int day, WeatherData value, Instant timestamp) + + JSONArray toJSON(String apiName) + + void fromJSON(JSONArray data) + } + + abstract class WeatherCachedAPI implements WeatherDataAPI { + ~ WeatherDataCache {final} cache + + JSONArray toJSON() + + void loadCache(JSONArray data) + + void loadCacheFromFile(String path) + + void saveCacheToFile(String path) + + ArrayList getTemperature(JSONArray data) + } + + Class OpenMeteo extends WeatherCachedAPI { + - String {final} forecastBaseUrl + - String {final} daylyQuery + ~ JSONFetcher JSONFetcher + ~ Clock clock + - JSONObject fetchWeather(int days, City city) + - Condition {static} getConditionFromCode(int WMOCode) + - WeatherData getWeatherDataFromForecast(JSONObject response, int day, String city) + } + + Class OpenWeatherMap extends WeatherCachedAPI { + - String {static} forecastBaseUrl + - String APIKey + ~ Clock clock + ~ JSONFetcher JSONFetcher + + - WeatherData getWeatherDataFromForecast(JSONObject response, int day, String city) + - JSONObject fetchWeather(City city) + } + + Class WeatherAPI extends WeatherCachedAPI { + - String APIKey + - String {static} forecastBaseUrl + ~ JSONFetcher JSONFetcher + + - JSONObject fetchWeather(int days, String city) + - WeatherData.Condition {static} getConditionFromString(String str) + - WeatherData {static} getWeatherDataFromForecast(JSONObject response, int day, String city) + } + } + + Class WeatherData { + - City city + - Instant date + - float temp + - Condition condition + - float windSpeed + - float windDirectionAngle + - WindDirection windDirection + + + String toString() + } + } + + + package display { + Class WeatherDisplayBasic implements WeatherDisplay { + - ArrayList apis + + - double getColumnSize() + - void displayHeader(int days, double sourceColumnSize, double dayColumnSize) + - void displayWeatherDatas(String apiName, ArrayList weatherDatas, String startColumnSize, double sourceColumnSize, double dayColumnSize) + - void displaySeparatorLine(int days, double sourceColumnSize, double dayColumnSize) + - void displayAllWeatherDatas() + } + + Interface WeatherDisplay { + + void display(int days, String city) + + void addAPI(WeatherDataAPI w) + } + } + + package exceptions { + Exception WeatherFeatchingException {} + Exception WeatherFeatchingExceptionApi extends WeatherFeatchingException{} + Exception WeatherFeatchingExceptionCityCoords extends WeatherFeatchingException{} + } + + package utils { + Class utils.Coords { + - float lat + - float lon + } + + Class utils.JSONFetcher { + + fetch(URL url) + - private {static} fetchString(URL url) + } + + Class City { + - String cityName + - utils.Coords cityCoords + ~ JSONFetcher JSONFetcher + + - private Coords getCoordsFromName(String cityName) + + public String toString() + } + } +} + +Exception Exception +Exception <|-- WeatherFeatchingException +WeatherDataCache "1" *-left- "1" WeatherCachedAPI +@enduml diff --git a/weather-app.png b/weather-app.png deleted file mode 100644 index c1756d9..0000000 Binary files a/weather-app.png and /dev/null differ