mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 11:45:49 +01:00
[ephemeris] Adopted configuration for Ephemeris service (#919)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
13e72f6142
commit
2bb5cb7f64
@ -13,6 +13,8 @@
|
||||
package org.eclipse.smarthome.core.ephemeris.internal;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
@ -23,6 +25,7 @@ import java.time.LocalDate;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -30,8 +33,8 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
@ -40,7 +43,9 @@ import org.eclipse.smarthome.config.core.ConfigurableService;
|
||||
import org.eclipse.smarthome.config.core.ParameterOption;
|
||||
import org.eclipse.smarthome.core.ephemeris.EphemerisManager;
|
||||
import org.eclipse.smarthome.core.i18n.LocaleProvider;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.Constants;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.service.component.annotations.Activate;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Modified;
|
||||
@ -65,27 +70,47 @@ import de.jollyday.ManagerParameters;
|
||||
ConfigurableService.SERVICE_PROPERTY_DESCRIPTION_URI + "=" + EphemerisManagerImpl.CONFIG_URI })
|
||||
@NonNullByDefault
|
||||
public class EphemerisManagerImpl implements EphemerisManager, ConfigOptionProvider {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(EphemerisManagerImpl.class);
|
||||
|
||||
// constants for the configuration properties
|
||||
protected static final String CONFIG_URI = "system:ephemeris";
|
||||
private static final String CONFIG_DAYSET_PREFIX = "dayset-";
|
||||
private static final String CONFIG_DAYSET_WEEKEND = "weekend";
|
||||
private static final String CONFIG_COUNTRY = "country";
|
||||
private static final String CONFIG_REGION = "region";
|
||||
private static final String CONFIG_CITY = "city";
|
||||
public static final String CONFIG_DAYSET_PREFIX = "dayset-";
|
||||
public static final String CONFIG_DAYSET_WEEKEND = "weekend";
|
||||
public static final String CONFIG_COUNTRY = "country";
|
||||
public static final String CONFIG_REGION = "region";
|
||||
public static final String CONFIG_CITY = "city";
|
||||
|
||||
private final Map<String, Set<DayOfWeek>> daysets = new HashMap<>();
|
||||
private static final String JOLLYDAY_COUNTRY_DESCRIPTIONS = "jollyday/descriptions/country_descriptions.properties";
|
||||
private static final String PROPERTY_COUNTRY_DESCRIPTION_PREFIX = "country.description.";
|
||||
private static final String PROPERTY_COUNTRY_DESCRIPTION_DELIMITER = "\\.";
|
||||
|
||||
final List<ParameterOption> countries = new ArrayList<>();
|
||||
final Map<String, List<ParameterOption>> regions = new HashMap<>();
|
||||
final Map<String, List<ParameterOption>> cities = new HashMap<>();
|
||||
|
||||
final Map<String, Set<DayOfWeek>> daysets = new HashMap<>();
|
||||
private final Map<Object, HolidayManager> holidayManagers = new HashMap<>();
|
||||
private final List<String> countryParameters = new ArrayList<>();
|
||||
|
||||
private final LocaleProvider localeProvider;
|
||||
|
||||
private @NonNullByDefault({}) String country;
|
||||
private @Nullable String region;
|
||||
|
||||
@Activate
|
||||
public EphemerisManagerImpl(final @Reference LocaleProvider localeProvider) {
|
||||
this.localeProvider = localeProvider;
|
||||
|
||||
final Bundle bundle = FrameworkUtil.getBundle(getClass());
|
||||
try (InputStream stream = bundle.getResource(JOLLYDAY_COUNTRY_DESCRIPTIONS).openStream()) {
|
||||
final Properties properties = new Properties();
|
||||
properties.load(stream);
|
||||
properties.forEach(this::parseProperty);
|
||||
} catch (IllegalArgumentException | IllegalStateException | IOException e) {
|
||||
logger.warn("The resource '{}' could not be loaded properly! ConfigDescription options are not available.",
|
||||
JOLLYDAY_COUNTRY_DESCRIPTIONS, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Activate
|
||||
@ -96,28 +121,45 @@ public class EphemerisManagerImpl implements EphemerisManager, ConfigOptionProvi
|
||||
@Modified
|
||||
protected void modified(Map<String, Object> config) {
|
||||
config.entrySet().stream().filter(e -> e.getKey().startsWith(CONFIG_DAYSET_PREFIX)).forEach(e -> {
|
||||
String[] setDefinition = e.getValue().toString().toUpperCase().split(",");
|
||||
String[] setNameParts = e.getKey().split("-");
|
||||
if (setDefinition.length > 0 && setNameParts.length > 1) {
|
||||
Set<DayOfWeek> dayset = new HashSet<>();
|
||||
Stream.of(setDefinition).forEach(day -> {
|
||||
dayset.add(DayOfWeek.valueOf(day));
|
||||
});
|
||||
daysets.put(setNameParts[1], dayset);
|
||||
if (setNameParts.length > 1) {
|
||||
String setName = setNameParts[1];
|
||||
Object entry = e.getValue();
|
||||
if (entry instanceof String) {
|
||||
String value = entry.toString();
|
||||
while (value.startsWith("[")) {
|
||||
value = value.substring(1);
|
||||
}
|
||||
while (value.endsWith("]")) {
|
||||
value = value.substring(0, value.length() - 1);
|
||||
}
|
||||
String[] setDefinition = value.split(",");
|
||||
if (setDefinition.length > 0) {
|
||||
addDayset(setName, Arrays.asList(setDefinition));
|
||||
} else {
|
||||
logger.warn("Erroneous dayset definition {} : {}", e.getKey(), entry);
|
||||
}
|
||||
} else if (entry instanceof Iterable) {
|
||||
addDayset(setName, (Iterable<?>) entry);
|
||||
}
|
||||
} else {
|
||||
logger.warn("Erroneous dayset definition {} : {}", e.getKey(), e.getValue());
|
||||
logger.warn("Erroneous dayset definition {}", e.getKey());
|
||||
}
|
||||
});
|
||||
|
||||
if (config.containsKey(CONFIG_COUNTRY)) {
|
||||
country = config.get(CONFIG_COUNTRY).toString();
|
||||
country = config.get(CONFIG_COUNTRY).toString().toLowerCase();
|
||||
} else {
|
||||
country = localeProvider.getLocale().getCountry();
|
||||
country = localeProvider.getLocale().getCountry().toLowerCase();
|
||||
logger.debug("Using system default country '{}' ", country);
|
||||
}
|
||||
|
||||
if (config.containsKey(CONFIG_REGION)) {
|
||||
countryParameters.add(config.get(CONFIG_REGION).toString());
|
||||
String region = config.get(CONFIG_REGION).toString().toLowerCase();
|
||||
countryParameters.add(region);
|
||||
this.region = region;
|
||||
} else {
|
||||
this.region = null;
|
||||
}
|
||||
|
||||
if (config.containsKey(CONFIG_CITY)) {
|
||||
@ -127,17 +169,33 @@ public class EphemerisManagerImpl implements EphemerisManager, ConfigOptionProvi
|
||||
|
||||
@Override
|
||||
public @Nullable Collection<ParameterOption> getParameterOptions(URI uri, String param, @Nullable Locale locale) {
|
||||
List<ParameterOption> options = null;
|
||||
if (CONFIG_URI.equals(uri.toString())) {
|
||||
Locale nullSafeLocale = locale == null ? localeProvider.getLocale() : locale;
|
||||
options = new ArrayList<>();
|
||||
for (DayOfWeek day : DayOfWeek.values()) {
|
||||
ParameterOption option = new ParameterOption(day.name(),
|
||||
day.getDisplayName(TextStyle.FULL, nullSafeLocale));
|
||||
options.add(option);
|
||||
switch (param) {
|
||||
case CONFIG_COUNTRY:
|
||||
return countries;
|
||||
case CONFIG_REGION:
|
||||
if (regions.containsKey(country)) {
|
||||
return regions.get(country);
|
||||
}
|
||||
case CONFIG_CITY:
|
||||
if (region != null && cities.containsKey(region)) {
|
||||
return cities.get(region);
|
||||
}
|
||||
default:
|
||||
if (param.startsWith(CONFIG_DAYSET_PREFIX)) {
|
||||
Locale nullSafeLocale = locale == null ? localeProvider.getLocale() : locale;
|
||||
final List<ParameterOption> options = new ArrayList<>();
|
||||
for (DayOfWeek day : DayOfWeek.values()) {
|
||||
ParameterOption option = new ParameterOption(day.name(),
|
||||
day.getDisplayName(TextStyle.FULL, nullSafeLocale));
|
||||
options.add(option);
|
||||
}
|
||||
return options;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return options;
|
||||
return null;
|
||||
}
|
||||
|
||||
private HolidayManager getHolidayManager(Object managerKey) {
|
||||
@ -227,4 +285,78 @@ public class EphemerisManagerImpl implements EphemerisManager, ConfigOptionProvi
|
||||
return holiday.isPresent() ? holiday.get() : null;
|
||||
}
|
||||
|
||||
private void addDayset(String setName, Iterable<?> values) {
|
||||
Set<DayOfWeek> dayset = new HashSet<>();
|
||||
for (Object day : values) {
|
||||
dayset.add(DayOfWeek.valueOf(day.toString().trim().toUpperCase()));
|
||||
}
|
||||
daysets.put(setName, dayset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses each entry of a properties list loaded from 'jolliday/descriptions/country_descriptions.properties'. The
|
||||
* file has been copied from
|
||||
* https://github.com/svendiedrichsen/jollyday/blob/master/src/main/resources/descriptions/country_descriptions.properties
|
||||
* and contains values in the following format - some examples:
|
||||
*
|
||||
* country.description.at = Austria
|
||||
* country.description.au = Australia
|
||||
* country.description.au.sa = South Australia
|
||||
* country.description.au.tas = Tasmania
|
||||
* country.description.au.tas.ho = Hobard Area
|
||||
* country.description.au.tas.nh = Non-Hobard Area
|
||||
*
|
||||
* "at" and "au" are keys of countries
|
||||
* "sa" and "tas" are keys of regions inside the country "au"
|
||||
* "ho" and "nh" are kess of cities or areas inside the region "tas"
|
||||
*
|
||||
* @param key key of the property will be parsed
|
||||
* @param value value of the property will be used as name
|
||||
* @throws IllegalArgumentException if the property could not be parsed properly
|
||||
*/
|
||||
void parseProperty(Object key, Object value) throws IllegalArgumentException {
|
||||
final String property = key.toString().replace(PROPERTY_COUNTRY_DESCRIPTION_PREFIX, "");
|
||||
final String[] parts = property.split(PROPERTY_COUNTRY_DESCRIPTION_DELIMITER);
|
||||
final String name = value.toString();
|
||||
final String part;
|
||||
final ParameterOption option;
|
||||
switch (parts.length) {
|
||||
case 1:
|
||||
countries.add(new ParameterOption(getValidPart(parts[0]), name));
|
||||
break;
|
||||
case 2:
|
||||
part = getValidPart(parts[0]);
|
||||
option = new ParameterOption(getValidPart(parts[1]), name);
|
||||
if (regions.containsKey(part)) {
|
||||
regions.get(part).add(option);
|
||||
} else {
|
||||
final List<ParameterOption> options = new ArrayList<>();
|
||||
options.add(option);
|
||||
regions.put(part, options);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
part = getValidPart(parts[1]);
|
||||
option = new ParameterOption(getValidPart(parts[2]), name);
|
||||
if (cities.containsKey(part)) {
|
||||
cities.get(part).add(option);
|
||||
} else {
|
||||
final List<ParameterOption> options = new ArrayList<>();
|
||||
options.add(option);
|
||||
cities.put(part, options);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("Unable to parse property '%s = %s'.", key, value));
|
||||
}
|
||||
}
|
||||
|
||||
private static String getValidPart(String part) {
|
||||
final String subject = part.trim();
|
||||
if (!subject.isEmpty()) {
|
||||
return subject.toLowerCase();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unable to parse property - token is empty.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,22 @@
|
||||
xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0 https://openhab.org/schemas/config-description-1.0.0.xsd">
|
||||
|
||||
<config-description uri="system:ephemeris">
|
||||
<parameter name="weekendDays" type="text" required="true" multiple="true">
|
||||
<parameter name="dayset-weekend" type="text" required="true" multiple="true">
|
||||
<label>Weekend Days</label>
|
||||
<description>List of usual non workable days.</description>
|
||||
</parameter>
|
||||
<default>SATURDAY,SUNDAY</default>
|
||||
</parameter>
|
||||
<parameter name="country" type="text">
|
||||
<label>Country</label>
|
||||
<description>Get the holidays for a specific country (e.g. United States of America = "us").</description>
|
||||
</parameter>
|
||||
<parameter name="region" type="text">
|
||||
<label>Region</label>
|
||||
<description>Get the holidays for a specific state (e.g. New York = "ny").</description>
|
||||
</parameter>
|
||||
<parameter name="city" type="text">
|
||||
<label>City</label>
|
||||
<description>Get the holidays for a specific city (e.g. New York City = "nyc").</description>
|
||||
</parameter>
|
||||
</config-description>
|
||||
</config-description:config-descriptions>
|
||||
|
@ -0,0 +1,534 @@
|
||||
|
||||
country.description.ad = Andorra
|
||||
country.description.ae = United Arab Emirates
|
||||
country.description.af = Afghanistan
|
||||
country.description.ag = Antigua And Barbuda
|
||||
country.description.ai = Anguilla
|
||||
country.description.al = Albania
|
||||
country.description.am = Armenia
|
||||
country.description.an = Netherlands Antilles
|
||||
country.description.ao = Angola
|
||||
country.description.aq = Antarctica
|
||||
country.description.ar = Argentina
|
||||
country.description.as = American Samoa
|
||||
country.description.at = Austria
|
||||
country.description.at.b = Burgenland
|
||||
country.description.at.k = K\u00E4rnten
|
||||
country.description.at.la = Lower Austria
|
||||
country.description.at.s = Salzburg
|
||||
country.description.at.st = Steiermark
|
||||
country.description.at.t = Tirol
|
||||
country.description.at.ua = Upper Austria
|
||||
country.description.at.va = Vorarlberg
|
||||
country.description.at.w = Vienna
|
||||
country.description.au = Australia
|
||||
country.description.au.act = Australian Capital Territory
|
||||
country.description.au.nsw = New South Wales
|
||||
country.description.au.nt = Nothern Territory
|
||||
country.description.au.qld = Queensland
|
||||
country.description.au.sa = South Australia
|
||||
country.description.au.tas = Tasmania
|
||||
country.description.au.tas.ho = Hobard Area
|
||||
country.description.au.tas.nh = Non-Hobard Area
|
||||
country.description.au.vic = Victoria
|
||||
country.description.au.wa = West Australia
|
||||
country.description.aw = Aruba
|
||||
country.description.ax = Aaland Islands
|
||||
country.description.az = Azerbaijan
|
||||
country.description.ba = Bosnia and Herzegowina
|
||||
country.description.ba.fbh = Federation of Bosnia and Herzegovina
|
||||
country.description.ba.rs = Republic of Srpska
|
||||
country.description.bb = Barbados
|
||||
country.description.bd = Bangladesh
|
||||
country.description.be = Belgium
|
||||
country.description.bf = Burkina Faso
|
||||
country.description.bg = Bulgaria
|
||||
country.description.bh = Bahrain
|
||||
country.description.bi = Burundi
|
||||
country.description.bj = Benin
|
||||
country.description.bm = Bermuda
|
||||
country.description.bn = Brunei Darussalam
|
||||
country.description.bo = Bolivia
|
||||
country.description.br = Brazil
|
||||
country.description.br.go = Goi\u00E1s
|
||||
country.description.br.mg = Minas Gerais
|
||||
country.description.br.mg.bh = Belo Horizonte
|
||||
country.description.br.ms = Mato Grosso do Sul
|
||||
country.description.br.ms.cg = Campo Grande
|
||||
country.description.br.ms.do = Dourados
|
||||
country.description.br.pb = Para\u00EDba
|
||||
country.description.br.pb.jpa = Jo\u00E3o Pessoa
|
||||
country.description.br.pe = Pernambuco
|
||||
country.description.br.pr = Parana
|
||||
country.description.br.pr.cu = Curitiba
|
||||
country.description.br.rj = Rio de Janeiro
|
||||
country.description.br.rj.crj = City of Rio de Janeiro
|
||||
country.description.br.rn = Rio Grande do Norte
|
||||
country.description.br.rn.na = Natal
|
||||
country.description.br.rs = Rio Grande do Sul
|
||||
country.description.br.rs.sm = Santa Maria
|
||||
country.description.br.sp=Sao Paulo
|
||||
country.description.br.sp.csp=City of Sao Paulo
|
||||
country.description.bs = Bahamas
|
||||
country.description.bt = Bhutan
|
||||
country.description.bv = Bouvet Island
|
||||
country.description.bw = Botswana
|
||||
country.description.by = Belarus
|
||||
country.description.bz = Belize
|
||||
country.description.ca = Canada
|
||||
country.description.ca.ab = Alberta
|
||||
country.description.ca.bc = British Columbia
|
||||
country.description.ca.mb = Manitoba
|
||||
country.description.ca.nb = New Brunswick
|
||||
country.description.ca.nl = Newfoundland and Labrador
|
||||
country.description.ca.ns = Nova Scotia
|
||||
country.description.ca.nt = Northwest Territories
|
||||
country.description.ca.nu = Nunavut
|
||||
country.description.ca.on = Ontario
|
||||
country.description.ca.pe = Prince Edward Island
|
||||
country.description.ca.qc = Quebec
|
||||
country.description.ca.sk = Saskatchewan
|
||||
country.description.ca.yt = Yukon
|
||||
country.description.cc = Cocos (Keeling) Islands
|
||||
country.description.cd = Congo, Democratic Republic Of (Was Zaire)
|
||||
country.description.cf = Central African Republic
|
||||
country.description.cg = Congo, Republic Of
|
||||
country.description.ch = Switzerland
|
||||
country.description.ch.ag = Aargau
|
||||
country.description.ch.ai = Appenzell Innerrhoden
|
||||
country.description.ch.ar = Appenzell Ausserrhoden
|
||||
country.description.ch.be = Bern
|
||||
country.description.ch.bl = Basel-Country
|
||||
country.description.ch.bs = Basel-City
|
||||
country.description.ch.fr = Fribourg
|
||||
country.description.ch.ge = Geneva
|
||||
country.description.ch.gl = Glarus
|
||||
country.description.ch.gr = Graub\uFFFDnden
|
||||
country.description.ch.ju = Jura
|
||||
country.description.ch.lu = Lucerne
|
||||
country.description.ch.ne = Neuch\uFFFDtel
|
||||
country.description.ch.nw = Nidwalden
|
||||
country.description.ch.ow = Obwalden
|
||||
country.description.ch.sg = St.Gallen
|
||||
country.description.ch.sh = Schaffhausen
|
||||
country.description.ch.so = Solothurn
|
||||
country.description.ch.sz = Schwyz
|
||||
country.description.ch.tg = Thurgau
|
||||
country.description.ch.ti = Ticino
|
||||
country.description.ch.ur = Uri
|
||||
country.description.ch.vd = Vaud
|
||||
country.description.ch.vs = Valais
|
||||
country.description.ch.zg = Zug
|
||||
country.description.ch.zh = Zurich
|
||||
country.description.ci = Cote D'ivoire
|
||||
country.description.ck = Cook Islands
|
||||
country.description.cl = Chile
|
||||
country.description.cm = Cameroon
|
||||
country.description.cn = China
|
||||
country.description.co = Colombia
|
||||
country.description.cr = Costa Rica
|
||||
country.description.cu = Cuba
|
||||
country.description.cv = Cape Verde
|
||||
country.description.cx = Christmas Island
|
||||
country.description.cy = Cyprus
|
||||
country.description.cz = Czech Republic
|
||||
country.description.de = Germany
|
||||
country.description.de.be = Berlin
|
||||
country.description.de.bb = Brandenburg
|
||||
country.description.de.bw = Baden-W\u00FCrttemberg
|
||||
country.description.de.by = Bavaria
|
||||
country.description.de.by.ag = Augsburg
|
||||
country.description.de.by.in = Ingolstadt
|
||||
country.description.de.by.mu = Munich
|
||||
country.description.de.by.re = Regensburg
|
||||
country.description.de.by.wu = W\u00FCrzburg
|
||||
country.description.de.hb = Bremen
|
||||
country.description.de.he = Hesse
|
||||
country.description.de.hh = Hamburg
|
||||
country.description.de.mv = Mecklenburg-Vorpommern
|
||||
country.description.de.ni = Lower Saxony
|
||||
country.description.de.nw = North Rhine-Westphalia
|
||||
country.description.de.rp = Rhineland-Palatinate
|
||||
country.description.de.sh = Schleswig-Holstein
|
||||
country.description.de.sl = Saarland
|
||||
country.description.de.sn = Saxony
|
||||
country.description.de.st = Saxony-Anhalt
|
||||
country.description.de.th = Thuringia
|
||||
country.description.dj = Djibouti
|
||||
country.description.dk = Denmark
|
||||
country.description.dm = Dominica
|
||||
country.description.do = Dominican Republic
|
||||
country.description.dz = Algeria
|
||||
country.description.ec = Ecuador
|
||||
country.description.ee = Estonia
|
||||
country.description.eg = Egypt
|
||||
country.description.eh = Western Sahara
|
||||
country.description.er = Eritrea
|
||||
country.description.es = Spain
|
||||
country.description.et = Ethiopia
|
||||
country.description.fi = Finland
|
||||
country.description.fj = Fiji
|
||||
country.description.fk = Falkland Islands (Malvinas)
|
||||
country.description.fm = Micronesia, Federated States Of
|
||||
country.description.fo = Faroe Islands
|
||||
country.description.fr = France
|
||||
country.description.fr.br = Bas-Rhin
|
||||
country.description.fr.gu = Guadeloupe
|
||||
country.description.fr.gy = Guyane
|
||||
country.description.fr.hr = Haut-Rhin
|
||||
country.description.fr.lr = La Reunion
|
||||
country.description.fr.ma = Martinique
|
||||
country.description.fr.mo = Moselle
|
||||
country.description.ga = Gabon
|
||||
country.description.gb = United Kingdom of Great Britain
|
||||
country.description.gb.al = Alderney
|
||||
country.description.gb.en = England
|
||||
country.description.gb.gu = Guernsey
|
||||
country.description.gb.im = Isle of Man
|
||||
country.description.gb.je = Jersey
|
||||
country.description.gb.ni = Northern Ireland
|
||||
country.description.gb.sc = Scotland
|
||||
country.description.gb.wa = Wales
|
||||
country.description.gd = Grenada
|
||||
country.description.ge = Georgia
|
||||
country.description.gf = French Guiana
|
||||
country.description.gg = Guernsey
|
||||
country.description.gh = Ghana
|
||||
country.description.gi = Gibraltar
|
||||
country.description.gl = Greenland
|
||||
country.description.gm = Gambia
|
||||
country.description.gn = Guinea
|
||||
country.description.gp = Guadeloupe
|
||||
country.description.gq = Equatorial Guinea
|
||||
country.description.gr = Greece
|
||||
country.description.gs = South Georgia And The South Sandwich Islands
|
||||
country.description.gt = Guatemala
|
||||
country.description.gu = Guam
|
||||
country.description.gw = Guinea-Bissau
|
||||
country.description.gy = Guyana
|
||||
country.description.hk = Hong Kong
|
||||
country.description.hm = Heard And Mc Donald Islands
|
||||
country.description.hn = Honduras
|
||||
country.description.hr = Croatia (Local Name: Hrvatska)
|
||||
country.description.ht = Haiti
|
||||
country.description.hu = Hungary
|
||||
country.description.id = Indonesia
|
||||
country.description.ie = Ireland
|
||||
country.description.il = Israel
|
||||
country.description.im = Isle of Man
|
||||
country.description.in = India
|
||||
country.description.in.an = Andaman and Nicobar Islands
|
||||
country.description.in.ap = Andhra Pradesh
|
||||
country.description.in.ar = Arunachal Pradesh
|
||||
country.description.in.as = Assam
|
||||
country.description.in.br = Bihar
|
||||
country.description.in.ch = Chandigarh
|
||||
country.description.in.ct = Chhattisgarh
|
||||
country.description.in.dd = Daman and Diu
|
||||
country.description.in.dl = Delhi
|
||||
country.description.in.dn = Dadra and Nagar Haveli
|
||||
country.description.in.ga = Goa
|
||||
country.description.in.gj = Gujarat
|
||||
country.description.in.hp = Himachal Pradesh
|
||||
country.description.in.hr = Haryana
|
||||
country.description.in.jh = Jharkhand
|
||||
country.description.in.jk = Jammu and Kashmir
|
||||
country.description.in.ka = Karnataka
|
||||
country.description.in.kl = Kerala
|
||||
country.description.in.ld = Lakshadweep
|
||||
country.description.in.mh = Maharashtra
|
||||
country.description.in.ml = Meghalaya
|
||||
country.description.in.mn = Manipur
|
||||
country.description.in.mp = Madhya Pradesh
|
||||
country.description.in.mz = Mizoram
|
||||
country.description.in.nl = Nagaland
|
||||
country.description.in.or = Orissa
|
||||
country.description.in.pb = Punjab
|
||||
country.description.in.py = Puducherry
|
||||
country.description.in.rj = Rajasthan
|
||||
country.description.in.sk = Sikkim
|
||||
country.description.in.tn = Tamil Nadu
|
||||
country.description.in.tr = Tripura
|
||||
country.description.in.ul = Uttarakhand
|
||||
country.description.in.up = Uttar Pradesh
|
||||
country.description.in.wb = West Bengal
|
||||
country.description.io = British Indian Ocean Territory
|
||||
country.description.iq = Iraq
|
||||
country.description.ir = Iran (Islamic Republic Of)
|
||||
country.description.is = Iceland
|
||||
country.description.it = Italy
|
||||
country.description.it.bz = South Tyrol
|
||||
country.description.je = Jersey
|
||||
country.description.jm = Jamaica
|
||||
country.description.jo = Jordan
|
||||
country.description.jp = Japan
|
||||
country.description.ke = Kenya
|
||||
country.description.kg = Kyrgyzstan
|
||||
country.description.kh = Cambodia
|
||||
country.description.ki = Kiribati
|
||||
country.description.km = Comoros
|
||||
country.description.kn = Saint Kitts And Nevis
|
||||
country.description.kp = Korea, Democratic People's Republic Of
|
||||
country.description.kr = Korea, Republic Of
|
||||
country.description.kw = Kuwait
|
||||
country.description.ky = Cayman Islands
|
||||
country.description.kz = Kazakhstan
|
||||
country.description.la = Lao People's Democratic Republic
|
||||
country.description.lb = Lebanon
|
||||
country.description.lc = Saint Lucia
|
||||
country.description.li = Liechtenstein
|
||||
country.description.lk = Sri Lanka
|
||||
country.description.lr = Liberia
|
||||
country.description.ls = Lesotho
|
||||
country.description.lt = Lithuania
|
||||
country.description.lu = Luxembourg
|
||||
country.description.lu.clu = City of Luxembourg
|
||||
country.description.lv = Latvia
|
||||
country.description.ly = Libyan Arab Jamahiriya
|
||||
country.description.ma = Morocco
|
||||
country.description.mc = Monaco
|
||||
country.description.md = Moldova, Republic Of
|
||||
country.description.md.bti = Balti
|
||||
country.description.md.ch = Chisinau
|
||||
country.description.me = Montenegro
|
||||
country.description.mg = Madagascar
|
||||
country.description.mh = Marshall Islands
|
||||
country.description.mk = Macedonia, The Former Yugoslav Republic Of
|
||||
country.description.ml = Mali
|
||||
country.description.mm = Myanmar
|
||||
country.description.mn = Mongolia
|
||||
country.description.mo = Macau
|
||||
country.description.mp = Northern Mariana Islands
|
||||
country.description.mq = Martinique
|
||||
country.description.mr = Mauritania
|
||||
country.description.ms = Montserrat
|
||||
country.description.mt = Malta
|
||||
country.description.mu = Mauritius
|
||||
country.description.mv = Maldives
|
||||
country.description.mw = Malawi
|
||||
country.description.mx = Mexico
|
||||
country.description.mx.pue = Puebla
|
||||
country.description.my = Malaysia
|
||||
country.description.mz = Mozambique
|
||||
country.description.na = Namibia
|
||||
country.description.nc = New Caledonia
|
||||
country.description.ne = Niger
|
||||
country.description.nf = Norfolk Island
|
||||
country.description.ng = Nigeria
|
||||
country.description.ng.lag = Lagos
|
||||
country.description.ni = Nicaragua
|
||||
country.description.ni.bo = Boaco
|
||||
country.description.ni.mn = Managua
|
||||
country.description.ni.mo = Moyogalpa
|
||||
country.description.ni.na = Nandaime
|
||||
country.description.ni.ni = Niquinohomo
|
||||
country.description.ni.om = Ometepe
|
||||
country.description.ni.so = Somoto
|
||||
country.description.nl = Netherlands
|
||||
country.description.no = Norway
|
||||
country.description.np = Nepal
|
||||
country.description.nr = Nauru
|
||||
country.description.nu = Niue
|
||||
country.description.nz = New Zealand
|
||||
country.description.om = Oman
|
||||
country.description.pa = Panama
|
||||
country.description.pe = Peru
|
||||
country.description.pf = French Polynesia
|
||||
country.description.pg = Papua New Guinea
|
||||
country.description.ph = Philippines
|
||||
country.description.pk = Pakistan
|
||||
country.description.pl = Poland
|
||||
country.description.pm = Saint Pierre And Miquelon
|
||||
country.description.pn = Pitcairn
|
||||
country.description.pr = Puerto Rico
|
||||
country.description.ps = Palestinian Territory, Occupied
|
||||
country.description.pt = Portugal
|
||||
country.description.pt.abf = Albufeira
|
||||
country.description.pt.abt = Abrantes
|
||||
country.description.pt.acb = Alcoba\u00E7a
|
||||
country.description.pt.ach = Alcochete
|
||||
country.description.pt.acn = Alcanena
|
||||
country.description.pt.act = Alcoutim
|
||||
country.description.pt.adl = Alandroal
|
||||
country.description.pt.adv = Almod\u00F4var
|
||||
country.description.pt.afe = Alf\u00E2ndega da F\u00E9
|
||||
country.description.pt.agb = Aguiar da Beira
|
||||
country.description.pt.agd = \u00C1gueda
|
||||
country.description.pt.agh = Angra do Hero\u00EDsmo
|
||||
country.description.pt.agn = Arganil
|
||||
country.description.pt.ajt = Aljustrel
|
||||
country.description.pt.ajz = Aljezur
|
||||
country.description.pt.alb = Albergaria-a-Velha
|
||||
country.description.pt.ald = Almeida
|
||||
country.description.pt.alj = Alij\u00F3
|
||||
country.description.pt.alm = Almada
|
||||
country.description.pt.alq = Alenquer
|
||||
country.description.pt.alr = Almeirim
|
||||
country.description.pt.alt = Alter do Ch\u00E3o
|
||||
country.description.pt.amd = Amadora
|
||||
country.description.pt.amm = Armamar
|
||||
country.description.pt.amr = Amares
|
||||
country.description.pt.amt = Amarante
|
||||
country.description.pt.and = Anadia
|
||||
country.description.pt.ans = Ansi\u00E3o
|
||||
country.description.pt.apc = Alpiar\u00E7a
|
||||
country.description.pt.arc = Arouca
|
||||
country.description.pt.arl = Arraiolos
|
||||
country.description.pt.arr = Arronches
|
||||
country.description.pt.arv = Arruda dos Vinhos
|
||||
country.description.pt.asl = Alc\u00E1cer do Sal
|
||||
country.description.pt.avr = Aveiro
|
||||
country.description.pt.avs = Avis
|
||||
country.description.pt.avt = Alvito
|
||||
country.description.pt.avv = Arcos de Valdevez
|
||||
country.description.pt.avz = Alvai\u00E1zere
|
||||
country.description.pt.azb = Azambuja
|
||||
country.description.pt.bao = Bai\u00E3o
|
||||
country.description.pt.bbr = Bombarral
|
||||
country.description.pt.bcl = Barcelos
|
||||
country.description.pt.bgc = Bragan\u00E7a
|
||||
country.description.pt.bja = Beja
|
||||
country.description.pt.bmt = Belmonte
|
||||
country.description.pt.bnv = Benavente
|
||||
country.description.pt.brb = Borba
|
||||
country.description.pt.brc = Barrancos
|
||||
country.description.pt.brg = Braga
|
||||
country.description.pt.brr = Barreiro
|
||||
country.description.pt.btc = Boticas
|
||||
country.description.pt.btl = Batalha
|
||||
country.description.pt.cbc = Cabeceiras de Basto
|
||||
country.description.pt.cdv = Cadaval
|
||||
country.description.pt.cht = Calheta (A\u00E7ores)
|
||||
country.description.pt.cld = Caldas da Rainha
|
||||
country.description.pt.clt = Calheta (Madeira)
|
||||
country.description.pt.cml = C\u00E2mara de Lobos
|
||||
country.description.pt.cmn = Caminha
|
||||
country.description.pt.cmr = Campo Maior
|
||||
country.description.pt.cnt = Cantanhede
|
||||
country.description.pt.cpr = Castanheira de Pera
|
||||
country.description.pt.crs = Carregal do Sal
|
||||
country.description.pt.crz = Carrazeda de Ansi\u00E3es
|
||||
country.description.pt.csc = Cascais
|
||||
country.description.pt.ctb = Castelo Branco
|
||||
country.description.pt.ctx = Cartaxo
|
||||
country.description.pw = Palau
|
||||
country.description.py = Paraguay
|
||||
country.description.qa = Qatar
|
||||
country.description.re = Reunion
|
||||
country.description.ro = Romania
|
||||
country.description.rs = Serbia And Montenegro
|
||||
country.description.ru = Russian Federation
|
||||
country.description.rw = Rwanda
|
||||
country.description.sa = Saudi Arabia
|
||||
country.description.sb = Solomon Islands
|
||||
country.description.sc = Seychelles
|
||||
country.description.sd = Sudan
|
||||
country.description.se = Sweden
|
||||
country.description.sg = Singapore
|
||||
country.description.sh = Saint Helena
|
||||
country.description.si = Slovenia
|
||||
country.description.sj = Svalbard And Jan Mayen Islands
|
||||
country.description.sk = Slovakia
|
||||
country.description.sl = Sierra Leone
|
||||
country.description.sm = San Marino
|
||||
country.description.sn = Senegal
|
||||
country.description.so = Somalia
|
||||
country.description.sr = Suriname
|
||||
country.description.ss = South Sudan
|
||||
country.description.st = Sao Tome And Principe
|
||||
country.description.sv = El Salvador
|
||||
country.description.sx = Saint Martin (Dutch part)
|
||||
country.description.sy = Syrian Arab Republic
|
||||
country.description.sz = Swaziland
|
||||
country.description.target = Trans-European Automated Real-time Gross settlement Express Transfer system closing dates
|
||||
country.description.tc = Turks And Caicos Islands
|
||||
country.description.td = Chad
|
||||
country.description.tf = French Southern Territories
|
||||
country.description.tg = Togo
|
||||
country.description.th = Thailand
|
||||
country.description.tj = Tajikistan
|
||||
country.description.tk = Tokelau
|
||||
country.description.tl = Timor-Leste
|
||||
country.description.tm = Turkmenistan
|
||||
country.description.tn = Tunisia
|
||||
country.description.to = Tonga
|
||||
country.description.tr = Turkey
|
||||
country.description.tt = Trinidad And Tobago
|
||||
country.description.tv = Tuvalu
|
||||
country.description.tw = Taiwan
|
||||
country.description.tz = Tanzania, United Republic Of
|
||||
country.description.ua = Ukraine
|
||||
country.description.ug = Uganda
|
||||
country.description.um = United States Minor Outlying Islands
|
||||
country.description.us = United States of America
|
||||
country.description.us.ak = Alaska
|
||||
country.description.us.al = Alabama
|
||||
country.description.us.ar = Arkansas
|
||||
country.description.us.az = Arizona
|
||||
country.description.us.be = Berkeley
|
||||
country.description.us.ca = California
|
||||
country.description.us.co = Colorado
|
||||
country.description.us.ct = Connecticut
|
||||
country.description.us.dc = District of Columbia
|
||||
country.description.us.de = Delaware
|
||||
country.description.us.fl = Florida
|
||||
country.description.us.ga = Georgia
|
||||
country.description.us.hi = Hawaii
|
||||
country.description.us.ia = Iowa
|
||||
country.description.us.id = Idaho
|
||||
country.description.us.il = Illinois
|
||||
country.description.us.in = Indiana
|
||||
country.description.us.ks = Kansas
|
||||
country.description.us.ky = Kentucky
|
||||
country.description.us.la = Louisiana
|
||||
country.description.us.ma = Massachusetts
|
||||
country.description.us.md = Maryland
|
||||
country.description.us.me = Maine
|
||||
country.description.us.mi = Michigan
|
||||
country.description.us.mn = Minnesota
|
||||
country.description.us.mo = Missouri
|
||||
country.description.us.ms = Mississippi
|
||||
country.description.us.mt = Montana
|
||||
country.description.us.nc = North Carolina
|
||||
country.description.us.nc.ce = Charlotte
|
||||
country.description.us.nc.me = Mecklenburg
|
||||
country.description.us.nd = North Dakota
|
||||
country.description.us.ne = Nebraska
|
||||
country.description.us.nh = New Hampshire
|
||||
country.description.us.nj = New Jersey
|
||||
country.description.us.nm = New Mexico
|
||||
country.description.us.nv = Nevada
|
||||
country.description.us.ny = New York
|
||||
country.description.us.ny.nyc = New York City
|
||||
country.description.us.oh = Ohio
|
||||
country.description.us.ok = Oklahoma
|
||||
country.description.us.or = Oregon
|
||||
country.description.us.pa = Pennsylvania
|
||||
country.description.us.ri = Rhode Island
|
||||
country.description.us.sc = South Carolina
|
||||
country.description.us.sd = South Dakota
|
||||
country.description.us.tn = Tennesee
|
||||
country.description.us.tx = Texas
|
||||
country.description.us.ut = Utah
|
||||
country.description.us.va = Virginia
|
||||
country.description.us.vt = Vermont
|
||||
country.description.us.wa = Washington
|
||||
country.description.us.wi = Wisconsin
|
||||
country.description.us.wv = West Virginia
|
||||
country.description.us.wy = Wyoming
|
||||
country.description.uy = Uruguay
|
||||
country.description.uz = Uzbekistan
|
||||
country.description.va = Vatican City State (Holy See)
|
||||
country.description.vc = Saint Vincent And The Grenadines
|
||||
country.description.ve = Venezuela
|
||||
country.description.vg = Virgin Islands (British)
|
||||
country.description.vi = Virgin Islands (U.S.)
|
||||
country.description.vn = Viet Nam
|
||||
country.description.vu = Vanuatu
|
||||
country.description.wf = Wallis And Futuna Islands
|
||||
country.description.ws = Samoa
|
||||
country.description.ye = Yemen
|
||||
country.description.yt = Mayotte
|
||||
country.description.za = South Africa
|
||||
country.description.zm = Zambia
|
||||
country.description.zw = Zimbabwe
|
@ -120,8 +120,8 @@
|
||||
<feature>openhab-core-base</feature>
|
||||
<bundle>mvn:org.openhab.core.bundles/org.openhab.core.ephemeris/${project.version}</bundle>
|
||||
<config name="org.openhab.ephemeris">
|
||||
dayset-weekend=Saturday,Sunday
|
||||
dayset-school=Monday,Tuesday,Wednesday,Thursday,Friday
|
||||
dayset-weekend=[SATURDAY,SUNDAY]
|
||||
dayset-school=[MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY]
|
||||
</config>
|
||||
</feature>
|
||||
|
||||
|
27
itests/org.openhab.core.ephemeris.tests/.classpath
Normal file
27
itests/org.openhab.core.ephemeris.tests/.classpath
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
23
itests/org.openhab.core.ephemeris.tests/.project
Normal file
23
itests/org.openhab.core.ephemeris.tests/.project
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.openhab.core.ephemeris.tests</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
14
itests/org.openhab.core.ephemeris.tests/NOTICE
Normal file
14
itests/org.openhab.core.ephemeris.tests/NOTICE
Normal file
@ -0,0 +1,14 @@
|
||||
This content is produced and maintained by the openHAB project.
|
||||
|
||||
* Project home: https://www.openhab.org
|
||||
|
||||
== Declared Project Licenses
|
||||
|
||||
This program and the accompanying materials are made available under the terms
|
||||
of the Eclipse Public License 2.0 which is available at
|
||||
https://www.eclipse.org/legal/epl-2.0/.
|
||||
|
||||
== Source Code
|
||||
|
||||
https://github.com/openhab/openhab-core
|
||||
|
64
itests/org.openhab.core.ephemeris.tests/itest.bndrun
Normal file
64
itests/org.openhab.core.ephemeris.tests/itest.bndrun
Normal file
@ -0,0 +1,64 @@
|
||||
-include: ../itest-common.bndrun
|
||||
|
||||
Bundle-SymbolicName: ${project.artifactId}
|
||||
Fragment-Host: org.openhab.core.ephemeris
|
||||
|
||||
feature.logging: \
|
||||
bnd.identity;id='org.apache.felix.log',\
|
||||
bnd.identity;id='org.apache.felix.logback'
|
||||
|
||||
feature.openhab-config: \
|
||||
bnd.identity;id='org.openhab.core.config.core',\
|
||||
bnd.identity;id='org.openhab.core.config.xml'
|
||||
|
||||
-runrequires: \
|
||||
${feature.logging},\
|
||||
${feature.openhab-config},\
|
||||
bnd.identity;id='org.openhab.core.ephemeris.tests'
|
||||
|
||||
# If we would like to use a storage at all, we will use the "volatile" storage.
|
||||
-runblacklist: \
|
||||
bnd.identity;id='org.openhab.core.storage.json',\
|
||||
bnd.identity;id='org.openhab.core.storage.mapdb'
|
||||
|
||||
#
|
||||
# done
|
||||
#
|
||||
-runbundles: \
|
||||
javax.measure.unit-api;version='[1.0.0,1.0.1)',\
|
||||
org.apache.commons.io;version='[2.2.0,2.2.1)',\
|
||||
org.apache.commons.lang;version='[2.6.0,2.6.1)',\
|
||||
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
|
||||
org.apache.felix.scr;version='[2.1.10,2.1.11)',\
|
||||
org.eclipse.equinox.event;version='[1.4.300,1.4.301)',\
|
||||
org.eclipse.jetty.http;version='[9.4.11,9.4.12)',\
|
||||
org.eclipse.jetty.io;version='[9.4.11,9.4.12)',\
|
||||
org.eclipse.jetty.security;version='[9.4.11,9.4.12)',\
|
||||
org.eclipse.jetty.server;version='[9.4.11,9.4.12)',\
|
||||
org.eclipse.jetty.servlet;version='[9.4.11,9.4.12)',\
|
||||
org.eclipse.jetty.util;version='[9.4.11,9.4.12)',\
|
||||
org.osgi.service.event;version='[1.4.0,1.4.1)',\
|
||||
osgi.enroute.hamcrest.wrapper;version='[1.3.0,1.3.1)',\
|
||||
osgi.enroute.junit.wrapper;version='[4.12.0,4.12.1)',\
|
||||
org.openhab.core;version='[2.5.0,2.5.1)',\
|
||||
org.openhab.core.config.core;version='[2.5.0,2.5.1)',\
|
||||
org.openhab.core.ephemeris.tests;version='[2.5.0,2.5.1)',\
|
||||
org.openhab.core.test;version='[2.5.0,2.5.1)',\
|
||||
ch.qos.logback.core;version='[1.2.3,1.2.4)',\
|
||||
slf4j.api;version='[1.7.25,1.7.26)',\
|
||||
ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
|
||||
com.google.gson;version='[2.8.2,2.8.3)',\
|
||||
org.apache.servicemix.specs.activation-api-1.1;version='[2.9.0,2.9.1)',\
|
||||
org.apache.servicemix.specs.annotation-api-1.3;version='[1.3.0,1.3.1)',\
|
||||
org.apache.servicemix.specs.jaxb-api-2.2;version='[2.9.0,2.9.1)',\
|
||||
org.apache.servicemix.specs.stax-api-1.2;version='[2.9.0,2.9.1)',\
|
||||
jollyday;version='[0.5.8,0.5.9)',\
|
||||
org.openhab.core.ephemeris;version='[2.5.0,2.5.1)',\
|
||||
org.threeten.extra;version='[1.4.0,1.4.1)',\
|
||||
org.apache.servicemix.bundles.xstream;version='[1.4.7,1.4.8)',\
|
||||
org.openhab.core.config.xml;version='[2.5.0,2.5.1)',\
|
||||
org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
|
||||
org.apache.felix.log;version='[1.2.0,1.2.1)',\
|
||||
org.apache.felix.logback;version='[1.0.0,1.0.1)',\
|
||||
tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\
|
||||
tec.uom.se;version='[1.0.10,1.0.11)'
|
23
itests/org.openhab.core.ephemeris.tests/pom.xml
Normal file
23
itests/org.openhab.core.ephemeris.tests/pom.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.openhab.core.itests</groupId>
|
||||
<artifactId>org.openhab.core.reactor.itests</artifactId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>org.openhab.core.ephemeris.tests</artifactId>
|
||||
|
||||
<name>openHAB Core :: Integration Tests :: Ephemeris Tests</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openhab.core.bundles</groupId>
|
||||
<artifactId>org.openhab.core.config.core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,236 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2019 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.smarthome.core.ephemeris.internal;
|
||||
|
||||
import static org.eclipse.smarthome.core.ephemeris.internal.EphemerisManagerImpl.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.DayOfWeek;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.smarthome.config.core.ParameterOption;
|
||||
import org.eclipse.smarthome.core.ephemeris.EphemerisManager;
|
||||
import org.eclipse.smarthome.test.java.JavaOSGiTest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test class for {@link EphemerisManagerImpl}.
|
||||
*
|
||||
* @author Christoph Weitkamp - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class EphemerisManagerImplOSGiTest extends JavaOSGiTest {
|
||||
|
||||
private static final URI CONFIG_URI = URI.create("system:ephemeris");
|
||||
private static final String COUNTRY_AUSTRALIA_KEY = "au";
|
||||
private static final String COUNTRY_AUSTRALIA_NAME = "Australia";
|
||||
private static final String REGION_BAVARIA_KEY = "by";
|
||||
private static final String REGION_NORTHRHINEWESTPHALIA_KEY = "nw";
|
||||
private static final String REGION_TASMANIA_KEY = "tas";
|
||||
private static final String REGION_TASMANIA_NAME = "Tasmania";
|
||||
private static final String CITY_HOBARD_AREA_KEY = "ho";
|
||||
private static final String CITY_HOBARD_AREA_NAME = "Hobard Area";
|
||||
|
||||
private @NonNullByDefault({}) EphemerisManagerImpl ephemerisManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ephemerisManager = getService(EphemerisManager.class, EphemerisManagerImpl.class);
|
||||
assertNotNull(ephemerisManager);
|
||||
|
||||
ephemerisManager.modified(Stream
|
||||
.of(new SimpleEntry<>(CONFIG_DAYSET_PREFIX + CONFIG_DAYSET_WEEKEND, "Saturday,Sunday"),
|
||||
new SimpleEntry<>(CONFIG_COUNTRY, Locale.GERMANY.getCountry()))
|
||||
.collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEphemerisManagerLoadedProperly() {
|
||||
assertTrue(ephemerisManager.daysets.containsKey(CONFIG_DAYSET_WEEKEND));
|
||||
assertEquals(Stream.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY).collect(Collectors.toSet()),
|
||||
ephemerisManager.daysets.get(CONFIG_DAYSET_WEEKEND));
|
||||
assertFalse(ephemerisManager.countries.isEmpty());
|
||||
assertFalse(ephemerisManager.regions.isEmpty());
|
||||
assertFalse(ephemerisManager.cities.isEmpty());
|
||||
}
|
||||
|
||||
@Test(expected = java.lang.IllegalArgumentException.class)
|
||||
public void testConfigurtationDaysetWeekendFailed() {
|
||||
ephemerisManager.modified(Collections.singletonMap(CONFIG_DAYSET_PREFIX + CONFIG_DAYSET_WEEKEND, "Foo,Bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigurtationDaysetWeekendIterable() {
|
||||
ephemerisManager.modified(Collections.singletonMap(CONFIG_DAYSET_PREFIX + CONFIG_DAYSET_WEEKEND,
|
||||
Stream.of("Saturday", "Sunday").collect(Collectors.toList())));
|
||||
assertTrue(ephemerisManager.daysets.containsKey(CONFIG_DAYSET_WEEKEND));
|
||||
assertEquals(Stream.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY).collect(Collectors.toSet()),
|
||||
ephemerisManager.daysets.get(CONFIG_DAYSET_WEEKEND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigurtationDaysetWeekendListAsString() {
|
||||
ephemerisManager.modified(Collections.singletonMap(CONFIG_DAYSET_PREFIX + CONFIG_DAYSET_WEEKEND,
|
||||
Stream.of("Saturday", "Sunday").collect(Collectors.toList()).toString()));
|
||||
assertTrue(ephemerisManager.daysets.containsKey(CONFIG_DAYSET_WEEKEND));
|
||||
assertEquals(Stream.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY).collect(Collectors.toSet()),
|
||||
ephemerisManager.daysets.get(CONFIG_DAYSET_WEEKEND));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testParsePropertyFailed() {
|
||||
ephemerisManager.parseProperty("", "");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsePropertyCountryCorrectly() {
|
||||
final Optional<ParameterOption> option = ephemerisManager.countries.stream()
|
||||
.filter(o -> COUNTRY_AUSTRALIA_KEY.equals(o.getValue())).findFirst();
|
||||
assertTrue(option.isPresent());
|
||||
assertEquals(COUNTRY_AUSTRALIA_KEY, option.get().getValue());
|
||||
assertEquals(COUNTRY_AUSTRALIA_NAME, option.get().getLabel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsePropertyRegionCorrectly() {
|
||||
assertTrue(ephemerisManager.regions.containsKey(COUNTRY_AUSTRALIA_KEY));
|
||||
final List<ParameterOption> regions = ephemerisManager.regions.get(COUNTRY_AUSTRALIA_KEY);
|
||||
assertFalse(regions.isEmpty());
|
||||
final Optional<ParameterOption> option = regions.stream().filter(o -> REGION_TASMANIA_KEY.equals(o.getValue()))
|
||||
.findFirst();
|
||||
assertTrue(option.isPresent());
|
||||
assertEquals(REGION_TASMANIA_KEY, option.get().getValue());
|
||||
assertEquals(REGION_TASMANIA_NAME, option.get().getLabel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsePropertyCityCorrectly() {
|
||||
assertTrue(ephemerisManager.cities.containsKey(REGION_TASMANIA_KEY));
|
||||
final List<ParameterOption> cities = ephemerisManager.cities.get(REGION_TASMANIA_KEY);
|
||||
assertFalse(cities.isEmpty());
|
||||
final Optional<ParameterOption> option = cities.stream().filter(o -> CITY_HOBARD_AREA_KEY.equals(o.getValue()))
|
||||
.findFirst();
|
||||
assertTrue(option.isPresent());
|
||||
assertEquals(CITY_HOBARD_AREA_KEY, option.get().getValue());
|
||||
assertEquals(CITY_HOBARD_AREA_NAME, option.get().getLabel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigOptionProviderDaysetDefault() {
|
||||
final Collection<ParameterOption> options = ephemerisManager.getParameterOptions(CONFIG_URI, "dayset-weekend",
|
||||
null);
|
||||
assertNotNull(options);
|
||||
assertEquals(7, options.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigOptionProviderDaysetUS() {
|
||||
final Collection<ParameterOption> options = ephemerisManager.getParameterOptions(CONFIG_URI, "dayset-weekend",
|
||||
Locale.US);
|
||||
assertNotNull(options);
|
||||
assertEquals(7, options.size());
|
||||
assertEquals(Stream.of(new ParameterOption("MONDAY", "Monday"), new ParameterOption("TUESDAY", "Tuesday"),
|
||||
new ParameterOption("WEDNESDAY", "Wednesday"), new ParameterOption("THURSDAY", "Thursday"),
|
||||
new ParameterOption("FRIDAY", "Friday"), new ParameterOption("SATURDAY", "Saturday"),
|
||||
new ParameterOption("SUNDAY", "Sunday")).collect(Collectors.toList()), options);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigOptionProviderDaysetGerman() {
|
||||
final Collection<ParameterOption> options = ephemerisManager.getParameterOptions(CONFIG_URI, "dayset-weekend",
|
||||
Locale.GERMAN);
|
||||
assertNotNull(options);
|
||||
assertEquals(7, options.size());
|
||||
assertEquals(Stream.of(new ParameterOption("MONDAY", "Montag"), new ParameterOption("TUESDAY", "Dienstag"),
|
||||
new ParameterOption("WEDNESDAY", "Mittwoch"), new ParameterOption("THURSDAY", "Donnerstag"),
|
||||
new ParameterOption("FRIDAY", "Freitag"), new ParameterOption("SATURDAY", "Samstag"),
|
||||
new ParameterOption("SUNDAY", "Sonntag")).collect(Collectors.toList()), options);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigOptionProviderCountries() {
|
||||
final Collection<ParameterOption> options = ephemerisManager.getParameterOptions(CONFIG_URI, CONFIG_COUNTRY,
|
||||
null);
|
||||
assertNotNull(options);
|
||||
assertFalse(options.isEmpty());
|
||||
assertEquals(ephemerisManager.countries, options);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigOptionProviderRegionsAustria() {
|
||||
ephemerisManager.modified(Collections.singletonMap(CONFIG_COUNTRY, COUNTRY_AUSTRALIA_KEY));
|
||||
|
||||
final Collection<ParameterOption> options = ephemerisManager.getParameterOptions(CONFIG_URI, CONFIG_REGION,
|
||||
null);
|
||||
assertNotNull(options);
|
||||
assertEquals(8, options.size());
|
||||
assertEquals(ephemerisManager.regions.get(COUNTRY_AUSTRALIA_KEY), options);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigOptionProviderRegionsGermany() {
|
||||
final Collection<ParameterOption> options = ephemerisManager.getParameterOptions(CONFIG_URI, CONFIG_REGION,
|
||||
null);
|
||||
assertNotNull(options);
|
||||
assertEquals(16, options.size());
|
||||
assertEquals(ephemerisManager.regions.get(Locale.GERMANY.getCountry().toLowerCase()), options);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigOptionProviderCitiesNorthRhineWestphalia() {
|
||||
ephemerisManager.modified(Stream
|
||||
.of(new SimpleEntry<>(CONFIG_COUNTRY, Locale.GERMANY.getCountry()),
|
||||
new SimpleEntry<>(CONFIG_REGION, REGION_NORTHRHINEWESTPHALIA_KEY))
|
||||
.collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
|
||||
|
||||
final Collection<ParameterOption> options = ephemerisManager.getParameterOptions(CONFIG_URI, CONFIG_CITY, null);
|
||||
assertNull(options);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigOptionProviderCitiesBavaria() {
|
||||
ephemerisManager.modified(Stream
|
||||
.of(new SimpleEntry<>(CONFIG_COUNTRY, Locale.GERMANY.getCountry()),
|
||||
new SimpleEntry<>(CONFIG_REGION, REGION_BAVARIA_KEY))
|
||||
.collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
|
||||
|
||||
final Collection<ParameterOption> options = ephemerisManager.getParameterOptions(CONFIG_URI, CONFIG_CITY, null);
|
||||
assertNotNull(options);
|
||||
assertFalse(options.isEmpty());
|
||||
assertEquals(ephemerisManager.cities.get(REGION_BAVARIA_KEY), options);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigOptionProviderCitiesTasmania() {
|
||||
ephemerisManager.modified(Stream
|
||||
.of(new SimpleEntry<>(CONFIG_COUNTRY, Locale.GERMANY.getCountry()),
|
||||
new SimpleEntry<>(CONFIG_REGION, REGION_TASMANIA_KEY))
|
||||
.collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
|
||||
|
||||
final Collection<ParameterOption> options = ephemerisManager.getParameterOptions(CONFIG_URI, CONFIG_CITY, null);
|
||||
assertNotNull(options);
|
||||
assertFalse(options.isEmpty());
|
||||
assertEquals(ephemerisManager.cities.get(REGION_TASMANIA_KEY), options);
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@
|
||||
<module>org.openhab.core.config.discovery.usbserial.tests</module>
|
||||
<module>org.openhab.core.config.dispatch.tests</module>
|
||||
<module>org.openhab.core.config.xml.tests</module>
|
||||
<module>org.openhab.core.ephemeris.tests</module>
|
||||
<module>org.openhab.core.io.rest.core.tests</module>
|
||||
<module>org.openhab.core.model.core.tests</module>
|
||||
<module>org.openhab.core.model.item.tests</module>
|
||||
|
Loading…
Reference in New Issue
Block a user