R/GBIFEOLReferencesExtension.R

Defines functions initializeGBIFEOLReferencesExtension getGBIFEOLReferencesExtensionMembers getGBIFEOLReferencesExtensionTerm

Documented in getGBIFEOLReferencesExtensionMembers getGBIFEOLReferencesExtensionTerm initializeGBIFEOLReferencesExtension

# ------ 1. EOLREFERENCESEXTENSION TERM INFORMATION ------
#' Return the information of the term associated with the GBIF EOLReferencesExtension class
#' @return A \code{DwCTerm} object containing the term information
#' @seealso \code{\link[DwCTerm]{DwCTerm}}
getGBIFEOLReferencesExtensionTerm <- function() {
	outValue <- NULL
	if("http://www.eol.org/schema/transfer#/EOLReferencesExtension" %in% names(GBIFCoreClassList)) {
		outValue <- GBIFCoreClassList[["http://www.eol.org/schema/transfer#/EOLReferencesExtension"]]$termInfo
	} else if("http://www.eol.org/schema/transfer#/EOLReferencesExtension" %in% names(GBIFExtClassList)) {
		outValue <- GBIFExtClassList[["http://www.eol.org/schema/transfer#/EOLReferencesExtension"]]$termInfo
	}
	outValue
}

# ------ 2. EOLREFERENCESEXTENSION MEMBER INFORMATION ------
#' Return a list of properties associated with the GBIF EOLReferencesExtension class
#' @return A \code{list} of \code{DwCTerm} objects, one for each member of the the
#' GBIF EOLReferencesExtension class
#' @seealso \code{\link[DwCTerm]{DwCTerm}}
getGBIFEOLReferencesExtensionMembers <- function() {
	outValue <- NULL
	if("http://www.eol.org/schema/transfer#/EOLReferencesExtension" %in% names(GBIFCoreClassList)) {
		outValue <- GBIFCoreClassList[["http://www.eol.org/schema/transfer#/EOLReferencesExtension"]]$compositeTerms
	} else if("http://www.eol.org/schema/transfer#/EOLReferencesExtension" %in% names(GBIFExtClassList)) {
		outValue <- GBIFExtClassList[["http://www.eol.org/schema/transfer#/EOLReferencesExtension"]]$compositeTerms
	}
	outValue
}

# ------ 3. GBIF EOLREFERENCESEXTENSION CLASS ------
#' R6 class representing a data structure for a GBIF EOLReferencesExtension augmented data table (based on the Dawrin core)
#'
#' The \code{GBIFEOLReferencesExtension} class allows for the specification of data tables that comply with the EOLReferencesExtension
#' \url{http://www.eol.org/schema/transfer#/EOLReferencesExtension}{class specification} of GBIF.
GBIFEOLReferencesExtension <- R6Class("GBIFEOLReferencesExtension",
	inherit = DwCGeneric,
	# ====== 3.1. Define private members of the GBIF EOLReferencesExtension class ======
	private = list(
	),
	public = list(
		# ====== 3.2. Define an initialization function for the GBIF EOLReferencesExtension class ======
		#' @description
		#' Create a new GBIFEOLReferencesExtension object
		#' @param objectData A \code{data.frame} containing the data to import into the object
		#' @param idColumnInfo Either a \code{character} scalar containing the column name of
		#' \code{objectData} or an \code{integer} scalar giving the index of the column of
		#' \code{objectData} that corresponds to the ID variable.  Alternatively, this parameter
		#' may be the qualified name of the Darwin core term for which the appropriately mapped column
		#' will be used as the ID variable (the possible Darwin core term names can be found by running
		#' \code{names(getGBIFEOLReferencesExtensionMembers())})
		#' @param nameAutoMap A \code{logical} scalar that if \code{TRUE} maps the columns of \code{objectData}
		#' to their respective Darwin core terms based on the column names
		#' @param defDateFormat A \code{character} scalar providing the default format for strings denoting dates in the
		#' data table.  See the \url{https://dwc.tdwg.org/text/#1-introduction}{Darwin Core text guide} for expected values
		#' for this string.
		#' @param ... A named set of paramaeters corresponding to Darwin core terms associated with the GBIFEOLReferencesExtension
		#' class type.  Each is either a \code{character} scalar containing the column name of \code{objectData}
		#' or an \code{integer} scalar giving the index of the column of \code{objectData} that corresponds to the
		#' term. Mappable terms can be found using: \code{sapply(X = getGBIFEOLReferencesExtensionMembers(), FUN = function(curTerm) { curTerm$getTermName() })}
		#' @return A new \code{GBIFEOLReferencesExtension} object
		#' @seealso \code{\link[DwCTerm]{DwCTerm}} \code{\link[getGBIFEOLReferencesExtensionMembers]{getGBIFEOLReferencesExtensionMembers}}
		initialize = function(objectData, idColumnInfo, nameAutoMap = FALSE, defDateFormat = "YYYY-MM-DD", ...) {
			super$initialize(
				classTermInfo = getGBIFEOLReferencesExtensionTerm(),
				associatedTerms = getGBIFEOLReferencesExtensionMembers(),
				objectData = objectData,
				idColumnInfo = idColumnInfo,
				nameAutoMap = nameAutoMap,
				defDateFormat = defDateFormat,
				...
			)
			invisible(self)
		}
	)
)

# ------ 4. INITIALISATION FUNCTION ------
#' Initialize a new GBIF EOLReferencesExtension object
#' @param objectData A \code{data.frame} containing the data to import into the object
#' @param idColumnInfo Either a \code{character} scalar containing the column name of
#' \code{objectData} or an \code{integer} scalar giving the index of the column of
#' \code{objectData} that corresponds to the ID variable.  Alternatively, this parameter
#' may be the qualified name of the Darwin core term for which the appropriately mapped column
#' will be used as the ID variable (the possible Darwin core term names can be found by running
#' \code{names(getGBIFEOLReferencesExtensionMembers())})
#' @param nameAutoMap A \code{logical} scalar that if \code{TRUE} maps the columns of \code{objectData}
#' to their respective Darwin core terms based on the column names
#' @param defDateFormat A \code{character} scalar providing the default format for strings denoting dates in the
#' data table.  See the \url{https://dwc.tdwg.org/text/#1-introduction}{Darwin Core text guide} for expected values
#' for this string.
#' @param ... A named set of paramaeters corresponding to Darwin core terms associated with the GBIFEOLReferencesExtension
#' class type.  Each is either a \code{character} scalar containing the column name of \code{objectData}
#' or an \code{integer} scalar giving the index of the column of \code{objectData} that corresponds to the
#' term. Mappable terms can be found using: \code{sapply(X = getGBIFEOLReferencesExtensionMembers(), FUN = function(curTerm) { curTerm$getTermName() })}
#' @return A new \code{GBIFEOLReferencesExtension} object
#' @seealso \code{\link[DwCTerm]{DwCTerm}} \code{\link[getGBIFEOLReferencesExtensionMembers]{getGBIFEOLReferencesExtensionMembers}}
initializeGBIFEOLReferencesExtension <- function(objectData, idColumnInfo, nameAutoMap = FALSE, defDateFormat = "YYYY-MM-DD", ...) {
	GBIFEOLReferencesExtension$new(objectData = objectData, idColumnInfo = idColumnInfo, nameAutoMap = nameAutoMap, defDateFormat = defDateFormat, ...)
}
LivingNorway/LivingNorwayR documentation built on Jan. 11, 2024, 5:07 a.m.