{
  "$schema": "https://json-schema.org/draft-07/schema#",
  "type": "object",
  "$id": "https://github.com/emdb-empiar/emdb-json-schemas/blob/master/emdb_exchange_schema/emdb_exchange_schema.json",
  "title": "EMDB exchange json schema",
  "description": "This schema contains information about files and data provided in the EMDB exchange",
  "patternProperties": {"^EMD-[0-9]{4,}$": {"$ref": "#/definitions/entry_info"}},
  "additionalProperties": false,
  "definitions": {
    "entry_info": {
      "type": "object",
      "properties": {
        "site": { "enum": ["PDBe", "RCSB", "PDBj", "PDBc"]},
        "status": {"enum": ["AUCO", "AUTH", "AUXS", "AUXU", "HOLD", "HOLD8W", "HPUB", "OBS", "POLC", "PROC", "REFI", "REL", "REPL", "REUP", "WAIT", "WDRN"]},
        "Dep_ID": {"type": "string", "pattern": "^D_[0-9]+$"},
        "last_update_date": { "type": "string", "format": "date"},
        "map_release_date": { "type": "string", "format": "date" },
        "header_release_date": { "type": "string", "format": "date"},
        "obsoleted_date": { "type": "string", "format": "date" },
        "withdrawn_date": { "type": "string", "format": "date" },
        "update": {"type": "boolean"},
        "header": {"$ref": "#/definitions/files_type"},
        "metadata": {"$ref": "#/definitions/files_type"},
        "map": {"$ref": "#/definitions/files_type"},
        "masks": {"$ref": "#/definitions/files_type"},
        "fscs": {"$ref": "#/definitions/files_type"},
        "images": {"$ref": "#/definitions/files_type"},
        "half_maps": {"$ref": "#/definitions/files_type"},
        "additional_maps": {"$ref": "#/definitions/files_type"},
        "current_reports": {"$ref": "#/definitions/files_type"},
        "missing_reports": {"$ref": "#/definitions/files_type"},
        "checks": {"$ref": "#/definitions/checks_type"}
      },
      "required": ["site", "missing_reports", "checks"]
    },
    "files_type": {
      "type": "array",
      "items": {"type": "object"},
      "properties": {
          "file_path": {"type": "string"},
          "file_name": {"type": "string"},
          "to_copy": {"type": "boolean"},
          "copied_to": {"type": "string"}
      },
      "required": ["file_path", "file_name", "to_copy", "copied_to"]
    },
    "checks_type": {
      "type": "object",
      "properties": {
        "blockers": {"$ref": "#/definitions/blockers_type"},
        "warnings": {"$ref": "#/definitions/warnings_type"}
      },
      "required": ["blockers"]
    },
    "check_results_type": {
      "type": "array",
      "items": [{"type": "boolean"}, {"type": "string"}]
    },
    "blockers_type": {
      "type": "object",
      "properties": {
        "entry_dir_exists": {"$ref": "#/definitions/check_results_type"},
        "header_dir_exists": {"$ref": "#/definitions/check_results_type"},
        "header_file_exists": {"$ref": "#/definitions/check_results_type"},
        "one_header": {"$ref": "#/definitions/check_results_type"},
        "header_has_data": {"$ref": "#/definitions/check_results_type"},
        "metadata_dir_exists": {"$ref": "#/definitions/check_results_type"},
        "mmcif_file_exists": {"$ref": "#/definitions/check_results_type"},
        "one_mmcif_file": {"$ref": "#/definitions/check_results_type"},
        "mmcif_has_data": {"$ref": "#/definitions/check_results_type"},
        "correct_num_of_half_maps": {"$ref": "#/definitions/check_results_type"},
        "correct_num_of_primary_maps": {"$ref": "#/definitions/check_results_type"},
        "all_files_have_data": {"$ref": "#/definitions/check_results_type"},
        "image_content_correct": {"$ref": "#/definitions/check_results_type"},
        "id_in_header_matches": {"$ref": "#/definitions/check_results_type"},
        "header_file_validates": {"$ref": "#/definitions/check_results_type"},
        "reports_validate": {"$ref": "#/definitions/check_results_type"},
        "map_file_validates": {"$ref": "#/definitions/check_results_type"},
        "miss_val_rep_entry_in_prep": {"$ref": "#/definitions/check_results_type"},
        "curr_val_rep_entry_in_exchange": {"$ref": "#/definitions/check_results_type"},
        "all_files_ref_in_header": {"$ref": "#/definitions/check_results_type"},
        "map_dir_exists": {"$ref": "#/definitions/check_results_type"},
        "map_file_exists": {"$ref": "#/definitions/check_results_type"},
        "image_dir_exists": {"$ref": "#/definitions/check_results_type"},
        "image_file_exists": {"$ref": "#/definitions/check_results_type"},
        "release_date_correct": {"$ref": "#/definitions/check_results_type"},
        "update_date_correct": {"$ref": "#/definitions/check_results_type"},
        "update_entry_released": {"$ref": "#/definitions/check_results_type"},
        "obsolete_date_correct": {"$ref": "#/definitions/check_results_type"}
      }
    },
    "warnings_type": {
      "type": "object",
      "properties": {
        "summary_exists": {"$ref": "#/definitions/check_results_type"},
        "no_stray_files": {"$ref": "#/definitions/check_results_type"},
        "correct_num_of_images": {"$ref": "#/definitions/check_results_type"},
        "image_ext_correct": {"$ref": "#/definitions/check_results_type"},
        "all_dirs_not_empty": {"$ref": "#/definitions/check_results_type"},
        "file_names_correct": {"$ref": "#/definitions/check_results_type"},
        "file_names_incorrect": {"$ref": "#/definitions/check_results_type"},
        "val_dir_exists": {"$ref": "#/definitions/check_results_type"},
        "correct_number_of_reports": {"$ref": "#/definitions/check_results_type"},
        "map_only_val_reps_exist": {"$ref": "#/definitions/check_results_type"},
        "map_statistics_correct": {"$ref": "#/definitions/check_results_type"},
        "fscs_content_correct": {"$ref": "#/definitions/check_results_type"},
        "associate_entries_from_same_site": {"$ref": "#/definitions/check_results_type"}
      }
    }
  }
}