Function to Build Release Zips (#429)
* buildRelease and buildReleaseZip * add buildRelease
This commit is contained in:
parent
d73a0f426d
commit
b3fddfbb85
|
@ -1,21 +1,21 @@
|
|||
Version: 1.0
|
||||
|
||||
RestoreWorkspace: Default
|
||||
SaveWorkspace: Default
|
||||
AlwaysSaveHistory: Default
|
||||
|
||||
EnableCodeIndexing: Yes
|
||||
UseSpacesForTab: Yes
|
||||
NumSpacesForTab: 2
|
||||
Encoding: UTF-8
|
||||
|
||||
RnwWeave: Sweave
|
||||
LaTeX: XeLaTeX
|
||||
|
||||
AutoAppendNewline: Yes
|
||||
StripTrailingWhitespace: Yes
|
||||
|
||||
BuildType: Package
|
||||
PackageUseDevtools: Yes
|
||||
PackageInstallArgs: --no-multiarch --with-keep.source
|
||||
PackageRoxygenize: rd,collate,namespace
|
||||
Version: 1.0
|
||||
|
||||
RestoreWorkspace: Default
|
||||
SaveWorkspace: Default
|
||||
AlwaysSaveHistory: Default
|
||||
|
||||
EnableCodeIndexing: Yes
|
||||
UseSpacesForTab: Yes
|
||||
NumSpacesForTab: 2
|
||||
Encoding: UTF-8
|
||||
|
||||
RnwWeave: Sweave
|
||||
LaTeX: XeLaTeX
|
||||
|
||||
AutoAppendNewline: Yes
|
||||
StripTrailingWhitespace: Yes
|
||||
|
||||
BuildType: Package
|
||||
PackageUseDevtools: Yes
|
||||
PackageInstallArgs: --no-multiarch --with-keep.source
|
||||
PackageRoxygenize: rd,collate,namespace
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
# Generated by roxygen2: do not edit by hand
|
||||
|
||||
export(buildReleaseZip)
|
||||
export(createDdl)
|
||||
export(createForeignKeys)
|
||||
export(createPrimaryKeys)
|
||||
export(downloadCurrentDdl)
|
||||
export(executeDdl)
|
||||
export(listSupportedDialects)
|
||||
export(listSupportedVersions)
|
||||
export(parseWiki)
|
||||
export(writeDdl)
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
# Copyright 2019 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
# This file is part of CdmDdlBase
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#' Create OMOP CDM SQL files
|
||||
#'
|
||||
#' Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion
|
||||
#' and targetDialect to the 'ddl' folder in current working directory.
|
||||
#'
|
||||
#' @param cdmVersion The version of the CDM you are creating, e.g. 5.3, 5.4.
|
||||
#' Defaults to all supported CDM versions.
|
||||
#' @param targetDialect The target dialect
|
||||
#'
|
||||
buildRelease <- function(cdmVersion = listSupportedVersions(),
|
||||
targetDialect = listSupportedDialects()){
|
||||
for (cdmVersion in cdmVersion) {
|
||||
for (targetDialect in targetDialect) {
|
||||
writeDdl(targetDialect = targetDialect,
|
||||
cdmVersion = cdmVersion)
|
||||
|
||||
writePrimaryKeys(targetDialect = targetDialect,
|
||||
cdmVersion = cdmVersion)
|
||||
|
||||
writeForeignKeys(targetDialect = targetDialect,
|
||||
cdmVersion = cdmVersion)
|
||||
|
||||
writeIndex(targetDialect = targetDialect,
|
||||
cdmVersion = cdmVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#' Create OMOP CDM release zip
|
||||
#'
|
||||
#' First calls \code{buildReleaseZips} for given cdmVersions and targetDialects.
|
||||
#' This writes the ddl sql files to the ddl folder.
|
||||
#' Then zips all written ddl files into a release zip to given output folder.
|
||||
#'
|
||||
#' If no (or multiple) targetDialect is given,
|
||||
#' then one zip is written with the files of all supported dialects.
|
||||
#'
|
||||
#' @param cdmVersion The version of the CDM you are creating, e.g. 5.3, 5.4.
|
||||
#' Defaults to all supported CDM versions.
|
||||
#' @param targetDialect The target dialect. Defaults to all supported dialects.
|
||||
#' @param outputfolder The output folder. Defaults to "output"
|
||||
#' @return A character string containing the OHDSQL DDL
|
||||
#' @export
|
||||
#' @examples
|
||||
#' buildReleaseZip(cdmVersion='5.3', targetDialect='sql server', outputfolder='.')
|
||||
#'
|
||||
buildReleaseZip <- function(cdmVersion,
|
||||
targetDialect = listSupportedDialects(),
|
||||
outputfolder = "output"){
|
||||
# argument checks
|
||||
stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions())
|
||||
|
||||
if (!dir.exists(outputfolder)) {
|
||||
dir.create(outputfolder)
|
||||
}
|
||||
|
||||
files <- c()
|
||||
for (dialect in targetDialect) {
|
||||
buildRelease(cdmVersion, dialect)
|
||||
files <- c(files, list.files(file.path('ddl', cdmVersion, gsub(" ", "_", dialect)),
|
||||
pattern = ".*\\.sql$",
|
||||
full.names = TRUE))
|
||||
}
|
||||
|
||||
if (length(targetDialect) == 1) {
|
||||
zipName <- file.path(outputfolder, paste0("OMOPCDM", "_", gsub(" ", "_", targetDialect), "_", cdmVersion, '.zip'))
|
||||
} else {
|
||||
zipName <- file.path(outputfolder, paste0("OMOPCDM", "_", cdmVersion, '.zip'))
|
||||
}
|
||||
|
||||
DatabaseConnector::createZipFile(zipFile = zipName, files = files)
|
||||
}
|
|
@ -6,3 +6,12 @@ listSupportedVersions <- function() {
|
|||
supportedVersions <- c("5.3", "5.4")
|
||||
return(supportedVersions)
|
||||
}
|
||||
|
||||
#' List RDBMS dialects supported by this package
|
||||
#'
|
||||
#' @export
|
||||
|
||||
listSupportedDialects <- function() {
|
||||
supportedDialects <- c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server")
|
||||
return(supportedDialects)
|
||||
}
|
||||
|
|
|
@ -22,6 +22,14 @@ for (cdmVersion in supportedVersions) {
|
|||
}
|
||||
}
|
||||
|
||||
#############
|
||||
# Zipping release
|
||||
# All dialects
|
||||
buildReleaseZip(cdmVersion="5.3", outputfolder="output")
|
||||
|
||||
# One dialect
|
||||
buildReleaseZip(cdmVersion="5.4", targetDialect="postgresql", outputfolder="output")
|
||||
|
||||
#############
|
||||
# BE SURE TO RUN THE EXTRAS/SITEMAINTENANCE.R BEFORE CREATING THE PDF
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/buildRelease.R
|
||||
\name{buildRelease}
|
||||
\alias{buildRelease}
|
||||
\title{Create OMOP CDM SQL files}
|
||||
\usage{
|
||||
buildRelease(
|
||||
cdmVersion = listSupportedVersions(),
|
||||
targetDialect = listSupportedDialects()
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4.
|
||||
Defaults to all supported CDM versions.}
|
||||
|
||||
\item{targetDialect}{The target dialect}
|
||||
}
|
||||
\description{
|
||||
Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion
|
||||
and targetDialect to the 'ddl' folder in current working directory.
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/buildRelease.R
|
||||
\name{buildReleaseZip}
|
||||
\alias{buildReleaseZip}
|
||||
\title{Create OMOP CDM release zip}
|
||||
\usage{
|
||||
buildReleaseZip(
|
||||
cdmVersion,
|
||||
targetDialect = listSupportedDialects(),
|
||||
outputfolder = "output"
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4.
|
||||
Defaults to all supported CDM versions.}
|
||||
|
||||
\item{targetDialect}{The target dialect. Defaults to all supported dialects.}
|
||||
|
||||
\item{outputfolder}{The output folder. Defaults to "output"}
|
||||
}
|
||||
\value{
|
||||
A character string containing the OHDSQL DDL
|
||||
}
|
||||
\description{
|
||||
First calls \code{buildReleaseZips} for given cdmVersions and targetDialects.
|
||||
This writes the ddl sql files to the ddl folder.
|
||||
Then zips all written ddl files into a release zip to given output folder.
|
||||
}
|
||||
\details{
|
||||
If no (or multiple) targetDialect is given,
|
||||
then one zip is written with the files of all supported dialects.
|
||||
}
|
||||
\examples{
|
||||
buildReleaseZip(cdmVersion='5.3', targetDialect='sql server', outputfolder='.')
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/createdDdl.R
|
||||
% Please edit documentation in R/createDdl.R
|
||||
\name{createDdl}
|
||||
\alias{createDdl}
|
||||
\alias{createPrimaryKeys}
|
||||
|
@ -30,9 +30,9 @@ Dashboard.
|
|||
}
|
||||
\section{Functions}{
|
||||
\itemize{
|
||||
\item \code{createPrimaryKeys}: createPrimaryKeys asdfladsfj
|
||||
\item \code{createPrimaryKeys}: createPrimaryKeys Returns a string containing the OHDSQL for creation of primary keys in the OMOP CDM.
|
||||
|
||||
\item \code{createForeignKeys}: createForeignKeys asdfladsf
|
||||
\item \code{createForeignKeys}: createForeignKeys Returns a string containing the OHDSQL for creation of foreign keys in the OMOP CDM.
|
||||
}}
|
||||
|
||||
\examples{
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/listSupportedVersions.R
|
||||
\name{listSupportedDialects}
|
||||
\alias{listSupportedDialects}
|
||||
\title{List RDBMS dialects supported by this package}
|
||||
\usage{
|
||||
listSupportedDialects()
|
||||
}
|
||||
\description{
|
||||
List RDBMS dialects supported by this package
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/writeDdl.R
|
||||
% Please edit documentation in R/writeDDL.R
|
||||
\name{writeDdl}
|
||||
\alias{writeDdl}
|
||||
\alias{writePrimaryKeys}
|
||||
|
|
Loading…
Reference in New Issue