-
Notifications
You must be signed in to change notification settings - Fork 15
/
dataset-catalog.R
39 lines (33 loc) · 1 KB
/
dataset-catalog.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
setMethod("initialize", "DatasetCatalog", init.sortCatalog)
setMethod("active", "DatasetCatalog", function(x) {
index(x) <- Filter(function(a) !isTRUE(a$archived), index(x))
return(x)
})
setMethod("archived", "DatasetCatalog", function(x) {
index(x) <- Filter(function(a) isTRUE(a$archived), index(x))
return(x)
})
#' See who owns these datasets
#'
#' @param x DatasetCatalog
#' @return For `owners`, the URLs of the users or projects that own
#' these datasets. For `ownerNames`, their names.
#' @export
owners <- function(x) getIndexSlot(x, "owner_id")
#' @rdname owners
#' @export
ownerNames <- function(x) getIndexSlot(x, "owner_display_name")
#' @rdname crunch-extract
#' @export
setMethod("[[", c("DatasetCatalog", "numeric"), function(x, i, ...) {
getTuple(x, i, DatasetTuple)
})
#' @rdname crunch-extract
#' @export
setMethod(
"[[<-", c("DatasetCatalog", "character", "missing", "DatasetTuple"),
function(x, i, j, value) {
index(x)[[i]] <- value@body
return(x)
}
)