Skip to content

Commit 47c873a

Browse files
authored
Issue 48490: Add options parameter to labkey.insertRows, labkey.updateRows, labkey.deleteRows to support "auditBehavior" (#98)
- add options param to labkey.insertRows, labkey.updateRows, and labkey.deleteRows - update related Rd doc files
1 parent f68bee8 commit 47c873a

10 files changed

+66
-17
lines changed

Rlabkey/DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: Rlabkey
2-
Version: 3.0.0
3-
Date: 2023-11-06
2+
Version: 3.1.0
3+
Date: 2023-12-04
44
Title: Data Exchange Between R and 'LabKey' Server
55
Author: Peter Hussey
66
Maintainer: Cory Nathe <cnathe@labkey.com>

Rlabkey/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Changes in 3.1.0
2+
o Issue 48490: Add options parameter to labkey.insertRows, labkey.updateRows, labkey.deleteRows to support
3+
specifying the "auditBehavior" and "auditUserComment" properties for the action
4+
15
Changes in 3.0.0
26
o Issue 41677: Fix for domain get/save round tripping of domain indices (need to use list() for index columnNames)
37
o Encode SQL parameters passed by labkey.executeSql to avoid rejection by web application firewalls

Rlabkey/R/labkey.deleteRows.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
##
1616

17-
labkey.deleteRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, toDelete, provenanceParams=NULL)
17+
labkey.deleteRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, toDelete, provenanceParams=NULL, options = NULL)
1818
{
1919
baseUrl=labkey.getBaseUrl(baseUrl)
2020

@@ -26,6 +26,8 @@ labkey.deleteRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, t
2626
if (missing(schemaName)) stop (paste("A value must be specified for schemaName."))
2727
if (missing(queryName)) stop (paste("A value must be specified for queryName."))
2828
if (missing(toDelete)) stop (paste("A value must be specified for toDelete."))
29+
if (!missing(options) & !is.list(options))
30+
stop (paste("The options parameter must be a list data structure."))
2931

3032
## normalize the folder path
3133
folderPath <- encodeFolderPath(folderPath)
@@ -38,6 +40,8 @@ labkey.deleteRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, t
3840
params <- list(schemaName=schemaName, queryName=queryName, apiVersion=8.3)
3941
if (!missing(provenanceParams))
4042
params$provenance = provenanceParams
43+
if (!missing(options))
44+
params <- c(params, options)
4145

4246
p1 <- toJSON(params, auto_unbox=TRUE)
4347
cnames <- colnames(toDelete)

Rlabkey/R/labkey.insertRows.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
##
1616

17-
labkey.insertRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, toInsert, na=NULL, provenanceParams=NULL)
17+
labkey.insertRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, toInsert, na=NULL, provenanceParams=NULL, options = NULL)
1818
{
1919
baseUrl=labkey.getBaseUrl(baseUrl)
2020

@@ -23,6 +23,8 @@ labkey.insertRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, t
2323
if (missing(schemaName)) stop (paste("A value must be specified for schemaName."))
2424
if (missing(queryName)) stop (paste("A value must be specified for queryName."))
2525
if (missing(toInsert)) stop (paste("A value must be specified for toInsert."))
26+
if (!missing(options) & !is.list(options))
27+
stop (paste("The options parameter must be a list data structure."))
2628

2729
## Default showAllRows=TRUE
2830
showAllRows=TRUE
@@ -38,6 +40,8 @@ labkey.insertRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, t
3840
params <- list(schemaName=schemaName, queryName=queryName, apiVersion=8.3)
3941
if (!missing(provenanceParams))
4042
params$provenance = provenanceParams
43+
if (!missing(options))
44+
params <- c(params, options)
4145

4246
p1 <- toJSON(params, auto_unbox=TRUE)
4347
cnames <- colnames(toInsert)

Rlabkey/R/labkey.query.import.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ labkey.query.import <- function(baseUrl=NULL, folderPath, schemaName, queryName,
2222
if (missing(baseUrl) || is.null(baseUrl) || missing(folderPath) || missing(schemaName) || missing(queryName) || missing(toImport))
2323
stop (paste("A value must be specified for each of baseUrl, folderPath, schemaName, queryName, and toImport."))
2424
if (!missing(options) & !is.list(options))
25-
stop (paste("options must be a list data structure."))
25+
stop (paste("The options parameter must be a list data structure."))
2626

2727
## normalize the folder path
2828
folderPath <- encodeFolderPath(folderPath)

Rlabkey/R/labkey.updateRows.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
##
1616

17-
labkey.updateRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, toUpdate, provenanceParams=NULL)
17+
labkey.updateRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, toUpdate, provenanceParams=NULL, options = NULL)
1818
{
1919
baseUrl=labkey.getBaseUrl(baseUrl)
2020

@@ -26,6 +26,8 @@ labkey.updateRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, t
2626
if (missing(schemaName)) stop (paste("A value must be specified for schemaName."))
2727
if (missing(queryName)) stop (paste("A value must be specified for queryName."))
2828
if (missing(toUpdate)) stop (paste("A value must be specified for toUpdate."))
29+
if (!missing(options) & !is.list(options))
30+
stop (paste("The options parameter must be a list data structure."))
2931

3032
## normalize the folder path
3133
folderPath <- encodeFolderPath(folderPath)
@@ -38,6 +40,8 @@ labkey.updateRows <- function(baseUrl=NULL, folderPath, schemaName, queryName, t
3840
params <- list(schemaName=schemaName, queryName=queryName, apiVersion=8.3)
3941
if (!missing(provenanceParams))
4042
params$provenance = provenanceParams
43+
if (!missing(options))
44+
params <- c(params, options)
4145

4246
p1 <- toJSON(params, auto_unbox=TRUE)
4347
cnames <- colnames(toUpdate)

Rlabkey/man/Rlabkey-package.Rd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ schema objects (\code{labkey.getSchema}).
1818
\tabular{ll}{
1919
Package: \tab Rlabkey\cr
2020
Type: \tab Package\cr
21-
Version: \tab 3.0.0\cr
22-
Date: \tab 2023-11-06\cr
21+
Version: \tab 3.1.0\cr
22+
Date: \tab 2023-12-04\cr
2323
License: \tab Apache License 2.0\cr
2424
LazyLoad: \tab yes\cr
2525
}

Rlabkey/man/labkey.deleteRows.Rd

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Specify rows of data to be deleted from the LabKey Server
66
}
77
\usage{
88
labkey.deleteRows(baseUrl, folderPath,
9-
schemaName, queryName, toDelete, provenanceParams=NULL)
9+
schemaName, queryName, toDelete,
10+
provenanceParams=NULL, options=NULL)
1011
}
1112
\arguments{
1213
\item{baseUrl}{a string specifying the \code{baseUrl}for LabKey server}
@@ -17,6 +18,7 @@ labkey.deleteRows(baseUrl, folderPath,
1718
\item{provenanceParams}{the provenance parameter object which contains the options to include as part of a provenance recording.
1819
This is a premium feature and requires the Provenance LabKey module to function correctly, if it is not present this parameter will be ignored.
1920
}
21+
\item{options}{(optional) a list containing options specific to the insert action of the query}
2022
}
2123
\details{
2224
A single row or multiple rows of data can be deleted. For the \code{toDelete} data frame, version 0.0.5 or later accepts either a single column
@@ -30,6 +32,14 @@ used \dQuote{behind the scenes} for database manipulation. It is the column name
3032
the Rlabkey functions when a column name is expected. To identify a particular column name in a dataset on
3133
a web site, use the \dQuote{export to R script} option available as a drop down option under the \dQuote{views}
3234
tab for each dataset.
35+
36+
The list of valid options for each query will vary, but some common examples include:
37+
\itemize{
38+
\item{ \code{auditBehavior (string)} : Can be used to override the audit behavior for the table the query is acting on.
39+
The set of types include: NONE, SUMMARY, and DETAILED.}
40+
\item{ \code{auditUserComment (string)} : Can be used to provide a comment from the user that will be attached to
41+
certain detailed audit log records.}
42+
}
3343
}
3444
\value{
3545
A list is returned with named categories of \bold{command}, \bold{rowsAffected}, \bold{rows}, \bold{queryName}, \bold{containerPath} and \bold{schemaName}.

Rlabkey/man/labkey.insertRows.Rd

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Insert new rows of data into the database.
66
}
77
\usage{
88
labkey.insertRows(baseUrl, folderPath,
9-
schemaName, queryName, toInsert, na, provenanceParams=NULL)
9+
schemaName, queryName, toInsert, na,
10+
provenanceParams=NULL, options=NULL)
1011
}
1112
\arguments{
1213
\item{baseUrl}{a string specifying the \code{baseUrl}for the labkey server}
@@ -18,13 +19,22 @@ labkey.insertRows(baseUrl, folderPath,
1819
\item{provenanceParams}{the provenance parameter object which contains the options to include as part of a provenance recording.
1920
This is a premium feature and requires the Provenance LabKey module to function correctly, if it is not present this parameter will be ignored.
2021
}
22+
\item{options}{(optional) a list containing options specific to the insert action of the query}
2123
}
2224
\details{
2325
A single row or multiple rows of data can be inserted. The \code{toInsert} data frame must contain
2426
values for each column in the dataset and must be created with the \code{stringsAsFactors} option
2527
set to FALSE. The names of the data in the data frame must be the column names from the
2628
LabKey Server.To insert a value of NULL, use an empty string ("") in the data frame (regardless of the database column type).
27-
Also, when inserting data into a study dataset, the sequence number must be specified..
29+
Also, when inserting data into a study dataset, the sequence number must be specified.
30+
\cr \cr
31+
The list of valid options for each query will vary, but some common examples include:
32+
\itemize{
33+
\item{ \code{auditBehavior (string)} : Can be used to override the audit behavior for the table the query is acting on.
34+
The set of types include: NONE, SUMMARY, and DETAILED.}
35+
\item{ \code{auditUserComment (string)} : Can be used to provide a comment from the user that will be attached to
36+
certain detailed audit log records.}
37+
}
2838
}
2939
3040
\value{
@@ -70,7 +80,8 @@ newrow <- data.frame(
7080
7181
insertedRow <- labkey.insertRows("http://localhost:8080/labkey",
7282
folderPath="/apisamples", schemaName="lists", queryName="AllTypes",
73-
toInsert=newrow)
83+
toInsert=newrow, options=list(auditBehavior="DETAILED",
84+
auditUserComment="testing audit comment for insert"))
7485
newRowId <- insertedRow$rows[[1]]$RowId
7586
7687
selectedRow<-labkey.selectRows("http://localhost:8080/labkey",
@@ -85,7 +96,8 @@ updaterow=data.frame(
8596
8697
updatedRow <- labkey.updateRows("http://localhost:8080/labkey",
8798
folderPath="/apisamples", schemaName="lists", queryName="AllTypes",
88-
toUpdate=updaterow)
99+
toUpdate=updaterow, options=list(auditBehavior="DETAILED",
100+
auditUserComment="testing audit comment for update"))
89101
selectedRow<-labkey.selectRows("http://localhost:8080/labkey",
90102
folderPath="/apisamples", schemaName="lists", queryName="AllTypes",
91103
colFilter=makeFilter(c("RowId", "EQUALS", newRowId)))

Rlabkey/man/labkey.updateRows.Rd

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Send data from an R session to update existing rows of data in the database.
66
}
77
\usage{
88
labkey.updateRows(baseUrl, folderPath,
9-
schemaName, queryName, toUpdate, provenanceParams=NULL)
9+
schemaName, queryName, toUpdate,
10+
provenanceParams=NULL, options=NULL)
1011
}
1112
\arguments{
1213
\item{baseUrl}{a string specifying the \code{baseUrl}for the labkey server}
@@ -17,13 +18,21 @@ labkey.updateRows(baseUrl, folderPath,
1718
\item{provenanceParams}{the provenance parameter object which contains the options to include as part of a provenance recording.
1819
This is a premium feature and requires the Provenance LabKey module to function correctly, if it is not present this parameter will be ignored.
1920
}
21+
\item{options}{(optional) a list containing options specific to the insert action of the query}
2022
}
2123
\details{
2224
A single row or multiple rows of data can be updated. The \code{toUpdate} data frame should contain
2325
the rows of data to be updated and must be created with the \code{stringsAsFactors} option
2426
set to FALSE. The names of the data in the data frame must be the column names from the
2527
labkey database. To update a row/column to a value of NULL, use an empty string ("") in the data frame (regardless of the database column type).
26-
28+
\cr \cr
29+
The list of valid options for each query will vary, but some common examples include:
30+
\itemize{
31+
\item{ \code{auditBehavior (string)} : Can be used to override the audit behavior for the table the query is acting on.
32+
The set of types include: NONE, SUMMARY, and DETAILED.}
33+
\item{ \code{auditUserComment (string)} : Can be used to provide a comment from the user that will be attached to
34+
certain detailed audit log records.}
35+
}
2736
}
2837
\value{
2938
A list is returned with named categories of \bold{command}, \bold{rowsAffected}, \bold{rows}, \bold{queryName}, \bold{containerPath} and \bold{schemaName}.
@@ -68,7 +77,8 @@ newrow <- data.frame(
6877

6978
insertedRow <- labkey.insertRows("http://localhost:8080/labkey",
7079
folderPath="/apisamples", schemaName="lists", queryName="AllTypes",
71-
toInsert=newrow)
80+
toInsert=newrow, options=list(auditBehavior="DETAILED",
81+
auditUserComment="testing audit comment for insert"))
7282
newRowId <- insertedRow$rows[[1]]$RowId
7383

7484
selectedRow<-labkey.selectRows("http://localhost:8080/labkey",
@@ -85,7 +95,8 @@ updaterow=data.frame(
8595

8696
updatedRow <- labkey.updateRows("http://localhost:8080/labkey",
8797
folderPath="/apisamples", schemaName="lists", queryName="AllTypes",
88-
toUpdate=updaterow)
98+
toUpdate=updaterow, options=list(auditBehavior="DETAILED",
99+
auditUserComment="testing audit comment for update"))
89100
selectedRow<-labkey.selectRows("http://localhost:8080/labkey",
90101
folderPath="/apisamples", schemaName="lists", queryName="AllTypes",
91102
colFilter=makeFilter(c("RowId", "EQUALS", newRowId)))

0 commit comments

Comments
 (0)