R/Infrastructure.r

# sunagriAPI
#
# An instance of OpenSILEX WebService
#
# OpenAPI spec version: 3.3.0
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' Infrastructure Class
#'
#' @field uri 
#' @field label 
#' @field comment 
#' @field ontologiesReferences 
#' @field properties 
#' @field rdfType 
#' @field rdfTypeLabel 
#' @field parent 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Infrastructure <- R6::R6Class(
  'Infrastructure',
  public = list(
    `uri` = NULL,
    `label` = NULL,
    `comment` = NULL,
    `ontologiesReferences` = NULL,
    `properties` = NULL,
    `rdfType` = NULL,
    `rdfTypeLabel` = NULL,
    `parent` = NULL,
    initialize = function(`uri`, `label`, `comment`, `ontologiesReferences`, `properties`, `rdfType`, `rdfTypeLabel`, `parent`){
      if (!missing(`uri`)) {
        stopifnot(is.character(`uri`), length(`uri`) == 1)
        self$`uri` <- `uri`
      }
      if (!missing(`label`)) {
        stopifnot(is.character(`label`), length(`label`) == 1)
        self$`label` <- `label`
      }
      if (!missing(`comment`)) {
        stopifnot(is.character(`comment`), length(`comment`) == 1)
        self$`comment` <- `comment`
      }
      if (!missing(`ontologiesReferences`)) {
        stopifnot(is.list(`ontologiesReferences`), length(`ontologiesReferences`) != 0)
        lapply(`ontologiesReferences`, function(x) stopifnot(R6::is.R6(x)))
        self$`ontologiesReferences` <- `ontologiesReferences`
      }
      if (!missing(`properties`)) {
        stopifnot(is.list(`properties`), length(`properties`) != 0)
        lapply(`properties`, function(x) stopifnot(R6::is.R6(x)))
        self$`properties` <- `properties`
      }
      if (!missing(`rdfType`)) {
        stopifnot(is.character(`rdfType`), length(`rdfType`) == 1)
        self$`rdfType` <- `rdfType`
      }
      if (!missing(`rdfTypeLabel`)) {
        stopifnot(is.character(`rdfTypeLabel`), length(`rdfTypeLabel`) == 1)
        self$`rdfTypeLabel` <- `rdfTypeLabel`
      }
      if (!missing(`parent`)) {
        stopifnot(is.character(`parent`), length(`parent`) == 1)
        self$`parent` <- `parent`
      }
    },
    toJSON = function() {
      InfrastructureObject <- list()
      if (!is.null(self$`uri`)) {
        InfrastructureObject[['uri']] <- self$`uri`
      }
      if (!is.null(self$`label`)) {
        InfrastructureObject[['label']] <- self$`label`
      }
      if (!is.null(self$`comment`)) {
        InfrastructureObject[['comment']] <- self$`comment`
      }
      if (!is.null(self$`ontologiesReferences`)) {
        InfrastructureObject[['ontologiesReferences']] <- lapply(self$`ontologiesReferences`, function(x) x$toJSON())
      }
      if (!is.null(self$`properties`)) {
        InfrastructureObject[['properties']] <- lapply(self$`properties`, function(x) x$toJSON())
      }
      if (!is.null(self$`rdfType`)) {
        InfrastructureObject[['rdfType']] <- self$`rdfType`
      }
      if (!is.null(self$`rdfTypeLabel`)) {
        InfrastructureObject[['rdfTypeLabel']] <- self$`rdfTypeLabel`
      }
      if (!is.null(self$`parent`)) {
        InfrastructureObject[['parent']] <- self$`parent`
      }

      InfrastructureObject
    },
    fromJSON = function(InfrastructureJson) {
      InfrastructureObject <- jsonlite::fromJSON(InfrastructureJson)
      if (!is.null(InfrastructureObject$`uri`)) {
        self$`uri` <- InfrastructureObject$`uri`
      }
      if (!is.null(InfrastructureObject$`label`)) {
        self$`label` <- InfrastructureObject$`label`
      }
      if (!is.null(InfrastructureObject$`comment`)) {
        self$`comment` <- InfrastructureObject$`comment`
      }
      if (!is.null(InfrastructureObject$`ontologiesReferences`)) {
        self$`ontologiesReferences` <- lapply(InfrastructureObject$`ontologiesReferences`, function(x) {
          ontologiesReferencesObject <- OntologyReference$new()
          ontologiesReferencesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          ontologiesReferencesObject
        })
      }
      if (!is.null(InfrastructureObject$`properties`)) {
        self$`properties` <- lapply(InfrastructureObject$`properties`, function(x) {
          propertiesObject <- Property$new()
          propertiesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          propertiesObject
        })
      }
      if (!is.null(InfrastructureObject$`rdfType`)) {
        self$`rdfType` <- InfrastructureObject$`rdfType`
      }
      if (!is.null(InfrastructureObject$`rdfTypeLabel`)) {
        self$`rdfTypeLabel` <- InfrastructureObject$`rdfTypeLabel`
      }
      if (!is.null(InfrastructureObject$`parent`)) {
        self$`parent` <- InfrastructureObject$`parent`
      }
    },
    fromJSONObject = function(InfrastructureObject) {
      if (!is.null(InfrastructureObject$`uri`)) {
        self$`uri` <- InfrastructureObject$`uri`
      }
      if (!is.null(InfrastructureObject$`label`)) {
        self$`label` <- InfrastructureObject$`label`
      }
      if (!is.null(InfrastructureObject$`comment`)) {
        self$`comment` <- InfrastructureObject$`comment`
      }
      if (!is.null(InfrastructureObject$`ontologiesReferences`)) {
        self$`ontologiesReferences` <- lapply(InfrastructureObject$`ontologiesReferences`, function(x) {
          ontologiesReferencesObject <- OntologyReference$new()
          ontologiesReferencesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          ontologiesReferencesObject
        })
      }
      if (!is.null(InfrastructureObject$`properties`)) {
        self$`properties` <- lapply(InfrastructureObject$`properties`, function(x) {
          propertiesObject <- Property$new()
          propertiesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          propertiesObject
        })
      }
      if (!is.null(InfrastructureObject$`rdfType`)) {
        self$`rdfType` <- InfrastructureObject$`rdfType`
      }
      if (!is.null(InfrastructureObject$`rdfTypeLabel`)) {
        self$`rdfTypeLabel` <- InfrastructureObject$`rdfTypeLabel`
      }
      if (!is.null(InfrastructureObject$`parent`)) {
        self$`parent` <- InfrastructureObject$`parent`
      }
    },
    toJSONString = function() {
      ontologiesReferencesList = paste(lapply(self$`ontologiesReferences`, function(x) x$toJSONString()),collapse = ",")
      propertiesList = paste(lapply(self$`properties`, function(x) x$toJSONString()),collapse = ",")
       sprintf(
        '{
           "uri": %s,
           "label": %s,
           "comment": %s,
           "ontologiesReferences": [%s],
           "properties": [%s],
           "rdfType": %s,
           "rdfTypeLabel": %s,
           "parent": %s
        }',
        jsonlite::toJSON(self$`uri`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`label`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`comment`,auto_unbox=TRUE, null = "null"),
        ontologiesReferencesList,
        propertiesList,
        jsonlite::toJSON(self$`rdfType`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`rdfTypeLabel`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`parent`,auto_unbox=TRUE, null = "null")
      )
    },
    fromJSONString = function(InfrastructureJson) {
      InfrastructureObject <- jsonlite::fromJSON(InfrastructureJson)
      self$`uri` <- InfrastructureObject$`uri`
      self$`label` <- InfrastructureObject$`label`
      self$`comment` <- InfrastructureObject$`comment`
      self$`ontologiesReferences` <- lapply(InfrastructureObject$`ontologiesReferences`, function(x) OntologyReference$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`properties` <- lapply(InfrastructureObject$`properties`, function(x) Property$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`rdfType` <- InfrastructureObject$`rdfType`
      self$`rdfTypeLabel` <- InfrastructureObject$`rdfTypeLabel`
      self$`parent` <- InfrastructureObject$`parent`
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.