R/InfrastructureGetDTO.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


#' InfrastructureGetDTO Class
#'
#' @field uri 
#' @field rdf_type 
#' @field rdf_type_name 
#' @field name 
#' @field parents 
#' @field children 
#' @field groups 
#' @field facilities 
#' @field sites 
#' @field experiments 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
InfrastructureGetDTO <- R6::R6Class(
  'InfrastructureGetDTO',
  public = list(
    `uri` = NULL,
    `rdf_type` = NULL,
    `rdf_type_name` = NULL,
    `name` = NULL,
    `parents` = NULL,
    `children` = NULL,
    `groups` = NULL,
    `facilities` = NULL,
    `sites` = NULL,
    `experiments` = NULL,
    initialize = function(`uri`, `rdf_type`, `rdf_type_name`, `name`, `parents`, `children`, `groups`, `facilities`, `sites`, `experiments`){
      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(`parents`)) {
        stopifnot(is.list(`parents`), length(`parents`) != 0)
        lapply(`parents`, function(x) stopifnot(R6::is.R6(x)))
        self$`parents` <- `parents`
      }
      if (!missing(`children`)) {
        stopifnot(is.list(`children`), length(`children`) != 0)
        lapply(`children`, function(x) stopifnot(R6::is.R6(x)))
        self$`children` <- `children`
      }
      if (!missing(`groups`)) {
        stopifnot(is.list(`groups`), length(`groups`) != 0)
        lapply(`groups`, function(x) stopifnot(R6::is.R6(x)))
        self$`groups` <- `groups`
      }
      if (!missing(`facilities`)) {
        stopifnot(is.list(`facilities`), length(`facilities`) != 0)
        lapply(`facilities`, function(x) stopifnot(R6::is.R6(x)))
        self$`facilities` <- `facilities`
      }
      if (!missing(`sites`)) {
        stopifnot(is.list(`sites`), length(`sites`) != 0)
        lapply(`sites`, function(x) stopifnot(R6::is.R6(x)))
        self$`sites` <- `sites`
      }
      if (!missing(`experiments`)) {
        stopifnot(is.list(`experiments`), length(`experiments`) != 0)
        lapply(`experiments`, function(x) stopifnot(R6::is.R6(x)))
        self$`experiments` <- `experiments`
      }
    },
    toJSON = function() {
      InfrastructureGetDTOObject <- list()
      if (!is.null(self$`uri`)) {
        InfrastructureGetDTOObject[['uri']] <- self$`uri`
      }
      if (!is.null(self$`rdf_type`)) {
        InfrastructureGetDTOObject[['rdf_type']] <- self$`rdf_type`
      }
      if (!is.null(self$`rdf_type_name`)) {
        InfrastructureGetDTOObject[['rdf_type_name']] <- self$`rdf_type_name`
      }
      if (!is.null(self$`name`)) {
        InfrastructureGetDTOObject[['name']] <- self$`name`
      }
      if (!is.null(self$`parents`)) {
        InfrastructureGetDTOObject[['parents']] <- lapply(self$`parents`, function(x) x$toJSON())
      }
      if (!is.null(self$`children`)) {
        InfrastructureGetDTOObject[['children']] <- lapply(self$`children`, function(x) x$toJSON())
      }
      if (!is.null(self$`groups`)) {
        InfrastructureGetDTOObject[['groups']] <- lapply(self$`groups`, function(x) x$toJSON())
      }
      if (!is.null(self$`facilities`)) {
        InfrastructureGetDTOObject[['facilities']] <- lapply(self$`facilities`, function(x) x$toJSON())
      }
      if (!is.null(self$`sites`)) {
        InfrastructureGetDTOObject[['sites']] <- lapply(self$`sites`, function(x) x$toJSON())
      }
      if (!is.null(self$`experiments`)) {
        InfrastructureGetDTOObject[['experiments']] <- lapply(self$`experiments`, function(x) x$toJSON())
      }

      InfrastructureGetDTOObject
    },
    fromJSON = function(InfrastructureGetDTOJson) {
      InfrastructureGetDTOObject <- jsonlite::fromJSON(InfrastructureGetDTOJson)
      if (!is.null(InfrastructureGetDTOObject$`uri`)) {
        self$`uri` <- InfrastructureGetDTOObject$`uri`
      }
      if (!is.null(InfrastructureGetDTOObject$`rdf_type`)) {
        self$`rdf_type` <- InfrastructureGetDTOObject$`rdf_type`
      }
      if (!is.null(InfrastructureGetDTOObject$`rdf_type_name`)) {
        self$`rdf_type_name` <- InfrastructureGetDTOObject$`rdf_type_name`
      }
      if (!is.null(InfrastructureGetDTOObject$`name`)) {
        self$`name` <- InfrastructureGetDTOObject$`name`
      }
      if (!is.null(InfrastructureGetDTOObject$`parents`)) {
        self$`parents` <- lapply(InfrastructureGetDTOObject$`parents`, function(x) {
          parentsObject <- NamedResourceDTOInfrastructureModel$new()
          parentsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          parentsObject
        })
      }
      if (!is.null(InfrastructureGetDTOObject$`children`)) {
        self$`children` <- lapply(InfrastructureGetDTOObject$`children`, function(x) {
          childrenObject <- NamedResourceDTOInfrastructureModel$new()
          childrenObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          childrenObject
        })
      }
      if (!is.null(InfrastructureGetDTOObject$`groups`)) {
        self$`groups` <- lapply(InfrastructureGetDTOObject$`groups`, function(x) {
          groupsObject <- NamedResourceDTOGroupModel$new()
          groupsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          groupsObject
        })
      }
      if (!is.null(InfrastructureGetDTOObject$`facilities`)) {
        self$`facilities` <- lapply(InfrastructureGetDTOObject$`facilities`, function(x) {
          facilitiesObject <- NamedResourceDTOInfrastructureFacilityModel$new()
          facilitiesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          facilitiesObject
        })
      }
      if (!is.null(InfrastructureGetDTOObject$`sites`)) {
        self$`sites` <- lapply(InfrastructureGetDTOObject$`sites`, function(x) {
          sitesObject <- NamedResourceDTOSiteModel$new()
          sitesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          sitesObject
        })
      }
      if (!is.null(InfrastructureGetDTOObject$`experiments`)) {
        self$`experiments` <- lapply(InfrastructureGetDTOObject$`experiments`, function(x) {
          experimentsObject <- NamedResourceDTOExperimentModel$new()
          experimentsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          experimentsObject
        })
      }
    },
    fromJSONObject = function(InfrastructureGetDTOObject) {
      if (!is.null(InfrastructureGetDTOObject$`uri`)) {
        self$`uri` <- InfrastructureGetDTOObject$`uri`
      }
      if (!is.null(InfrastructureGetDTOObject$`rdf_type`)) {
        self$`rdf_type` <- InfrastructureGetDTOObject$`rdf_type`
      }
      if (!is.null(InfrastructureGetDTOObject$`rdf_type_name`)) {
        self$`rdf_type_name` <- InfrastructureGetDTOObject$`rdf_type_name`
      }
      if (!is.null(InfrastructureGetDTOObject$`name`)) {
        self$`name` <- InfrastructureGetDTOObject$`name`
      }
      if (!is.null(InfrastructureGetDTOObject$`parents`)) {
        self$`parents` <- lapply(InfrastructureGetDTOObject$`parents`, function(x) {
          parentsObject <- NamedResourceDTOInfrastructureModel$new()
          parentsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          parentsObject
        })
      }
      if (!is.null(InfrastructureGetDTOObject$`children`)) {
        self$`children` <- lapply(InfrastructureGetDTOObject$`children`, function(x) {
          childrenObject <- NamedResourceDTOInfrastructureModel$new()
          childrenObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          childrenObject
        })
      }
      if (!is.null(InfrastructureGetDTOObject$`groups`)) {
        self$`groups` <- lapply(InfrastructureGetDTOObject$`groups`, function(x) {
          groupsObject <- NamedResourceDTOGroupModel$new()
          groupsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          groupsObject
        })
      }
      if (!is.null(InfrastructureGetDTOObject$`facilities`)) {
        self$`facilities` <- lapply(InfrastructureGetDTOObject$`facilities`, function(x) {
          facilitiesObject <- NamedResourceDTOInfrastructureFacilityModel$new()
          facilitiesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          facilitiesObject
        })
      }
      if (!is.null(InfrastructureGetDTOObject$`sites`)) {
        self$`sites` <- lapply(InfrastructureGetDTOObject$`sites`, function(x) {
          sitesObject <- NamedResourceDTOSiteModel$new()
          sitesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          sitesObject
        })
      }
      if (!is.null(InfrastructureGetDTOObject$`experiments`)) {
        self$`experiments` <- lapply(InfrastructureGetDTOObject$`experiments`, function(x) {
          experimentsObject <- NamedResourceDTOExperimentModel$new()
          experimentsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          experimentsObject
        })
      }
    },
    toJSONString = function() {
      parentsList = paste(lapply(self$`parents`, function(x) x$toJSONString()),collapse = ",")
      childrenList = paste(lapply(self$`children`, function(x) x$toJSONString()),collapse = ",")
      groupsList = paste(lapply(self$`groups`, function(x) x$toJSONString()),collapse = ",")
      facilitiesList = paste(lapply(self$`facilities`, function(x) x$toJSONString()),collapse = ",")
      sitesList = paste(lapply(self$`sites`, function(x) x$toJSONString()),collapse = ",")
      experimentsList = paste(lapply(self$`experiments`, function(x) x$toJSONString()),collapse = ",")
       sprintf(
        '{
           "uri": %s,
           "rdf_type": %s,
           "rdf_type_name": %s,
           "name": %s,
           "parents": [%s],
           "children": [%s],
           "groups": [%s],
           "facilities": [%s],
           "sites": [%s],
           "experiments": [%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")),
        parentsList,
        childrenList,
        groupsList,
        facilitiesList,
        sitesList,
        experimentsList
      )
    },
    fromJSONString = function(InfrastructureGetDTOJson) {
      InfrastructureGetDTOObject <- jsonlite::fromJSON(InfrastructureGetDTOJson)
      self$`uri` <- InfrastructureGetDTOObject$`uri`
      self$`rdf_type` <- InfrastructureGetDTOObject$`rdf_type`
      self$`rdf_type_name` <- InfrastructureGetDTOObject$`rdf_type_name`
      self$`name` <- InfrastructureGetDTOObject$`name`
      self$`parents` <- lapply(InfrastructureGetDTOObject$`parents`, function(x) NamedResourceDTOInfrastructureModel$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`children` <- lapply(InfrastructureGetDTOObject$`children`, function(x) NamedResourceDTOInfrastructureModel$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`groups` <- lapply(InfrastructureGetDTOObject$`groups`, function(x) NamedResourceDTOGroupModel$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`facilities` <- lapply(InfrastructureGetDTOObject$`facilities`, function(x) NamedResourceDTOInfrastructureFacilityModel$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`sites` <- lapply(InfrastructureGetDTOObject$`sites`, function(x) NamedResourceDTOSiteModel$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`experiments` <- lapply(InfrastructureGetDTOObject$`experiments`, function(x) NamedResourceDTOExperimentModel$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
    }
  )
)
OpenSILEX/opensilexClientToolsR documentation built on Jan. 28, 2022, 5:03 a.m.