Skip to content

Commit

Permalink
Remove dialect API
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi committed Jul 10, 2023
1 parent e270269 commit c60dee7
Show file tree
Hide file tree
Showing 68 changed files with 86 additions and 829 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- ![API] Refactor cache API [#500](https://github.com/nbbrd/sdmx-dl/issues/500)
- ![API] Refactor network API [#503](https://github.com/nbbrd/sdmx-dl/issues/503)
- ![API] Remove dialect API [#505](https://github.com/nbbrd/sdmx-dl/issues/505)
- ![SOURCE] Update ECB endpoint [#495](https://github.com/nbbrd/sdmx-dl/issues/495)
- ![FORMAT] Refactor file format API [#502](https://github.com/nbbrd/sdmx-dl/issues/502)
- ![PROVIDER] Move curl backend to an external project
Expand Down
11 changes: 5 additions & 6 deletions docs/content/cli/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ Output format:
[`Description:string`](../datatypes#string),
[`Aliases:list`](../datatypes#list),
[`Driver:string`](../datatypes#string),
[`Dialect:string`](../datatypes#string),
[`Endpoint:uri`](../datatypes#uri),
[`Properties:map`](../datatypes#list),
[`Website:url`](../datatypes#url),
Expand All @@ -254,11 +253,11 @@ Output format:

{{< expand "Output sample" >}}

| Name | Description | Aliases | Driver | Dialect | Endpoint | Properties | Website | Monitor | MonitorWebsite | Languages |
|-------|---------------------------------|----------|---------------------|---------|--------------------------------------------------|----------------------|---------------------------------------------|-----------------------------------|----------------------------------------------------|-----------|
| ABS | Australian Bureau of Statistics | | ri:abs | | https://stat.data.abs.gov.au/restsdmx/sdmx.ashx | | https://stat.data.abs.gov.au | upptime:/nbbrd/sdmx-upptime/ABS | https://nbbrd.github.io/sdmx-upptime/history/abs | en |
| ECB | European Central Bank | | ri:sdmx21 | ECB2020 | https://sdw-wsrest.ecb.europa.eu/service | detailSupported=true | https://sdw.ecb.europa.eu | upptime:/nbbrd/sdmx-upptime/ECB | https://nbbrd.github.io/sdmx-upptime/history/ecb | en |
| ESTAT | Eurostat | EUROSTAT | connectors:eurostat | | https://ec.europa.eu/eurostat/SDMX/diss-web/rest | | https://ec.europa.eu/eurostat/data/database | upptime:/nbbrd/sdmx-upptime/ESTAT | https://nbbrd.github.io/sdmx-upptime/history/estat | en,de,fr |
| Name | Description | Aliases | Driver | Endpoint | Properties | Website | Monitor | MonitorWebsite | Languages |
|-------|---------------------------------|----------|---------------------|--------------------------------------------------|----------------------|---------------------------------------------|-----------------------------------|----------------------------------------------------|-----------|
| ABS | Australian Bureau of Statistics | | ri:abs | https://stat.data.abs.gov.au/restsdmx/sdmx.ashx | | https://stat.data.abs.gov.au | upptime:/nbbrd/sdmx-upptime/ABS | https://nbbrd.github.io/sdmx-upptime/history/abs | en |
| ECB | European Central Bank | | ri:sdmx21 | https://sdw-wsrest.ecb.europa.eu/service | detailSupported=true | https://sdw.ecb.europa.eu | upptime:/nbbrd/sdmx-upptime/ECB | https://nbbrd.github.io/sdmx-upptime/history/ecb | en |
| ESTAT | Eurostat | EUROSTAT | connectors:eurostat | https://ec.europa.eu/eurostat/SDMX/diss-web/rest | | https://ec.europa.eu/eurostat/data/database | upptime:/nbbrd/sdmx-upptime/ESTAT | https://nbbrd.github.io/sdmx-upptime/history/estat | en,de,fr |

{{< /expand >}}

Expand Down
68 changes: 34 additions & 34 deletions docs/tmp/sources.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,6 @@ public boolean isAvailable() {
return result;
}

@Override
public @NonNull String getDefaultDialect() {
String result;

try {
result = delegate.getDefaultDialect();
} catch (RuntimeException ex) {
unexpectedError("while getting default dialect", ex);
return NO_DEFAULT_DIALECT;
}

if (result == null) {
unexpectedNull("null list");
return NO_DEFAULT_DIALECT;
}

return result;
}

private IOException newUnexpectedError(String context, RuntimeException ex) {
String msg = "Unexpected " + ex.getClass().getSimpleName() + " " + context;
onUnexpectedError.accept(msg, ex);
Expand Down
1 change: 0 additions & 1 deletion sdmx-dl-api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
exports sdmxdl.web.spi;

uses sdmxdl.ext.spi.Caching;
uses sdmxdl.ext.spi.Dialect;
uses sdmxdl.file.spi.FileReader;
uses sdmxdl.web.spi.Networking;
uses sdmxdl.web.spi.WebAuthenticator;
Expand Down
3 changes: 0 additions & 3 deletions sdmx-dl-api/src/main/java/sdmxdl/SdmxManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import sdmxdl.web.SdmxWebManager;

import java.io.IOException;
import java.util.Optional;

/**
* @author Philippe Charles
Expand All @@ -45,8 +44,6 @@ public abstract class SdmxManager<SOURCE extends SdmxSource> {

public abstract @NonNull SdmxSourceConsumer<? super SOURCE, ? super String> getEventListener();

public abstract @NonNull Optional<String> getDialect(@NonNull SOURCE source);

public static final SdmxSourceConsumer<SdmxSource, String> NO_OP_EVENT_LISTENER = (source, t) -> {
};
}
2 changes: 0 additions & 2 deletions sdmx-dl-api/src/main/java/sdmxdl/SdmxSource.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sdmxdl;

import nbbrd.design.SealedType;
import org.checkerframework.checker.nullness.qual.Nullable;
import sdmxdl.file.SdmxFileSource;
import sdmxdl.web.SdmxWebSource;

Expand All @@ -11,5 +10,4 @@
})
public abstract class SdmxSource {

public abstract @Nullable String getDialect();
}
63 changes: 0 additions & 63 deletions sdmx-dl-api/src/main/java/sdmxdl/ext/Registry.java

This file was deleted.

49 changes: 0 additions & 49 deletions sdmx-dl-api/src/main/java/sdmxdl/ext/spi/Dialect.java

This file was deleted.

5 changes: 0 additions & 5 deletions sdmx-dl-api/src/main/java/sdmxdl/file/SdmxFileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ public class SdmxFileManager extends SdmxManager<SdmxFileSource> {
return reader.read(source, getContext());
}

@Override
public @NonNull Optional<String> getDialect(@NonNull SdmxFileSource source) {
return Optional.ofNullable(source.getDialect());
}

private FileContext initContext() {
return FileContext
.builder()
Expand Down
3 changes: 0 additions & 3 deletions sdmx-dl-api/src/main/java/sdmxdl/file/SdmxFileSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public class SdmxFileSource extends SdmxSource {
@Nullable
File structure;

@Nullable
String dialect;

@NonNull
public DataflowRef asDataflowRef() {
return DataflowRef.parse("data" + (structure != null && !structure.toString().isEmpty() ? "&struct" : ""));
Expand Down
7 changes: 0 additions & 7 deletions sdmx-dl-api/src/main/java/sdmxdl/web/SdmxWebManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,6 @@ public MonitorReport getMonitorReport(@NonNull SdmxWebSource source) throws IOEx
return monitoring.getReport(source, getContext());
}

@Override
public @NonNull Optional<String> getDialect(@NonNull SdmxWebSource source) {
return source.getDialect() != null
? Optional.of(source.getDialect())
: lookupDriverById(source.getDriver()).map(WebDriver::getDefaultDialect);
}

private void checkSourceProperties(SdmxWebSource source, WebDriver driver) {
if (eventListener != NO_OP_EVENT_LISTENER) {
Collection<String> expected = driver.getSupportedProperties();
Expand Down
3 changes: 0 additions & 3 deletions sdmx-dl-api/src/main/java/sdmxdl/web/SdmxWebSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ public class SdmxWebSource extends SdmxSource {
@lombok.NonNull
String driver;

@Nullable
String dialect;

@lombok.NonNull
URI endpoint;

Expand Down
4 changes: 0 additions & 4 deletions sdmx-dl-api/src/main/java/sdmxdl/web/spi/WebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ Connection connect(
@NonNull
Collection<String> getSupportedProperties();

@NonNull String getDefaultDialect();

int NATIVE_RANK = Byte.MAX_VALUE;
int WRAPPED_RANK = 0;
int UNKNOWN_RANK = -1;

String NO_DEFAULT_DIALECT = "";
}
19 changes: 1 addition & 18 deletions sdmx-dl-api/src/test/java/_test/sdmxdl/TestDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import java.util.Collection;
import java.util.Collections;

import static sdmxdl.ext.spi.Dialect.SDMX21_DIALECT;

/**
* @author Philippe Charles
*/
Expand Down Expand Up @@ -61,11 +59,6 @@ public boolean isAvailable() {
public @NonNull Collection<String> getSupportedProperties() {
return Collections.singletonList("hello");
}

@Override
public @NonNull String getDefaultDialect() {
return NO_DEFAULT_DIALECT;
}
}, FAILING {
@Override
public @NonNull String getId() {
Expand Down Expand Up @@ -96,11 +89,6 @@ public boolean isAvailable() {
public @NonNull Collection<String> getSupportedProperties() {
throw new CustomException();
}

@Override
public @NonNull String getDefaultDialect() {
throw new CustomException();
}
}, NULL {
@Override
public @NonNull String getId() {
Expand Down Expand Up @@ -131,12 +119,7 @@ public boolean isAvailable() {
public @NonNull Collection<String> getSupportedProperties() {
return null;
}

@Override
public @NonNull String getDefaultDialect() {
return null;
}
};

public static final SdmxWebSource SOURCE = SdmxWebSource.builder().id("123").driver("456").dialect(SDMX21_DIALECT).endpointOf("http://localhost").build();
public static final SdmxWebSource SOURCE = SdmxWebSource.builder().id("123").driver("456").endpointOf("http://localhost").build();
}
13 changes: 3 additions & 10 deletions sdmx-dl-api/src/test/java/sdmxdl/web/SdmxWebManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
import org.junit.jupiter.api.Test;
import sdmxdl.*;
import sdmxdl.ext.spi.Caching;
import sdmxdl.ext.spi.Dialect;
import sdmxdl.web.spi.Networking;
import sdmxdl.web.spi.WebDriver;
import tests.sdmxdl.api.SdmxManagerAssert;
import tests.sdmxdl.ext.MockedDialect;
import tests.sdmxdl.web.MockedDriver;

import java.io.IOException;
Expand Down Expand Up @@ -103,7 +101,6 @@ public void testGetSources() {
SdmxWebSource abs = SdmxWebSource.builder().id("abs").driver("sdmx21").endpointOf("http://abs").build();

SdmxWebSource nbbAlias = nbb.alias("bnb");
SdmxWebSource nbbDialect = nbb.toBuilder().dialect("custom").clearAliases().build();

WebDriver sdmx21 = MockedDriver
.builder()
Expand Down Expand Up @@ -141,7 +138,6 @@ public void testGetSources() {
SdmxWebManager
.builder()
.customSource(nbb)
.customSource(nbbDialect)
.customSource(abs)
.build()
.getSources()
Expand All @@ -157,7 +153,6 @@ public void testGetSources() {
SdmxWebManager
.builder()
.driver(sdmx21)
.customSource(nbbDialect)
.customSource(abs)
.build()
.getSources()
Expand All @@ -167,7 +162,7 @@ public void testGetSources() {
entryOf("abs", abs),
entryOf("bnb", nbbAlias),
entryOf("ecb", ecb),
entryOf("nbb", nbbDialect)
entryOf("nbb", nbb)
);
}

Expand Down Expand Up @@ -207,7 +202,7 @@ public void testGetConnection() throws IOException {
.rank(WRAPPED_RANK)
.available(true)
.repo(sample, EnumSet.allOf(Feature.class))
.customSource(SdmxWebSource.builder().id("source").driver("d1").dialect("azerty").endpointOf(sample.getName()).build())
.customSource(SdmxWebSource.builder().id("source").driver("d1").endpointOf(sample.getName()).build())
.build();

WebDriver driver2 = MockedDriver
Expand All @@ -216,7 +211,7 @@ public void testGetConnection() throws IOException {
.rank(NATIVE_RANK)
.available(true)
.repo(sample, EnumSet.allOf(Feature.class))
.customSource(SdmxWebSource.builder().id("source").driver("d2").dialect("azerty").endpointOf(sample.getName()).build())
.customSource(SdmxWebSource.builder().id("source").driver("d2").endpointOf(sample.getName()).build())
.build();

try (Connection c = SdmxWebManager.builder().driver(driver2).driver(driver1).build().getConnection("source")) {
Expand Down Expand Up @@ -278,7 +273,6 @@ public void testInvalidSourceProperties() throws IOException {
.builder()
.id("repoSource")
.driver("repoDriver")
.dialect("azerty")
.endpointOf(sample.getName())
.build();
private final WebDriver sampleDriver = MockedDriver
Expand All @@ -289,7 +283,6 @@ public void testInvalidSourceProperties() throws IOException {
.repo(sample, EnumSet.allOf(Feature.class))
.customSource(sampleSource)
.build();
private final Dialect sampleDialect = new MockedDialect("azerty");

private static <K, V> AbstractMap.SimpleEntry<K, V> entryOf(K name, V source) {
return new AbstractMap.SimpleEntry<>(name, source);
Expand Down
Loading

0 comments on commit c60dee7

Please sign in to comment.