Skip to content

Commit

Permalink
#181 support M4 - MCC existing classes + MD_metadata as MDB class
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Sep 12, 2024
1 parent 8a704bf commit 5ee8b78
Show file tree
Hide file tree
Showing 26 changed files with 497 additions and 244 deletions.
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export(ISODataFile)
export(ISODataIdentification)
export(ISODataQuality)
export(ISODataQualityAbstractElement)
export(ISODataQualityScope)
export(ISODataSet)
export(ISODatatype)
export(ISODate)
Expand Down Expand Up @@ -190,7 +191,6 @@ export(ISOGeorectified)
export(ISOGeoreferenceable)
export(ISOGridSpatialRepresentation)
export(ISOGriddedDataPositionalAccuracy)
export(ISOHierarchyLevel)
export(ISOIdentification)
export(ISOIdentifier)
export(ISOImageDescription)
Expand Down Expand Up @@ -279,6 +279,7 @@ export(ISOPortrayalCatalogueReference)
export(ISOPresentationForm)
export(ISOProcessStep)
export(ISOProductionSeries)
export(ISOProgress)
export(ISOPropertyType)
export(ISOQuantitativeAttributeAccuracy)
export(ISOQuantitativeResult)
Expand Down
6 changes: 5 additions & 1 deletion R/ISOAbstractObject.R
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,11 @@ ISOAbstractObject$getISOClasses = function(extended = FALSE, pretty = FALSE){
"pivot_format"))
}
}
return(r6Predicate & envPredicate & includePredicate)
notDeprecated <- FALSE
if(r6Predicate & envPredicate & includePredicate){
notDeprecated = !isTRUE(clazz$private_fields$deprecated)
}
return(r6Predicate & envPredicate & includePredicate & notDeprecated)
})]
list_of_classes <- as.vector(list_of_classes)
list_of_classes <- list_of_classes[!startsWith(list_of_classes, "pivot")]
Expand Down
5 changes: 4 additions & 1 deletion R/ISOBrowseGraphic.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ ISOBrowseGraphic <- R6Class("ISOBrowseGraphic",
inherit = ISOAbstractObject,
private = list(
xmlElement = "MD_BrowseGraphic",
xmlNamespacePrefix = "GMD"
xmlNamespacePrefix = list(
"19115-1/2" = "GMD",
"19115-3" = "MCC"
)
),
public = list(
#'@field fileName file name
Expand Down
6 changes: 3 additions & 3 deletions R/ISODataQuality.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @examples
#' #create dataQuality object with a 'dataset' scope
#' dq <- ISODataQuality$new()
#' scope <- ISOScope$new()
#' scope <- ISODataQualityScope$new()
#' scope$setLevel("dataset")
#' dq$setScope(scope)
#'
Expand Down Expand Up @@ -107,8 +107,8 @@ ISODataQuality <- R6Class("ISODataQuality",
#'@description Set scope
#'@param scope scope
setScope = function(scope){
if(!is(scope, "ISOScope")){
stop("The argument should be a 'ISOScope' object")
if(!is(scope, "ISODataQualityScope")){
stop("The argument should be a 'ISODataQualityScope' object")
}
self$scope <- scope
},
Expand Down
46 changes: 46 additions & 0 deletions R/ISODataQualityScope.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#' ISODataQualityScope
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO extent
#' @return Object of \code{\link{R6Class}} for modelling an ISO Scope
#' @format \code{\link{R6Class}} object.
#'
#' @examples
#' md <- ISODataQualityScope$new()
#' md$setLevel("dataset")
#' xml <- md$encode()
#'
#' @references
#' ISO 19115:2003 - Geographic information -- Metadata
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISODataQualityScope <- R6Class("ISODataQualityScope",
inherit = ISOAbstractObject,
private = list(
xmlElement = "DQ_Scope",
xmlNamespacePrefix = "GMD"
),
public = list(
#'@field level level
level = NULL,

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

#'@description Set level
#'@param level object of class \link{ISOScope} or any \link{character}
#' among values returned by \link{ISOScope}
setLevel = function(level){
if(is(level, "character")){
level <- ISOScope$new(value = level)
}
self$level <- level
}
)
)
43 changes: 0 additions & 43 deletions R/ISOHierarchyLevel.R

This file was deleted.

18 changes: 9 additions & 9 deletions R/ISOIdentification.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ISOIdentification <- R6Class("ISOIdentification",
purpose = NULL,
#'@field credit credit [0..*]: character
credit = list(),
#'@field status status [0..*]: ISOStatus
#'@field status status [0..*]: ISOProgress
status = list(),
#'@field pointOfContact pointOfContact [0..*]: ISOResponsibleParty
pointOfContact = list(),
Expand Down Expand Up @@ -109,23 +109,23 @@ ISOIdentification <- R6Class("ISOIdentification",
},

#'@description Adds status
#'@param status object of class \link{ISOStatus} or any \link{character} among
#' values returned by \code{ISOStatus$values()}
#'@param status object of class \link{ISOProgress} or any \link{character} among
#' values returned by \code{ISOProgress$values()}
#'@return \code{TRUE} if added, \code{FALSE} otherwise
addStatus = function(status){
if(!is(status,"ISOStatus")){
status <- ISOStatus$new(value = status)
if(!is(status,"ISOProgress")){
status <- ISOProgress$new(value = status)
}
return(self$addListElement("status", status))
},

#'@description Deletes status
#'@param status object of class \link{ISOStatus} or any \link{character} among
#' values returned by \code{ISOStatus$values()}
#'@param status object of class \link{ISOProgress} or any \link{character} among
#' values returned by \code{ISOProgress$values()}
#'@return \code{TRUE} if deleted, \code{FALSE} otherwise
delStatus = function(status){
if(!is(status,"ISOStatus")){
status <- ISOStatus$new(value = status)
if(!is(status,"ISOProgress")){
status <- ISOProgress$new(value = status)
}
return(self$delListElement("status", status))
},
Expand Down
5 changes: 4 additions & 1 deletion R/ISOMetaIdentifier.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ ISOMetaIdentifier <- R6Class("ISOMetaIdentifier",
inherit = ISOIdentifier,
private = list(
xmlElement = "MD_Identifier",
xmlNamespacePrefix = "GMD"
xmlNamespacePrefix = list(
"19115-1/2" = "GMD",
"19115-3" = "MCC"
)
),
public = list(
#'@description Initializes object
Expand Down
31 changes: 17 additions & 14 deletions R/ISOMetadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
#'
#' #create dataQuality object with a 'dataset' scope
#' dq <- ISODataQuality$new()
#' scope <- ISOScope$new()
#' scope <- ISODataQualityScope$new()
#' scope$setLevel("dataset")
#' dq$setScope(scope)
#'
Expand Down Expand Up @@ -332,7 +332,10 @@ ISOMetadata <- R6Class("ISOMetadata",
private = list(
document = TRUE,
xmlElement = "MD_Metadata",
xmlNamespacePrefix = "GMD"
xmlNamespacePrefix = list(
"19115-1/2" = "GMD",
"19115-3" = "MDB"
)
),
public = list(
#'@field fileIdentifier fileIdentifier [0..1] : character
Expand All @@ -343,7 +346,7 @@ ISOMetadata <- R6Class("ISOMetadata",
characterSet = NULL,
#'@field parentIdentifier parentIdentifier [0..1] : character
parentIdentifier = NULL,
#'@field hierarchyLevel hierarchyLevel [0..*] : ISOHierarchyLevel = "dataset"
#'@field hierarchyLevel hierarchyLevel [0..*] : ISOScope = "dataset"
hierarchyLevel = list(),
#'@field hierarchyLevelName hierarchyLevelName [0..*] : character
hierarchyLevelName = list(),
Expand Down Expand Up @@ -390,7 +393,7 @@ ISOMetadata <- R6Class("ISOMetadata",
#default values
defaults <- list(
characterSet = ISOCharacterSet$new(value = "utf8"),
hierarchyLevel = list(ISOHierarchyLevel$new(value = "dataset"))
hierarchyLevel = list(ISOScope$new(value = "dataset"))
)

if(!is.null(xml)){
Expand Down Expand Up @@ -439,19 +442,19 @@ ISOMetadata <- R6Class("ISOMetadata",
},

#'@description Adds hierarchy level
#'@param level object of class \link{ISOHierarchyLevel} or any \link{character}
#' from values returned by \code{ISOHierarchyLevel$values()}
#'@param level object of class \link{ISOScope} or any \link{character}
#' from values returned by \code{ISOScope$values()}
#'@return \code{TRUE} if added, \code{FALSE} otherwise
addHierarchyLevel = function(level){
if(!is(level, "ISOHierarchyLevel")){
level <- ISOHierarchyLevel$new(value = level)
if(!is(level, "ISOScope")){
level <- ISOScope$new(value = level)
}
return(self$addListElement("hierarchyLevel", level))
},

#'@description Sets hierarchy level
#'@param level object of class \link{ISOHierarchyLevel} or any \link{character}
#' from values returned by \code{ISOHierarchyLevel$values()}
#'@param level object of class \link{ISOScope} or any \link{character}
#' from values returned by \code{ISOScope$values()}
#'@return \code{TRUE} if added, \code{FALSE} otherwise
setHierarchyLevel = function(level){
warning("Method 'setHierarchyLevel' is deprecated, please use 'addHierarchyLevel'!")
Expand All @@ -460,12 +463,12 @@ ISOMetadata <- R6Class("ISOMetadata",
},

#'@description Deletes hierarchy level
#'@param level object of class \link{ISOHierarchyLevel} or any \link{character}
#' from values returned by \code{ISOHierarchyLevel$values()}
#'@param level object of class \link{ISOScope} or any \link{character}
#' from values returned by \code{ISOScope$values()}
#'@return \code{TRUE} if deleted, \code{FALSE} otherwise
delHierarchyLevel = function(level){
if(!is(level, "ISOHierarchyLevel")){
level <- ISOHierarchyLevel$new(value = level)
if(!is(level, "ISOScope")){
level <- ISOScope$new(value = level)
}
return(self$delListElement("hierarchyLevel", level))
},
Expand Down
97 changes: 97 additions & 0 deletions R/ISOProgress.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#' ISOProgress
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO status
#' @return Object of \code{\link{R6Class}} for modelling an ISO progress status
#' @format \code{\link{R6Class}} object.
#'
#' @examples
#' #possible values
#' values <- ISOProgress$values(labels = TRUE)
#'
#' #pending status
#' pending <- ISOProgress$new(value = "pending")
#'
#' @references
#' ISO 19115:2003 - Geographic information -- Metadata
#' ISO/TS 19115-3:2016 - Geographic information — Metadata — Part 3: XML schema implementation for fundamental concepts
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOProgress<- R6Class("ISOProgress",
inherit = ISOCodeListValue,
private = list(
xmlElement = "MD_ProgressCode",
xmlNamespacePrefix = list(
"19115-1/2" = "GMD",
"19115-3" = "MCC"
)
),
public = list(

#'@description Initializes object
#'@param xml object of class \link{XMLInternalNode-class}
#'@param value value
#'@param description description
initialize = function(xml = NULL, value, description = NULL){
super$initialize(xml = xml, id = private$xmlElement, value = value, description = description,
setValue = FALSE, addCodeSpaceAttr = FALSE)
}
)
)

ISOProgress$values <- function(labels = FALSE){
return(ISOCodeListValue$values(ISOProgress, labels))
}

#' ISOStatus
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO status
#' @return Object of \code{\link{R6Class}} for modelling an ISO progress status
#' @format \code{\link{R6Class}} object.
#'
#' @examples
#' #possible values
#' values <- ISOStatus$values(labels = TRUE)
#'
#' #pending status
#' pending <- ISOStatus$new(value = "pending")
#'
#' @note deprecated - use \link{ISOProgress} instead
#'
#' @references
#' ISO 19115:2003 - Geographic information -- Metadata
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOStatus<- R6Class("ISOStatus",
inherit = ISOCodeListValue,
private = list(
deprecated = TRUE,
xmlElement = "MD_ProgressCode",
xmlNamespacePrefix = list(
"19115-1/2" = "GMD",
"19115-3" = "MCC"
)
),
public = list(

#'@description Initializes object
#'@param xml object of class \link{XMLInternalNode-class}
#'@param value value
#'@param description description
initialize = function(xml = NULL, value, description = NULL){
warnings("Class 'ISOStatus' is deprecated, please use 'ISOProgress' instead!")
ISOProgress$new(xml = xml, value = value, description = description)
}
)
)

ISOStatus$values <- function(labels = FALSE){
return(ISOProgress$values(labels = labels))
}
Loading

0 comments on commit 5ee8b78

Please sign in to comment.