-
Notifications
You must be signed in to change notification settings - Fork 24
/
print.R
126 lines (118 loc) · 4.15 KB
/
print.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# sword dataset list
#' @export
print.dataverse_dataset_list <- function(x, ...) {
cat("Dataverse name: ", x$title[[1]], "\n", sep = "")
cat("Released? ", if (x$dataverseHasBeenReleased[[1]] == "true") "Yes" else "No", "\n", sep = "")
print(x$datasets)
invisible(x)
}
# dataverse class
#' @export
print.dataverse <- function(x, ...) {
if ("id" %in% names(x)) {
cat("Dataverse (", x$id, "): ", x$alias, "\n", sep = "")
cat("Name: ", x$name, "\n", sep = "")
} else {
cat("Dataverse: ", x$alias, "\n", sep = "")
cat("Name: ", x$name, "\n", sep = "")
}
if ("description" %in% names(x)) {
cat("Description: ", x$description, "\n", sep = "")
}
if ("creationDate" %in% names(x)) {
cat("Created: ", x$creationDate, "\n", sep = "")
}
if ("creator" %in% names(x)) {
cat("Creator: ", x$creator$identifier, "\n", sep = "")
}
if (("terms_apply" %in% names(x)) && (x$terms_apply == "true")) {
cat("Terms of Use: ", x$terms_of_use, "\n", sep = "")
}
invisible(x)
}
# dataverse_dataset class
#' @importFrom utils str
#' @export
print.dataverse_dataset <- function(x, ...) {
cat("Dataset (", x$id, "): ", x$persistentUrl, "\n", sep = "")
if ("publisher" %in% names(x)) {
cat("Publisher: ", x$publisher, "\n", sep = "")
}
if ("publicationDate" %in% names(x)) {
cat("publicationDate: ", x$publicationDate, "\n", sep = "")
}
if ("latestVersion" %in% names(x)) {
print(x$latestVersion)
} else {
if ("versionNumber" %in% names(x)) {
cat("Version: ", x$versionNumber, ".", x$versionMinorNumber, ", ", x$versionState, "\n", sep = "")
} else {
cat("\n")
}
if ("releaseTime" %in% names(x)) {
cat("Release Date: ", x$releaseTime, "\n", sep = "")
}
if ("license" %in% names(x)) {
cat("License: ", x$license, "\n", sep = "")
}
if ("files" %in% names(x)) {
n <- length(x$files)
cat(n, ngettext(n, " File:", " Files:"), "\n", sep = "")
print(x$files[c("label", "version", "id", "contentType")])
}
}
invisible(x)
}
# dataverse_dataset_version class
#' @export
print.dataverse_dataset_version <- function(x, ...) {
cat("Version (", x$id, "): ", x$versionNumber, ".", x$versionMinorNumber, ", ", x$versionState, "\n", sep = "")
cat("Release Date: ", x$releaseTime, "\n", sep = "")
n <- length(x$files)
cat(n, ngettext(n, " File:", " Files:"), "\n", sep = "")
print(x$files)
invisible(x)
}
# get_file class
#' @export
print.get_file <- function(x, ...) {
cat("File (", x$datafile$id, "): ", x$datafile$filename, "\n", sep = "")
cat("Dataset version: ", x$datasetVersionId, "\n", sep = "")
if ("md5" %in% names(x$datafile)) {
cat("MD5: ", x$datafile$md5, "\n", sep = "")
}
cat("Description: ", x$datafile$description, "\n", sep = "")
invisible(x)
}
# get_file class
#' @export
print.dataverse_file <- function(x, ...) {
cat("File (", x$dataFile$id, "): ", x$dataFile$filename, "\n", sep = "")
cat("Dataset version: ", x$datasetVersionId, "\n", sep = "")
if ("md5" %in% names(x$dataFile)) {
cat("MD5: ", x$dataFile$md5, "\n", sep = "")
}
cat("Description: ", x$dataFile$description, "\n", sep = "")
invisible(x)
}
# dataverse_group class
#' @export
print.dataverse_group <- function(x, ...) {
cat("Group: ", x$displayName, "\n", sep = "")
cat("Alias: ", x$groupAliasInOwner, "\n", sep = "")
cat("Owner: ", x$owner, "\n", sep = "")
cat("Dataverse: ", x$dataverse, "\n", sep = "")
cat("Identifier: ", x$identifier, "\n", sep = "")
cat("Assignees: ", length(x$containedRoleAssignees), "\n\n", sep = "")
invisible(x)
}
# dataverse_role class
# dataverse_role_assignment class
#' @export
print.dataverse_role_assignment <- function(x, ...) {
cat("ID: ", x$id, "\n", sep = "")
cat("Assignee: ", x$assignee, "\n", sep = "")
cat("Role (", x$roleId, "): ", x[["_roleAlias"]], "\n", sep = "")
cat("Dataverse: ", x$dataverse, "\n", sep = "")
invisible(x)
}