Skip to content

Commit

Permalink
Merge pull request #42 from ThomasThelen/master
Browse files Browse the repository at this point in the history
Fix Issue #22
  • Loading branch information
amoeba authored Sep 21, 2017
2 parents 7476848 + 30996c1 commit c0adcce
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions R/access.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @import datapack
#' @export
set_rights_holder <- function(mn, pids, subject) {
stopifnot(class(mn) == "MNode")
stopifnot(is(mn, "MNode"))
stopifnot(is.character(pids),
all(nchar(pids) > 0))
stopifnot(is.character(subject),
Expand Down Expand Up @@ -141,7 +141,7 @@ set_public_read <- function(mn, pids) {
#'
#' @examples
remove_public_read <- function(mn, pids) {
stopifnot(class(mn) == "MNode",
stopifnot(is(mn, "MNode"),
all(is.character(pids)),
all(nchar(pids) > 0))

Expand Down Expand Up @@ -215,7 +215,7 @@ remove_public_read <- function(mn, pids) {
#'
#' @examples
set_rights_and_access <- function(mn, pids, subject, permissions=c("read", "write", "changePermission")) {
stopifnot(class(mn) == "MNode",
stopifnot(is(mn, "MNode"),
all(is.character(pids)),
all(nchar(pids) > 0),
is.character(subject),
Expand Down
2 changes: 1 addition & 1 deletion R/dataone.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ is_token_expired <- function(node) {
#' @examples
get_mn_base_url <- function(mn) {
# Determine MN URL. Accept either an MNode or a character string
if (class(mn) == "MNode") {
if (is(mn, "MNode")) {
mn_base_url <- mn$base_url
}

Expand Down
10 changes: 5 additions & 5 deletions R/editing.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ publish_object <- function(mn,
clone_pid=NULL,
public=TRUE) {

stopifnot(class(mn) == "MNode")
stopifnot(is(mn, "MNode"))
stopifnot(file.exists(path))

# Decide the format_id
Expand Down Expand Up @@ -509,7 +509,7 @@ create_resource_map <- function(mn,
data_pids=NULL,
child_pids=NULL,
check_first=TRUE) {
stopifnot(class(mn) == "MNode")
stopifnot(is(mn, "MNode"))
stopifnot(is.character(metadata_pid),
nchar(metadata_pid) > 0)

Expand Down Expand Up @@ -591,7 +591,7 @@ update_resource_map <- function(mn,
check_first=TRUE) {

# Check arguments
stopifnot(class(mn) == "MNode")
stopifnot(is(mn, "MNode"))
stopifnot(is.character(resource_map_pid),
nchar(resource_map_pid) > 0)
stopifnot(is.character(metadata_pid),
Expand All @@ -613,7 +613,7 @@ update_resource_map <- function(mn,

# Get the current rightsHolder
sysmeta <- dataone::getSystemMetadata(mn, resource_map_pid)
stopifnot(class(sysmeta) == "SystemMetadata")
stopifnot(is(sysmeta, "SystemMetadata"))

previous_rights_holder <- sysmeta@rightsHolder

Expand Down Expand Up @@ -648,7 +648,7 @@ update_resource_map <- function(mn,

message(paste0("Getting updated copy of System Metadata for ", resource_map_pid))
sysmeta <- dataone::getSystemMetadata(mn, resource_map_pid)
stopifnot(class(sysmeta) == "SystemMetadata")
stopifnot(is(sysmeta, "SystemMetadata"))

new_rm_sysmeta <- sysmeta
new_rm_sysmeta@identifier <- identifier
Expand Down
10 changes: 5 additions & 5 deletions R/eml.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' pid_to_other_entity(mn, pkg$data)
#' }
pid_to_eml_other_entity <- function(mn, pids) {
stopifnot(class(mn) == "MNode")
stopifnot(is(mn, "MNode"))
stopifnot(is.character(pids),
all(nchar(pids)) > 0)

Expand Down Expand Up @@ -60,7 +60,7 @@ sysmeta_to_other_entity <- function(mn, pids) {
#' pid_to_eml_physical(mn, pkg$data)
#' }
pid_to_eml_physical <- function(mn, pids) {
stopifnot(class(mn) == "MNode")
stopifnot(is(mn, "MNode"))
stopifnot(is.character(pids),
all(nchar(pids)) > 0)

Expand Down Expand Up @@ -196,7 +196,7 @@ sysmeta_to_eml_physical <- function(sysmeta) {
#' set_other_entities(mn, eml_path, "a_data_pid")
#' }
set_other_entities <- function(mn, path, pids) {
stopifnot(class(mn) == "MNode")
stopifnot(is(mn, "MNode"))
stopifnot(file.exists(path))
stopifnot(all(is.character(pids)),
all(nchar(pids) > 0))
Expand All @@ -208,7 +208,7 @@ set_other_entities <- function(mn, path, pids) {

# Get the metadata document from the MN and load it as an EML document
doc <- EML::read_eml(path)
stopifnot(class(doc) == "eml")
stopifnot(is(doc, "eml"))

message("Setting EML otherEntity elements. This can take a while if there are lots of PIDs...")

Expand Down Expand Up @@ -237,7 +237,7 @@ set_other_entities <- function(mn, path, pids) {
#'
#' @examples
get_doc_id <- function(sysmeta) {
stopifnot(class(sysmeta) == "SystemMetadata")
stopifnot(is(sysmeta, "SystemMetadata"))

message("Looking up docid for ", sysmeta@identifier, ".")

Expand Down
2 changes: 1 addition & 1 deletion R/inventory.R
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ inv_load_identifiers <- function(inventory, paths) {
#'
#' @export
inv_add_extra_columns <- function(inventory) {
stopifnot(class(inventory) == "data.frame", "file" %in% names(inventory))
stopifnot(is(inventory, "data.frame"), "file" %in% names(inventory))

# Mark metadata files
cat("Adding 'is_metadata' column.\n")
Expand Down
6 changes: 3 additions & 3 deletions R/packaging.R
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,12 @@ create_object <- function(file, sysmeta, base_path, mn) {
"pid" %in% names(file),
"file" %in% names(file))

stopifnot(class(sysmeta) == "SystemMetadata")
stopifnot(is(sysmeta, "SystemMetadata"))

stopifnot(is.character(base_path),
nchar(base_path) > 0)

stopifnot(class(env$mn) == "MNode")
stopifnot(is(env$mn, "MNode"))

# Set the return value to FALSE by default
result <- FALSE
Expand Down Expand Up @@ -741,7 +741,7 @@ validate_environment <- function(env) {
"mn_base_url",
"submitter",
"rights_holder")
stopifnot(class(env) == "list",
stopifnot(is(env, "list"),
length(env) > 0)
stopifnot(!is.null(env), length(env) > 0)
stopifnot(all(env_default_components %in% names(env)))
Expand Down
2 changes: 1 addition & 1 deletion R/sysmeta.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ replace_subject <- function(sysmeta,
#'
#' @examples
clear_replication_policy <- function(sysmeta) {
if (!(class(sysmeta) == "SystemMetadata")) {
if (!(is(sysmeta, "SystemMetadata"))) {
stop("First argument was not of class SystemMetadata.")
}

Expand Down
6 changes: 3 additions & 3 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ object_exists <- function(node, pids) {
e
})

if (inherits(sysmeta, "error") || class(sysmeta) != "SystemMetadata") {
if (inherits(sysmeta, "error") || !is(sysmeta, "SystemMetadata")) {
result[i] <- FALSE
} else {
result[i] <- TRUE
Expand Down Expand Up @@ -425,7 +425,7 @@ replace_package_id <- function(path, replacement) {
nchar(replacement) > 0)

doc <- EML::read_eml(path)
stopifnot(class(doc) == "eml")
stopifnot(is(doc, "eml"))

doc@packageId <- new("xml_attribute", replacement)
doc@system <- new("xml_attribute", "arcticdata")
Expand Down Expand Up @@ -582,7 +582,7 @@ is_resource_map <- function(node, pids) {
#'
#' @examples
is_obsolete <- function(node, pids) {
stopifnot(class(node) == "MNode" || class(node) == "CNode")
stopifnot(is(node, "MNode") || is(node, "CNode"))
stopifnot(is.character(pids))

response <- vector(mode = "logical", length = length(pids))
Expand Down

0 comments on commit c0adcce

Please sign in to comment.