Skip to content

Commit

Permalink
Cherry pick fixes from CRAN branch from R check
Browse files Browse the repository at this point in the history
  • Loading branch information
katieb1 committed Oct 14, 2024
1 parent 0b5443f commit 2395bfa
Show file tree
Hide file tree
Showing 43 changed files with 117 additions and 72 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ Imports:
DBI,
RSQLite,
terra,
gtools,
lifecycle
gtools
Suggests:
knitr,
testthat (>= 3.0.0),
Expand Down
18 changes: 9 additions & 9 deletions R/chartCriteria.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ setMethod("chartCriteria", signature(ssimObject = "SsimObject"),
returnSingleChart <- (is(ssimObject, "Chart") || !is.null(chart)) &&
(is.null(variable))
returnAllChart <- (is(ssimObject, "Project") || !is.null(variable))

# Grab list of chart information for project to match names
if (is(ssimObject, "Project")){
ssimProj <- ssimObject
} else {
ssimProj <- .project(ssimObject)
}

if (returnSingleChart){

Expand Down Expand Up @@ -111,13 +118,6 @@ setMethod("chartCriteria", signature(ssimObject = "SsimObject"),
df <- rbind(df, xResult)
}

# Grab list of chart information for project to match names
if (is(ssimObject, "Project")){
ssimProj <- ssimObject
} else {
ssimProj <- .project(ssimObject)
}

# dissagregateBy should match filter values in projectchartCriteria
for (i in 1:nrow(df)){

Expand Down Expand Up @@ -189,7 +189,7 @@ setMethod("chartCriteria", signature(ssimObject = "SsimObject"),
chartDS <- subsetInfo$datasheet
args <- list(list = NULL, columns = NULL, lib=libPath, allprops = NULL,
sheet = chartDS, csv = NULL)
tt <- command(args, mySession)
tt <- command(args, chartSession)
df <- .dataframeFromSSim(tt)
df_filtered <- df[df$name %in% filter, ]

Expand All @@ -198,7 +198,7 @@ setMethod("chartCriteria", signature(ssimObject = "SsimObject"),
}

displayNameDS <- gsub(".*formula1\\^(.+)\\!formula2.*", "\\1", df_filtered$properties)
valuesDS <- .datasheet(myProject, name = displayNameDS, rawValues = T, includeKey = T)
valuesDS <- .datasheet(ssimProj, name = displayNameDS, rawValues = T, includeKey = T)
names(valuesDS) <- c("ID", "Name")
return(valuesDS[1:2])
}
Expand Down
2 changes: 1 addition & 1 deletion R/chartId.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ NULL
#'
#' Retrieves the Chart Id of a SyncroSim \code{\link{Chart}}.
#'
#' @param chart \code{\link{Chart}} object
#' @param ssimObject \code{\link{Chart}} object
#'
#' @return
#' An integer: chart id.
Expand Down
9 changes: 5 additions & 4 deletions R/datasheet.R
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ setMethod("datasheet",
ParentId <- NULL
ParentName <- NULL
Name <- NULL
xProjScn <- .getFromXProjScn(ssimObject, project, scenario, returnIds = TRUE, convertObject = FALSE, complainIfMissing = TRUE)
xProjScn <- .getFromXProjScn(ssimObject, project, scenario, returnIds = TRUE,
convertObject = FALSE, complainIfMissing = TRUE)
IDColumns <- c("ScenarioId", "ProjectId")

if (is(ssimObject, "SsimLibrary")){
Expand Down Expand Up @@ -341,7 +342,7 @@ setMethod("datasheet",
sumInfo <- subset(sumInfo, select = c("scope", "name", "displayName", "order"))
sumInfo[order(sumInfo$order), ]
sumInfo$order <- NULL
sumInfo <- subset(sumInfo, scope == scopeDS)
sumInfo <- sumInfo[sumInfo$scope == scopeDS,]

return(sumInfo)
}
Expand All @@ -356,7 +357,7 @@ setMethod("datasheet",

sumInfo[order(sumInfo$order), ]
sumInfo$order <- NULL
sumInfo <- subset(sumInfo, scope == scopeDS)
sumInfo <- sumInfo[sumInfo$scope == scopeDS,]

return(sumInfo)
}
Expand Down Expand Up @@ -398,7 +399,7 @@ setMethod("datasheet",
sumInfo <- subset(sumInfo, select = c(prevNames, setdiff(names(sumInfo), prevNames)))
sumInfo <- sumInfo[order(sumInfo$order, sumInfo$scenario), ]
sumInfo$order <- NULL
sumInfo <- subset(sumInfo, scope == scopeDS)
sumInfo <- sumInfo[sumInfo$scope == scopeDS,]

return(sumInfo)
}
Expand Down
5 changes: 4 additions & 1 deletion R/delete.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ setMethod("delete", signature(ssimObject = "SsimObject"),
force, session) {

ScenarioId <- NULL
Name <- NULL
FolderId <- NULL
ChartId <- NULL

xProjScn <- .getFromXProjScn(ssimObject, project = project,
scenario = scenario, folder = folder,
Expand All @@ -115,7 +118,7 @@ setMethod("delete", signature(ssimObject = "SsimObject"),

if (is.null(folder)) {
folderId <- .folderId(ssimObject)
folderName <- .name(ssimobject)
folderName <- .name(ssimObject)
} else {
allFolders <- getFolderData(ssimObject)

Expand Down
8 changes: 8 additions & 0 deletions R/deleteLibrary.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) 2024 Apex Resource Management Solution Ltd. (ApexRMS). All rights reserved.
# MIT License
#' @include AAAClassDefinitions.R
NULL

#' Delete Library
#'
#' Deletes a SyncroSim library. Note this is irreversable.
Expand Down Expand Up @@ -38,18 +43,21 @@
#'
#' @export

#' @rdname deleteLibrary
setGeneric("deleteLibrary",
function(ssimLibrary, force = FALSE, removeBackup = FALSE,
removePublish = FALSE, removeCustom = FALSE,
session = NULL) standardGeneric("deleteLibrary"))

#' @rdname deleteLibrary
setMethod("deleteLibrary", signature(ssimLibrary = "SsimLibrary"),
function(ssimLibrary, force, removeBackup, removePublish, removeCustom) {

return(deleteLibrary(.filepath(ssimLibrary), force, removeBackup,
removePublish, removeCustom, .session(ssimLibrary)))
})

#' @rdname deleteLibrary
setMethod("deleteLibrary", signature(ssimLibrary = "character"),
function(ssimLibrary, force, removeBackup, removePublish,
removeCustom, session) {
Expand Down
25 changes: 15 additions & 10 deletions R/dependency.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ NULL
#' If the dependency argument includes more than one element, elements are ordered
#' from lowest to highest precedence.
#'
#' @param scenario \code{\link{Scenario}} object, character string, integer, or
#' @param ssimObject \code{\link{Scenario}} object, character string, integer, or
#' vector of these. The Scenario object, name, or ID to which a dependency is to
#' be added (or has already been added if \code{remove=TRUE}). Note that integer ids
#' are slightly faster
#' are slightly faster.
#' @param value \code{\link{Scenario}} object, character string, integer, or
#' vector of these. The Scenario object, name, or ID to be used as the
#' dependency. If an empty vector is provided, all dependencies are removed.
#'
#' @return
#' A data.frame: all dependencies for a given Scenario
Expand Down Expand Up @@ -55,18 +58,18 @@ NULL
#' }
#'
#' @export
setGeneric("dependency", function(scenario) standardGeneric("dependency"))
setGeneric("dependency", function(ssimObject) standardGeneric("dependency"))

#' @rdname dependency
setMethod("dependency", signature(scenario = "character"), function(scenario) {
return(SyncroSimNotFound(scenario))
setMethod("dependency", signature(ssimObject = "character"), function(ssimObject) {
return(SyncroSimNotFound(ssimObject))
})

#' @rdname dependency
setMethod("dependency", signature(scenario = "Scenario"), function(scenario) {
setMethod("dependency", signature(ssimObject = "Scenario"), function(ssimObject) {

# Rename variable so it's not the same as the rsyncrosim::scenario() function
s <- scenario
# Rename variable
s <- ssimObject

# get set of existing dependencies
args <- list(list = NULL, dependencies = NULL, lib = .filepath(s),
Expand Down Expand Up @@ -121,9 +124,11 @@ setReplaceMethod(
cDep <- allScns$ScenarioId[allScns$Name == v]

if (length(cDep) == 0) {
stop("Could not find dependency scenario ", cDepRaw)
stop("Could not find dependency scenario ", v)
} else if (length(cDep) > 1) {
stop("Found more than one scenario named ", v, ". Please specify a dependency scenario id:", paste0(v, collapse = ","))
stop("Found more than one scenario named ", v,
". Please specify a dependency scenario id:",
paste0(v, collapse = ","))
} else {
valueList <- c(valueList, cDep)
}
Expand Down
4 changes: 4 additions & 0 deletions R/folder.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ setMethod(

Name <- NULL
FolderId <- NULL
ProjectId <- NULL
x <- ssimObject

# Set default parent ID
Expand Down Expand Up @@ -184,6 +185,9 @@ folder <- function(ssimObject = NULL, folder = NULL, parentFolder = NULL,
stop("Cannot create a folder at the Scenario-level.")
}

FolderId <- NULL
Name <- NULL

x <- ssimObject

if (is(ssimObject, "Folder") & (summary == TRUE)){
Expand Down
2 changes: 2 additions & 0 deletions R/internalHelpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ deleteScenarioDatasheet <- function(x, datasheet, scenario,

deleteScenario <- function(x, scenario, allScenarios, out = list(), force){

ScenarioId <- NULL

for (i in seq(length.out = length(scenario))) {
cScn <- scenario[i]
name <- allScenarios$Name[allScenarios$ScenarioId == cScn]
Expand Down
2 changes: 2 additions & 0 deletions R/packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ setMethod("packages", signature(ssimObject = "missingOrNULL"),
setMethod("packages", signature(ssimObject = "Session"),
function(ssimObject, installed = TRUE) {

Name <- NULL

if (installed == FALSE) {
arg <- "available"
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/projectId.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ NULL
#' \code{\link{Scenario}}, \code{\link{Folder}} or \code{\link{Chart}}.
#'
#' @param ssimObject \code{\link{Scenario}}, \code{\link{Project}},
#' \code{\link{Folder}}, or \code{\link{{Chart}}} object
#' \code{\link{Folder}}, or \code{\link{Chart}} object
#'
#' @return
#' An integer: project id.
Expand Down
3 changes: 2 additions & 1 deletion R/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ setMethod("run", signature(ssimObject = "list"),
setMethod("run", signature(ssimObject = "SsimObject"),
function(ssimObject, scenario, summary, copyExternalInputs,
transformerName) {


ScenarioId <- NULL
xProjScn <- .getFromXProjScn(ssimObject, scenario = scenario,
convertObject = TRUE, returnIds = TRUE,
goal = "scenario", complainIfMissing = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion man/addPackage.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/backup.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/chart.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/chartId.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/datasheet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/delete.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 20 additions & 6 deletions man/deleteLibrary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2395bfa

Please sign in to comment.