Skip to content

Commit

Permalink
Tested and fixed addPackage & removePackage
Browse files Browse the repository at this point in the history
  • Loading branch information
katieb1 committed Dec 2, 2023
1 parent a50a92b commit d9830bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
17 changes: 13 additions & 4 deletions R/addPackage.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,26 @@ setMethod("addPackage", signature(ssimLibrary = "character"), function(ssimLibra

#' @rdname addPackage
setMethod("addPackage", signature(ssimLibrary = "SsimLibrary"), function(ssimLibrary, name) {
cAdds <- packages(ssimLibrary)
sessionPkgs <- packages(.session(ssimLibrary))
libraryPkgs <- packages(ssimLibrary)
retList <- list()
for (i in seq(length.out = length(name))) {
cVal <- name[i]
if (!is.element(cVal, cAdds$name)) {
print(paste0("Warning - ", cVal, " is not among the available packages: ", paste(cAdds$name, collapse = ",")))
if (is.element(cVal, libraryPkgs$name)){
print(paste0(cVal, " has already been added to the ssimLibrary"))
retList[[cVal]] <- FALSE
next
}

if (!is.element(cVal, sessionPkgs$name)) {
print(paste0("Warning - ", cVal, " is not among the available packages: ",
paste(sessionPkgs$name, collapse = ",")))
retList[[cVal]] <- FALSE
next
}

tt <- command(list(add = NULL, package = NULL, lib = .filepath(ssimLibrary), pkg = cVal), .session(ssimLibrary))
tt <- command(list(add = NULL, package = NULL, lib = .filepath(ssimLibrary),
pkg = cVal), .session(ssimLibrary))
if (tt == "saved"){
message(paste0("Package <", cVal, "> added"))
retList[[cVal]] <- TRUE
Expand Down
2 changes: 1 addition & 1 deletion R/packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ setMethod("packages", signature(ssimObject = "SsimLibrary"), function(ssimObject
#TODO: change to --packages when update to next version of SyncroSim v3
args <- list(list = NULL, pkgvers = NULL, lib = filepath(ssimObject), csv = NULL)
tt <- command(args, program = "SyncroSim.Console.exe",
progName=filepath(session(ssimObject)))
progName=filepath(.session(ssimObject)))
out <- .dataframeFromSSim(tt, csv = T)

return(out)
Expand Down
7 changes: 4 additions & 3 deletions R/removePackage.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ setMethod("removePackage", signature(ssimLibrary = "character"), function(ssimLi

#' @rdname removePackage
setMethod("removePackage", signature(ssimLibrary = "SsimLibrary"), function(ssimLibrary, name) {
cAdds <- subset(addon(ssimLibrary))
libraryPkgs <- subset(packages(ssimLibrary))
retList <- list()

for (i in seq(length.out = length(name))) {
cVal <- name[i]
if (!is.element(cVal, cAdds$name)) {
print(paste0("Warning - ", cVal, " is not among the available packages: ", paste(cAdds$name, collapse = ",")))
if (!is.element(cVal, libraryPkgs$name)) {
print(paste0("Warning - ", cVal, " is not among the available packages: ",
paste(libraryPkgs$name, collapse = ",")))
retList[[cVal]] <- FALSE
next
}
Expand Down

0 comments on commit d9830bd

Please sign in to comment.