Skip to content

Commit

Permalink
#181 support M4 - GCO existing classes refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Sep 10, 2024
1 parent f62c0f9 commit c41cb57
Show file tree
Hide file tree
Showing 25 changed files with 128 additions and 26 deletions.
5 changes: 4 additions & 1 deletion R/ISOAbstractObject.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ ISOAbstractObject <- R6Class("ISOAbstractObject",
private = list(
metadataStandardCompliance = TRUE,
xmlElement = "AbstractObject",
xmlNamespacePrefix = "GCO",
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
),
encoding = options("encoding"),
document = FALSE,
system_fields = c("wrap", "value_as_field", "valueDescription",
Expand Down
5 changes: 4 additions & 1 deletion R/ISOAngle.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ ISOAngle <- R6Class("ISOAngle",
inherit = ISOMeasure,
private = list(
xmlElement = "Angle",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(

Expand Down
5 changes: 4 additions & 1 deletion R/ISOBaseBoolean.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ ISOBaseBoolean <- R6Class("ISOBaseBoolean",
inherit = ISOAbstractObject,
private = list(
xmlElement = "Boolean",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISOBaseCharacterString.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ ISOBaseCharacterString <- R6Class("ISOBaseCharacterString",
inherit = ISOAbstractObject,
private = list(
xmlElement = "CharacterString",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISOBaseDate.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ ISOBaseDate <- R6Class("ISOBaseDate",
inherit = ISOAbstractObject,
private = list(
xmlElement = "Date",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISOBaseDateTime.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ ISOBaseDateTime <- R6Class("ISOBaseDateTime",
inherit = ISOAbstractObject,
private = list(
xmlElement = "DateTime",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISOBaseDecimal.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ ISOBaseDecimal <- R6Class("ISOBaseDecimal",
inherit = ISOAbstractObject,
private = list(
xmlElement = "Decimal",
xmlNamespacePrefix = "GCO",
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
),

#decimal places
decimalplaces = function(x) {
Expand Down
5 changes: 4 additions & 1 deletion R/ISOBaseInteger.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ ISOBaseInteger <- R6Class("ISOBaseInteger",
inherit = ISOAbstractObject,
private = list(
xmlElement = "Integer",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISOBaseReal.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ ISOBaseReal <- R6Class("ISOBaseReal",
inherit = ISOAbstractObject,
private = list(
xmlElement = "Real",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISOBinary.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ ISOBinary <- R6Class("ISOBinary",
inherit = ISOAbstractObject,
private = list(
xmlElement = "Binary",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISODistance.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ ISODistance <- R6Class("ISODistance",
inherit = ISOLength,
private = list(
xmlElement = "Distance",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(

Expand Down
5 changes: 4 additions & 1 deletion R/ISOLength.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ ISOLength <- R6Class("ISOLength",
inherit = ISOMeasure,
private = list(
xmlElement = "Length",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(

Expand Down
5 changes: 4 additions & 1 deletion R/ISOLocalName.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ ISOLocalName <- R6Class("ISOLocalName",
inherit = ISOAbstractGenericName,
private = list(
xmlElement = "LocalName",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISOMeasure.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ ISOMeasure <- R6Class("ISOMeasure",
inherit = ISOAbstractObject,
private = list(
xmlElement = "Measure",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISOMemberName.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ ISOMemberName <- R6Class("ISOMemberName",
inherit = ISOAbstractObject,
private = list(
xmlElement = "MemberName",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field aName name
Expand Down
5 changes: 4 additions & 1 deletion R/ISOMultiplicity.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ ISOMultiplicity <- R6Class("ISOMultiplicity",
inherit = ISOAbstractObject,
private = list(
xmlElement = "Multiplicity",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field range range
Expand Down
5 changes: 4 additions & 1 deletion R/ISOMultiplicityRange.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ ISOMultiplicityRange <- R6Class("ISOMultiplicityRange",
inherit = ISOAbstractObject,
private = list(
xmlElement = "MultiplicityRange",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field lower lower
Expand Down
5 changes: 4 additions & 1 deletion R/ISOPresentationForm.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ ISOPresentationForm <- R6Class("ISOPresentationForm",
inherit = ISOCodeListValue,
private = list(
xmlElement = "CI_PresentationFormCode",
xmlNamespacePrefix = "GMD"
xmlNamespacePrefix = list(
"19115-1/2" = "GMD",
"19115-3" = "CIT"
)
),
public = list(

Expand Down
5 changes: 4 additions & 1 deletion R/ISORecordType.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ ISORecordType <- R6Class("ISORecordType",
inherit = ISOAbstractObject,
private = list(
xmlElement = "RecordType",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISOScale.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ ISOScale <- R6Class("ISOScale",
inherit = ISOMeasure,
private = list(
xmlElement = "Scale",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(

Expand Down
5 changes: 4 additions & 1 deletion R/ISOScopedName.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ ISOScopedName <- R6Class("ISOScopedName",
inherit = ISOAbstractGenericName,
private = list(
xmlElement = "ScopedName",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
5 changes: 4 additions & 1 deletion R/ISOTypeName.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ ISOTypeName <- R6Class("ISOTypeName",
inherit = ISOAbstractObject,
private = list(
xmlElement = "TypeName",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(

Expand Down
5 changes: 4 additions & 1 deletion R/ISOUnlimitedInteger.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ ISOUnlimitedInteger <- R6Class("ISOUnlimitedInteger",
inherit = ISOAbstractObject,
private = list(
xmlElement = "UnlimitedInteger",
xmlNamespacePrefix = "GCO"
xmlNamespacePrefix = list(
"19115-1/2" = "GCO",
"19115-3" = "GCO"
)
),
public = list(
#'@field value value
Expand Down
21 changes: 19 additions & 2 deletions tests/testthat/test_ISOBaseBoolean.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require(testthat)

context("ISOBaseBoolean")

test_that("encoding",{
test_that("encoding - ISO 19115-1",{
#encoding
md <- ISOBaseBoolean$new(value = TRUE)
expect_is(md, "ISOBaseBoolean")
Expand All @@ -24,7 +24,7 @@ test_that("encoding",{

})

test_that("encoding with coercing",{
test_that("encoding - ISO 19115-1 - with coercing",{

#encoding
md <- ISOBaseBoolean$new(value = "true")
Expand All @@ -39,4 +39,21 @@ test_that("encoding with coercing",{

expect_true(ISOAbstractObject$compare(md, md2))

})

test_that("encoding - ISO 19115-3",{
setMetadataStandard("19115-3")
#encoding
md <- ISOBaseBoolean$new(value = TRUE)
expect_is(md, "ISOBaseBoolean")
expect_equal(md$value, "true")
xml <- md$encode()
expect_is(xml, "XMLInternalNode")

#decoding
md2 <- ISOBaseBoolean$new(xml = xml)
xml2 <- md2$encode()

expect_true(ISOAbstractObject$compare(md, md2))
setMetadataStandard("19115-1/2")
})
18 changes: 17 additions & 1 deletion tests/testthat/test_ISOBaseCharacterString.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require(testthat)

context("ISOBaseCharacterString")

test_that("encoding",{
test_that("encoding - ISO 19115-1",{
#encoding
md <- ISOBaseCharacterString$new(value = "myvalue")
expect_is(md, "ISOBaseCharacterString")
Expand All @@ -21,5 +21,21 @@ test_that("encoding",{
xml2 <- md2$encode()

expect_true(ISOAbstractObject$compare(md, md2))
})

test_that("encoding - ISO 19115-3",{
setMetadataStandard("19115-3")
#encoding
md <- ISOBaseCharacterString$new(value = "myvalue")
expect_is(md, "ISOBaseCharacterString")
expect_equal(md$value, "myvalue")
xml <- md$encode()
expect_is(xml, "XMLInternalNode")

#decoding
md2 <- ISOBaseCharacterString$new(xml = xml)
xml2 <- md2$encode()

expect_true(ISOAbstractObject$compare(md, md2))
setMetadataStandard("19115-1/2")
})

0 comments on commit c41cb57

Please sign in to comment.