{
    "title": "plan",
    "id": "schemas/order/plan",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "javaType": "com.sos.joc.model.plan.Plan",
    "type": "object",
    "required": [
        "deliveryDate",
        "planItems"
    ],
    "properties": {
        "deliveryDate": {
            "id": "schemas/common/timestamp",
            "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
            "type": "string",
            "format": "date-time"
        },
        "created": {
            "javaType": "com.sos.joc.model.plan.PlanCreated",
            "type": "object",
            "properties": {
                "until": {
                    "id": "schemas/common/timestamp",
                    "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                    "type": "string",
                    "format": "date-time"
                },
                "days": {
                    "type": "../common/nonNegativeInteger-schema.json"
                }
            }
        },
        "planItems": {
            "type": "array",
            "items": {
                "id": "schemas/plan/planItem",
                "type": "object",
                "oneOf": [
                    {
                        "required": [
                            "surveyDate",
                            "jobChain",
                            "orderId",
                            "plannedStartTime",
                            "expectedEndTime",
                            "startMode"
                        ]
                    },
                    {
                        "required": [
                            "surveyDate",
                            "job",
                            "plannedStartTime",
                            "expectedEndTime",
                            "startMode"
                        ]
                    }
                ],
                "properties": {
                    "surveyDate": {
                        "id": "schemas/common/surveyDate_p",
                        "description": "Date of the inventory data. Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ",
                        "type": "string",
                        "format": "date-time"
                    },
                    "job": {
                        "id": "schemas/common/path",
                        "description": "absolute path based on live folder of a JobScheduler object.",
                        "type": "string",
                        "pattern": "/([^/]+/)*[^/]+"
                    },
                    "jobChain": {
                        "id": "schemas/common/path",
                        "description": "absolute path based on live folder of a JobScheduler object.",
                        "type": "string",
                        "pattern": "/([^/]+/)*[^/]+"
                    },
                    "orderId": {
                        "type": "string"
                    },
                    "plannedStartTime": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "expectedEndTime": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "startTime": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "endTime": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "historyId": {
                        "type": "string"
                    },
                    "node": {
                        "description": "only for orders",
                        "type": "string"
                    },
                    "exitCode": {
                        "id": "schemas/common/nonNegativeInteger",
                        "type": "integer",
                        "minimum": 0
                    },
                    "error": {
                        "id": "schemas/common/error",
                        "javaType": "com.sos.joc.model.common.Err",
                        "type": "object",
                        "required": [
                            "code",
                            "message"
                        ],
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            }
                        }
                    },
                    "startMode": {
                        "description": "0=single_start, 1=start_start_repeat, 2=start_end_repeat",
                        "type": "integer",
                        "default": 0
                    },
                    "period": {
                        "description": "undefined for startMode=0",
                        "required": [
                            "begin",
                            "end",
                            "repeat"
                        ],
                        "type": "object",
                        "properties": {
                            "begin": {
                                "id": "schemas/common/timestamp",
                                "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                                "type": "string",
                                "format": "date-time"
                            },
                            "end": {
                                "id": "schemas/common/timestamp",
                                "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                                "type": "string",
                                "format": "date-time"
                            },
                            "repeat": {
                                "id": "schemas/common/nonNegativeInteger",
                                "type": "integer",
                                "minimum": 0
                            }
                        }
                    },
                    "late": {
                        "type": "boolean"
                    },
                    "state": {
                        "id": "schemas/plan/planState",
                        "javaType": "com.sos.joc.model.plan.PlanState",
                        "type": "object",
                        "required": [
                            "severity",
                            "_text"
                        ],
                        "properties": {
                            "severity": {
                                "description": "0=SUCCESSFUL, 1=INCOMPLETE, 2=FAILED, 4=PLANNED",
                                "type": "integer"
                            },
                            "_text": {
                                "id": "schemas/plan/planStateText",
                                "javaType": "com.sos.joc.model.plan.PlanStateText",
                                "type": "string",
                                "enum": [
                                    "PLANNED",
                                    "SUCCESSFUL",
                                    "INCOMPLETE",
                                    "FAILED"
                                ]
                            }
                        }
                    }
                }
            }
        }
    }
}