Skip to content

Commit

Permalink
Merge branch 'release-2.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi committed Mar 1, 2018
2 parents 78acfe6 + 23d49bf commit 2728e5a
Show file tree
Hide file tree
Showing 190 changed files with 8,691 additions and 3,734 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
/sdmx-facade/sdmx-facade-connectors/target/
/sdmx-facade/sdmx-facade-util/target/
/sdmx-facade/sdmx-facade-file/target/
/sdmx-facade/sdmx-facade-samples/target/
/sdmx-facade/sdmx-facade-samples/target/
/sdmx-facade/sdmx-facade-web/target/
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: java
jdk:
- oraclejdk8
sudo: required

cache:
directories:
Expand Down
12 changes: 6 additions & 6 deletions demetra-dotstat-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>be.nbb.demetra</groupId>
<artifactId>demetra-dotstat-core</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
<packaging>jar</packaging>

<name>Demetra - DotStat - Core</name>
Expand All @@ -18,7 +18,7 @@
<licenses>
<license>
<name>European Union Public Licence (EUPL)</name>
<url>https://joinup.ec.europa.eu/software/page/eupl/licence-eupl</url>
<url>https://joinup.ec.europa.eu/page/eupl-text-11-12</url>
</license>
</licenses>

Expand Down Expand Up @@ -73,7 +73,7 @@
</dependency>
<dependency>
<groupId>be.nbb.sdmx</groupId>
<artifactId>sdmx-facade-connectors</artifactId>
<artifactId>sdmx-facade-web</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -115,8 +115,8 @@
<url>http://bits.netbeans.org/maven2/</url>
</repository>
<repository>
<id>joinup-releases</id>
<url>https://joinup.ec.europa.eu/nexus/content/repositories/releases/</url>
<id>oss-jfrog-artifactory-releases</id>
<url>https://oss.jfrog.org/artifactory/oss-release-local</url>
</repository>
</repositories>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public DbAccessor<DotStatBean> memoize() {
}

