Skip to content

Commit

Permalink
#181 - M4 - refactor data quality existing classes for MDQ namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Dec 12, 2024
1 parent a0c6c38 commit 317647f
Show file tree
Hide file tree
Showing 49 changed files with 906 additions and 213 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: geometa
Type: Package
Title: Tools for Reading and Writing ISO/OGC Geographic Metadata
Version: 0.9
Date: 2024-12-08
Date: 2024-12-12
Authors@R: c(
person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "emmanuel.blondel1@gmail.com", comment = c(ORCID = "0000-0002-5870-5762")),
person("R Consortium", role = "fnd"))
Expand Down
15 changes: 7 additions & 8 deletions R/ISOAbstractResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@
#' @note abstract class
#'
#' @references
#' ISO 19115:2003 - Geographic information -- Metadata
#' - ISO 19139 \link{https://schemas.isotc211.org/19139/-/gmd/1.0/gmd/#element_AbstractDQ_Result}
#'
#' - ISO 19115-3 \link{https://schemas.isotc211.org/19157/-/mdq/1.2/mdq/#element_AbstractDQ_Result}
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOAbstractResult <- R6Class("ISOAbstractResult",
inherit = ISOAbstractObject,
private = list(
xmlElement = "AbstractDQ_Result",
xmlNamespacePrefix = "GMD"
xmlNamespacePrefix = list(
"19139" = "GMD",
"19115-3" = "MDQ"
)
),
public = list(
#'@field specification specification
specification = NULL,
#'@field explanation explanation
explanation = NULL,
#'@field pass pass
pass = NULL,

#'@description Initializes object
#'@param xml object of class \link{XMLInternalNode-class}
Expand Down
34 changes: 32 additions & 2 deletions R/ISOConformanceResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,27 @@
#' xml <- md$encode()
#'
#' @references
#' ISO 19115:2003 - Geographic information -- Metadata
#' - ISO 19139 \link{https://schemas.isotc211.org/19139/-/gmd/1.0/gmd/#element_DQ_ConformanceResult}
#'
#' - ISO 19115-3 \link{https://schemas.isotc211.org/19157/-/mdq/1.2/mdq/#element_DQ_ConformanceResult}
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOConformanceResult <- R6Class("ISOConformanceResult",
inherit = ISOAbstractResult,
private = list(
xmlElement = "DQ_ConformanceResult",
xmlNamespacePrefix = "GMD"
xmlNamespacePrefix = list(
"19139" = "GMD",
"19115-3" = "MDQ"
)
),
public = list(

#'@field resultScope resultScope [0..1]: ISOScope (=> 19115-3)
resultScope = NULL,
#'@field dateTime dateTime [0..1] (=> 19115-3)
dateTime = NULL,
#'@field specification specification
specification = NULL,
#'@field explanation explanation
Expand All @@ -46,6 +56,26 @@ ISOConformanceResult <- R6Class("ISOConformanceResult",
super$initialize(xml = xml)
},

#'@description Set result scope
#'@param scope object of class \link{ISOScope}
setResultScope = function(scope){
self$stopIfMetadataStandardIsNot("19115-3")
if(!is(scope, "ISOScope")){
stop("The argument should be a 'ISOScope' object")
}
self$resultScope = scope
},

#'@description Set date time
#'@param dateTime date time, object of class \link{POSIXct}
setDateTime = function(dateTime){
self$stopIfMetadataStandardIsNot("19115-3")
if(!all(class(dateTime) == c("POSIXct","POSIXt"))){
stop("The argument should be an 'POSIXct'/'POSIXt' object")
}
self$dateTime <- dateTime
},

#'@description Set specification
#'@param specification specification
setSpecification = function(specification){
Expand Down
40 changes: 32 additions & 8 deletions R/ISODataQuality.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,17 @@ ISODataQuality <- R6Class("ISODataQuality",
inherit = ISOAbstractObject,
private = list(
xmlElement = "DQ_DataQuality",
xmlNamespacePrefix = "GMD"
xmlNamespacePrefix = list(
"19139" = "GMD",
"19115-3" = "MDQ"
)
),
public = list(
#'@field scope scope
scope = NULL,
#'@field report list of reports
#'@field standaloneQualityReport standalone quality report (=> 19115-3)
standaloneQualityReport = NULL,
#'@field report list of reports (=> 19139)
report = list(),
#'@field lineage lineage
lineage = NULL,
Expand All @@ -107,25 +112,44 @@ ISODataQuality <- R6Class("ISODataQuality",
#'@description Set scope
#'@param scope scope
setScope = function(scope){
if(!is(scope, "ISODataQualityScope")){
stop("The argument should be a 'ISODataQualityScope' object")
}
switch(getMetadataStandard(),
"19139" = {
if(!is(scope, "ISODataQualityScope")){
stop("The argument should be a 'ISODataQualityScope' object")
}
},
"19115-3" = {
if(!is(scope, "ISOScope")){
stop("The argument should be a 'ISOScope' object")
}
}
)
self$scope <- scope
},

#'@description Set standalone quality report
#'@param report object of class \link{ISOStandaloneQualityReportInformation}
setStandaloneQualityReport = function(report){
if(!is(report, "ISOStandaloneQualityReportInformation")){
stop("The argument should inherit class 'ISOStandaloneQualityReportInformation'")
}
self$standaloneQualityReport = report
},

#'@description Adds report
#'@param report report, object of class \link{ISODomainConsistency}
#'@param report report, object of class \link{ISODataQualityAbstractElement}
#'@return \code{TRUE} if added, \code{FALSE} otherwise
addReport = function(report){
if(!is(report, "ISODomainConsistency")){
stop("The argument should be a 'ISODomainConsistency' object")
if(!is(report, "ISODataQualityAbstractElement")){
stop("The argument should inherit class 'ISODataQualityAbstractElement'")
}
self$report <- c(self$report, report)
},

#'@description Set lineage
#'@param lineage lineage, object of class \link{ISOLineage}
setLineage = function(lineage){
self$stopIfMetadataStandardIsNot("19139")
if(!is(lineage, "ISOLineage")){
stop("The argument should be a 'ISOLineage' object")
}
Expand Down
102 changes: 85 additions & 17 deletions R/ISODataQualityAbstractElement.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,67 @@
#' @format \code{\link{R6Class}} object.
#'
#' @references
#' ISO 19115:2003 - Geographic information -- Metadata
#' - ISO 19139 \link{https://schemas.isotc211.org/19139/-/gmd/1.0/gmd/#element_AbstractDQ_Element}
#'
#' - ISO 19115-3 \link{https://schemas.isotc211.org/19157/-/mdq/1.2/mdq/#element_AbstractDQ_Element}
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISODataQualityAbstractElement <- R6Class("ISODataQualityAbstractElement",
inherit = ISOAbstractObject,
private = list(
xmlElement = "AbstractDQ_Element",
xmlNamespacePrefix = "GMD"
xmlNamespacePrefix = list(
"19139" = "GMD",
"19115-3" = "MDQ"
)
),
public = list(

#'@field nameOfMeasure nameOfMeasure [0..*]: character

#'@field standaloneQualityReportDetails standaloneQualityReportDetails [0..1]: character (=> 19115-3)
standaloneQualityReportDetails = NULL,
#'@field nameOfMeasure nameOfMeasure [0..*]: character (=> 19139)
nameOfMeasure = list(),
#'@field measureIdentification measureIdentification [0..1]: ISOMetaIdentifier
#'@field measureIdentification measureIdentification [0..1]: ISOMetaIdentifier (=> 19139)
measureIdentification = NULL,
#'@field measureDescription measureDescription [0..1]: character
#'@field measureDescription measureDescription [0..1]: character (=> 19139)
measureDescription = NULL,
#'@field evaluationMethodType evaluationMethodType [0..1]: ISOEvaluationMethodType
#'@field measure measure [0..1]: ISOMeasureReference (=> 19115-3)
measure = NULL,
#'@field evaluationMethodType evaluationMethodType [0..1]: ISOEvaluationMethodType (=> 19139)
evaluationMethodType = NULL,
#'@field evaluationMethodDescription evaluationMethodDescription [0..1]: character
#'@field evaluationMethodDescription evaluationMethodDescription [0..1]: character (=> 19139)
evaluationMethodDescription = NULL,
#'@field evaluationProcedure evaluationProcedure [0..1]: ISOCitation
#'@field evaluationProcedure evaluationProcedure [0..1]: ISOCitation (=> 19139)
evaluationProcedure = NULL,
#'@field dateTime dateTime [0..1]: ISODateTime
#'@field evaluationMethod evaluationMethod [0..1]: ISOEvaluationMethod (=> 19115-3)
evaluationMethod = NULL,
#'@field dateTime dateTime [0..1]: ISODateTime (=> 19139)
dateTime = NULL,
#'@field result result [1..2]: ISOConformanceResult
#'@field result result [1..2]: ISOAbstractResult
result = list(),
#'@field derivedElement derivedElement [0..*]: ISODataQualityAbstractElement (=> 19115-3)
derivedElement = list(),

#'@description Initializes object
#'@param xml object of class \link{XMLInternalNode-class}
initialize = function(xml = NULL){
super$initialize(xml = xml)
},

#'@description Set Standalone quality report details
#'@param details object of class \link{character}
setStandaloneQualityReportDetails = function(details){
self$stopIfMetadataStandardIsNot("19115-3")
self$standaloneQualityReportDetails = details
},

#'@description Adds name of measure
#'@param name name
#'@param locales list of localized names. Default is \code{NULL}
#'@return \code{TRUE} if added, \code{FALSE}
addNameOfMeasure = function(name, locales = NULL){
self$stopIfMetadataStandardIsNot("19139")
if(!is.null(locales)){
name <- self$createLocalisedProperty(name, locales)
}
Expand All @@ -59,6 +80,7 @@ ISODataQualityAbstractElement <- R6Class("ISODataQualityAbstractElement",
#'@param locales list of localized names. Default is \code{NULL}
#'@return \code{TRUE} if deleted, \code{FALSE}
delNameOfMeasure = function(name, locales = NULL){
self$stopIfMetadataStandardIsNot("19139")
if(!is.null(locales)){
name <- self$createLocalisedProperty(name, locales)
}
Expand All @@ -68,16 +90,28 @@ ISODataQualityAbstractElement <- R6Class("ISODataQualityAbstractElement",
#'@description Set measure identification
#'@param identification object of class \link{ISOMetaIdentifier}
setMeasureIdentification = function(identification){
self$stopIfMetadataStandardIsNot("19139")
if(!is(identification, "ISOMetaIdentifier")){
stop("The argument value should be an object of class 'ISOMetaIdentifier")
}
self$measureIdentification = identification
},

#'@description Set measure
#'@param measure object of class \link{ISOMeasureReference}
setMeasure = function(measure){
self$stopIfMetadataStandardIsNot("19115-3")
if(!is(measure, "ISOMeasureReference")){
stop("The argument value should be an object of class 'ISOMeasureReference")
}
self$measure = measure
},

#'@description Set measure description
#'@param description object of class \link{character}
#'@param locales list of localized descriptions. Default is \code{NULL}
setMeasureDescription = function(description, locales = NULL){
self$stopIfMetadataStandardIsNot("19139")
if(!is.null(locales)){
description <- self$createLocalisedProperty(description, locales)
}
Expand All @@ -88,6 +122,7 @@ ISODataQualityAbstractElement <- R6Class("ISODataQualityAbstractElement",
#'@param type object of class \link{ISOEvaluationMethodType} or any \link{character} value
#' from those returned by \code{ISOEvaluationMethodType$values()}
setEvaluationMethodType = function(type){
self$stopIfMetadataStandardIsNot("19139")
if(!is(type, "ISOEvaluationMethodType")){
type <- ISOEvaluationMethodType$new(value = type)
}
Expand All @@ -98,6 +133,7 @@ ISODataQualityAbstractElement <- R6Class("ISODataQualityAbstractElement",
#'@param description description
#'@param locales list of localized descriptions. Default is \code{NULL}
setEvaluationMethodDescription = function(description, locales = NULL){
self$stopIfMetadataStandardIsNot("19139")
if(!is.null(locales)){
description <- self$createLocalisedProperty(description, locales)
}
Expand All @@ -107,39 +143,71 @@ ISODataQualityAbstractElement <- R6Class("ISODataQualityAbstractElement",
#'@description Set evaluation procedure
#'@param procedure procedure, object of class \link{ISOCitation}
setEvaluationProcedure = function(procedure){
self$stopIfMetadataStandardIsNot("19139")
if(!is(procedure, "ISOCitation")){
stop("The argument value should be an object of class 'ISOCitation'")
}
self$evaluationProcedure <- procedure
},

#'@description Set evaluation method
#'@param evaluationMethod object of class \link{ISOEvaluationMethod}
setEvaluationMethod = function(evaluationMethod){
self$stopIfMetadataStandardIsNot("19115-3")
if(!is(evaluationMethod, "ISOEvaluationMethod")){
stop("The argument value should be an object of class 'ISOEvaluationMethod")
}
self$evaluationMethod = evaluationMethod
},

#'@description Set date time
#'@param dateTime date time, object of class \link{POSIXct}
setDateTime = function(dateTime){
self$stopIfMetadataStandardIsNot("19139")
if(!all(class(dateTime) == c("POSIXct","POSIXt"))){
stop("The argument should be an 'POSIXct'/'POSIXt' object")
}
self$dateTime <- dateTime
},

#'@description Adds result
#'@param result object of class \link{ISOConformanceResult}
#'@param result object of class \link{ISOAbstractResult}
#'@return \code{TRUE} if added, \code{FALSE} otherwise
addResult = function(result){
if(!is(result, "ISOConformanceResult")){
stop("The argument value should be an object of class 'ISOConformanceResult'")
if(!is(result, "ISOAbstractResult")){
stop("The argument value should be an object of class 'ISOAbstractResult'")
}
return(self$addListElement("result", result))
},

#'@description Deletes result
#'@param result object of class \link{ISOConformanceResult}
#'@param result object of class \link{ISOAbstractResult}
#'@return \code{TRUE} if deleted, \code{FALSE} otherwise
delResult = function(result){
if(!is(result, "ISOConformanceResult")){
stop("The argument value should be an object of class 'ISOConformanceResult'")
if(!is(result, "ISOAbstractResult")){
stop("The argument value should be an object of class 'ISOAbstractResult'")
}
return(self$delListElement("result", result))
},

#'@description Adds element
#'@param element object of class \link{ISODataQualityAbstractElement}
#'@return \code{TRUE} if added, \code{FALSE} otherwise
addElement = function(element){
if(!is(element, "ISODataQualityAbstractElement")){
stop("The argument value should be an object of class 'ISODataQualityAbstractElement'")
}
return(self$addListElement("element", element))
},

#'@description Deletes element
#'@param element object of class \link{ISODataQualityAbstractElement}
#'@return \code{TRUE} if deleted, \code{FALSE} otherwise
delElement = function(element){
if(!is(element, "ISODataQualityAbstractElement")){
stop("The argument value should be an object of class 'ISODataQualityAbstractElement'")
}
return(self$delListElement("element", element))
}
)
)
Loading

0 comments on commit 317647f

Please sign in to comment.