Commits (2)
Package: DIZutils
Title: Utilities for DIZ R package development
Version: 0.0.2
Date: 2020-04-20
Version: 0.0.3
Date: 2020-05-07
Authors@R:
c(person(given = "Jonathan M.",
family = "Mang",
......
......@@ -10,4 +10,5 @@ export(firstup)
export(get_config)
export(get_config_env)
export(global_env_hack)
export(query_database)
export(set_env_vars)
......@@ -7,29 +7,37 @@
#' If no output is selected, the print_this string will be printed to the
#' console and to logfile.
#' One of these must be a string with length > 0: print_me, console, ui
#' @param print_this (Optional, String)
#' @param type (Optional, String) E.g. "Warning", "Error. Default: "Info"
#' @param ui (Optional, Boolean/String) If true, the message will
#' also be printed to the user in form of a modal. Can also be a string.
#' @param console (Optional, Boolean/String) If true, the message will also
#' be printed to the console as is. Can also be a string.
#' @param logfile (Optional, Boolean) If true (default) the print_this string
#' will also be printed to the console.
#' @param logjs (Optional, Boolean) If true (default: false) the print_this
#' @param print_this (Optional, String, default: "")
#' @param type (Optional, String, default: "Info")
#' E.g. "Warning", "Error. Default: "Info"
#' @param ui (Optional, Boolean/String, default: FALSE)
#' If true, the message will also be printed to the user in form of a modal.
#' Can also be a string.
#' @param console (Optional, Boolean/String, default: TRUE)
#' If true, the message will also be printed to the console as is.
#' Can also be a string.
#' @param logfile (Optional, Boolean, default: TRUE)
#' If true (default) the print_this string will also be printed
#' to the console.
#' @param logjs (Optional, Boolean, default: FALSE)
#' If true (default: false) the print_this
#' string will also be printed to the javascript-console.
#' This only makes sense, if the gui is active.
#' @param prefix Prefix (Optional, String) This is useful if
#' print_this is an array/list.
#' @param prefix Prefix (Optional, String, default: "")
#' This is useful if print_this is an array/list.
#' Each entry will then be new row with this prefix.
#' @param suffix Suffix (Optional, String). Same like prefix but at the
#' end of each line.
#' @param findme (Optional, String) String to find the message in the code.
#' @param suffix Suffix (Optional, String, default: "")
#' Same like prefix but at the end of each line.
#' @param findme (Optional, String, default: "")
#' Recommended with length 10.
#' String to find the message in the code.
#' E.g. 10-digit random hex from https://www.browserling.com/tools/random-hex
#' or https://onlinerandomtools.com/generate-random-hexadecimal-numbers
#' @param logfile_dir The absolute path to folder where the logfile
#' will be stored.
#'
#' @inheritParams db_connection
#' @param logfile_dir (Optional, String, default: "tempdir()")
#' The absolute path to folder where the logfile will be stored.
#' @param headless (Optional, Boolean, default: TRUE)
#' Indicating, if the function is run only in the console (headless = TRUE)
#' or on a GUI frontend (headless = FALSE).
#'
#' @export
#'
......
#' @title query_database helper function
#'
#' @description Internal function to query the database. The function
#' sends a sql statement to the database and returns a data.table.
#'
#' @param db_con A DBI database connection.
#' @param sql_statement A character string containing a valid SQL statement.
#'
#' @export
#'
# query_database
query_database <- function(db_con,
sql_statement) {
stopifnot(!is.null(sql_statement), !is.null(db_con))
# avoid sql-injection
# https://db.rstudio.com/best-practices/run-queries-safely/
sql <- DBI::sqlInterpolate(db_con, sql_statement)
# return data as data.table
outdat <-
data.table::data.table(
RPostgres::dbGetQuery(db_con, sql),
stringsAsFactors = TRUE
)
return(outdat)
}
......@@ -36,7 +36,7 @@ my_desc$set("Copyright", "Universitätsklinikum Erlangen")
my_desc$del("Maintainer")
# Set the version
my_desc$set_version("0.0.2")
my_desc$set_version("0.0.3")
# The title of your package
my_desc$set(Title = "Utilities for DIZ R package development")
......
......@@ -7,8 +7,8 @@
cleanup_old_logfile(logfile_dir)
}
\arguments{
\item{logfile_dir}{The absolute path to folder where the logfile
will be stored.}
\item{logfile_dir}{(Optional, String, default: "tempdir()")
The absolute path to folder where the logfile will be stored.}
}
\description{
This function is called once at the beginning of the
......
......@@ -7,12 +7,12 @@
close_all_connections(logfile_dir, headless)
}
\arguments{
\item{logfile_dir}{The absolute path to folder where the logfile
will be stored.}
\item{logfile_dir}{(Optional, String, default: "tempdir()")
The absolute path to folder where the logfile will be stored.}
\item{headless}{A boolean (default: FALSE). Indicating, if the function is
run only in the console (headless = TRUE) or on a GUI frontend
(headless = FALSE).}
\item{headless}{(Optional, Boolean, default: TRUE)
Indicating, if the function is run only in the console (headless = TRUE)
or on a GUI frontend (headless = FALSE).}
}
\description{
This function is meant to be called at the end of a
......
......@@ -37,8 +37,8 @@ Additionally for Oracle DB's: 'sid'.}
Values below 2 seconds are not recommended.
Default is 30 seconds.}
\item{logfile_dir}{The absolute path to folder where the logfile
will be stored.}
\item{logfile_dir}{(Optional, String, default: "tempdir()")
The absolute path to folder where the logfile will be stored.}
\item{lib_path}{A character string. The path to the ojdbc7.jar file.}
}
......
......@@ -20,40 +20,47 @@ feedback(
)
}
\arguments{
\item{print_this}{(Optional, String)}
\item{print_this}{(Optional, String, default: "")}
\item{type}{(Optional, String) E.g. "Warning", "Error. Default: "Info"}
\item{type}{(Optional, String, default: "Info")
E.g. "Warning", "Error. Default: "Info"}
\item{ui}{(Optional, Boolean/String) If true, the message will
also be printed to the user in form of a modal. Can also be a string.}
\item{ui}{(Optional, Boolean/String, default: FALSE)
If true, the message will also be printed to the user in form of a modal.
Can also be a string.}
\item{console}{(Optional, Boolean/String) If true, the message will also
be printed to the console as is. Can also be a string.}
\item{console}{(Optional, Boolean/String, default: TRUE)
If true, the message will also be printed to the console as is.
Can also be a string.}
\item{logfile}{(Optional, Boolean) If true (default) the print_this string
will also be printed to the console.}
\item{logfile}{(Optional, Boolean, default: TRUE)
If true (default) the print_this string will also be printed
to the console.}
\item{logjs}{(Optional, Boolean) If true (default: false) the print_this
\item{logjs}{(Optional, Boolean, default: FALSE)
If true (default: false) the print_this
string will also be printed to the javascript-console.
This only makes sense, if the gui is active.}
\item{prefix}{Prefix (Optional, String) This is useful if
print_this is an array/list.
\item{prefix}{Prefix (Optional, String, default: "")
This is useful if print_this is an array/list.
Each entry will then be new row with this prefix.}
\item{suffix}{Suffix (Optional, String). Same like prefix but at the
end of each line.}
\item{suffix}{Suffix (Optional, String, default: "")
Same like prefix but at the end of each line.}
\item{findme}{(Optional, String) String to find the message in the code.
\item{findme}{(Optional, String, default: "")
Recommended with length 10.
String to find the message in the code.
E.g. 10-digit random hex from https://www.browserling.com/tools/random-hex
or https://onlinerandomtools.com/generate-random-hexadecimal-numbers}
\item{logfile_dir}{The absolute path to folder where the logfile
will be stored.}
\item{logfile_dir}{(Optional, String, default: "tempdir()")
The absolute path to folder where the logfile will be stored.}
\item{headless}{A boolean (default: FALSE). Indicating, if the function is
run only in the console (headless = TRUE) or on a GUI frontend
(headless = FALSE).}
\item{headless}{(Optional, Boolean, default: TRUE)
Indicating, if the function is run only in the console (headless = TRUE)
or on a GUI frontend (headless = FALSE).}
}
\description{
This function provides the functionality to publish
......
......@@ -7,20 +7,23 @@
feedback_get_formatted_string(print_this, type, findme, prefix, suffix)
}
\arguments{
\item{print_this}{(Optional, String)}
\item{print_this}{(Optional, String, default: "")}
\item{type}{(Optional, String) E.g. "Warning", "Error. Default: "Info"}
\item{type}{(Optional, String, default: "Info")
E.g. "Warning", "Error. Default: "Info"}
\item{findme}{(Optional, String) String to find the message in the code.
\item{findme}{(Optional, String, default: "")
Recommended with length 10.
String to find the message in the code.
E.g. 10-digit random hex from https://www.browserling.com/tools/random-hex
or https://onlinerandomtools.com/generate-random-hexadecimal-numbers}
\item{prefix}{Prefix (Optional, String) This is useful if
print_this is an array/list.
\item{prefix}{Prefix (Optional, String, default: "")
This is useful if print_this is an array/list.
Each entry will then be new row with this prefix.}
\item{suffix}{Suffix (Optional, String). Same like prefix but at the
end of each line.}
\item{suffix}{Suffix (Optional, String, default: "")
Same like prefix but at the end of each line.}
}
\description{
Helper function for the feedback function to combine the input
......
......@@ -15,27 +15,31 @@ feedback_to_console(
)
}
\arguments{
\item{print_this}{(Optional, String)}
\item{print_this}{(Optional, String, default: "")}
\item{type}{(Optional, String) E.g. "Warning", "Error. Default: "Info"}
\item{type}{(Optional, String, default: "Info")
E.g. "Warning", "Error. Default: "Info"}
\item{findme}{(Optional, String) String to find the message in the code.
\item{findme}{(Optional, String, default: "")
Recommended with length 10.
String to find the message in the code.
E.g. 10-digit random hex from https://www.browserling.com/tools/random-hex
or https://onlinerandomtools.com/generate-random-hexadecimal-numbers}
\item{prefix}{Prefix (Optional, String) This is useful if
print_this is an array/list.
\item{prefix}{Prefix (Optional, String, default: "")
This is useful if print_this is an array/list.
Each entry will then be new row with this prefix.}
\item{suffix}{Suffix (Optional, String). Same like prefix but at the
end of each line.}
\item{suffix}{Suffix (Optional, String, default: "")
Same like prefix but at the end of each line.}
\item{logjs}{(Optional, Boolean) If true (default: false) the print_this
\item{logjs}{(Optional, Boolean, default: FALSE)
If true (default: false) the print_this
string will also be printed to the javascript-console.
This only makes sense, if the gui is active.}
\item{logfile_dir}{The absolute path to folder where the logfile
will be stored.}
\item{logfile_dir}{(Optional, String, default: "tempdir()")
The absolute path to folder where the logfile will be stored.}
}
\description{
Helper function for the feedback function to print
......
......@@ -7,23 +7,26 @@
feedback_to_logfile(print_this, type, findme, prefix, suffix, logfile_dir)
}
\arguments{
\item{print_this}{(Optional, String)}
\item{print_this}{(Optional, String, default: "")}
\item{type}{(Optional, String) E.g. "Warning", "Error. Default: "Info"}
\item{type}{(Optional, String, default: "Info")
E.g. "Warning", "Error. Default: "Info"}
\item{findme}{(Optional, String) String to find the message in the code.
\item{findme}{(Optional, String, default: "")
Recommended with length 10.
String to find the message in the code.
E.g. 10-digit random hex from https://www.browserling.com/tools/random-hex
or https://onlinerandomtools.com/generate-random-hexadecimal-numbers}
\item{prefix}{Prefix (Optional, String) This is useful if
print_this is an array/list.
\item{prefix}{Prefix (Optional, String, default: "")
This is useful if print_this is an array/list.
Each entry will then be new row with this prefix.}
\item{suffix}{Suffix (Optional, String). Same like prefix but at the
end of each line.}
\item{suffix}{Suffix (Optional, String, default: "")
Same like prefix but at the end of each line.}
\item{logfile_dir}{The absolute path to folder where the logfile
will be stored.}
\item{logfile_dir}{(Optional, String, default: "tempdir()")
The absolute path to folder where the logfile will be stored.}
}
\description{
Helper function for the feedback function to add content
......
......@@ -7,14 +7,14 @@
feedback_to_logjs(print_this, logfile_dir, headless)
}
\arguments{
\item{print_this}{(Optional, String)}
\item{print_this}{(Optional, String, default: "")}
\item{logfile_dir}{The absolute path to folder where the logfile
will be stored.}
\item{logfile_dir}{(Optional, String, default: "tempdir()")
The absolute path to folder where the logfile will be stored.}
\item{headless}{A boolean (default: FALSE). Indicating, if the function is
run only in the console (headless = TRUE) or on a GUI frontend
(headless = FALSE).}
\item{headless}{(Optional, Boolean, default: TRUE)
Indicating, if the function is run only in the console (headless = TRUE)
or on a GUI frontend (headless = FALSE).}
}
\description{
Helper function for the feedback function to also show the
......
......@@ -7,16 +7,17 @@
feedback_to_ui(print_this, type, logfile_dir, headless)
}
\arguments{
\item{print_this}{(Optional, String)}
\item{print_this}{(Optional, String, default: "")}
\item{type}{(Optional, String) E.g. "Warning", "Error. Default: "Info"}
\item{type}{(Optional, String, default: "Info")
E.g. "Warning", "Error. Default: "Info"}
\item{logfile_dir}{The absolute path to folder where the logfile
will be stored.}
\item{logfile_dir}{(Optional, String, default: "tempdir()")
The absolute path to folder where the logfile will be stored.}
\item{headless}{A boolean (default: FALSE). Indicating, if the function is
run only in the console (headless = TRUE) or on a GUI frontend
(headless = FALSE).}
\item{headless}{(Optional, Boolean, default: TRUE)
Indicating, if the function is run only in the console (headless = TRUE)
or on a GUI frontend (headless = FALSE).}
}
\description{
Helper function for the feedback function to show modals
......
......@@ -14,12 +14,12 @@ containing the database configuration.}
database. This string must be conform with the corresponding config
section in the config.yml-file.}
\item{logfile_dir}{The absolute path to folder where the logfile
will be stored.}
\item{logfile_dir}{(Optional, String, default: "tempdir()")
The absolute path to folder where the logfile will be stored.}
\item{headless}{A boolean (default: FALSE). Indicating, if the function is
run only in the console (headless = TRUE) or on a GUI frontend
(headless = FALSE).}
\item{headless}{(Optional, Boolean, default: TRUE)
Indicating, if the function is run only in the console (headless = TRUE)
or on a GUI frontend (headless = FALSE).}
}
\description{
Internal function to read config files
......
......@@ -10,8 +10,8 @@ get_config_env(system_name, logfile_dir, headless)
\item{system_name}{The name of the system (This is also the prefix used
to get the environment variables with 'SYSTEM_KEY', e.g. 'I2B2_DBNAME')}
\item{logfile_dir}{The absolute path to folder where the logfile
will be stored.}
\item{logfile_dir}{(Optional, String, default: "tempdir()")
The absolute path to folder where the logfile will be stored.}
\item{headless}{A boolean (default: FALSE). Indicating, if the function is
run only in the console (headless = TRUE) or on a GUI frontend
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/query_database.R
\name{query_database}
\alias{query_database}
\title{query_database helper function}
\usage{
query_database(db_con, sql_statement)
}
\arguments{
\item{db_con}{A DBI database connection.}
\item{sql_statement}{A character string containing a valid SQL statement.}
}
\description{
Internal function to query the database. The function
sends a sql statement to the database and returns a data.table.
}