Skip to content

Commit 962e086

Browse files
committed
Changed mechanism of selecting appropriate web portal
1 parent b92d3af commit 962e086

File tree

9 files changed

+53
-24
lines changed

9 files changed

+53
-24
lines changed

R/read_database.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ read_database <- function(id, include_series = FALSE, tidy = FALSE, ...) {
1919
} else {
2020
version <- "latest"
2121
}
22-
23-
env <- fromJSON(system.file("settings.json",
24-
package = "econdatar"))[[agencyid]]
22+
if (!is.null(params$portal)) {
23+
portal <- params$portal
24+
} else {
25+
portal <- "econdata"
26+
}
27+
env <- fromJSON(system.file("settings.json", package = "econdatar"))[[portal]]
2528

2629

2730
# Fetch data set(s) ----

R/read_dataset.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ read_dataset <- function(id, tidy = FALSE, ...) {
1919
} else {
2020
version <- "latest"
2121
}
22-
23-
env <- fromJSON(system.file("settings.json",
24-
package = "econdatar"))[[agencyid]]
22+
if (!is.null(params$portal)) {
23+
portal <- params$portal
24+
} else {
25+
portal <- "econdata"
26+
}
27+
env <- fromJSON(system.file("settings.json", package = "econdatar"))[[portal]]
2528

2629

2730
# Fetch data set(s) ----

R/read_registry.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ read_registry <- function(structure, tidy = FALSE, ...) {
2727
} else {
2828
version <- "latest"
2929
}
30-
31-
env <- fromJSON(system.file("settings.json",
32-
package = "econdatar"))[[agencyid]]
30+
if (!is.null(params$portal)) {
31+
portal <- params$portal
32+
} else {
33+
portal <- "econdata"
34+
}
35+
env <- fromJSON(system.file("settings.json", package = "econdatar"))[[portal]]
3336
params$env <- env
3437

3538

R/read_release.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ read_release <- function(id, tidy = FALSE, ...) {
2929
if (!is.null(params$description)) {
3030
query_params$description <- params$description
3131
}
32-
env <- fromJSON(system.file("settings.json",
33-
package = "econdatar"))[[agencyid]]
32+
if (!is.null(params$portal)) {
33+
portal <- params$portal
34+
} else {
35+
portal <- "econdata"
36+
}
37+
env <- fromJSON(system.file("settings.json", package = "econdatar"))[[portal]]
3438

3539

3640
# Fetch release ----

R/write_database.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
write_database <- function(x, method = "update", ...) {
22

33

4-
# Parameters ---
4+
# Parameters ----
55

66
params <- list(...)
77
if (!is.null(params$username) && !is.null(params$password)) {
88
credentials <- paste(params$username, params$password, sep = ";")
99
} else {
1010
credentials <- NULL
1111
}
12+
if (!is.null(params$portal)) {
13+
portal <- params$portal
14+
} else {
15+
portal <- "econdata"
16+
}
1217
stopifnot(length(method) == 1)
1318
stopifnot(method %in% c("create", "update"))
14-
env <- fromJSON(system.file("settings.json",
15-
package = "econdatar"))[[x$agencyid]]
19+
env <- fromJSON(system.file("settings.json", package = "econdatar"))[[portal]]
1620

1721

18-
# Push data message ---
22+
# Push data message ----
1923

2024
if (is.null(params$file) && !exists("econdata_session", envir = .pkgenv)) {
2125
login_helper(credentials, env$repository$url)
@@ -41,7 +45,7 @@ write_database <- function(x, method = "update", ...) {
4145
}
4246

4347

44-
# Push each data set individually ---
48+
# Push each data set individually ----
4549

4650
lapply(datasets, function(dataset) {
4751
dataset_ref <- paste(attr(dataset, "metadata")$agencyid,

R/write_dataset.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ write_dataset <- function(x, method = "stage", ...) {
1010
} else {
1111
credentials <- NULL
1212
}
13+
if (!is.null(params$portal)) {
14+
portal <- params$portal
15+
} else {
16+
portal <- "econdata"
17+
}
1318
stopifnot(length(method) == 1)
1419
stopifnot(method %in% c("stage", "validate"))
15-
env <- fromJSON(system.file("settings.json",
16-
package = "econdatar"))[[x$agencyid]]
20+
env <- fromJSON(system.file("settings.json", package = "econdatar"))[[portal]]
1721

1822

1923
# Push data message ----

R/write_registry.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ write_registry <- function(structure, x, method = "update", ...) {
99
} else {
1010
credentials <- NULL
1111
}
12+
if (!is.null(params$portal)) {
13+
portal <- params$portal
14+
} else {
15+
portal <- "econdata"
16+
}
1217
stopifnot(length(method) == 1)
1318
stopifnot(method %in% c("create", "update"))
14-
env <- fromJSON(system.file("settings.json",
15-
package = "econdatar"))[[x$agencyid]]
19+
env <- fromJSON(system.file("settings.json", package = "econdatar"))[[portal]]
1620
params$env <- env
1721

1822

R/write_release.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ write_release <- function(id, version, providerid, description, method = "releas
2323
"%Y-%m-%dT%H:%M:%S",
2424
tz = "Africa/Johannesburg")
2525
}
26+
if (!is.null(params$portal)) {
27+
portal <- params$portal
28+
} else {
29+
portal <- "econdata"
30+
}
2631
stopifnot(length(method) == 1)
2732
stopifnot(method %in% c("release", "reset", "rollback"))
28-
env <- fromJSON(system.file("settings.json",
29-
package = "econdatar"))[[agencyid]]
33+
env <- fromJSON(system.file("settings.json", package = "econdatar"))[[portal]]
3034

3135

3236
# Commit data set release ----

inst/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"ECONDATA" : {
2+
"econdata" : {
33
"repository" : {
44
"url" : "https://www.econdata.co.za",
55
"path" : "sdmx-codera/v1"
@@ -9,7 +9,7 @@
99
"path" : "sdmx-codera/v1"
1010
}
1111
},
12-
"FIRSTRAND" : {
12+
"firstrand" : {
1313
"repository" : {
1414
"url" : "https://firstrand.econdata.co.za",
1515
"path" : "sdmx-codera/v1"

0 commit comments

Comments
 (0)