{
  "$id": "https://www.hestia.earth/schema-data/json-schema/Infrastructure.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$comment": "Schema version 39.0.1",
  "title": "Infrastructure",
  "description": "A physical item located on a specific [Site](/schema/Site) (e.g., trellises on vineyards) or a physical item held at the [Organisation](/schema/Organisation) level and used across multiple Sites (e.g., a tractor). Infrastructure is depreciated over [Cycles](/schema/Cycle) and then becomes an [Input](/schema/Input) and terms describing the depreciated Infrastructure are available in the [Glossary](/glossary?termType=material). Each item of Infrastructure must be unique, and the fields which determine uniqueness are defined in the <code>[infrastructure](/schema/Site#infrastructure)</code> field of the Site or Organisation.\n",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "type": {
      "type": "string",
      "description": "Type of the Node",
      "default": "Infrastructure",
      "enum": [
        "Infrastructure"
      ]
    },
    "@type": {
      "type": "string",
      "description": "Type of the Node",
      "default": "Infrastructure",
      "enum": [
        "Infrastructure"
      ],
      "extend": true
    },
    "infrastructureId": {
      "type": "string",
      "pattern": "^[\\w\\-\\.\\s\\(\\)]+$",
      "description": "An identifier for each Infrastructure which must be unique within the Site.",
      "examples": [
        "dripIrrigationEquipment"
      ],
      "exportDefaultCSV": true
    },
    "term": {
      "$ref": "./Term-deep.json#",
      "description": "A reference to the Term describing the Infrastructure.",
      "examples": [
        {
          "@id": "dripIrrigationEquipment",
          "@type": "Term",
          "name": "Drip irrigation equipment",
          "termType": "irrigation"
        }
      ],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "name": {
      "type": "string",
      "description": "A name for the Infrastructure, if not described by a Term.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "description": {
      "type": "string",
      "description": "A short description of the Infrastructure. Use this to specify the machinery brand name or manufacturer name (e.g., \"Valtra BM 100\" or \"John Deere 5090E\").",
      "examples": [],
      "exportDefaultCSV": true
    },
    "startDate": {
      "type": "string",
      "description": "The date when the Infrastructure was built ISO 8601 format (YYYY-MM-DD, YYYY-MM, or YYYY).",
      "examples": [
        "1988-01-01"
      ],
      "datePattern": true,
      "exportDefaultCSV": true
    },
    "endDate": {
      "type": "string",
      "description": "The (expected) date when the Infrastructure was (will be) dismantled ISO 8601 format (YYYY-MM-DD, YYYY-MM, or YYYY).",
      "examples": [],
      "datePattern": true,
      "exportDefaultCSV": true
    },
    "defaultLifespan": {
      "type": "number",
      "description": "The (expected) lifespan of all Inputs required to create the Infrastructure, expressed in decimal years. Equal to endDate - startDate. If each Input has a different lifespan (e.g., the greenhouse glass lasts for 5 years while the metal frame lasts for 20 years) this should be specified for each Input.",
      "examples": [
        25
      ],
      "exclusiveMinimum": 0,
      "exportDefaultCSV": true
    },
    "defaultLifespanHours": {
      "type": "number",
      "description": "The (expected) lifespan, expressed in hours.",
      "examples": [],
      "exclusiveMinimum": 0,
      "exportDefaultCSV": true
    },
    "mass": {
      "type": "number",
      "description": "The mass of the Infrastructure, expressed in kilograms. This value should be expressed per the site.area, if site.area is missing then functionalArea should be used to specify the area the value is expressed per.",
      "examples": [],
      "exclusiveMinimum": 0,
      "exportDefaultCSV": true,
      "recommended": true
    },
    "area": {
      "type": "number",
      "description": "The area of the Infrastructure, expressed in hectares. This value should be expressed per the site.area, if site.area is missing then functionalArea should be used to specify the area the value is expressed per.",
      "examples": [],
      "exclusiveMinimum": 0,
      "exportDefaultCSV": true
    },
    "ownershipStatus": {
      "type": "string",
      "description": "The ownership status of the Infrastructure.",
      "examples": [],
      "enum": [
        "owned",
        "rented",
        "borrowed"
      ],
      "exportDefaultCSV": true
    },
    "methodClassification": {
      "type": "string",
      "description": "A classification of the method used to acquire or estimate the term and value. Overrides the defaultMethodClassification specified in the Site.    physical measurement means the amount is quantified using weighing,\n    volume measurement, metering, chemical methods, or other physical approaches.\n\n    verified survey data means the data are initially collected through\n    surveys; all or a subset of the data are verified using physical methods; and\n    erroneous survey data are discarded or corrected.\n\n    non-verified survey data means the data are collected through\n    surveys that have not been subjected to verification.\n\n    modelled means a previously calibrated model is used to estimate\n    this data point from other data points describing this Cycle.\n\n    estimated with assumptions means a documented assumption is used\n    to estimate this data point from other data points describing this Cycle.\n\n    consistent external sources means the data are taken from external\n    datasets referring to different producers/enterprises:\n\n        Using the same technology (defined as the same\n        System or the same key Practices\n        as those specified in the Cycle);\n\n        At the same date (defined as occurring within the\n        startDate and endDate of the Cycle);\n        and\n\n        In the same region or country.\n\n    Modelling or assumptions may have also been used to transform these data.\n\n    inconsistent external sources means the data are taken from external\n    datasets referring to different producers/enterprises:\n\n        Using a different technology (defined as a different\n        System or using different key\n        Practices to those specified in the Cycle);\n\n        At a different date (defined as occurring within the\n        startDate and endDate of the Cycle);\n        or\n\n        In a different region or country.\n\n    Modelling or assumptions may have also been used to transform these data.\n\n    expert opinion means the data have been estimated by experts in\n    the field.\n\n    unsourced assumption means the data do not have a clear source\n    and/or are based on assumptions only.\n",
      "examples": [],
      "enum": [
        "physical measurement",
        "verified survey data",
        "non-verified survey data",
        "modelled",
        "estimated with assumptions",
        "consistent external sources",
        "inconsistent external sources",
        "expert opinion",
        "unsourced assumption"
      ],
      "searchable": true,
      "exportDefaultCSV": true
    },
    "methodClassificationDescription": {
      "type": "string",
      "description": "A justification of the methodClassification used. If the data were estimated with assumptions this field should also describe the assumptions. This is a required field if methodClassification is specified.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "source": {
      "$ref": "./Source-deep.json#",
      "description": "A reference to the Source of these data, if different from the Source of the Site.",
      "examples": [
        {
          "@id": "s66765d",
          "@type": "Source",
          "name": "Gigou (1990)"
        }
      ],
      "exportDefaultCSV": true
    },
    "impactAssessment": {
      "$ref": "./ImpactAssessment-deep.json#",
      "description": "A reference to the node containing environmental impact data related to producing this Infrastructure.",
      "examples": [],
      "exportDefaultCSV": true
    },
    "inputs": {
      "type": "array",
      "items": {
        "$ref": "./Input.json#"
      },
      "description": "The material and substrate inputs required to create the infrastructure. Any other input must be added to cycle.inputs with the relevant operation. The value of these inputs should be expressed per the site.area,if site.area is missing then functionalArea should be used to specify the area the values are expressed per.",
      "examples": [
        [
          {
            "@type": "Input",
            "term": {
              "@id": "polyvinylChloride",
              "@type": "Term",
              "name": "Polyvinyl Chloride",
              "units": "kg",
              "termType": "material"
            },
            "value": [
              1100
            ]
          }
        ]
      ],
      "exportDefaultCSV": true,
      "uniqueArrayItem": [
        "term.@id",
        "transport.term.@id",
        "operation.@id",
        "country.@id"
      ]
    },
    "inputsCompleteness": {
      "type": "boolean",
      "description": "Whether the inputs required to create this Infrastructure are complete. Set to true if every Input used to create this Infrastructure is specified, and to false if any are missing. This is a required field if inputs are specified, and applies to this Infrastructure only, not to the Site or the Cycle as a whole.",
      "examples": [
        true
      ],
      "exportDefaultCSV": true
    },
    "transport": {
      "type": "array",
      "items": {
        "$ref": "./Transport.json#"
      },
      "description": "A list of Transport stages to bring this Infrastructure to the Site or Organisation.",
      "examples": [],
      "exportDefaultCSV": true,
      "uniqueArrayItem": [
        "term.@id",
        "value",
        "distance"
      ]
    },
    "functionalArea": {
      "type": "number",
      "description": "The area the mass, area, or inputs of the Infrastructure is expressed per. This should be used only if site.area is missing.",
      "examples": [],
      "exclusiveMinimum": 0,
      "exportDefaultCSV": true
    },
    "schemaVersion": {
      "type": "string",
      "description": "The version of the schema when these data were created.",
      "examples": [],
      "internal": true
    }
  },
  "allOf": [
    {
      "if": {
        "required": [
          "term"
        ]
      },
      "then": {
        "properties": {
          "term": {
            "properties": {
              "termType": {
                "enum": [
                  "building",
                  "cropSupport",
                  "irrigation",
                  "machinery"
                ]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "inputs"
        ]
      },
      "then": {
        "properties": {
          "inputs": {
            "items": {
              "properties": {
                "term": {
                  "properties": {
                    "termType": {
                      "enum": [
                        "material",
                        "substrate"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "inputs"
        ]
      },
      "then": {
        "required": [
          "inputsCompleteness"
        ]
      }
    },
    {
      "if": {
        "required": [
          "inputs"
        ]
      },
      "then": {
        "properties": {
          "inputs": {
            "items": {
              "if": {
                "required": [
                  "term"
                ],
                "properties": {
                  "term": {
                    "required": [
                      "termType"
                    ],
                    "properties": {
                      "termType": {
                        "enum": [
                          "material",
                          "substrate"
                        ]
                      }
                    }
                  }
                }
              },
              "then": {
                "properties": {
                  "term": {
                    "properties": {
                      "units": {
                        "const": "kg"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    {
      "anyOf": [
        {
          "required": [
            "term"
          ]
        },
        {
          "required": [
            "name"
          ]
        },
        {
          "required": [
            "description"
          ]
        }
      ]
    },
    {
      "if": {
        "required": [
          "methodClassification"
        ]
      },
      "then": {
        "required": [
          "methodClassificationDescription"
        ]
      }
    }
  ],
  "oneOf": [
    {
      "required": [
        "@type"
      ]
    },
    {
      "required": [
        "type"
      ]
    }
  ],
  "required": [
    "infrastructureId",
    "term"
  ]
}