export(Arvados)
export(ArvadosFile)
export(Collection)
-export(CollectionTree)
export(Subcollection)
+export(print.Arvados)
+export(print.ArvadosFile)
+export(print.Collection)
+export(print.Subcollection)
cloneable = FALSE
)
+
+#' @export print.Arvados
+print.Arvados = function(arvados)
+{
+ cat(paste0("Type: ", "\"", "Arvados", "\""), sep = "\n")
+ cat(paste0("Host: ", "\"", arvados$getHostName(), "\""), sep = "\n")
+ cat(paste0("Token: ", "\"", arvados$getToken(), "\"") , sep = "\n")
+}
cloneable = FALSE
)
+
+#' @export print.ArvadosFile
+print.ArvadosFile = function(arvadosFile)
+{
+ collection <- NULL
+ relativePath <- arvadosFile$getRelativePath()
+
+ if(!is.null(arvadosFile$getCollection()))
+ {
+ collection <- arvadosFile$getCollection()$uuid
+ relativePath <- paste0("/", relativePath)
+ }
+
+ cat(paste0("Type: ", "\"", "ArvadosFile", "\""), sep = "\n")
+ cat(paste0("Name: ", "\"", arvadosFile$getName(), "\""), sep = "\n")
+ cat(paste0("Relative path: ", "\"", relativePath, "\"") , sep = "\n")
+ cat(paste0("Collection: ", "\"", collection, "\""), sep = "\n")
+}
"Subcollection" %in% class(content))
{
subcollection$add(content)
-
content
}
else
elementToMove <- self$get(content)
if(is.null(elementToMove))
- stop("Element you want to move doesn't exist in the collection.")
+ stop("Content you want to move doesn't exist in the collection.")
elementToMove$move(newLocation)
},
REST = NULL,
tree = NULL,
- fileContent = NULL,
-
- generateTree = function(content)
- {
- treeBranches <- sapply(collectionContent, function(filePath)
- {
- splitPath <- unlist(strsplit(filePath$name, "/", fixed = TRUE))
-
- branch = private$createBranch(splitPath, filePath$fileSize)
- })
- }
+ fileContent = NULL
),
cloneable = FALSE
)
+
+#' @export print.Collection
+print.Collection = function(collection)
+{
+ cat(paste0("Type: ", "\"", "Arvados Collection", "\""), sep = "\n")
+ cat(paste0("uuid: ", "\"", collection$uuid, "\""), sep = "\n")
+}
#' Update description
#'
#' @examples arv = Collection$new(api, uuid)
-#' @export CollectionTree
CollectionTree <- R6::R6Class(
"CollectionTree",
public = list(
}
else
{
- # Note: REST always returns folder name alone before other folder content
- # (for some reason), so in first iteration we don't know if it's a file
+ # Note: REST always returns folder name alone before other folder
+ # content, so in first iteration we don't know if it's a file
# or folder since its just a name, so we assume it's a file.
# If we encounter that same name again we know
# it's a folder so we need to replace ArvadosFile with Subcollection.
initialize = function(name)
{
- private$name <- name
+ private$name <- name
},
getName = function() private$name,
getFileListing = function(fullPath = TRUE)
{
- content <- NULL
-
- if(fullPath)
- {
- for(child in private$children)
- content <- c(content, child$getFileListing())
-
- if(private$name != "")
- content <- unlist(paste0(private$name, "/", content))
- }
- else
- {
- for(child in private$children)
- content <- c(content, child$getName())
- }
+ content <- private$getContentAsCharVector(fullPath)
content[order(tolower(content))]
},
parent$remove(private$name)
parent$setCollection(parentsCollection, setRecursively = FALSE)
+ },
+
+ getContentAsCharVector = function(fullPath = TRUE)
+ {
+ content <- NULL
+
+ if(fullPath)
+ {
+ for(child in private$children)
+ content <- c(content, child$getFileListing())
+
+ if(private$name != "")
+ content <- unlist(paste0(private$name, "/", content))
+ }
+ else
+ {
+ for(child in private$children)
+ content <- c(content, child$getName())
+ }
+
+ content
+
}
),
cloneable = FALSE
)
+
+#' @export print.Subcollection
+print.Subcollection = function(subCollection)
+{
+ collection <- NULL
+ relativePath <- subCollection$getRelativePath()
+
+ if(!is.null(subCollection$getCollection()))
+ {
+ collection <- subCollection$getCollection()$uuid
+
+ if(!subCollection$getName() == "")
+ relativePath <- paste0("/", relativePath)
+ }
+
+ cat(paste0("Type: ", "\"", "Arvados Subcollection", "\""), sep = "\n")
+ cat(paste0("Name: ", "\"", subCollection$getName(), "\""), sep = "\n")
+ cat(paste0("Relative path: ", "\"", relativePath, "\"") , sep = "\n")
+ cat(paste0("Collection: ", "\"", collection, "\""), sep = "\n")
+}
nameAndPath$name <- components[length(components)]
nameAndPath$path <- trimFromStart(paste0(components[-length(components)], collapse = "/"),
"/")
-
+
nameAndPath
}
#Update a collection's metadata:
-updatedCollection <- arv$updateCollection("uuid", list(name = "My new name", description = "a brand new description"))
+updatedCollection <- arv$updateCollection("uuid", list(name = "New name", description = "New description"))
--------------------------------------------------------------------------------------------------------------------------------
subcollection <- collection$get("location/to/folder")
subcollection$move("newDestination/folder")
-#Make sure to include file name in new destination
+#Make sure to include new file name in destination
#In second example file$move("newDestination/") will not work
--------------------------------------------------------------------------------------------------------------------------------
collection <- Collection$new(api, "myUUID")
expect_that(collection$move("fish", "object"),
- throws_error("Element you want to move doesn't exist in the collection.",
+ throws_error("Content you want to move doesn't exist in the collection.",
fixed = TRUE))
})
-context("Http Parser")
+context("Http Request")
test_that(paste("createQuery generates and encodes query portion of http",