-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
472 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
demetra-dotstat-desktop/src/main/java/be/nbb/demetra/sdmx/web/actions/CopyPathSetAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...a-dotstat-desktop/src/main/java/be/nbb/demetra/sdmx/web/actions/CopyPathSourceAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.