131 lines
4.0 KiB
Plaintext
131 lines
4.0 KiB
Plaintext
@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<WeatherData> getTemperature(int day, String city)
|
|
+ ArrayList<WeatherData> getTemperature(int day, int hour, String city)
|
|
+ ArrayList<WeatherData> getTemperatures(int days, String city)
|
|
+ String getAPIName()
|
|
}
|
|
|
|
class WeatherDataCache {
|
|
+ private HashMap<String,WeatherDataCache.CacheValue> {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<WeatherData> 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<WeatherDataAPI> apis
|
|
|
|
- double 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()
|
|
}
|
|
|
|
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
|