From bfacaf514aef4f7061e53374ca878b5b3e65ad8a Mon Sep 17 00:00:00 2001 From: Nemo D'ACREMONT Date: Fri, 20 Dec 2024 18:40:40 +0100 Subject: [PATCH] fix: small fix to uml --- Weather_App.svg | 2 +- diagram_class.puml | 12 ++++++------ .../pg203/weather/data/api/WeatherDataCache.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Weather_App.svg b/Weather_App.svg index 832b973..9879a79 100644 --- a/Weather_App.svg +++ b/Weather_App.svg @@ -1 +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 +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> cacheprivate long 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)WeatherCachedAPIprivate WeatherDataCache cacheJSONArray toJSON()void loadCache(JSONArray data)void loadCacheFromFile(String path)void saveCacheToFile(String path)ArrayList<WeatherData> getTemperature(JSONArray data)OpenMeteoString forecastBaseUrlString daylyQueryJSONFetcher JSONFetcherClock clockJSONObject fetchWeather(int days, City city)Condition getConditionFromCode(int WMOCode)ArrayList<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 a140409..604bad3 100644 --- a/diagram_class.puml +++ b/diagram_class.puml @@ -16,8 +16,8 @@ package eirb.pg203.weather { } class WeatherDataCache { - + private HashMap {final} cache - + private long {static} {final} cacheTTL + - private HashMap cache + - private long cacheTTL + boolean has(String cityName, int day) + boolean needsUpdate(String cityName, int day) + void set(String cityName, int day, WeatherData value, Instant timestamp) @@ -26,7 +26,7 @@ package eirb.pg203.weather { } abstract class WeatherCachedAPI implements WeatherDataAPI { - ~ WeatherDataCache {final} cache + - private WeatherDataCache cache + JSONArray toJSON() + void loadCache(JSONArray data) + void loadCacheFromFile(String path) @@ -35,13 +35,13 @@ package eirb.pg203.weather { } Class OpenMeteo extends WeatherCachedAPI { - - String {final} forecastBaseUrl - - String {final} daylyQuery + - String forecastBaseUrl + - String daylyQuery ~ JSONFetcher JSONFetcher ~ Clock clock - JSONObject fetchWeather(int days, City city) - Condition {static} getConditionFromCode(int WMOCode) - - WeatherData getWeatherDataFromForecast(JSONObject response, int day, String city) + - ArrayList getWeatherDataFromForecast(JSONObject response, int day, String city) } Class OpenWeatherMap extends WeatherCachedAPI { diff --git a/src/main/java/eirb/pg203/weather/data/api/WeatherDataCache.java b/src/main/java/eirb/pg203/weather/data/api/WeatherDataCache.java index 429cfcf..30169ba 100644 --- a/src/main/java/eirb/pg203/weather/data/api/WeatherDataCache.java +++ b/src/main/java/eirb/pg203/weather/data/api/WeatherDataCache.java @@ -60,7 +60,7 @@ public class WeatherDataCache { } private final HashMap cache = new HashMap<>(); - private static final long cacheTTL = 3600; // Cache data Time To Live in sec + private final long cacheTTL = 3600; // Cache data Time To Live in sec private String makeKey(String cityName, int day) { return String.format(Locale.ENGLISH, "%s%d", cityName, day);