From 41deeab0612e5674a86a22894aa6716e1e21eb5f Mon Sep 17 00:00:00 2001 From: katieb1 Date: Tue, 12 Mar 2024 11:23:07 -0700 Subject: [PATCH] Add chart/folder deletion + refactor delete, add name(Chart) and projectId(Chart) --- DESCRIPTION | 1 + NAMESPACE | 13 +- R/AAAClassDefinitions.R | 20 ++- R/chart.R | 2 +- R/chartId.R | 43 +++++ R/chartMapConstructor.R | 75 +++++++- R/delete.R | 237 ++++++++++++------------- R/internalHelpers.R | 381 +++++++++++++++++++++++++++++++++++----- R/internalWrappers.R | 2 + R/name.R | 26 ++- R/projectId.R | 12 +- man/Chart-class.Rd | 29 +++ man/add_ssimChart.Rd | 23 +++ man/chart-add.Rd | 19 ++ man/chart.Rd | 29 +-- man/chartId.Rd | 43 +++++ man/command.Rd | 9 +- man/delete.Rd | 60 +++++-- man/deleteLibrary.Rd | 28 +++ man/name.Rd | 6 + 20 files changed, 836 insertions(+), 222 deletions(-) create mode 100644 R/chartId.R create mode 100644 man/Chart-class.Rd create mode 100644 man/add_ssimChart.Rd create mode 100644 man/chart-add.Rd create mode 100644 man/chartId.Rd create mode 100644 man/deleteLibrary.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 6038eb87..23c83e5b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -51,6 +51,7 @@ Collate: 'autogentags.R' 'backup.R' 'chart.R' + 'chartId.R' 'chartMapConstructor.R' 'command.R' 'condaFilepath.R' diff --git a/NAMESPACE b/NAMESPACE index 7befde5d..b1af5e5c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,11 @@ # Generated by roxygen2: do not edit by hand -export("%+%") +S3method("+",Chart) +S3method(ssimChart_add,Criteria) +S3method(ssimChart_add,column_chart) +S3method(ssimChart_add,line_chart) +S3method(ssimChart_add,y) +export("+.Chart") export("autogentags<-") export("condaFilepath<-") export("dependency<-") @@ -14,6 +19,7 @@ export("readOnly<-") export("session<-") export("silent<-") export("useConda<-") +export(Chart) export(Folder) export(Project) export(Scenario) @@ -21,9 +27,12 @@ export(Session) export(SsimLibrary) export(addPackage) export(addRow) +export(add_ssimChart) +export(as.Chart) export(autogentags) export(backup) export(chart) +export(chartId) export(command) export(condaFilepath) export(datasheet) @@ -39,6 +48,7 @@ export(ignoreDependencies) export(info) export(installConda) export(installPackage) +export(is.Chart) export(mergeDependencies) export(name) export(owner) @@ -61,6 +71,7 @@ export(scenarioId) export(session) export(silent) export(sqlStatement) +export(ssimChart_add) export(ssimEnvironment) export(ssimLibrary) export(ssimUpdate) diff --git a/R/AAAClassDefinitions.R b/R/AAAClassDefinitions.R index 32b89ab1..fc70a0e5 100644 --- a/R/AAAClassDefinitions.R +++ b/R/AAAClassDefinitions.R @@ -127,11 +127,12 @@ Project <- setClass("Project", contains = "SsimObject", #' @name Folder-class #' @rdname Folder-class #' @export Folder -Folder <- setClass("Folder", representation(session = "Session", - filepath = "character", - folderId = "numeric", - parentId = "numeric", - projectId = "numeric")) +Folder <- setClass("Folder", contains = "SsimObject", + representation(session = "Session", + filepath = "character", + folderId = "numeric", + parentId = "numeric", + projectId = "numeric")) #' SyncroSim Chart class #' @@ -149,9 +150,10 @@ Folder <- setClass("Folder", representation(session = "Session", #' @name Chart-class #' @rdname Chart-class #' @export Chart -Chart <- setClass("Chart", representation(session = "Session", - filepath = "character", - chartId = "numeric", - projectId = "numeric")) +Chart <- setClass("Chart", contains = "SsimObject", + representation(session = "Session", + filepath = "character", + chartId = "numeric", + projectId = "numeric")) diff --git a/R/chart.R b/R/chart.R index f21bc01c..bbb4332e 100644 --- a/R/chart.R +++ b/R/chart.R @@ -129,7 +129,7 @@ setMethod( #' #' # Create a new chart #' myChart <- chart(myProject, chart = "New Chart") -#' +#' } #' @name chart #' @export chart <- function(ssimObject = NULL, chart = NULL, create = FALSE, summary = FALSE) { diff --git a/R/chartId.R b/R/chartId.R new file mode 100644 index 00000000..6f9af444 --- /dev/null +++ b/R/chartId.R @@ -0,0 +1,43 @@ +# Copyright (c) 2024 Apex Resource Management Solution Ltd. (ApexRMS). All rights reserved. +# MIT License +#' @include AAAClassDefinitions.R +NULL + +#' Retrieves chartId of SyncroSim Chart +#' +#' Retrieves the Chart Id of a SyncroSim \code{\link{Chart}}. +#' +#' @param chart \code{\link{Chart}} object +#' +#' @return +#' An integer: chart id. +#' +#' @examples +#' \donttest{ +#' # Set the file path and name of the new SsimLibrary +#' myLibraryName <- file.path(tempdir(),"testlib") +#' +#' # Set the SyncroSim Session, SsimLibrary, and Project +#' mySession <- session() +#' myLibrary <- ssimLibrary(name = myLibraryName, +#' session = mySession, +#' overwrite = TRUE) +#' myProject <- project(myLibrary, project = "Definitions") +#' +#' # Get the chart object corresponding to the chart called "My Chart" +#' myChart <- chart(myProject, chart = "My Chart") +#' +#' # Get Chart ID for SyncroSim Chart +#' chartId(myChart) +#' } +#' +#' @export +setGeneric("chartId", function(ssimObject) standardGeneric("chartId")) +#' @rdname chartId +setMethod("chartId", signature(ssimObject = "character"), function(ssimObject) { + return(SyncroSimNotFound(ssimObject)) +}) +#' @rdname chartId +setMethod("chartId", signature(ssimObject = "Chart"), function(ssimObject) { + return(ssimObject@chartId) +}) \ No newline at end of file diff --git a/R/chartMapConstructor.R b/R/chartMapConstructor.R index 3b982114..c805f757 100644 --- a/R/chartMapConstructor.R +++ b/R/chartMapConstructor.R @@ -1,8 +1,13 @@ -# Testing out plotting construction code -# Below taken and modified from ggplot plot-construction.R - -# Create function for adding together SyncroSim charting and mapping objects -"+.ssim" <- function(e1, e2) { +#' Testing out plotting construction code +#' Below taken and modified from ggplot plot-construction.R +#' +#' Create function for adding together SyncroSim charting and mapping objects +#' @param e1 An object of class [ssimChart()]. +#' @param e2 A chart or map component, as described below. +#' @export +#' @method + Chart +#' @rdname chart-add +"+.Chart" <- function(e1, e2) { if (missing(e2)) { cli::cli_abort(c( "Cannot use {.code +} with a single argument.", @@ -14,15 +19,30 @@ # can be displayed in error messages e2name <- deparse(substitute(e2)) - if (is.ssimChart(e1)) add_ssimChart(e1, e2, e2name) - else if (is.ssimMap(e1)) add_ssimMap(e1, e2, e2name) + if (is.Chart(e1)) add_ssimChart(e1, e2, e2name) + else if (is.Map(e2)) add_ssimMap(e1, e2, e2name) } # Overload the "+" -#' @rdname ssim-add +#' @rdname chart-add #' @export -"%+%" <- `+.ssim` +`+.Chart` <- function(e1, e2){ + UseMethod("ssimChart_add") +} +#' Customize the chart +#' +#' This generic allows you to add your own methods for adding custom objects to +#' a chart with [+.Chart]. +#' +#' @param object An object to add to the chart +#' @param plot The chart object to add `object` to +#' @param object_name The name of the object to add +#' +#' @return A modified chart object +#' +#' @keywords internal +#' @export add_ssimChart <- function(c, object, objectname) { if (is.null(object)) return(c) @@ -30,10 +50,47 @@ add_ssimChart <- function(c, object, objectname) { c } +#' @export +as.Chart <- function(x){ + if(!inherits(x, "Chart")) class(x) <- c("Chart", class(x)) + x +} + +#' @export +is.Chart <- function(x){ + inherits(x, "Chart") +} + +#' @export ssimChart_add <- function(object, chart, object_name) { UseMethod("ssimChart_add") } + +# Below we specify what happens when an object of a certain type is added +# to a chart object (e.g., legend object, format object, title object, etc.) + +# Adds an object of type "Criteria" to the chart and returns a chart object +#' @export +ssimChart_add.Criteria <- function(object, chart, object_name){ + browser() + chart$type <- "line" + chart +} + +#' @export +ssimChart_add.line_chart <- function(object, chart, object_name){ + chart$type <- "line" + chart +} + +#' @export +ssimChart_add.column_chart <- function(object, chart, object_name){ + chart$type <- "column" + chart +} + +#' @export ssimChart_add.y <- function(object, chart, object_name){ chart$yVariable <- object chart diff --git a/R/delete.R b/R/delete.R index 193d0c83..a1d22f1a 100644 --- a/R/delete.R +++ b/R/delete.R @@ -3,23 +3,43 @@ #' @include AAAClassDefinitions.R NULL -#' Delete SsimLibrary, Project, Scenario, Datasheet +#' Delete SsimLibrary, Project, Scenario, Folder, Chart or Datasheet #' #' Deletes one or more items. Note that this is irreversible. #' #' @param ssimObject \code{\link{SsimLibrary}}, \code{\link{Project}}, -#' or \code{\link{Scenario}} object, or character (i.e. path to a SsimLibrary) +#' \code{\link{Scenario}}, \code{\link{Folder}}, or \code{\link{Chart}} +#' object, or character (i.e. path to a SsimLibrary) #' @param project character string, numeric, or vector of these. One or more #' \code{\link{Project}} names or ids. Note that project argument is ignored -#' if SsimObject is a list. Note that integer ids are slightly faster (optional) +#' if ssimObject is a list. Note that integer ids are slightly faster (optional) #' @param scenario character string, numeric, or vector of these. One or more -#' \code{\link{Scenario}} names or ids. Note that Scenario argument is +#' \code{\link{Scenario}} names or ids. Note that scenario argument is +#' ignored if ssimObject is a list. Note that integer ids are slightly faster +#' (optional) +#' @param folder character string, numeric, or vector of these. One or more +#' \code{\link{Folder}} names or ids. Note that folder argument is +#' ignored if ssimObject is a list. Note that integer ids are slightly faster +#' (optional) +#' @param chart character string, numeric, or vector of these. One or more +#' \code{\link{Chart}} names or ids. Note that chart argument is #' ignored if SsimObject is a list. Note that integer ids are slightly faster #' (optional) -#' @param datasheet character string or vector of these. One or more Datasheet +#' @param datasheet character string or vector of these. One or more datasheet #' names (optional) #' @param force logical. If \code{FALSE} (default), user will be prompted to approve #' removal of each item +#' @param removeBackup logical. If \code{TRUE}, will remove the backup folder when +#' deleting a library. Default is \code{FALSE} +#' @param removePublish logical. If \code{TRUE}, will remove the publish folder when +#' deleting a library. Default is \code{FALSE} +#' @param removeCustom logical. If \code{TRUE} and custom folders have been configured +#' for a library, then will remove the custom publish and/or backup folders when +#' deleting a library. Note that the `removePublish` and `removeBackup` arguments +#' must also be set to \code{TRUE} to remove the respective custom folders. Default +#' is \code{FALSE} +#' @param session \code{\link{Session}} object. If \code{NULL} (default), session() +#' will be used. Only applicable when `ssimObject` argument is a character #' #' @return #' Invisibly returns a list of boolean values corresponding to each @@ -46,29 +66,50 @@ NULL #' } #' #' @export -# Note delete supports character paths because sometimes we want to delete a library without updating it. -# Note delete supports project/scenario arguments because sometimes we want to delete objects without creating them. -setGeneric("delete", function(ssimObject, project = NULL, scenario = NULL, datasheet = NULL, force = FALSE) standardGeneric("delete")) +# Note delete supports character paths because sometimes we want to delete a +# library without updating it. +# Note delete supports project/scenario/folder/chart arguments because sometimes +# we want to delete objects without creating them. +setGeneric("delete", + function(ssimObject, project = NULL, scenario = NULL, + folder = NULL, chart = NULL, datasheet = NULL, + force = FALSE, removeBackup = FALSE, removePublish = FALSE, + removeCustom = FALSE, session = NULL) standardGeneric("delete")) #' @rdname delete -setMethod("delete", signature(ssimObject = "character"), function(ssimObject, project, scenario, datasheet, force) { - if (is.null(datasheet) & is.null(project) & is.null(scenario)) { - return(deleteLibrary(ssimObject, force)) +setMethod("delete", signature(ssimObject = "character"), + function(ssimObject, project, scenario, folder, chart, datasheet, + force, removeBackup, removePublish, removeCustom, session) { + + if (is.null(datasheet) && is.null(project) && is.null(scenario) && + is.null(folder) && is.null(chart)) { + + return(deleteLibrary(ssimObject, force, removeBackup, removePublish, + removeCustom, session)) } else { + if (ssimObject == SyncroSimNotFound(warn = FALSE)) { + return(SyncroSimNotFound()) } ssimObject <- .ssimLibrary(ssimObject) - return(delete(ssimObject, project, scenario, datasheet, force)) + return(delete(ssimObject, project, scenario, folder, chart, datasheet, + force, session)) } }) #' @rdname delete -setMethod("delete", signature(ssimObject = "SsimObject"), function(ssimObject, project, scenario, datasheet, force) { +setMethod("delete", signature(ssimObject = "SsimObject"), + function(ssimObject, project, scenario, folder, chart, datasheet, + force, session) { + ScenarioId <- NULL - xProjScn <- .getFromXProjScn(ssimObject, project = project, scenario = scenario, returnIds = TRUE, convertObject = FALSE, complainIfMissing = TRUE) + xProjScn <- .getFromXProjScn(ssimObject, project = project, + scenario = scenario, folder = folder, + chart = chart, returnIds = TRUE, + convertObject = FALSE, complainIfMissing = TRUE) # expect to have a vector of valid project or scenario ids - checking already done x <- xProjScn$ssimObject @@ -78,10 +119,13 @@ setMethod("delete", signature(ssimObject = "SsimObject"), function(ssimObject, p if (goal == "library") { if (is.null(datasheet)) { - out <- deleteLibrary(ssimObject, force) + out <- deleteLibrary(ssimObject, force, removeBackup, removePublish, + removeCustom, session) } else { datasheets <- .datasheets(ssimObject) - out <- deleteDatasheet(datasheet, datasheets, cProj = NULL, cScn = NULL, cProjName = NULL, cScnName = NULL, force = force) + out <- deleteDatasheet(datasheet, datasheets, cProj = NULL, + cScn = NULL, cProjName = NULL, + cScnName = NULL, force = force) } if (out == "saved"){ @@ -96,133 +140,90 @@ setMethod("delete", signature(ssimObject = "SsimObject"), function(ssimObject, p } if (goal == "project") { - allProjects <- xProjScn$projectSet if (!is.numeric(project)) { stop("Error in delete: project ids are not numeric.") } if (!is.null(datasheet)) { - if (is.element(class(ssimObject), c("Project", "Scenario"))) { - datasheets <- .datasheets(ssimObject, refresh = TRUE) - } else { - datasheets <- .datasheets(.project(ssimObject, project = project[1])) - } - } - - out <- list() - for (i in seq(length.out = length(project))) { - cProj <- project[i] - name <- allProjects$name[allProjects$projectId == cProj] - - # If datasheets(s) specified delete them. Otherwise delete the projects. - if (!is.null(datasheet)) { - outBit <- deleteDatasheet(x, datasheet, datasheets, cProj = cProj, cScn = NULL, cProjName = name, cScnName = NULL, out = out, force = force) - - if (outBit == "saved"){ - message(paste0("Datasheet " , datasheet, " deleted")) - outBit <- TRUE - } else{ - message(outBit) - outBit <- FALSE - } - - } else { - if (force) { - answer <- "y" - } else { - answer <- readline(prompt = paste0("Do you really want to delete project ", name, "(", cProj, ")? (y/n): ")) - } - if (answer == "y") { - outBit <- command(list(delete = NULL, project = NULL, lib = .filepath(x), pid = cProj, force = NULL), .session(x)) - } else { - outBit <- paste0("Deletion of project " , cProj, " skipped") - } - - if (outBit == "saved"){ - message(paste0("Project " , cProj, " deleted")) - outBit <- TRUE - } else{ - message(outBit) - outBit <- FALSE - } - - } - - out[[as.character(cProj)]] <- outBit - } - - if (length(out) == 1) { - out <- out[[1]] + allProjects <- xProjScn$projectSet + out <- deleteProjectDatasheet(x, datasheet, project, allProjects, + out = list(), force) + } else { + out <- deleteProject(x, project, out = list(), force) } return(invisible(out)) } if (goal == "scenario") { - allScenarios <- xProjScn$scenarioSet if (!is.numeric(scenario)) { stop("Error in delete: expect to have valid scenario ids.") } - if (!is.null(datasheet)) { - if (is.element(class(ssimObject), c("Scenario"))) { - datasheets <- .datasheets(ssimObject, refresh = TRUE) - scenarioSet <- scenario(.ssimLibrary(ssimObject), summary = TRUE) - } else { - datasheets <- .datasheets(.scenario(ssimObject, scenario = scenario[1])) - scenarioSet <- scenario(ssimObject, summary = TRUE) - } + if (!is.null(datasheet)){ + allScenarios <- xProjScn$scenarioSet + out <- deleteScenarioDatasheet(x, datasheet, scenario, allScenarios, + out = list(), force) + } else { + out <- deleteScenario(x, scenario, out = list(), force) } - out <- list() - for (i in seq(length.out = length(scenario))) { - cScn <- scenario[i] - name <- allScenarios$Name[allScenarios$ScenarioId == cScn] + return(invisible(out)) + } + + if (goal == "folder") { + + if (is.null(folder)) { + folderId <- .folderId(ssimObject) + folderName <- .name(ssimobject) + } else { + allFolders <- getFolderData(ssimObject) - if (!is.null(datasheet)) { - cProj <- subset(scenarioSet, ScenarioId == cScn)$ProjectId - outBit <- deleteDatasheet(x, datasheet = datasheet, datasheets = datasheets, - cProj = cProj, cScn = cScn, cProjName = "", - cScnName = name, out = out, force = force) - - if (outBit == "saved"){ - message(paste0("Datasheet " , datasheet, " deleted")) - outBit <- TRUE - } else{ - message(outBit) - outBit <- FALSE - } - - } else { - if (force) { - answer <- "y" - } else { - answer <- readline(prompt = paste0("Do you really want to remove scenario ", name, "(", cScn, ")? (y/n): ")) - } - if (answer == "y") { - outBit <- command(list(delete = NULL, scenario = NULL, lib = .filepath(x), sid = cScn, force = NULL), .session(x)) - } else { - outBit <- paste0("Deletion of scenario " , cProj, " skipped") - } - - if (outBit == "saved"){ - message(paste0("Scenario " ,cScn, " deleted")) - outBit <- TRUE - } else{ - message(outBit) - outBit <- FALSE - } - + if (is.character(folder)) { + folderId <- subset(allFolders, Name %in% folder)$FolderId + folderName <- subset(allFolders, Name %in% folder)$Name + } else if (is.numeric(folder)){ + folderId <- subset(allFolders, FolderId %in% folder)$FolderId + folderName <- subset(allFolders, FolderId %in% folder)$Name } + } + + if (length(folderId) == 0){ + stop(paste0("The specified folder(s) does not exist: ", + paste0(folder, collapse=","))) + } + + out <- deleteFolder(x, folderId, folderName, out = list(), force) + + return(invisible(out)) + } + + if (goal == "chart") { + + if (is.null(chart)) { + chartId <- .chartId(ssimObject) + chartName <- .name(ssimObject) + } else { + allCharts <- getChartData(ssimObject) - out[[as.character(cScn)]] <- outBit + if (is.character(chart)) { + chartId <- subset(allCharts, Name %in% chart)$ChartId + chartName <- subset(allCharts, Name %in% chart)$Name + } else if (is.numeric(chart)){ + chartId <- subset(allCharts, ChartId %in% chart)$ChartId + chartName <- subset(allCharts, ChartId %in% chart)$Name + } } - if (length(out) == 1) { - out <- out[[1]] + if (length(chartId) == 0){ + stop(paste0("The specified chart(s) does not exist: ", + paste0(chart, collapse=","))) } + + out <- deleteChart(x, chartId, chartName, out = list(), force) + return(invisible(out)) } diff --git a/R/internalHelpers.R b/R/internalHelpers.R index 3040e8e9..4144e6d4 100644 --- a/R/internalHelpers.R +++ b/R/internalHelpers.R @@ -43,7 +43,9 @@ backupEnabled <- function(path) { return(TRUE) } -deleteDatasheet <- function(x, datasheet, datasheets, cProj = NULL, cScn = NULL, cProjName = NULL, cScnName = NULL, out = list(), force) { +deleteDatasheet <- function(x, datasheet, datasheets, cProj = NULL, cScn = NULL, + cProjName = NULL, cScnName = NULL, out = list(), + force) { out <- list() lib = ssimLibrary(.filepath(x), summary=T) @@ -92,6 +94,240 @@ deleteDatasheet <- function(x, datasheet, datasheets, cProj = NULL, cScn = NULL, return(out) } +deleteProjectDatasheet <- function(x, datasheet, project, allProjects, + out = list(), force){ + + if (is.element(class(ssimObject), c("Project", "Scenario"))) { + datasheets <- .datasheets(ssimObject, refresh = TRUE) + } else { + datasheets <- .datasheets(.project(ssimObject, project = project[1])) + } + + out <- list() + for (i in seq(length.out = length(project))) { + + cProj <- project[i] + name <- allProjects$name[allProjects$projectId == cProj] + outBit <- deleteDatasheet(x, datasheet, datasheets, cProj = cProj, + cScn = NULL, cProjName = name, cScnName = NULL, + out = out, force = force) + + if (outBit == "saved"){ + message(paste0("Datasheet " , datasheet, " deleted")) + outBit <- TRUE + } else{ + message(outBit) + outBit <- FALSE + } + + out[[as.character(cProj)]] <- outBit + } + + if (length(out) == 1) { + out <- out[[1]] + } + + return(out) +} + +deleteProject <- function(x, project, out = list(), force){ + + out <- list() + for (i in seq(length.out = length(project))) { + cProj <- project[i] + name <- allProjects$name[allProjects$projectId == cProj] + + if (force) { + answer <- "y" + } else { + answer <- readline(prompt = paste0("Do you really want to delete project ", + name, "(", cProj, ")? (y/n): ")) + } + + if (answer == "y") { + outBit <- command(list(delete = NULL, project = NULL, lib = .filepath(x), + pid = cProj, force = NULL), .session(x)) + } else { + outBit <- paste0("Deletion of project " , cProj, " skipped") + } + + if (outBit == "saved"){ + message(paste0("Project " , cProj, " deleted")) + outBit <- TRUE + } else{ + message(outBit) + outBit <- FALSE + } + + out[[as.character(cProj)]] <- outBit + } + + if (length(out) == 1) { + out <- out[[1]] + } + + return(out) +} + + +deleteScenarioDatasheet <- function(x, datasheet, scenario, + allScenarios, out = list(), force){ + ScenarioId <- NULL + + if (is.element(class(ssimObject), c("Scenario"))) { + datasheets <- .datasheets(ssimObject, refresh = TRUE) + scenarioSet <- scenario(.ssimLibrary(ssimObject), summary = TRUE) + } else { + datasheets <- .datasheets(.scenario(ssimObject, scenario = scenario[1])) + scenarioSet <- scenario(ssimObject, summary = TRUE) + } + + out <- list() + for (i in seq(length.out = length(scenario))) { + cScn <- scenario[i] + name <- allScenarios$Name[allScenarios$ScenarioId == cScn] + + cProj <- subset(scenarioSet, ScenarioId == cScn)$ProjectId + outBit <- deleteDatasheet(x, datasheet = datasheet, datasheets = datasheets, + cProj = cProj, cScn = cScn, cProjName = "", + cScnName = name, out = out, force = force) + + if (outBit == "saved"){ + message(paste0("Datasheet " , datasheet, " deleted")) + outBit <- TRUE + } else{ + message(outBit) + outBit <- FALSE + } + out[[as.character(cScn)]] <- outBit + } + + if (length(out) == 1) { + out <- out[[1]] + } + + return(out) +} + +deleteScenario <- function(x, scenario, out = list(), force){ + + for (i in seq(length.out = length(scenario))) { + + if (force) { + answer <- "y" + } else { + answer <- readline(prompt = paste0("Do you really want to remove scenario ", + name, "(", cScn, ")? (y/n): ")) + } + + if (answer == "y") { + outBit <- command(list(delete = NULL, scenario = NULL, lib = .filepath(x), + sid = cScn, force = NULL), .session(x)) + } else { + outBit <- paste0("Deletion of scenario " , cProj, " skipped") + } + + if (outBit == "saved"){ + message(paste0("Scenario " ,cScn, " deleted")) + outBit <- TRUE + } else{ + message(outBit) + outBit <- FALSE + } + + out[[as.character(cScn)]] <- outBit + } + + if (length(out) == 1) { + out <- out[[1]] + } + + return(out) +} + +deleteFolder <- function(x, folderId, folderName, out = list(), force){ + + for (i in seq(length.out = length(folderId))) { + + folderIdToDelete <- folderId[i] + folderNameToDelete <- folderName[i] + + if (force) { + answer <- "y" + } else { + answer <- readline(prompt = paste0("Do you really want to remove folder ", + folderNameToDelete, "(", + folderIdToDelete, ")? (y/n): ")) + } + + if (answer == "y") { + outBit <- command(list(delete = NULL, folder = NULL, lib = .filepath(x), + fid = folderIdToDelete, force = NULL), .session(x)) + } else { + outBit <- paste0("Deletion of folder ", folderNameToDelete, " skipped") + } + + if (outBit == paste0("Folder deleted: ", folderIdToDelete)){ + message(paste0("Folder ", folderNameToDelete, " deleted")) + outBit <- TRUE + } else{ + message(outBit) + outBit <- FALSE + } + + out[[as.character(folderNameToDelete)]] <- outBit + } + + if (length(out) == 1) { + out <- out[[1]] + } + + return(out) +} + +deleteChart <- function(x, chartId, chartName, out = list(), force){ + + for (i in seq(length.out = length(chartId))) { + + chartIdToDelete <- chartId[i] + chartNameToDelete <- chartName[i] + + if (force) { + answer <- "y" + } else { + answer <- readline(prompt = paste0("Do you really want to remove chart ", + chartNameToDelete, "(", chartIdToDelete, + ")? (y/n): ")) + } + + if (answer == "y") { + args <- list(delete = NULL, + chart = NULL, lib = .filepath(x), + cid = chartIdToDelete, force = NULL) + outBit <- command(args, session = .session(x), + program = "SyncroSim.CPConsole.exe") + } else { + outBit <- paste0("Deletion of chart ", chartNameToDelete, " skipped") + } + + if (outBit == paste0("Chart deleted: ", chartIdToDelete)){ + message(paste0("Chart ", chartNameToDelete, " deleted")) + outBit <- TRUE + } else{ + message(outBit) + outBit <- FALSE + } + + out[[as.character(chartNameToDelete)]] <- outBit + } + + if (length(out) == 1) { + out <- out[[1]] + } + + return(out) +} + getIdsFromListOfObjects <- function(ssimObject, expecting = NULL, scenario = NULL, project = NULL) { if (is.null(expecting)) { expecting <- class(ssimObject[[1]]) @@ -531,13 +767,17 @@ datasheets <- function(x, project = NULL, scenario = NULL, scope = NULL, refresh # Internal helper - return uniquely identified and valid SyncroSim object -.getFromXProjScn <- function(ssimObject, project = NULL, scenario = NULL, convertObject = FALSE, returnIds = NULL, goal = NULL, complainIfMissing = TRUE) { +.getFromXProjScn <- function(ssimObject, project = NULL, scenario = NULL, + folder = NULL, chart = NULL, + convertObject = FALSE, returnIds = NULL, + goal = NULL, complainIfMissing = TRUE) { # If x is scenario, ignore project and scenario arguments Freq <- NULL ProjectId <- NULL ScenarioId <- NULL - if (!is.element(class(ssimObject), c("character", "SsimLibrary", "Project", "Scenario"))) { + if (!is.element(class(ssimObject), c("character", "SsimLibrary", "Project", + "Scenario", "Folder", "Chart"))) { stop("ssimObject should be a filepath, or an SsimLibrary/Scenario object.") } @@ -546,51 +786,69 @@ datasheets <- function(x, project = NULL, scenario = NULL, scope = NULL, refresh } # Check for conflicts between ssimObject and project/scenario. - if (is.element(class(ssimObject), c("Project", "Scenario")) & (!is.null(project))) { - warning("project argument is ignored when ssimObject is a Project/Scenario or list of these.") + if (is.element(class(ssimObject), + c("Project", "Scenario", "Folder", "Chart")) & (!is.null(project))) { + warning("project argument is ignored when ssimObject is a Project/Scenario/Folder/Chart or list of these.") project <- NULL } - if (is.element(class(ssimObject), c("Scenario")) & (!is.null(scenario))) { - warning("scenario argument is ignored when ssimObject is a Scenario or list of these.") + if (is.element(class(ssimObject), + c("Scenario", "Folder", "Chart")) && (!is.null(scenario))) { + warning("scenario argument is ignored when ssimObject is a Scenario/Folder/Chart or list of these.") scenario <- NULL } - if (is.null(goal) & (!is.null(project) | (is(ssimObject, "Project")) & is.null(scenario))) { - goal <- "project" - if (is.null(returnIds)) { - if (length(project) > 1) { - returnIds <- TRUE - } else { - returnIds <- FALSE + if (is.null(goal)){ + if (!is.null(project) || (is(ssimObject, "Project")) && is.null(c(scenario, chart, folder))) { + goal <- "project" + if (is.null(returnIds)) { + if (length(project) > 1) { + returnIds <- TRUE + } else { + returnIds <- FALSE + } } - } - } - - if (is.null(goal) & (!is.null(scenario) | (is(ssimObject, "Scenario")))) { - goal <- "scenario" - if (is.null(returnIds)) { - if (length(scenario) > 1) { - returnIds <- TRUE - } else { - returnIds <- FALSE + } else if (!is.null(scenario) || (is(ssimObject, "Scenario"))){ + goal <- "scenario" + if (is.null(returnIds)) { + if (length(scenario) > 1) { + returnIds <- TRUE + } else { + returnIds <- FALSE + } } - } - } - - if (is.null(goal)) { - if (is.null(project) & is.null(scenario)) { - if (!is.null(returnIds) && returnIds) { - return(list(ssimObject = ssimObject, project = NULL, scenario = NULL, goal = "library")) - } else { - return(ssimObject) + } else if (!is.null(folder) || is(ssimObject, "Folder")) { + goal <- "folder" + if (is.null(returnIds)) { + if (length(folder) > 1) { + returnIds <- TRUE + } else { + returnIds <- FALSE + } } + } else if (!is.null(chart) || is(ssimObject, "Chart")) { + goal <- "chart" + if (is.null(returnIds)) { + if (length(chart) > 1) { + returnIds <- TRUE + } else { + returnIds <- FALSE + } + } + } else { + if (is.null(project) && is.null(scenario) && is.null(folder) && is.null(chart)) { + if (!is.null(returnIds) && returnIds) { + return(list(ssimObject = ssimObject, project = NULL, scenario = NULL, goal = "library")) + } else { + return(ssimObject) + } + } + stop("Error in getFromXProjScn()") } - stop("Error in getFromXProjScn()") } # If the goal is a project, return one or more, or complain - if (!is.null(goal) && (goal == "project")) { + if (!is.null(goal) && ((goal == "project") || (goal == "folder") || (goal == "chart"))) { # if ssimObject is a scenario, return the parent project if ((is(ssimObject, "Scenario"))) { if (convertObject | !returnIds) { @@ -794,6 +1052,7 @@ datasheets <- function(x, project = NULL, scenario = NULL, scope = NULL, refresh return(list(ssimObject = ssimObject, project = project, scenario = scenario, scenarioSet = fullScnSet, goal = goal)) } + stop(paste0("Could not identify a SsimLibrary, Project or Scenario from ssimObject, project, and scenario arguments.")) } @@ -803,34 +1062,64 @@ datasheets <- function(x, project = NULL, scenario = NULL, scope = NULL, refresh # # @param ssimLibrary SsimLibrary or path to a library # @param force Logical. If FALSE (default) prompt to confirm that the library should be deleted. This is irreversable. +# @param removeBackup logical. If \code{TRUE}, will remove the backup folder when +#' deleting a library. Default is FALSE +# @param removePublish logical. If TRUE, will remove the publish folder when +#' deleting a library. Default is FALSE +# @param removeCustom logical. If TRUE and custom folders have been configured +#' for a library, then will remove the custom publish and/or backup folders when +#' deleting a library. Note that the `removePublish` and `removeBackup` arguments +#' must also be set to TRUE to remove the respective custom folders. Default +#' is FALSE +# @param session Session # @return "saved" or failure message. # @export -setGeneric("deleteLibrary", function(ssimLibrary, force = FALSE) standardGeneric("deleteLibrary")) +setGeneric("deleteLibrary", + function(ssimLibrary, force = FALSE, removeBackup = FALSE, + removePublish = FALSE, removeCustom = FALSE, + session = NULL) standardGeneric("deleteLibrary")) -setMethod("deleteLibrary", signature(ssimLibrary = "SsimLibrary"), function(ssimLibrary, force) { - return(deleteLibrary(.filepath(ssimLibrary), force)) +setMethod("deleteLibrary", signature(ssimLibrary = "SsimLibrary"), + function(ssimLibrary, force, removeBackup, removePublish, removeCustom) { + + return(deleteLibrary(.filepath(ssimLibrary), force, removeBackup, + removePublish, removeCustom, .session(ssimLibrary))) }) -setMethod("deleteLibrary", signature(ssimLibrary = "character"), function(ssimLibrary, force) { +setMethod("deleteLibrary", signature(ssimLibrary = "character"), + function(ssimLibrary, force, removeBackup, removePublish, + removeCustom, session) { + if (!file.exists(ssimLibrary)) { stop(paste0("Library not found: ", ssimLibrary)) } + if (force) { answer <- "y" } else { answer <- readline(prompt = paste0("Do you really want to delete library ", ssimLibrary, "? (y/n): ")) } + if (answer == "y") { - unlink(ssimLibrary) - if (file.exists(ssimLibrary)) { - return(paste0("Failed to delete ", ssimLibrary)) + + args <- list(delete = NULL, library = NULL, lib = ssimLibrary, force = NULL) + + if (removeBackup){ + args <- c(args, list(delrelback = NULL)) + if (removeCustom){ + args <- c(args, list(delcustback = NULL)) + } + } + + if (removePublish){ + args <- c(args, list(delrelpub = NULL)) + if (removeCustom){ + args <- c(args, list(delcustpub = NULL)) + } } - unlink(paste0(ssimLibrary, ".backup"), recursive = TRUE, force = TRUE) - unlink(paste0(ssimLibrary, ".input"), recursive = TRUE, force = TRUE) - unlink(paste0(ssimLibrary, ".output"), recursive = TRUE, force = TRUE) - unlink(paste0(ssimLibrary, ".temp"), recursive = TRUE, force = TRUE) + tt <- command(args = args, session = session) return("saved") } else { diff --git a/R/internalWrappers.R b/R/internalWrappers.R index 1adb2f44..d4f6504f 100644 --- a/R/internalWrappers.R +++ b/R/internalWrappers.R @@ -27,6 +27,8 @@ NULL # @export .folderId <- folderId # @export +.chartId <- chartId +# @export .filepath <- filepath # @export .tempfilepath <- tempfilepath diff --git a/R/name.R b/R/name.R index 311957b2..142b6cff 100644 --- a/R/name.R +++ b/R/name.R @@ -3,13 +3,13 @@ #' @include AAAClassDefinitions.R NULL -#' Name of a SsimLibrary, Project, Scenario, or Folder +#' Name of a SsimLibrary, Project, Scenario, Folder, or Chart #' #' Retrieves or sets the name of a \code{\link{SsimLibrary}}, #' \code{\link{Project}}, \code{\link{Scenario}}, or \code{\link{Folder}}. #' #' @param ssimObject \code{\link{Scenario}}, \code{\link{Project}}, -#' \code{\link{SsimLibrary}}, or\code{\link{Folder}} object +#' \code{\link{SsimLibrary}}, \code{\link{Folder}} or \code{\link{Chart}} object #' @param value character string of the new name #' #' @return @@ -26,12 +26,14 @@ NULL #' myProject <- project(myLibrary, project = "Definitions") #' myScenario <- scenario(myProject, scenario = "My Scenario") #' myFolder <- folder(myProject, folder = "New Folder") +#' myChart <- chart(myProject, chart = "New Chart") #' #' # Retrieve names of the SsimObjects #' name(myLibrary) #' name(myProject) #' name(myScenario) #' name(myFolder) +#' name(myChart) #' #' # Set the name of the SyncroSim Scenario #' name(myScenario) <- "My Scenario Name" @@ -70,6 +72,12 @@ setMethod("name", signature(ssimObject = "Folder"), function(ssimObject) { return(info$Name) }) +#' @rdname name +setMethod("name", signature(ssimObject = "Chart"), function(ssimObject) { + info <- getChartData(ssimObject) + return(info$Name) +}) + #' @rdname name #' @export setGeneric("name<-", function(ssimObject, value) standardGeneric("name<-")) @@ -134,3 +142,17 @@ setReplaceMethod( return(ssimObject) } ) + +#' @rdname name +setReplaceMethod( + f = "name", + signature = "Chart", + definition = function(ssimObject, value) { + tt <- command(list(setprop = NULL, lib = .filepath(ssimObject), cid = .chartId(ssimObject), name = value), .session(ssimObject)) + if (!identical(tt, "saved")) { + stop(tt) + } + return(ssimObject) + } +) + diff --git a/R/projectId.R b/R/projectId.R index 56ad7731..12fc59fe 100644 --- a/R/projectId.R +++ b/R/projectId.R @@ -3,13 +3,13 @@ #' @include AAAClassDefinitions.R NULL -#' Retrieves projectId of SyncroSim Project, Scenario, or Folder +#' Retrieves projectId of SyncroSim Project, Scenario, Folder, or Chart #' #' Retrieves the projectId of a SyncroSim \code{\link{Project}}, -#' \code{\link{Scenario}}, or \code{\link{Folder}}. +#' \code{\link{Scenario}}, \code{\link{Folder}} or \code{\link{Chart}}. #' -#' @param ssimObject \code{\link{Scenario}}, \code{\link{Project}}, or -#' \code{\link{Folder}} object +#' @param ssimObject \code{\link{Scenario}}, \code{\link{Project}}, +#' \code{\link{Folder}}, or \code{\link{{Chart}}} object #' #' @return #' An integer: project id. @@ -48,3 +48,7 @@ setMethod("projectId", signature(ssimObject = "Scenario"), function(ssimObject) setMethod("projectId", signature(ssimObject = "Folder"), function(ssimObject) { return(ssimObject@projectId) }) +#' @rdname projectId +setMethod("projectId", signature(ssimObject = "Chart"), function(ssimObject) { + return(ssimObject@projectId) +}) diff --git a/man/Chart-class.Rd b/man/Chart-class.Rd new file mode 100644 index 00000000..060f8d5c --- /dev/null +++ b/man/Chart-class.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/AAAClassDefinitions.R +\docType{class} +\name{Chart-class} +\alias{Chart-class} +\alias{Chart} +\title{SyncroSim Chart class} +\description{ +\code{Chart} object representing a SyncroSim Chart object. A Chart object +is used to create line or column charts from tabular output data in the +and can be viewed using the SyncroSim User Interface. +} +\section{Slots}{ + +\describe{ +\item{\code{session}}{\code{\link{Session}} object. The Session associated with the +Chart's SsimLibrary} + +\item{\code{filepath}}{character string. The path to the Chart's SsimLibrary on disk} + +\item{\code{chartId}}{integer. The Chart id} + +\item{\code{projectId}}{integer. The Project id} +}} + +\seealso{ +See \code{\link{chart}} for options when creating or loading a +SyncroSim Chart +} diff --git a/man/add_ssimChart.Rd b/man/add_ssimChart.Rd new file mode 100644 index 00000000..f790f4fe --- /dev/null +++ b/man/add_ssimChart.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/chartMapConstructor.R +\name{add_ssimChart} +\alias{add_ssimChart} +\title{Customize the chart} +\usage{ +add_ssimChart(c, object, objectname) +} +\arguments{ +\item{object}{An object to add to the chart} + +\item{plot}{The chart object to add \code{object} to} + +\item{object_name}{The name of the object to add} +} +\value{ +A modified chart object +} +\description{ +This generic allows you to add your own methods for adding custom objects to +a chart with \link{+.Chart}. +} +\keyword{internal} diff --git a/man/chart-add.Rd b/man/chart-add.Rd new file mode 100644 index 00000000..d2fc5269 --- /dev/null +++ b/man/chart-add.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/chartMapConstructor.R +\name{+.Chart} +\alias{+.Chart} +\title{Testing out plotting construction code +Below taken and modified from ggplot plot-construction.R} +\usage{ +\method{+}{Chart}(e1, e2) + +`+.Chart`(e1, e2) +} +\arguments{ +\item{e1}{An object of class \code{\link[=ssimChart]{ssimChart()}}.} + +\item{e2}{A chart or map component, as described below.} +} +\description{ +Create function for adding together SyncroSim charting and mapping objects +} diff --git a/man/chart.Rd b/man/chart.Rd index b13b6a5e..097caf89 100644 --- a/man/chart.Rd +++ b/man/chart.Rd @@ -4,13 +4,7 @@ \alias{chart} \title{Create or open a chart} \usage{ -chart( - ssimObject = NULL, - chart = NULL, - type = "line", - create = FALSE, - summary = FALSE -) +chart(ssimObject = NULL, chart = NULL, create = FALSE, summary = FALSE) } \arguments{ \item{ssimObject}{\code{\link{Project}} or \code{\link{Scenario}} object} @@ -19,10 +13,8 @@ chart( existing chart if \code{create=FALSE}, or will create a new chart with the given name if the chart does not exist yet or \code{create=TRUE}. If integer, will open the existing chart with the given chart ID (if the -ID exists). If no value is provided, the default is to create a new chart -called "_Chart"} - -\item{type}{character. Can be "line" (Default) or "bar"} +ID exists). If no value is provided and \code{create=TRUE}, a new chart will +be created with the default naming convention (e.g. "_Chart1", "_Chart2")} \item{create}{logical. Whether to create a new chart if the chart name given already exists in the SyncroSim library. If \code{FALSE} (Default), then will @@ -41,3 +33,18 @@ A \code{Chart} object representing a SyncroSim chart Create or open a \code{\link{Chart}} from a SyncroSim \code{\link{Project}}. } +\examples{ +\donttest{ +# Set the file path and name of the new SsimLibrary +myLibraryName <- file.path(tempdir(),"testlib") + +# Set the SyncroSim Session, SsimLibrary, Project, and Scenario +mySession <- session() +myLibrary <- ssimLibrary(name = myLibraryName, session = mySession) +myProject <- project(myLibrary, project = "My Project") +myScenario <- scenario(myProject, scenario = "My Scenario") + +# Create a new chart +myChart <- chart(myProject, chart = "New Chart") +} +} diff --git a/man/chartId.Rd b/man/chartId.Rd new file mode 100644 index 00000000..96069ceb --- /dev/null +++ b/man/chartId.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/chartId.R +\name{chartId} +\alias{chartId} +\alias{chartId,character-method} +\alias{chartId,Chart-method} +\title{Retrieves chartId of SyncroSim Chart} +\usage{ +chartId(ssimObject) + +\S4method{chartId}{character}(ssimObject) + +\S4method{chartId}{Chart}(ssimObject) +} +\arguments{ +\item{chart}{\code{\link{Chart}} object} +} +\value{ +An integer: chart id. +} +\description{ +Retrieves the Chart Id of a SyncroSim \code{\link{Chart}}. +} +\examples{ +\donttest{ +# Set the file path and name of the new SsimLibrary +myLibraryName <- file.path(tempdir(),"testlib") + +# Set the SyncroSim Session, SsimLibrary, and Project +mySession <- session() +myLibrary <- ssimLibrary(name = myLibraryName, + session = mySession, + overwrite = TRUE) +myProject <- project(myLibrary, project = "Definitions") + +# Get the chart object corresponding to the chart called "My Chart" +myChart <- chart(myProject, chart = "My Chart") + +# Get Chart ID for SyncroSim Chart +chartId(myChart) +} + +} diff --git a/man/command.Rd b/man/command.Rd index 8dbdaf37..8e89241a 100644 --- a/man/command.Rd +++ b/man/command.Rd @@ -9,8 +9,7 @@ command( session = NULL, program = "SyncroSim.Console.exe", wait = TRUE, - progName = NULL, - console = NULL + progName = NULL ) } \arguments{ @@ -22,7 +21,7 @@ information about this argument} session will be used} \item{program}{character. The name of the target SyncroSim executable. -Options include "SyncroSim.Console.exe" (default), "SyncroSim.Server.exe", +Options include "SyncroSim.Console.exe" (default), "SyncroSim.CPConsole.exe", "SyncroSim.PackageManager.exe" and "SyncroSim.Multiband.exe"} \item{wait}{logical. If \code{TRUE}(default) R will wait for the command to finish @@ -30,10 +29,6 @@ before proceeding. Note that silent(session) is ignored if \code{wait=FALSE}} \item{progName}{character. Internal argument for setting path to SyncroSim installation folder.} - -\item{console}{character. Which console to issue a command to. By default, -this is the "core" console. For charts and maps, this should be set to -"corestime".} } \value{ Character string: output from the SyncroSim program. diff --git a/man/delete.Rd b/man/delete.Rd index 5be7f6d1..33adb0c3 100644 --- a/man/delete.Rd +++ b/man/delete.Rd @@ -4,50 +4,82 @@ \alias{delete} \alias{delete,character-method} \alias{delete,SsimObject-method} -\title{Delete SsimLibrary, Project, Scenario, Datasheet} +\title{Delete SsimLibrary, Project, Scenario, Folder, Chart or Datasheet} \usage{ delete( ssimObject, project = NULL, scenario = NULL, + folder = NULL, + chart = NULL, datasheet = NULL, - force = FALSE + force = FALSE, + removeBackup = FALSE, + removePublish = FALSE, + removeCustom = FALSE, + session = NULL ) \S4method{delete}{character}( ssimObject, project = NULL, scenario = NULL, + folder = NULL, + chart = NULL, datasheet = NULL, - force = FALSE + force = FALSE, + removeBackup = FALSE, + removePublish = FALSE, + removeCustom = FALSE, + session = NULL ) -\S4method{delete}{SsimObject}( - ssimObject, - project = NULL, - scenario = NULL, - datasheet = NULL, - force = FALSE -) +\S4method{delete}{SsimObject}(ssimObject, project, scenario, folder, chart, datasheet, force, session) } \arguments{ \item{ssimObject}{\code{\link{SsimLibrary}}, \code{\link{Project}}, -or \code{\link{Scenario}} object, or character (i.e. path to a SsimLibrary)} +\code{\link{Scenario}}, \code{\link{Folder}}, or \code{\link{Chart}} +object, or character (i.e. path to a SsimLibrary)} \item{project}{character string, numeric, or vector of these. One or more \code{\link{Project}} names or ids. Note that project argument is ignored -if SsimObject is a list. Note that integer ids are slightly faster (optional)} +if ssimObject is a list. Note that integer ids are slightly faster (optional)} \item{scenario}{character string, numeric, or vector of these. One or more -\code{\link{Scenario}} names or ids. Note that Scenario argument is +\code{\link{Scenario}} names or ids. Note that scenario argument is +ignored if ssimObject is a list. Note that integer ids are slightly faster +(optional)} + +\item{folder}{character string, numeric, or vector of these. One or more +\code{\link{Folder}} names or ids. Note that folder argument is +ignored if ssimObject is a list. Note that integer ids are slightly faster +(optional)} + +\item{chart}{character string, numeric, or vector of these. One or more +\code{\link{Chart}} names or ids. Note that chart argument is ignored if SsimObject is a list. Note that integer ids are slightly faster (optional)} -\item{datasheet}{character string or vector of these. One or more Datasheet +\item{datasheet}{character string or vector of these. One or more datasheet names (optional)} \item{force}{logical. If \code{FALSE} (default), user will be prompted to approve removal of each item} + +\item{removeBackup}{logical. If \code{TRUE}, will remove the backup folder when +deleting a library. Default is \code{FALSE}} + +\item{removePublish}{logical. If \code{TRUE}, will remove the publish folder when +deleting a library. Default is \code{FALSE}} + +\item{removeCustom}{logical. If \code{TRUE} and custom folders have been configured +for a library, then will remove the custom publish and/or backup folders when +deleting a library. Note that the \code{removePublish} and \code{removeBackup} arguments +must also be set to \code{TRUE} to remove the respective custom folders. Default +is \code{FALSE}} + +\item{session}{\code{\link{Session}} object. If \code{NULL} (default), session() +will be used. Only applicable when \code{ssimObject} argument is a character} } \value{ Invisibly returns a list of boolean values corresponding to each diff --git a/man/deleteLibrary.Rd b/man/deleteLibrary.Rd new file mode 100644 index 00000000..b2fa3332 --- /dev/null +++ b/man/deleteLibrary.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/internalHelpers.R +\name{deleteLibrary} +\alias{deleteLibrary} +\title{deleting a library. Default is FALSE +deleting a library. Default is FALSE +for a library, then will remove the custom publish and/or backup folders when +deleting a library. Note that the \code{removePublish} and \code{removeBackup} arguments +must also be set to TRUE to remove the respective custom folders. Default +is FALSE} +\usage{ +deleteLibrary( + ssimLibrary, + force = FALSE, + removeBackup = FALSE, + removePublish = FALSE, + removeCustom = FALSE, + session = NULL +) +} +\description{ +deleting a library. Default is FALSE +deleting a library. Default is FALSE +for a library, then will remove the custom publish and/or backup folders when +deleting a library. Note that the \code{removePublish} and \code{removeBackup} arguments +must also be set to TRUE to remove the respective custom folders. Default +is FALSE +} diff --git a/man/name.Rd b/man/name.Rd index 10b1612b..acf48790 100644 --- a/man/name.Rd +++ b/man/name.Rd @@ -7,12 +7,14 @@ \alias{name,Scenario-method} \alias{name,Project-method} \alias{name,Folder-method} +\alias{name,Chart-method} \alias{name<-} \alias{name<-,character-method} \alias{name<-,SsimLibrary-method} \alias{name<-,Project-method} \alias{name<-,Scenario-method} \alias{name<-,Folder-method} +\alias{name<-,Chart-method} \title{Name of a SsimLibrary, Project, Scenario, or Folder} \usage{ name(ssimObject) @@ -27,6 +29,8 @@ name(ssimObject) \S4method{name}{Folder}(ssimObject) +\S4method{name}{Chart}(ssimObject) + name(ssimObject) <- value \S4method{name}{character}(ssimObject) <- value @@ -38,6 +42,8 @@ name(ssimObject) <- value \S4method{name}{Scenario}(ssimObject) <- value \S4method{name}{Folder}(ssimObject) <- value + +\S4method{name}{Chart}(ssimObject) <- value } \arguments{ \item{ssimObject}{\code{\link{Scenario}}, \code{\link{Project}},