Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi committed Feb 4, 2025
2 parents d67d2f2 + 6734963 commit eba025d
Show file tree
Hide file tree
Showing 17 changed files with 472 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Check links
id: lychee
uses: lycheeverse/lychee-action@v1.10.0
uses: lycheeverse/lychee-action@v2.2.0
with:
fail: true
args: --max-concurrency 1 --cache --no-progress --exclude-all-private './**/*.md'
11 changes: 7 additions & 4 deletions .github/workflows/java-ea-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ jobs:
java-version: ${{ matrix.java }}
cache: 'maven'

- name: Build and (headless) test with Maven
uses: smithki/[email protected]
with:
run: mvn -U -B -ntp verify
- name: Build and (headless) test with Maven (Linux)
if: ${{ runner.os == 'Linux' }}
run: xvfb-run mvn -U -B -ntp verify

- name: Build and (headless) test with Maven (Windows and macOS)
if: ${{ runner.os != 'Linux' }}
run: mvn -U -B -ntp verify
11 changes: 7 additions & 4 deletions .github/workflows/java8-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ jobs:
max_attempts: 3
timeout_minutes: 5

- name: Build and (headless) test with Maven
uses: smithki/[email protected]
with:
run: mvn -U -B -ntp verify
- name: Build and (headless) test with Maven (Linux)
if: ${{ runner.os == 'Linux' }}
run: xvfb-run mvn -U -B -ntp verify

- name: Build and (headless) test with Maven (Windows and macOS)
if: ${{ runner.os != 'Linux' }}
run: mvn -U -B -ntp verify

auto-merge-job:
needs: build-and-test-job
Expand Down
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

## [2.2.9] - 2025-02-04

