diff --git a/BUILD b/BUILD index 56372908..7947d1dc 100644 --- a/BUILD +++ b/BUILD @@ -1 +1 @@ -20180504-1035 \ No newline at end of file +20180619-1557 \ No newline at end of file diff --git a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/BaseObservation.java b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/BaseObservation.java index c30deef6..565a0bda 100644 --- a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/BaseObservation.java +++ b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/BaseObservation.java @@ -22,7 +22,7 @@ public abstract class BaseObservation implements Serializable, Comparable obsAttributes; /** @@ -83,6 +83,14 @@ public String getTimeslot() { return timeslot; } + + /** + * @param Set this observation's timestamp + */ + public void setTimeslot(String newTime) + { + this.timeslot = newTime; + } /** * @return This observation's value @@ -90,10 +98,10 @@ public String getTimeslot() public abstract T getValue(); /** - * Get this observation's value as a {@code double} number.
- * If either value is null, is not a {@link Number} instance, or if its {@link T#toString()} method returns an + * Get this observation's value as a {@code double} number. + * If either value is null, is not a {@link Number} instance, or if its {@link Object#toString() toString()} method returns an * invalid number representation, a {@link Double#NaN} is returned instead. - *

+ * * IMPLEMENTATION NOTE: This method will cause major boxing/unboxing performance impact. It was implemented * as a compatibility layer for other tools. Please use the specialized instances for series based on primitive types. * diff --git a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/GenericSDMXClient.java b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/GenericSDMXClient.java index ce40ae14..0272b395 100644 --- a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/GenericSDMXClient.java +++ b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/GenericSDMXClient.java @@ -149,5 +149,12 @@ public String buildDataURL(Dataflow dataflow, String resource, * @return the client name */ public String getName(); + + /** + *

Sets the name of this client + * @param name the name of this client + */ + + public void setName(String name); } diff --git a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/LongObservation.java b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/LongObservation.java index f62aae74..84ba2e0c 100644 --- a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/LongObservation.java +++ b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/LongObservation.java @@ -20,7 +20,6 @@ public class LongObservation extends BaseObservation * @param timeslot The timestamp of the observation. * @param value The value of the observation * @param obsAttributes A map of observation-level attributes. - * @param frequency The frequency of the series. */ public LongObservation(String timeslot, long value, Map obsAttributes) { diff --git a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/PortableTimeSeries.java b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/PortableTimeSeries.java index f1fd0ff0..83e5ee63 100644 --- a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/PortableTimeSeries.java +++ b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/api/PortableTimeSeries.java @@ -689,7 +689,7 @@ public void addDimension(String dimension) * @deprecated Use this series iterator to extract the status from each * {@link BaseObservation#getAttributeValue(String) BaseObservation}. * - * @See {@link BaseObservation#getAttributeValue(String) BaseObservation.getAttributeValue("OBS_STATUS")} + * @see BaseObservation#getAttributeValue(String) BaseObservation.getAttributeValue("OBS_STATUS") */ @Deprecated public List getStatus() @@ -704,7 +704,7 @@ public List getStatus() * @deprecated Use this series iterator to extract the status from each * {@link BaseObservation#getAttributeValue(String) BaseObservation}. * - * @See {@link BaseObservation#getAttributeValue(String) BaseObservation.getAttributeValue("OBS_STATUS")} + * @see BaseObservation#getAttributeValue(String) BaseObservation.getAttributeValue("OBS_STATUS") */ @Deprecated public String[] getStatusArray() diff --git a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/RestSdmxClient.java b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/RestSdmxClient.java index 3e823ac2..db4f8157 100644 --- a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/RestSdmxClient.java +++ b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/RestSdmxClient.java @@ -88,7 +88,7 @@ public class RestSdmxClient implements GenericSDMXClient private static final String sourceClass = RestSdmxClient.class.getSimpleName(); protected static final Logger logger = Configuration.getSdmxLogger(); - protected final String name; + protected String name; protected final boolean needsURLEncoding; protected final boolean supportsCompression; @@ -267,6 +267,12 @@ public String getName() { return name; } + + @Override + public void setName(String name) + { + this.name = name; + } @Override public String buildDataURL(Dataflow dataflow, String resource, String startTime, String endTime, boolean seriesKeyOnly, String updatedAfter, @@ -389,8 +395,10 @@ else if (conn.getContentType() != null && conn.getContentType().contains("applic } else { + InputStream is = ((HttpURLConnection)conn).getErrorStream(); + String msg = new BufferedReader(new InputStreamReader(is)).readLine(); SdmxException ex = SdmxExceptionFactory.createRestException(code, null, null); - logger.severe(ex.getMessage()); + logger.severe(msg); if (conn instanceof HttpURLConnection) ((HttpURLConnection) conn).disconnect(); throw ex; diff --git a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/SDMXClientFactory.java b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/SDMXClientFactory.java index 695bbb42..2cb31b56 100644 --- a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/SDMXClientFactory.java +++ b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/SDMXClientFactory.java @@ -65,6 +65,7 @@ public class SDMXClientFactory { private static final String INEGI_PROVIDER = "http://sdmx.snieg.mx/service/Rest"; private static final String IMF_SDMX_CENTRAL_PROVIDER = "https://sdmxcentral.imf.org/ws/public/sdmxapi/rest"; private static final String WB_PROVIDER = "https://api.worldbank.org/v2/sdmx/rest"; + private static final String ILO_PROVIDER = "https://www.ilo.org/sdmx/rest"; //read the configuration file static { @@ -100,6 +101,7 @@ private static void initBuiltInProviders() throws SdmxException{ addBuiltInProvider("INEGI", INEGI_PROVIDER, false, false, false, "Instituto Nacional de Estadistica y Geografia", false); addBuiltInProvider("IMF_SDMX_CENTRAL", IMF_SDMX_CENTRAL_PROVIDER, false, false, true, "International Monetary Fund SDMX Central", false); addBuiltInProvider("WB", WB_PROVIDER, false, false, false, "World Bank - World Development Indicators", false); + addBuiltInProvider("ILO", ILO_PROVIDER, false, false, false, "International Labour Organization", false); //add internal 2.0 providers @@ -107,20 +109,13 @@ private static void initBuiltInProviders() throws SdmxException{ addBuiltInProvider("OECD", null, false, false, false, "The Organisation for Economic Co-operation and Development", true); addBuiltInProvider("StatsEE", null, false, false, false, "Statistics Estonia (BETA)", true); addBuiltInProvider("OECD_RESTR", null, true, false, false, "The Organisation for Economic Co-operation and Development, RESTRICTED ACCESS", true); - addBuiltInProvider("ILO", null, false, false, false, "International Labour Organization", true); + addBuiltInProvider("ILO_Legacy", null, false, false, false, "International Labour Organization - Old Endpoint", true); addBuiltInProvider("IMF2", null, false, false, false, "New International Monetary Fund endpoint", true); addBuiltInProvider("ABS", null, false, false, false, "Australian Bureau of Statistics", true); addBuiltInProvider("NBB", null, false, false, false, "National Bank Belgium", true); addBuiltInProvider("UIS", null, false, false, false, "Unesco Institute for Statistics", true); addBuiltInProvider("EUROSTAT", null, false, false, false, "Eurostat", true); - //addBuiltInProvider("FILE", null, false, false, false, "File offline provider", true); - - //Legacy 2.0 - ServiceLoader ldr = ServiceLoader.load(GenericSDMXClient.class); - for (GenericSDMXClient provider : ldr) { - addProvider(provider.getClass().getSimpleName(), null, null, provider.needsCredentials(), false, false, provider.getClass().getSimpleName(), true); - } } /** @@ -253,9 +248,11 @@ public static GenericSDMXClient createClient(String providerName) throws SdmxExc logger.fine("Create an SDMX client for '" + providerName + "'"); GenericSDMXClient client = null; Provider provider = providers.get(providerName); + if(provider == null){ + throw new SdmxInvalidParameterException("The provider '" + providerName + "' is not available in this configuration."); + } String hostname = null; - String errorMsg = "The provider '" + providerName + "' is not available in this configuration."; if(provider != null && !provider.isCustom()) { hostname = provider.getEndpoint().getHost(); @@ -267,8 +264,7 @@ else if(provider.getEndpoint().getScheme().toLowerCase().equals("file")){ } else { - logger.severe("The protocol '" + provider.getEndpoint().getScheme() + "' is not supported."); - throw new SdmxInvalidParameterException(errorMsg); + throw new SdmxInvalidParameterException("The protocol '" + provider.getEndpoint().getScheme() + "' is not supported."); } } else { @@ -283,6 +279,8 @@ else if(provider.getEndpoint().getScheme().toLowerCase().equals("file")){ if (client.getEndpoint() != null) hostname = client.getEndpoint().getHost(); + + client.setName(providerName); } catch (ClassNotFoundException e) { logger.severe("The provider '" + providerName + "' is not available in this configuration."); diff --git a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/custom/ILO.java b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/custom/ILO_Legacy.java similarity index 89% rename from JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/custom/ILO.java rename to JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/custom/ILO_Legacy.java index 128c70c0..ba4ebb2f 100644 --- a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/custom/ILO.java +++ b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/client/custom/ILO_Legacy.java @@ -36,13 +36,13 @@ * @author Attilio Mattiocco * */ -public class ILO extends RestSdmx20Client { +public class ILO_Legacy extends RestSdmx20Client { protected static Logger logger = Configuration.getSdmxLogger(); - public ILO() throws URISyntaxException { + public ILO_Legacy() throws URISyntaxException { //the ILO providers supports https but it gets errors with java 1.6 - super("ILO", new URI("https://www.ilo.org/ilostat/sdmx/ws/rest"), false, "application/vnd.sdmx.structurespecificdata+xml;version=2.1", ""); + super("ILO_Legacy", new URI("https://www.ilo.org/ilostat/sdmx/ws/rest"), false, "application/vnd.sdmx.structurespecificdata+xml;version=2.1", ""); } @Override diff --git a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/parser/v21/CompactDataParser.java b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/parser/v21/CompactDataParser.java index 5b4f0bf5..5f8a7436 100644 --- a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/parser/v21/CompactDataParser.java +++ b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/parser/v21/CompactDataParser.java @@ -212,6 +212,7 @@ else if (name.equals(dsd.getMeasure())) try { ts.add(new DoubleObservation(time, Double.valueOf(obs_val), obs_attr)); } catch (NumberFormatException e) { + logger.fine("The date: " + time + "has an obs value that is not parseable to a numer: " + obs_val + ". A NaN will be set."); ts.add(new DoubleObservation(time, Double.NaN, obs_attr)); } continue; diff --git a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/parser/v21/GenericDataParser.java b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/parser/v21/GenericDataParser.java index 343fcc60..0c8e70a5 100644 --- a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/parser/v21/GenericDataParser.java +++ b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/parser/v21/GenericDataParser.java @@ -200,7 +200,7 @@ else if (attribute.getName().toString().equalsIgnoreCase(VALUE)) { private static void setSeriesSingleObs(PortableTimeSeries ts, XMLEventReader eventReader) throws XMLStreamException, SdmxException { String time = null; - String val = null; + String val = ""; Hashtable obs_attr = new Hashtable(); while (eventReader.hasNext()) { XMLEvent event = eventReader.nextEvent(); @@ -208,12 +208,32 @@ private static void setSeriesSingleObs(PortableTimeSeries ts, XMLEventRe if (event.isStartElement()) { StartElement startElement = event.asStartElement(); if (startElement.getName().getLocalPart() == (OBS_TIME)) { - time = startElement.getAttributeByName(new QName(VALUE)).getValue(); + @SuppressWarnings("unchecked") + Iterator attributes = startElement.getAttributes(); + while (attributes.hasNext()) + { + Attribute attribute = attributes.next(); + String name = attribute.getName().toString(); + if (name.equals(VALUE)) + { + time = attribute.getValue(); + } + } } - if (startElement.getName().getLocalPart() == (OBS_VALUE)) { - val = startElement.getAttributeByName(new QName(VALUE)).getValue(); + else if (startElement.getName().getLocalPart() == (OBS_VALUE)) { + @SuppressWarnings("unchecked") + Iterator attributes = startElement.getAttributes(); + while (attributes.hasNext()) + { + Attribute attribute = attributes.next(); + String name = attribute.getName().toString(); + if (name.equals(VALUE)) + { + val = attribute.getValue(); + } + } } - if (startElement.getName().getLocalPart() == (ATTRIBUTEVALUE)) { + else if (startElement.getName().getLocalPart() == (ATTRIBUTEVALUE)) { String name = startElement.getAttributeByName(new QName(ID)).getValue(); String value = startElement.getAttributeByName(new QName(VALUE)).getValue(); obs_attr.put(name, value); @@ -225,6 +245,7 @@ private static void setSeriesSingleObs(PortableTimeSeries ts, XMLEventRe try { ts.add(new DoubleObservation(time, Double.valueOf(val), obs_attr)); } catch (NumberFormatException e) { + logger.fine("The date: " + time + "has an obs value that is not parseable to a numer: " + val + ". A NaN will be set."); ts.add(new DoubleObservation(time, Double.NaN, obs_attr)); } break; diff --git a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/util/Configuration.java b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/util/Configuration.java index d7d76b7a..e4983d84 100644 --- a/JAVA/src/main/java/it/bancaditalia/oss/sdmx/util/Configuration.java +++ b/JAVA/src/main/java/it/bancaditalia/oss/sdmx/util/Configuration.java @@ -135,7 +135,8 @@ protected static void setSdmxLogger() public static Logger getSdmxLogger() { - return SDMX_LOGGER == null ? (SDMX_LOGGER = Logger.getLogger(LOGGER_NAME)) : SDMX_LOGGER; + Logger r = SDMX_LOGGER == null ? (SDMX_LOGGER = Logger.getLogger(LOGGER_NAME)) : SDMX_LOGGER; + return r; } public static Properties getConfiguration(){ @@ -229,7 +230,9 @@ private static void init() { SDMX_LOGGER.info("Local configuration file found: " + confType ); } catch (SecurityException e) { // impossible + e.printStackTrace(); } catch (IOException e) { + e.printStackTrace(); SDMX_LOGGER.finer(logException(e)); } } @@ -245,8 +248,10 @@ private static void init() { confType = central; SDMX_LOGGER.info("Central configuration file found: " + confType); } catch (SecurityException e) { + e.printStackTrace(); // impossible } catch (IOException e) { + e.printStackTrace(); SDMX_LOGGER.finer(logException(e)); } } @@ -268,13 +273,18 @@ private static void init() { SDMX_LOGGER.fine("Class configuration not found, skipping to global conf"); } catch (SecurityException e) { // impossible + e.printStackTrace(); } catch (NoSuchMethodException e) { // impossible + e.printStackTrace(); } catch (IllegalArgumentException e) { // impossible + e.printStackTrace(); } catch (IllegalAccessException e) { // impossible + e.printStackTrace(); } catch (InvocationTargetException e) { + e.printStackTrace(); SDMX_LOGGER.info("Error during SdmxConfiguration class initialization, skipping to global conf."); SDMX_LOGGER.severe(logException(e.getCause())); } diff --git a/JAVA/src/test/java/it/bancaditalia/oss/sdmx/it/DimensionsAndCodesIT.java b/JAVA/src/test/java/it/bancaditalia/oss/sdmx/it/DimensionsAndCodesIT.java index 6dd7f6a9..595deeb8 100644 --- a/JAVA/src/test/java/it/bancaditalia/oss/sdmx/it/DimensionsAndCodesIT.java +++ b/JAVA/src/test/java/it/bancaditalia/oss/sdmx/it/DimensionsAndCodesIT.java @@ -32,7 +32,7 @@ public static Collection data() { { "ISTAT", "144_125", "FREQ", "A", "annual", "[Dimension [id=FREQ, position=1, codelist=Codelist [id=IT1/CL_FREQ/1.0, codes={D=daily, E=event (not supported), W=weekly, Q=quarterly, A=an" }, { "INSEE", "CNA-2010-CONSO-SI", "FREQ", "A", "Annual", "[Dimension [id=FREQ, position=1, codelist=Codelist [id=FR1/CL_PERIODICITE/1.0, codes={T=Quarterly, A=Annual, B=Two-monthly, S=Semi-annual, M=Monthly}]]" }, { "INEGI", "DF_STEI", "REF_AREA", "MX", "Mexico", "[Dimension [id=REF_AREA, position=1, codelist=Codelist [id=SDMX/CL_AREA/1.0, codes={VU=Vanuatu, EC=Ecuador, VN=Viet Nam, VI=U.S.\", DZ=Algeria, VG=British\", DM=Dominica, VE=Venezuela, DO=Dominican " }, - { "ILO", "DF_YI_ALL_EMP_TEMP_SEX_AGE_NB", "COLLECTION", "MIG", "Labour Migration Statistics", "[Dimension [id=COLLECTION, position=1, codelist=Codelist [id=ILO/CL_COLLECTION, codes={YTH=youthSTATS - discontinued (latest period: 2013), SSI=Social Security Indicators, KIST=Key I" }, + { "ILO", "DF_YI_ALL_EMP_TEMP_SEX_AGE_NB", "COLLECTION", "YI", "Yearly indicators", "[Dimension [id=COLLECTION, position=1, codelist=Codelist [id=ILO/CL_COLLECTION/1.0, codes={YI=Yearly indica" }, { "EUROSTAT", "prc_hicp_midx", "FREQ", "A", "Annual", "[Dimension [id=FREQ, position=1, codelist=Codelist [id=ESTAT/CL_FREQ/1.0, codes={D=Daily, W=Weekly, Q=Quarterly, A=Annual, S=Semi-annual, M=Monthly, H" }, { "IMF2", "DS-WHDREO", "FREQ", "A", "Annual", "[Dimension [id=FREQ, position=1, codelist=Codelist [id=IMF/CL_FREQ, codes={D=Daily, W=Weekly, Q=Quarterly, A=Annu" }, { "IMF_SDMX_CENTRAL", "SPI", "FREQ", "A", "Annual", "[Dimension [id=DATA_DOMAIN, position=1, codelist=Codelist [id=IMF/CL_DATADOMAIN/1.0, codes={SPI=S" }, diff --git a/JAVA/src/test/java/it/bancaditalia/oss/sdmx/ut/AllTests.java b/JAVA/src/test/java/it/bancaditalia/oss/sdmx/ut/AllTests.java index d5681759..de63de3b 100644 --- a/JAVA/src/test/java/it/bancaditalia/oss/sdmx/ut/AllTests.java +++ b/JAVA/src/test/java/it/bancaditalia/oss/sdmx/ut/AllTests.java @@ -31,7 +31,6 @@ @Suite.SuiteClasses( { SdmxInterfaceTest.class, DimensionsAndCodesIT.class, DSDIdentifiersIT.class, -// NBBTest.class, ProxyTest.class, // FileTest.class, LanguagePriorityListTest.class, diff --git a/MATLAB/Contents.m b/MATLAB/Contents.m index fa2e6af3..4109aaf3 100644 --- a/MATLAB/Contents.m +++ b/MATLAB/Contents.m @@ -1,5 +1,5 @@ % Toolbox MatSDMX -% Version 2.0.6 +% Version 2.1.0 % MATLAB interface to SDMX Web Services % % Files diff --git a/RJSDMX/DESCRIPTION b/RJSDMX/DESCRIPTION index 2c5a8dfb..c080552f 100644 --- a/RJSDMX/DESCRIPTION +++ b/RJSDMX/DESCRIPTION @@ -1,5 +1,5 @@ Package: RJSDMX -Version: 2.0-7 +Version: 2.1-0 Title: R Interface to SDMX Web Services Author: Attilio Mattiocco, Diana Nicoletti, Gianpaolo Lopez, Banca d'Italia Maintainer: Attilio Mattiocco diff --git a/RJSDMX/R/onLoad.R b/RJSDMX/R/onLoad.R index 90813300..4016bc6b 100644 --- a/RJSDMX/R/onLoad.R +++ b/RJSDMX/R/onLoad.R @@ -20,10 +20,10 @@ # .onLoad <- function(libname, pkgname) { .jpackage(pkgname, lib.loc = libname) - jv <- .jcall("java/lang/System", "S", "getProperty", "java.runtime.version") - if(substr(jv, 1L, 1L) == "1") { - jvn <- as.numeric(paste0(strsplit(jv, "[.]")[[1L]][1:2], collapse = ".")) - if(jvn < 1.7) stop(paste("Java 7 is needed for this package but rJava is linked to Java ", jvn)) - } + #jv <- .jcall("java/lang/System", "S", "getProperty", "java.runtime.version") + #if(substr(jv, 1L, 1L) == "1") { + # jvn <- as.numeric(paste0(strsplit(jv, "[.]")[[1L]][1:2], collapse = ".")) + # if(jvn < 1.7) stop(paste("Java 7 is needed for this package but rJava is linked to Java ", jvn)) + #} } diff --git a/RJSDMX/inst/java/SDMX.jar b/RJSDMX/inst/java/SDMX.jar index 377c0abe..d4a22c76 100644 Binary files a/RJSDMX/inst/java/SDMX.jar and b/RJSDMX/inst/java/SDMX.jar differ diff --git a/STATA/jar/SDMX.jar b/STATA/jar/SDMX.jar index 377c0abe..156bd0f0 100644 Binary files a/STATA/jar/SDMX.jar and b/STATA/jar/SDMX.jar differ