private static List<DbSetId> getAllSeries(SdmxConnection conn, DataflowRef flowRef, DbSetId ref) throws IOException {
Converter<DbSetId, Key> converter = getConverter(conn.getDataStructure(flowRef), ref);
Converter<DbSetId, Key> converter = getConverter(conn.getStructure(flowRef), ref);

Key colKey = converter.convert(ref);
try (TsCursor<Key> cursor = SdmxQueryUtil.getAllSeries(conn, flowRef, colKey, SdmxQueryUtil.NO_LABEL)) {
Expand All @@ -113,7 +113,7 @@ private static List<DbSetId> getAllSeries(SdmxConnection conn, DataflowRef flowR
}

private static List<DbSeries> getAllSeriesWithData(SdmxConnection conn, DataflowRef flowRef, DbSetId ref) throws IOException {
Converter<DbSetId, Key> converter = getConverter(conn.getDataStructure(flowRef), ref);
Converter<DbSetId, Key> converter = getConverter(conn.getStructure(flowRef), ref);

Key colKey = converter.convert(ref);
try (TsCursor<Key> cursor = SdmxQueryUtil.getAllSeriesWithData(conn, flowRef, colKey, SdmxQueryUtil.NO_LABEL)) {
Expand All @@ -126,15 +126,18 @@ private static List<DbSeries> getAllSeriesWithData(SdmxConnection conn, Dataflow
}

private static DbSeries getSeriesWithData(SdmxConnection conn, DataflowRef flowRef, DbSetId ref) throws IOException {
Converter<DbSetId, Key> converter = getConverter(conn.getDataStructure(flowRef), ref);
Converter<DbSetId, Key> converter = getConverter(conn.getStructure(flowRef), ref);

Key seriesKey = converter.convert(ref);
return new DbSeries(ref, SdmxQueryUtil.getSeriesWithData(conn, flowRef, seriesKey));
try (TsCursor<Key> cursor = SdmxQueryUtil.getSeriesWithData(conn, flowRef, seriesKey, SdmxQueryUtil.NO_LABEL)) {
return new DbSeries(ref, cursor.nextSeries() ? cursor.getSeriesData() : SdmxQueryUtil.MISSING_DATA);
}
}

private static List<String> getChildren(SdmxConnection conn, DataflowRef flowRef, DbSetId ref) throws IOException {
Converter<DbSetId, Key> converter = getConverter(conn.getDataStructure(flowRef), ref);
int dimensionPosition = dimensionById(conn.getDataStructure(flowRef)).get(ref.getColumn(ref.getLevel())).getPosition();
DataStructure dsd = conn.getStructure(flowRef);
Converter<DbSetId, Key> converter = getConverter(dsd, ref);
int dimensionPosition = dimensionById(dsd).get(ref.getColumn(ref.getLevel())).getPosition();
return SdmxQueryUtil.getChildren(conn, flowRef, converter.convert(ref), dimensionPosition);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import be.nbb.sdmx.facade.Key;
import be.nbb.sdmx.facade.LanguagePriorityList;
import be.nbb.sdmx.facade.SdmxConnection;
import be.nbb.sdmx.facade.SdmxConnectionSupplier;
import be.nbb.sdmx.facade.driver.SdmxDriverManager;
import be.nbb.sdmx.facade.web.SdmxWebManager;
import com.google.common.collect.Maps;
import ec.tss.ITsProvider;
import ec.tss.TsAsyncMode;
Expand All @@ -32,9 +31,9 @@
import ec.tss.tsproviders.db.DbAccessor;
import ec.tss.tsproviders.db.DbBean;
import ec.tss.tsproviders.db.DbProvider;
import internal.sdmx.SdmxPropertiesSupport;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.openide.util.lookup.ServiceProvider;
Expand All @@ -49,20 +48,21 @@
public final class DotStatProvider extends DbProvider<DotStatBean> implements HasSdmxProperties {

public static final String NAME = "DOTSTAT", VERSION = "20150203";
private final AtomicReference<SdmxConnectionSupplier> connectionSupplier;
private final AtomicReference<LanguagePriorityList> languages;

@lombok.experimental.Delegate
private final HasSdmxProperties properties;

private boolean displayCodes;

public DotStatProvider() {
super(LoggerFactory.getLogger(DotStatProvider.class), NAME, TsAsyncMode.Once);
this.connectionSupplier = new AtomicReference<>(SdmxDriverManager.getDefault());
this.languages = new AtomicReference<>(LanguagePriorityList.ANY);
this.properties = SdmxPropertiesSupport.of(SdmxWebManager::ofServiceLoader, this::clearCache, () -> LanguagePriorityList.ANY, this::clearCache);
this.displayCodes = false;
}

@Override
protected DbAccessor<DotStatBean> loadFromBean(DotStatBean bean) throws Exception {
return new DotStatAccessor(bean, connectionSupplier.get(), languages.get()).memoize();
return new DotStatAccessor(bean, getConnectionSupplier(), getLanguages()).memoize();
}

@Override
Expand All @@ -85,7 +85,7 @@ public String getDisplayName(DataSource dataSource) {
DotStatBean bean = decodeBean(dataSource);
if (!displayCodes) {
try (SdmxConnection conn = connect(bean.getDbName())) {
return String.format("%s ~ %s", bean.getDbName(), conn.getDataflow(bean.getFlowRef()).getLabel());
return String.format("%s ~ %s", bean.getDbName(), conn.getFlow(bean.getFlowRef()).getLabel());
} catch (IOException | RuntimeException ex) {
}
}
Expand All @@ -96,7 +96,7 @@ public String getDisplayName(DataSource dataSource) {
public String getDisplayName(DataSet dataSet) {
DotStatBean bean = decodeBean(dataSet.getDataSource());
try (SdmxConnection conn = connect(bean.getDbName())) {
DataStructure dfs = conn.getDataStructure(bean.getFlowRef());
DataStructure dfs = conn.getStructure(bean.getFlowRef());
Key.Builder b = Key.builder(dfs);
for (Dimension o : dfs.getDimensions()) {
String value = dataSet.get(o.getId());
Expand All @@ -117,7 +117,7 @@ public String getDisplayNodeName(DataSet dataSet) {
if (!displayCodes) {
DotStatBean bean = decodeBean(dataSet.getDataSource());
try (SdmxConnection conn = connect(bean.getDbName())) {
DataStructure dfs = conn.getDataStructure(bean.getFlowRef());
DataStructure dfs = conn.getStructure(bean.getFlowRef());
for (Dimension o : dfs.getDimensions()) {
if (o.getId().equals(nodeDim.getKey())) {
return o.getCodes().get(nodeDim.getValue());
Expand All @@ -137,32 +137,6 @@ public DataSource encodeBean(Object bean) throws IllegalArgumentException {
return support.checkBean(bean, DotStatBean.class).toDataSource(NAME, VERSION);
}

@Override
public SdmxConnectionSupplier getConnectionSupplier() {
return connectionSupplier.get();
}

@Override
public void setConnectionSupplier(SdmxConnectionSupplier connectionSupplier) {
SdmxConnectionSupplier old = this.connectionSupplier.get();
if (this.connectionSupplier.compareAndSet(old, connectionSupplier != null ? connectionSupplier : SdmxDriverManager.getDefault())) {
clearCache();
}
}

@Override
public LanguagePriorityList getLanguages() {
return languages.get();
}

@Override
public void setLanguages(LanguagePriorityList languages) {
LanguagePriorityList old = this.languages.get();
if (this.languages.compareAndSet(old, languages != null ? languages : LanguagePriorityList.ANY)) {
clearCache();
}
}

@Nonnull
public String getPreferredLanguage() {
return getLanguages().toString();
Expand All @@ -184,7 +158,7 @@ public void setDisplayCodes(boolean displayCodes) {
}

private SdmxConnection connect(String name) throws IOException {
return connectionSupplier.get().getConnection(name, languages.get());
return getConnectionSupplier().getConnection(name, getLanguages());
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
import be.nbb.sdmx.facade.SdmxConnectionSupplier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

/**
*
* @author Philippe Charles
*/
@ThreadSafe
public interface HasSdmxProperties {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public final class SdmxFileBean implements IFileBean {

private File file;
private File structureFile;
private String dialect;
private List<String> dimensions;
private String labelAttribute;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ final class V1 implements SdmxFileParam {

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, 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 All @@ -60,6 +61,7 @@ public SdmxFileBean defaultValue() {
SdmxFileBean result = new SdmxFileBean();
result.setFile(file.defaultValue());
result.setStructureFile(structureFile.defaultValue());
result.setDialect(dialect.defaultValue());
result.setDimensions(dimensionIds.defaultValue());
result.setLabelAttribute(labelAttribute.defaultValue());
return result;
Expand All @@ -70,6 +72,7 @@ public SdmxFileBean get(DataSource dataSource) {
SdmxFileBean result = new SdmxFileBean();
result.setFile(file.get(dataSource));
result.setStructureFile(structureFile.get(dataSource));
result.setDialect(dialect.get(dataSource));
result.setDimensions(dimensionIds.get(dataSource));
result.setLabelAttribute(labelAttribute.get(dataSource));
return result;
Expand All @@ -79,6 +82,7 @@ public SdmxFileBean get(DataSource dataSource) {
public void set(IConfig.Builder<?, DataSource> builder, SdmxFileBean value) {
file.set(builder, value.getFile());
structureFile.set(builder, value.getStructureFile());
dialect.set(builder, value.getDialect());
dimensionIds.set(builder, value.getDimensions());
labelAttribute.set(builder, value.getLabelAttribute());
}
Expand Down
Loading

0 comments on commit 2728e5a

Please sign in to comment.