This is a feature release of **jdemetra-dotstat**.
[JDemetra+ 2.2.4 or later version](https://github.com/jdemetra/jdemetra-app/releases) is required to run it.

### Added

- Add copy path actions

### Changed

- Modernize use of NIO API

## [2.2.8] - 2024-10-04

This is a feature release of **jdemetra-dotstat**.
Expand Down Expand Up @@ -248,7 +261,8 @@ This is a feature release of **jdemetra-dotstat**.
This is the initial release of **jdemetra-dotstat**.
[JDemetra+ 2.0.0 or later version](https://github.com/jdemetra/jdemetra-app/releases) is required to run it.

[Unreleased]: https://github.com/nbbrd/jdemetra-dotstat/compare/v2.2.8...HEAD
[Unreleased]: https://github.com/nbbrd/jdemetra-dotstat/compare/v2.2.9...HEAD
[2.2.9]: https://github.com/nbbrd/jdemetra-dotstat/compare/v2.2.8...v2.2.9
[2.2.8]: https://github.com/nbbrd/jdemetra-dotstat/compare/v2.2.7...v2.2.8
[2.2.7]: https://github.com/nbbrd/jdemetra-dotstat/compare/v2.2.6...v2.2.7
[2.2.6]: https://github.com/nbbrd/jdemetra-dotstat/compare/v2.2.5...v2.2.6
Expand Down
4 changes: 2 additions & 2 deletions demetra-dotstat-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>be.nbb.demetra</groupId>
<artifactId>demetra-dotstat-parent</artifactId>
<version>2.2.8</version>
<version>2.2.9</version>
</parent>

<artifactId>demetra-dotstat-core</artifactId>
Expand Down Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-lookup</artifactId>
<version>RELEASE230</version>
<version>RELEASE240</version>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import static ec.tss.tsproviders.utils.Params.onStringList;
import java.io.File;
import java.nio.file.Paths;
import java.util.List;

/**
Expand All @@ -47,8 +48,8 @@ final class V1 implements SdmxFileParam {
private final Splitter dimensionSplitter = Splitter.on(',').trimResults().omitEmptyStrings();
private final Joiner dimensionJoiner = Joiner.on(',');

private final IParam<DataSource, File> file = Params.onFile(new File(""), "f");
private final IParam<DataSource, File> structureFile = Params.onFile(new File(""), "s");
private final IParam<DataSource, File> file = Params.onFile(Paths.get("").toFile(), "f");
private final IParam<DataSource, File> structureFile = Params.onFile(Paths.get("").toFile(), "s");
private final IParam<DataSource, String> dialect = Params.onString("", "j");
private final IParam<DataSource, List<String>> dimensionIds = onStringList(ImmutableList.of(), "d", dimensionSplitter, dimensionJoiner);
private final IParam<DataSource, String> labelAttribute = Params.onString("", "l");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import ec.tss.tsproviders.IDataSourceLoaderAssert;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -57,7 +58,7 @@ private static File createTemp(ByteSource bytes, String prefix, String suffix) t
public static void beforeClass() throws IOException {
NO_XML = File.createTempFile("sdmx_empty", ".xml");
NO_XML.deleteOnExit();
BLANK = new File("");
BLANK = Paths.get("").toFile();
GENERIC20 = createTemp(SdmxXmlSources.NBB_DATA, "sdmx_generic20", ".xml");
STRUCT20 = createTemp(SdmxXmlSources.NBB_DATA_STRUCTURE, "sdmx_struct20", ".xml");
}
Expand All @@ -76,7 +77,7 @@ public void testMonikerUri() {
String uri = "demetra://tsprovider/sdmx-file/v1/SERIES?f=BLS.xml&l=TITLE#k=Q.AT.ALL.BC.E.LE.B3.ST.S.DINX";

SdmxFileBean bean = new SdmxFileBean();
bean.setFile(new File("BLS.xml"));
bean.setFile(Paths.get("BLS.xml").toFile());
bean.setLabelAttribute("TITLE");

DataSource.Builder dataSource = DataSource.builder("sdmx-file", "v1");
Expand Down
7 changes: 6 additions & 1 deletion demetra-dotstat-desktop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>be.nbb.demetra</groupId>
<artifactId>demetra-dotstat-parent</artifactId>
<version>2.2.8</version>
<version>2.2.9</version>
</parent>

<artifactId>demetra-dotstat-desktop</artifactId>
Expand Down Expand Up @@ -145,6 +145,11 @@
<artifactId>java-desktop-util-favicon</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.j2html</groupId>
<artifactId>j2html</artifactId>
<version>1.6.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
import ec.tss.tsproviders.utils.Params;
import internal.sdmx.SdmxWebSourceService;
import lombok.NonNull;
import org.netbeans.api.options.OptionsDisplayer;
import org.openide.nodes.Sheet;
import org.openide.util.lookup.ServiceProvider;

import java.io.File;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -135,7 +135,7 @@ private static final class BuddyConfigConverter extends Converter<BuddyConfig, C
private final IParam<Config, String> preferredLanguageParam = Params.onString("en", "preferredLanguage");
private final IParam<Config, Boolean> displayCodesParam = Params.onBoolean(false, "displayCodes");
private final IParam<Config, Boolean> curlBackendParam = Params.onBoolean(false, "curlBackend");
private final IParam<Config, File> customSourcesParam = Params.onFile(new File(""), "customSources");
private final IParam<Config, File> customSourcesParam = Params.onFile(Paths.get("").toFile(), "customSources");

@Override
protected Config doForward(BuddyConfig a) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Locale;
import java.util.Properties;
import java.util.function.Function;
Expand Down Expand Up @@ -225,7 +226,7 @@ public void storeBean(SdmxWebProviderBuddy resource, @NonNull SdmxWebConfigurati

private static final class ConfigConverter extends Converter<SdmxWebConfiguration, Config> {

private final IParam<Config, File> sources = Params.onFile(new File(""), SOURCES_PROPERTY);
private final IParam<Config, File> sources = Params.onFile(Paths.get("").toFile(), SOURCES_PROPERTY);
private final IParam<Config, String> languages = Params.onString("", LANGUAGES_PROPERTY);
private final IParam<Config, Toggle> curlBackend = Params.onEnum(DEFAULT_CURL_BACKEND, CURL_BACKEND_PROPERTY);
private final IParam<Config, Toggle> noCache = Params.onEnum(DEFAULT_NO_CACHE, NO_CACHE_PROPERTY);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package be.nbb.demetra.sdmx.web.actions;

import be.nbb.demetra.sdmx.web.SdmxWebBean;
import be.nbb.demetra.sdmx.web.SdmxWebProvider;
import ec.nbdemetra.ui.tsproviders.CollectionNode;
import ec.nbdemetra.ui.tsproviders.SeriesNode;
import ec.tss.tsproviders.DataSet;
import ec.tss.tsproviders.DataSource;
import ec.ui.ExtAction;
import internal.jd3.AbilityNodeAction3;
import internal.jd3.TsManager3;
import internal.sdmx.CatalogRef;
import internal.sdmx.OnDemandMenuBuilder;
import internal.sdmx.SdmxCommand;
import internal.sdmx.SdmxURI;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.Presenter;
import sdmxdl.Connection;
import sdmxdl.FlowRef;
import sdmxdl.Key;
import sdmxdl.Structure;

import javax.swing.*;
import java.io.IOException;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@ActionID(category = "Edit", id = CopyPathSetAction.ID)
@ActionRegistration(displayName = "#CTL_CopyPathSetAction", lazy = false)
@Messages("CTL_CopyPathSetAction=Copy Path/Reference...")
@ActionReferences({
@ActionReference(path = CollectionNode.ACTION_PATH, position = 1422, id = @ActionID(category = "Edit", id = CopyPathSetAction.ID)),
@ActionReference(path = SeriesNode.ACTION_PATH, position = 1422, id = @ActionID(category = "Edit", id = CopyPathSetAction.ID))
})
public final class CopyPathSetAction extends AbilityNodeAction3<DataSet> implements Presenter.Popup {

static final String ID = "be.nbb.demetra.sdmx.web.actions.CopyPathSetAction";

public CopyPathSetAction() {
super(DataSet.class, true);
}

@Override
public JMenuItem getPopupPresenter() {
return ExtAction.hideWhenDisabled(new JMenuItem(this));
}

@Override
protected void performAction(Stream<DataSet> items) {
DataSet item = single(items).orElseThrow(NoSuchElementException::new);
SdmxWebProvider provider = providerOf(item.getDataSource()).orElseThrow(NoSuchElementException::new);
SdmxWebBean bean = provider.decodeBean(item.getDataSource());
FlowRef flowRef = FlowRef.parse(bean.getFlow());
Key key = getKey(provider, bean.getSource(), flowRef, item);
CatalogRef catalog = CatalogRef.NO_CATALOG;
new OnDemandMenuBuilder()
.copyToClipboard("SDMX-DL URI", SdmxURI.dataSetURI(bean.getSource(), flowRef, key, catalog))
.copyToClipboard("Source", bean.getSource())
.copyToClipboard("Flow", flowRef.toString())
.copyToClipboard("Key", key.toString())
.addSeparator()
.copyToClipboard("Fetch data command", SdmxCommand.fetchData(catalog, bean.getSource(), flowRef.toString(), key))
.copyToClipboard("Fetch meta command", SdmxCommand.fetchMeta(catalog, bean.getSource(), flowRef.toString(), key))
.copyToClipboard("Fetch keys command", SdmxCommand.fetchKeys(catalog, bean.getSource(), flowRef.toString(), key))
.showMenuAsPopup(null);
}

@Override
protected boolean enable(Stream<DataSet> items) {
Optional<DataSet> item = single(items);
return item.isPresent() && providerOf(item.get().getDataSource()).isPresent();
}

@Override
public String getName() {
return Bundle.CTL_CopyPathSetAction();
}

private static Optional<SdmxWebProvider> providerOf(DataSource dataSource) {
return TsManager3.get().getProvider(SdmxWebProvider.class, dataSource);
}

private static <T> Optional<T> single(Stream<T> items) {
List<T> list = items.collect(Collectors.toList());
return list.size() == 1 ? Optional.of(list.get(0)) : Optional.empty();
}

private static Key getKey(SdmxWebProvider provider, String source, FlowRef flowRef, DataSet dataSet) {
try (Connection connection = provider.getSdmxManager().getConnection(source, provider.getLanguages())) {
Structure structure = connection.getStructure(flowRef);
Key.Builder result = Key.builder(structure);
structure.getDimensions().forEach(dimension -> result.put(dimension.getId(), dataSet.get(dimension.getId())));
return result.build();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package be.nbb.demetra.sdmx.web.actions;

import be.nbb.demetra.sdmx.web.SdmxWebBean;
import be.nbb.demetra.sdmx.web.SdmxWebProvider;
import ec.nbdemetra.ui.tsproviders.DataSourceNode;
import ec.tss.tsproviders.DataSource;
import ec.ui.ExtAction;
import internal.jd3.AbilityNodeAction3;
import internal.jd3.TsManager3;
import internal.sdmx.CatalogRef;
import internal.sdmx.OnDemandMenuBuilder;
import internal.sdmx.SdmxCommand;
import internal.sdmx.SdmxURI;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.Presenter;
import sdmxdl.FlowRef;
import sdmxdl.Key;

import javax.swing.*;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@ActionID(category = "Edit", id = CopyPathSourceAction.ID)
@ActionRegistration(displayName = "#CTL_CopyPathSourceAction", lazy = false)
@Messages("CTL_CopyPathSourceAction=Copy Path/Reference...")
@ActionReference(path = DataSourceNode.ACTION_PATH, position = 1412, id = @ActionID(category = "Edit", id = CopyPathSourceAction.ID))
public final class CopyPathSourceAction extends AbilityNodeAction3<DataSource> implements Presenter.Popup {

static final String ID = "be.nbb.demetra.sdmx.web.actions.CopyPathSourceAction";

public CopyPathSourceAction() {
super(DataSource.class, true);
}

@Override
public JMenuItem getPopupPresenter() {
return ExtAction.hideWhenDisabled(new JMenuItem(this));
}

@SuppressWarnings("resource")
@Override
protected void performAction(Stream<DataSource> items) {
DataSource item = single(items).orElseThrow(NoSuchElementException::new);
SdmxWebProvider provider = providerOf(item).orElseThrow(NoSuchElementException::new);
SdmxWebBean bean = provider.decodeBean(item);
FlowRef flowRef = FlowRef.parse(bean.getFlow());
CatalogRef catalog = CatalogRef.NO_CATALOG;
new OnDemandMenuBuilder()
.copyToClipboard("SDMX-DL URI", SdmxURI.dataSourceURI(bean.getSource(), flowRef, catalog))
.copyToClipboard("Source", bean.getSource())
.copyToClipboard("Flow", flowRef.toString())
.addSeparator()
.copyToClipboard("List dimensions command", SdmxCommand.listDimensions(catalog, bean.getSource(), flowRef))
.copyToClipboard("List attributes command", SdmxCommand.listAttributes(catalog, bean.getSource(), flowRef))
.copyToClipboard("Fetch all keys command", SdmxCommand.fetchKeys(catalog, bean.getSource(), bean.getFlow(), Key.ALL))
.showMenuAsPopup(null);
}

@Override
protected boolean enable(Stream<DataSource> items) {
Optional<DataSource> item = single(items);
return item.isPresent() && providerOf(item.get()).isPresent();
}

@Override
public String getName() {
return Bundle.CTL_CopyPathSourceAction();
}

private static Optional<SdmxWebProvider> providerOf(DataSource dataSource) {
return TsManager3.get().getProvider(SdmxWebProvider.class, dataSource);
}

private static <T> Optional<T> single(Stream<T> items) {
List<T> list = items.collect(Collectors.toList());
return list.size() == 1 ? Optional.of(list.get(0)) : Optional.empty();
}
}
Loading

0 comments on commit eba025d

Please sign in to comment.