# Roxygen documentation
#' Import structured data into main db.
#' @param dump.name Specify a name for this data dump. It will be used in the files. Default is 'data dump'.
#' @param master.path Specify data frame that contains all relevant information. Default is 'master'.
#' @param test.size Number of state acts to include in the test set. Default is 5. There is NO overlap between the test and the full set CSVs i.e. you have to import both eventually.
#' @param author State your name. Default is "Piotr".
#' @param sa.id Name of the column containing the state act ID. Default is 'state.act.id'.
#' @param sa.title Name of the column containing the title of the state act. Default is 'title'.
#' @param sa.description Name of the column containing the announcement description. Default is 'announcement.description'.
#' @param announcement.date Name of the column containing the announcement date. Default is 'date.announced'.
#' @param sa.source Name of the column containing the source. Default is 'source'.
#' @param source.off Name of the column containing whether source is official (T/F). Default is 'source.official'.
#' @param int.id Name of the column containing ther intervention ID. Default is 'intervention.id'.
#' @param implementer Name of the column containing the implementing jurisdiction. Default is 'implementing.jurisdiction'.
#' @param implementer.type State how the implementing countries are specified ('un','name'). Default is 'name'.
#' @param int.type Name of the column containing the intervention type. Default is 'intervention.type'.
#' @param int.description Name of the column containing the intervention description. Default is 'intervention.description'.
#' @param int.flow Name of the column containing the affected flow. Default is 'affected.flow'.
#' @param eval.gta Name of the column containing the GTA evaluation. Default is 'gta.evaluation'.
#' @param eval.research Name of the column containing the research evaluation. Default is 'research.evaluation'.
#' @param inception.date Name of the column containing the inception date. Default is 'date.implemented'.
#' @param removal.date Name of the column containing the removal date. Default is 'date.removed'.
#' @param temporary Name of the column containing whether duration is announced as temporary (T/F). Default is 'duration.limited'.
#' @param firms Name of the column containing the eligible firms. Default is 'eligible.firms'.
#' @param imp.level Name of the column containing the implementation level. Default is 'implementation.level'.
#' @param is.noncommercial Name of the column containing whether there is a higher motive (T/F). Default is 'non.commercial'.
#' @param is.horizontal Name of the column containing whether the intervention is horizontal. Default is 'horizontal'.
#' @param is.fta Name of the column containing whether the affected trading partners may include FTA partners (T/F). Default is 'include.fta'.
#' @param int.prior Name of the column containing the prior level values for the intervention description. Default is 'level.prior'.
#' @param int.new Name of the column containing the new level values for the intervention description. Default is 'level.prior'.
#' @param int.unit Name of the column containing the unit for level values attached to the intervention description. Default is 'level.prior'.
#' @param sectors.nonhs Name of the column containing the affected sectors that are not generated by the affected tariff lines. Default is 'affected.sectors.nonhs'.
#' @param dm.nonsupport Name of the column containing the distorted markets that are not generated from a support table. Default is 'dm.editor.choice'.
#' @param dm.type State how the distorted markets are specified ('un','name'). Default is 'name'.
#' @param dm.freeze Name of the column containing whether the distorted market choice should be frozen as specified (T/F). Default is 'freeze.dm'.
#' @param aj.nonsupport Name of the column containing the affected jurisdictions that are not generated from a support table. Default is 'aj.editor.choice'.
#' @param aj.type State how the affected jurisdictions are specified ('un','name'). Default is 'name'.
#' @param aj.freeze Name of the column containing whether the affected jurisdictions choice should be frozen as specified (T/F). Default is 'freeze.aj'.
#' @param hs.code Name of the column containing the affected tariff line. Default is 'affected.product'.
#' @param hs.prior Name of the column containing the prior level for the affected tariff line. Default is 'atl.prior'.
#' @param hs.new Name of the column containing the new level for the affected tariff line. Default is 'atl.new'.
#' @param hs.unit Name of the column containing the unit for the affected tariff line values. Default is 'atl.unit'.
#' @param hs.official Name of the column containing the whether the affected tariff line is official (T/F). Default is 'atl.official'.
#' @param hs.inception Name of the column containing the inception date for the affected tariff line (if different from intervention date). Default is 'atl.implemented'.
#' @param hs.removal Name of the column containing the removal date for the affected tariff line (if different from intervention date). Default is 'atl.removed'.
#'
#' @return Only status and error messages..
#' @references www.globaltradealert.org
#' @author Global Trade Alert
gta_bulk_upload = function( dump.name="data dump",
master.path=NULL,
test.size=5,
sa.id="state.act.id",
sa.title="title",
sa.description="announcement.description",
announcement.date="date.announced",
sa.source="source",
source.off="source.official",
int.id="intervention.id",
implementer="implementing.jurisdiction",
implementer.type="name",
int.type="intervention.type",
int.description="intervention.description",
int.flow="affected.flow",
eval.gta="gta.evaluation",
eval.research="research.evaluation",
inception.date="date.implemented",
removal.date="date.removed",
temporary="duration.limited",
firms="eligible.firms",
imp.level="implementation.level",
is.noncommercial="non.commercial",
is.horizontal="horizontal",
is.fta="include.fta",
int.prior="level.prior",
int.new="level.new",
int.unit="level.unit",
sectors.nonhs="affected.sectors.nonhs",
dm.nonsupport="dm.editor.choice",
dm.type="name",
dm.freeze="freeze.dm",
aj.nonsupport="aj.editor.choice",
aj.type="name",
aj.freeze="freeze.aj",
hs.code="affected.product",
hs.prior="atl.prior",
hs.new="atl.new",
hs.unit="atl.unit",
hs.official="atl.official",
hs.inception="atl.implemented",
hs.removed="atl.removed"){
library(gtalibrary)
library(gtasql)
library(gtalibrary)
library(pool)
library(RMariaDB)
library(data.table)
library(sodium)
gta_setwd()
database <<- "gtamain"
gta_sql_pool_open(db.title=database,
db.host = gta_pwd(database)$host,
db.name = gta_pwd(database)$name,
db.user = gta_pwd(database)$user,
db.password = gta_pwd(database)$password,
table.prefix = "gta_")
source("setup/keys/main db upload.R")
if(is.null(master.path)){
gta_sql_pool_close()
stop("Please path to master Rdata file")
}
# ## Authetification TBA
# login= readline("Please provide your Admin Panel login name: ")
# pwd= readline("Please provide your Admin Panel password: ")
#
#
# user.credentials <- gta_sql_get_value(sqlInterpolate(pool, "SELECT f_name, passwd FROM fw_users WHERE login = ?userLogin;", userLogin = login))
# if(nrow(user.credentials)==0){
# stop("Unknown login name.")
# } else {
#
# if(password_verify(as.character(user.credentials$password), as.character(pwd))){
#
# print(paste0("Good luck, ",unique(user.credentials$f.name)[1],"!"))
#
# } else {
#
# stop("---- wrong password ----")
#
# }
#
#
# }
pwd=readline("Please enter upload password: ")
if(pwd==pwd.main){
print("Thanks & good luck")
} else {
gta_sql_pool_close()
stop("---- wrong password ----")
}
## loading data
load(master.path)
gta_sql_pool_close()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.