-
Notifications
You must be signed in to change notification settings - Fork 0
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
46 changed files
with
1,784 additions
and
1,008 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
49 changes: 0 additions & 49 deletions
49
sdmx-dl-desktop/src/main/java/internal/sdmxdl/desktop/DataSetRefFormats.java
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
sdmx-dl-desktop/src/main/java/internal/sdmxdl/desktop/DataSourceRefFormats.java
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
sdmx-dl-desktop/src/main/java/internal/sdmxdl/desktop/ObsFormats.java
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
sdmx-dl-desktop/src/main/java/internal/sdmxdl/desktop/PropertyFormats.java
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
sdmx-dl-desktop/src/main/java/internal/sdmxdl/desktop/SeriesMetaFormats.java
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
sdmx-dl-desktop/src/main/java/internal/sdmxdl/desktop/XmlDataSourceRef.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,72 @@ | ||
package internal.sdmxdl.desktop; | ||
|
||
import nbbrd.io.xml.Xml; | ||
import nbbrd.io.xml.bind.Jaxb; | ||
import sdmxdl.Languages; | ||
import sdmxdl.desktop.DataSourceRef; | ||
|
||
import javax.xml.bind.annotation.XmlRootElement; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
public final class XmlDataSourceRef { | ||
|
||
private XmlDataSourceRef() { | ||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); | ||
} | ||
|
||
public static final Xml.Parser<List<DataSourceRef>> PARSER = Jaxb.Parser.of(DataSourceBeans.class).andThen(DataSourceBeans::to); | ||
public static final Xml.Formatter<List<DataSourceRef>> FORMATTER = Jaxb.Formatter.of(DataSourceBeans.class).compose(DataSourceBeans::from); | ||
|
||
@XmlRootElement | ||
@lombok.Data | ||
public static class DataSourceBeans { | ||
|
||
List<DataSourceBean> list; | ||
|
||
static DataSourceBeans from(List<DataSourceRef> list) { | ||
DataSourceBeans result = new DataSourceBeans(); | ||
result.list = list.stream().map(DataSourceBean::from).collect(Collectors.toList()); | ||
return result; | ||
} | ||
|
||
List<DataSourceRef> to() { | ||
return list != null ? list.stream().map(DataSourceBean::to).collect(Collectors.toList()) : emptyList(); | ||
} | ||
} | ||
|
||
|
||
@XmlRootElement | ||
@lombok.Data | ||
public static class DataSourceBean { | ||
|
||
String source; | ||
String catalog; | ||
String flow; | ||
List<String> dimensions; | ||
String languages; | ||
|
||
static DataSourceBean from(DataSourceRef ref) { | ||
DataSourceBean result = new DataSourceBean(); | ||
result.source = ref.getSource(); | ||
result.catalog = ref.getCatalog(); | ||
result.flow = ref.getFlow(); | ||
result.dimensions = ref.getDimensions(); | ||
result.languages = ref.getLanguages().toString(); | ||
return result; | ||
} | ||
|
||
DataSourceRef to() { | ||
return DataSourceRef | ||
.builder() | ||
.source(source) | ||
.catalog(catalog) | ||
.flow(flow) | ||
.dimensions(dimensions != null ? dimensions : emptyList()) | ||
.languages(Languages.parse(languages)) | ||
.build(); | ||
} | ||
} | ||
} |
Oops, something went wrong.