R/ScientificObjectDetailDTO.r

# OpenSilex API
#
# No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
#
# OpenAPI spec version: 1.0.0-rc+2
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' ScientificObjectDetailDTO Class
#'
#' @field uri 
#' @field rdf_type 
#' @field rdf_type_name 
#' @field name 
#' @field parent 
#' @field parent_name 
#' @field factor_level 
#' @field relations 
#' @field geometry 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ScientificObjectDetailDTO <- R6::R6Class(
  'ScientificObjectDetailDTO',
  public = list(
    `uri` = NULL,
    `rdf_type` = NULL,
    `rdf_type_name` = NULL,
    `name` = NULL,
    `parent` = NULL,
    `parent_name` = NULL,
    `factor_level` = NULL,
    `relations` = NULL,
    `geometry` = NULL,
    initialize = function(`uri`, `rdf_type`, `rdf_type_name`, `name`, `parent`, `parent_name`, `factor_level`, `relations`, `geometry`){
      if (!missing(`uri`)) {
        stopifnot(is.character(`uri`), length(`uri`) == 1)
        self$`uri` <- `uri`
      }
      if (!missing(`rdf_type`)) {
        stopifnot(is.character(`rdf_type`), length(`rdf_type`) == 1)
        self$`rdf_type` <- `rdf_type`
      }
      if (!missing(`rdf_type_name`)) {
        stopifnot(is.character(`rdf_type_name`), length(`rdf_type_name`) == 1)
        self$`rdf_type_name` <- `rdf_type_name`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`parent`)) {
        stopifnot(is.character(`parent`), length(`parent`) == 1)
        self$`parent` <- `parent`
      }
      if (!missing(`parent_name`)) {
        stopifnot(is.character(`parent_name`), length(`parent_name`) == 1)
        self$`parent_name` <- `parent_name`
      }
      if (!missing(`factor_level`)) {
        stopifnot(is.list(`factor_level`), length(`factor_level`) != 0)
        lapply(`factor_level`, function(x) stopifnot(R6::is.R6(x)))
        self$`factor_level` <- `factor_level`
      }
      if (!missing(`relations`)) {
        stopifnot(is.list(`relations`), length(`relations`) != 0)
        lapply(`relations`, function(x) stopifnot(R6::is.R6(x)))
        self$`relations` <- `relations`
      }
      if (!missing(`geometry`)) {
        stopifnot(R6::is.R6(`geometry`))
        self$`geometry` <- `geometry`
      }
    },
    toJSON = function() {
      ScientificObjectDetailDTOObject <- list()
      if (!is.null(self$`uri`)) {
        ScientificObjectDetailDTOObject[['uri']] <- self$`uri`
      }
      if (!is.null(self$`rdf_type`)) {
        ScientificObjectDetailDTOObject[['rdf_type']] <- self$`rdf_type`
      }
      if (!is.null(self$`rdf_type_name`)) {
        ScientificObjectDetailDTOObject[['rdf_type_name']] <- self$`rdf_type_name`
      }
      if (!is.null(self$`name`)) {
        ScientificObjectDetailDTOObject[['name']] <- self$`name`
      }
      if (!is.null(self$`parent`)) {
        ScientificObjectDetailDTOObject[['parent']] <- self$`parent`
      }
      if (!is.null(self$`parent_name`)) {
        ScientificObjectDetailDTOObject[['parent_name']] <- self$`parent_name`
      }
      if (!is.null(self$`factor_level`)) {
        ScientificObjectDetailDTOObject[['factor_level']] <- lapply(self$`factor_level`, function(x) x$toJSON())
      }
      if (!is.null(self$`relations`)) {
        ScientificObjectDetailDTOObject[['relations']] <- lapply(self$`relations`, function(x) x$toJSON())
      }
      if (!is.null(self$`geometry`)) {
        ScientificObjectDetailDTOObject[['geometry']] <- self$`geometry`$toJSON()
      }

      ScientificObjectDetailDTOObject
    },
    fromJSON = function(ScientificObjectDetailDTOJson) {
      ScientificObjectDetailDTOObject <- jsonlite::fromJSON(ScientificObjectDetailDTOJson)
      if (!is.null(ScientificObjectDetailDTOObject$`uri`)) {
        self$`uri` <- ScientificObjectDetailDTOObject$`uri`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`rdf_type`)) {
        self$`rdf_type` <- ScientificObjectDetailDTOObject$`rdf_type`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`rdf_type_name`)) {
        self$`rdf_type_name` <- ScientificObjectDetailDTOObject$`rdf_type_name`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`name`)) {
        self$`name` <- ScientificObjectDetailDTOObject$`name`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`parent`)) {
        self$`parent` <- ScientificObjectDetailDTOObject$`parent`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`parent_name`)) {
        self$`parent_name` <- ScientificObjectDetailDTOObject$`parent_name`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`factor_level`)) {
        self$`factor_level` <- lapply(ScientificObjectDetailDTOObject$`factor_level`, function(x) {
          factor_levelObject <- NamedResourceDTOFactorLevelModel$new()
          factor_levelObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          factor_levelObject
        })
      }
      if (!is.null(ScientificObjectDetailDTOObject$`relations`)) {
        self$`relations` <- lapply(ScientificObjectDetailDTOObject$`relations`, function(x) {
          relationsObject <- RDFObjectRelationDTO$new()
          relationsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          relationsObject
        })
      }
      if (!is.null(ScientificObjectDetailDTOObject$`geometry`)) {
        geometryObject <- GeoJsonObject$new()
        geometryObject$fromJSON(jsonlite::toJSON(ScientificObjectDetailDTOObject$geometry, auto_unbox = TRUE, null = "null"))
        self$`geometry` <- geometryObject
      }
    },
    fromJSONObject = function(ScientificObjectDetailDTOObject) {
      if (!is.null(ScientificObjectDetailDTOObject$`uri`)) {
        self$`uri` <- ScientificObjectDetailDTOObject$`uri`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`rdf_type`)) {
        self$`rdf_type` <- ScientificObjectDetailDTOObject$`rdf_type`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`rdf_type_name`)) {
        self$`rdf_type_name` <- ScientificObjectDetailDTOObject$`rdf_type_name`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`name`)) {
        self$`name` <- ScientificObjectDetailDTOObject$`name`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`parent`)) {
        self$`parent` <- ScientificObjectDetailDTOObject$`parent`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`parent_name`)) {
        self$`parent_name` <- ScientificObjectDetailDTOObject$`parent_name`
      }
      if (!is.null(ScientificObjectDetailDTOObject$`factor_level`)) {
        self$`factor_level` <- lapply(ScientificObjectDetailDTOObject$`factor_level`, function(x) {
          factor_levelObject <- NamedResourceDTOFactorLevelModel$new()
          factor_levelObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          factor_levelObject
        })
      }
      if (!is.null(ScientificObjectDetailDTOObject$`relations`)) {
        self$`relations` <- lapply(ScientificObjectDetailDTOObject$`relations`, function(x) {
          relationsObject <- RDFObjectRelationDTO$new()
          relationsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          relationsObject
        })
      }
      if (!is.null(ScientificObjectDetailDTOObject$`geometry`)) {
        geometryObject <- GeoJsonObject$new()
        geometryObject$fromJSON(jsonlite::toJSON(ScientificObjectDetailDTOObject$geometry, auto_unbox = TRUE, null = "null"))
        self$`geometry` <- geometryObject
      }
    },
    toJSONString = function() {
      factor_levelList = paste(lapply(self$`factor_level`, function(x) x$toJSONString()),collapse = ",")
      relationsList = paste(lapply(self$`relations`, function(x) x$toJSONString()),collapse = ",")
       sprintf(
        '{
           "uri": %s,
           "rdf_type": %s,
           "rdf_type_name": %s,
           "name": %s,
           "parent": %s,
           "parent_name": %s,
           "factor_level": [%s],
           "relations": [%s],
           "geometry": %s
        }',
        ifelse(is.null(self$`uri`), "null",jsonlite::toJSON(self$`uri`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`rdf_type`), "null",jsonlite::toJSON(self$`rdf_type`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`rdf_type_name`), "null",jsonlite::toJSON(self$`rdf_type_name`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`name`), "null",jsonlite::toJSON(self$`name`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`parent`), "null",jsonlite::toJSON(self$`parent`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`parent_name`), "null",jsonlite::toJSON(self$`parent_name`,auto_unbox=TRUE, null = "null")),
        factor_levelList,
        relationsList,
        jsonlite::toJSON(self$`geometry`$toJSON(),auto_unbox=TRUE, null = "null")
      )
    },
    fromJSONString = function(ScientificObjectDetailDTOJson) {
      ScientificObjectDetailDTOObject <- jsonlite::fromJSON(ScientificObjectDetailDTOJson)
      self$`uri` <- ScientificObjectDetailDTOObject$`uri`
      self$`rdf_type` <- ScientificObjectDetailDTOObject$`rdf_type`
      self$`rdf_type_name` <- ScientificObjectDetailDTOObject$`rdf_type_name`
      self$`name` <- ScientificObjectDetailDTOObject$`name`
      self$`parent` <- ScientificObjectDetailDTOObject$`parent`
      self$`parent_name` <- ScientificObjectDetailDTOObject$`parent_name`
      self$`factor_level` <- lapply(ScientificObjectDetailDTOObject$`factor_level`, function(x) NamedResourceDTOFactorLevelModel$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`relations` <- lapply(ScientificObjectDetailDTOObject$`relations`, function(x) RDFObjectRelationDTO$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      GeoJsonObjectObject <- GeoJsonObject$new()
      self$`geometry` <- GeoJsonObjectObject$fromJSON(jsonlite::toJSON(ScientificObjectDetailDTOObject$geometry, auto_unbox = TRUE))
    }
  )
)
OpenSILEX/opensilexClientToolsR documentation built on Jan. 28, 2022, 5:03 a.m.