Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi committed Oct 16, 2023
2 parents 1cf724b + 27dea34 commit 3e1cd19
Show file tree
Hide file tree
Showing 38 changed files with 826 additions and 842 deletions.
5 changes: 3 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
version: 2
updates:
- package-ecosystem: "maven"
- package-ecosystem: maven
target-branch: "develop"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
day: "saturday"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
target-branch: "develop"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/java-ea-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [ '-ea' ]
java: [ 20 ]
os: [ ubuntu-latest ]

name: JDK${{ matrix.java }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand Down
30 changes: 25 additions & 5 deletions .github/workflows/java-maven.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Java with Maven
name: Java8+ with Maven

on: [ push, pull_request ]

jobs:
build-and-test-job:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/tags/v')
strategy:
fail-fast: false
matrix:
Expand All @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand All @@ -28,11 +28,31 @@ jobs:
java-version: ${{ matrix.java }}
cache: 'maven'

- name: Pre-download dependencies with Maven
run: mvn -U -B -ntp dependency:go-offline

- name: Build and (headless) test with Maven
uses: smithki/xvfb-action@v1.1.2
with:
run: mvn -U -B -ntp package

auto-merge-job:
needs: build-and-test-job
if: startsWith(github.repository, 'nbbrd/') && github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
permissions:
contents: write
pull-requests: write

name: Auto-merge on dependabot PR
runs-on: ubuntu-latest

steps:
- name: Merge PR
run: gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

snapshot-job:
needs: build-and-test-job
if: startsWith(github.repository, 'nbbrd/') && startsWith(github.ref, 'refs/heads/develop')
Expand All @@ -46,7 +66,7 @@ jobs:

steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand Down Expand Up @@ -96,7 +116,7 @@ jobs:

steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand Down
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [3.1.0] - 2023-10-16

This is a feature release of SDMX extensions for JDemetra+ v3.
[JDemetra+ v3.1.1 or later](https://github.com/jdemetra/jdplus-main) version is required to run it.

### Added

- Allow configuration by environment variables

### Fixed

- Fix favicons transparency, cache and loading
- Fix dimensions and attributes autocompletion

### Changed

- Bump sdmx-dl from 3.0.0-beta.11 to [3.0.0-beta.12](https://github.com/nbbrd/sdmx-dl/releases/tag/v3.0.0-beta.12)

## [3.0.0] - 2023-06-14

This is the **initial release** of SDMX extensions for JDemetra+ v3.
[JDemetra+ v3.0.2 or later](https://github.com/jdemetra/jdplus-main) version is required to run it.

[Unreleased]: https://github.com/nbbrd/jdplus-sdmx/compare/v3.0.0...HEAD
[Unreleased]: https://github.com/nbbrd/jdplus-sdmx/compare/v3.1.0...HEAD
[3.1.0]: https://github.com/nbbrd/jdplus-sdmx/compare/v3.0.0...v3.1.0
[3.0.0]: https://github.com/nbbrd/jdplus-sdmx/releases/tag/v3.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.nbbrd.jdplus-sdmx</groupId>
<artifactId>jdplus-sdmx-base-parent</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
</parent>

<artifactId>jdplus-sdmx-base-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import jdplus.toolkit.base.tsp.cube.CubeId;
import jdplus.toolkit.base.tsp.cube.CubeSeries;
import jdplus.toolkit.base.tsp.cube.CubeSeriesWithData;
import lombok.NonNull;
import nbbrd.design.VisibleForTesting;
import sdmxdl.*;
import sdmxdl.ext.SdmxCubeUtil;
Expand All @@ -45,22 +46,23 @@
@lombok.RequiredArgsConstructor
public final class SdmxCubeConnection implements CubeConnection {

public static SdmxCubeConnection of(Connection connection, DataflowRef ref, List<String> dimensions, String labelAttribute, String sourceLabel) throws IOException {
Dataflow flow = connection.getFlow(ref);
DataStructure dsd = connection.getStructure(ref);
public static SdmxCubeConnection of(Connection connection, FlowRef ref, List<String> dimensions, String labelAttribute, String sourceLabel, boolean displayCodes) throws IOException {
Flow flow = connection.getFlow(ref);
Structure dsd = connection.getStructure(ref);
CubeId root = getOrLoadRoot(dimensions, dsd);
return new SdmxCubeConnection(connection, flow, dsd, root, labelAttribute, sourceLabel);
return new SdmxCubeConnection(connection, flow, dsd, root, labelAttribute, sourceLabel, displayCodes);
}

private final Connection connection;
private final Dataflow flow;
private final DataStructure dsd;
private final Flow flow;
private final Structure dsd;
private final CubeId root;
private final String labelAttribute;
private final String sourceLabel;
private final boolean displayCodes;

@Override
public Optional<IOException> testConnection() {
public @NonNull Optional<IOException> testConnection() {
try {
connection.testConnection();
return Optional.empty();
Expand All @@ -70,44 +72,44 @@ public Optional<IOException> testConnection() {
}

@Override
public CubeId getRoot() {
public @NonNull CubeId getRoot() {
return root;
}

@Override
public Stream<CubeSeries> getAllSeries(CubeId ref) throws IOException {
public @NonNull Stream<CubeSeries> getAllSeries(@NonNull CubeId ref) throws IOException {
KeyConverter converter = KeyConverter.of(dsd, ref);
return SdmxCubeUtil
.getAllSeries(connection, flow.getRef(), converter.toKey(ref))
.map(series -> cubeSeriesOf(converter, series, labelAttribute));
}

@Override
public Stream<CubeSeriesWithData> getAllSeriesWithData(CubeId ref) throws IOException {
public @NonNull Stream<CubeSeriesWithData> getAllSeriesWithData(@NonNull CubeId ref) throws IOException {
KeyConverter converter = KeyConverter.of(dsd, ref);
return SdmxCubeUtil
.getAllSeriesWithData(connection, flow.getRef(), converter.toKey(ref))
.map(series -> cubeSeriesWithDataOf(converter, series, labelAttribute));
}

@Override
public Optional<CubeSeries> getSeries(CubeId id) throws IOException {
public @NonNull Optional<CubeSeries> getSeries(@NonNull CubeId id) throws IOException {
KeyConverter converter = KeyConverter.of(dsd, id);
return SdmxCubeUtil
.getSeries(connection, flow.getRef(), converter.toKey(id))
.map(series -> cubeSeriesOf(converter, series, labelAttribute));
}

@Override
public Optional<CubeSeriesWithData> getSeriesWithData(CubeId ref) throws IOException {
public @NonNull Optional<CubeSeriesWithData> getSeriesWithData(@NonNull CubeId ref) throws IOException {
KeyConverter converter = KeyConverter.of(dsd, ref);
return SdmxCubeUtil
.getSeriesWithData(connection, flow.getRef(), converter.toKey(ref))
.map(series -> cubeSeriesWithDataOf(converter, series, labelAttribute));
}

@Override
public Stream<CubeId> getChildren(CubeId ref) throws IOException {
public @NonNull Stream<CubeId> getChildren(@NonNull CubeId ref) throws IOException {
KeyConverter converter = KeyConverter.of(dsd, ref);
String dimensionId = ref.getDimensionId(ref.getLevel());
int dimensionIndex = SdmxCubeUtil.getDimensionIndexById(dsd, dimensionId).orElseThrow(RuntimeException::new);
Expand All @@ -118,24 +120,26 @@ public Stream<CubeId> getChildren(CubeId ref) throws IOException {
}

@Override
public String getDisplayName() {
public @NonNull String getDisplayName() {
return String.format(Locale.ROOT, "%s ~ %s", sourceLabel, flow.getName());
}

@Override
public String getDisplayName(CubeId id) {
public @NonNull String getDisplayName(CubeId id) {
if (id.isVoid()) {
return "All";
}
return getKey(dsd, id).toString();
}

@Override
public String getDisplayNodeName(CubeId id) {
public @NonNull String getDisplayNodeName(CubeId id) {
if (id.isVoid()) {
return "All";
}
return getDisplayNodeName(dsd, id);
return displayCodes
? getDimensionCodeId(id)
: getDimensionCodeLabel(id, dsd);
}

@Override
Expand All @@ -152,7 +156,12 @@ private static CubeSeriesWithData cubeSeriesWithDataOf(KeyConverter converter, S
return new CubeSeriesWithData(converter.fromKey(series.getKey()), series.getMeta().get(labelAttribute), series.getMeta(), getData(series));
}

private static String getDisplayNodeName(DataStructure dsd, CubeId ref) {
private static String getDimensionCodeId(CubeId ref) {
int index = ref.getLevel() - 1;
return ref.getDimensionValue(index);
}

private static String getDimensionCodeLabel(CubeId ref, Structure dsd) {
if (ref.isRoot()) {
return "Invalid reference '" + dump(ref) + "'";
}
Expand All @@ -169,7 +178,7 @@ private static String dump(CubeId ref) {
}

@VisibleForTesting
static Key getKey(DataStructure dsd, CubeId ref) {
static Key getKey(Structure dsd, CubeId ref) {
if (ref.isRoot()) {
return Key.ALL;
}
Expand All @@ -186,11 +195,11 @@ static Key getKey(DataStructure dsd, CubeId ref) {
@lombok.RequiredArgsConstructor
static final class KeyConverter {

static KeyConverter of(DataStructure dsd, CubeId ref) {
static KeyConverter of(Structure dsd, CubeId ref) {
return new KeyConverter(dsd, new CubeIdBuilder(dsd, ref));
}

final DataStructure dsd;
final Structure dsd;
final CubeIdBuilder builder;

public Key toKey(CubeId a) {
Expand All @@ -208,7 +217,7 @@ private static final class CubeIdBuilder {
private final int[] indices;
private final String[] dimValues;

CubeIdBuilder(DataStructure dsd, CubeId ref) {
CubeIdBuilder(Structure dsd, CubeId ref) {
this.ref = ref;
this.indices = new int[ref.getDepth()];
for (int i = 0; i < indices.length; i++) {
Expand Down Expand Up @@ -271,13 +280,13 @@ private static TsUnit getTsUnit(Obs obs) {
}
}

private static CubeId getOrLoadRoot(List<String> dimensions, DataStructure dsd) {
private static CubeId getOrLoadRoot(List<String> dimensions, Structure dsd) {
return dimensions.isEmpty()
? CubeId.root(loadDefaultDimIds(dsd))
: CubeId.root(dimensions);
}

private static List<String> loadDefaultDimIds(DataStructure dsd) {
private static List<String> loadDefaultDimIds(Structure dsd) {
return dsd
.getDimensions()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import jdplus.sdmx.base.api.file.SdmxFileBean;
import jdplus.toolkit.base.tsp.HasFilePaths;
import sdmxdl.file.SdmxFileSource;
import sdmxdl.file.FileSource;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -29,16 +29,12 @@
@lombok.experimental.UtilityClass
public class SdmxCubeItems {

public static SdmxFileSource resolveFileSet(HasFilePaths paths, SdmxFileBean bean) throws FileNotFoundException {
SdmxFileSource.Builder result = SdmxFileSource.builder().data(paths.resolveFilePath(bean.getFile()));
public static FileSource resolveFileSet(HasFilePaths paths, SdmxFileBean bean) throws FileNotFoundException {
FileSource.Builder result = FileSource.builder().data(paths.resolveFilePath(bean.getFile()));
File structure = bean.getStructureFile();
if (structure != null && !structure.toString().isEmpty()) {
result.structure(paths.resolveFilePath(structure));
}
String dialect = bean.getDialect();
if (dialect != null && !dialect.isEmpty()) {
result.dialect(dialect);
}
return result.build();
}
}
Loading

0 comments on commit 3e1cd19

Please sign in to comment.