{
    "copyright": "Licensed Materials - Property of IBM. IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2018, 2020. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.",
    "$id": "widgetsSchema.json",
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "widget set",
    "description": "The widget of the dashboard specification, representing ...",
    "definitions": {
        "widgetData": {
            "type": "object",
            "properties": {
                "id": { "$ref": "schemaDefs.json#/definitions/modelId" },
                "itemId": { "$ref": "schemaDefs.json#/definitions/queryId" },
                "itemLabel": { "$ref": "schemaDefs.json#/definitions/name" },
                "selection": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "operation": {
                                "type": "string",
                                "enum": ["add", "remove", "order", "keep"]
                            },
                            "selectDepth": { "type": "string"},
                            "set": { "$ref": "schemaDefs.json#/definitions/strArray" },
                            "filter": {
                                "type": "object",
                                "properties": {
                                    "not": { "$ref": "#/definitions/filterEntry" },
                                    "or": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "type": { "$ref": "#/definitions/filterEntry" },
                                                "not": { "$ref": "#/definitions/filterEntry" }
                                            }
                                        }
                                    }
                                }
                            },
                            "children": { "$ref": "schemaDefs.json#/definitions/strArray" },
                            "sort": {
                                "type": "object",
                                "properties": {
                                    "type": {
                                        "type": "string",
                                        "enum": ["asc", "desc"]
                                    },
                                    "priority": { "type": "number" },
                                    "by": {
                                        "type": "string",
                                        "enum": ["caption"]
                                    }
                                }
                            },
                            "topBottom": {
                                "type": "object",
                                "properties": {
                                    "type": {
                                        "type": "string",
                                        "enum": ["topcount", "bottomcount", "toppercent", "bottompercent"]
                                    },
                                    "value": { "type": "number" }
                                }
                            },
                            "context": {
                                "type": "array",
                                "items": {
                                    "itemId": { "$ref": "schemaDefs.json#/definitions/id" }
                                }
                            }
                        }
                    }
                },
                "format": {
                    "type": "object",
                    "properties": {
                        "formatSpec": {
                            "type": "object",
                            "properties": {
                                "local": { "type": "boolean" },
                                "type": {
                                    "type": "string",
                                    "enum": ["number","percent","currency"]
                                },
                                "timezone": { "type": "string" },
                                "locale": { "type": "string" },
                                "convertPercent": { "type": "boolean" },
                                "currencyCode": { "type": "string" },
                                "currencyDisplay": {
                                    "type": "string",
                                    "enum": ["symbol", "code"]
                                },
                                "maximumFractionDigits": { "type": "number" },
                                "minimumFractionDigits": { "type": "number" },
                                "dateStyle": {
                                    "type": "string",
                                    "enum": ["short", "medium", "full", "long"]

                                },
                                "timeStyle": {
                                    "type": "string",
                                    "enum": ["short", "full", "long"]
                                }
                            }
                        }
                    }
                },
                "aggregate": { "$ref": "#/definitions/aggregationType" }
            }
        },
        "filterEntry": {
            "type": "object",
            "properties": {
                "id": { "$ref": "schemaDefs.json#/definitions/modelId" },
                "columnId": { "$ref": "schemaDefs.json#/definitions/id" },
                "operator": { "$ref": "#/definitions/operatorType" },
                "values": { "$ref": "#/definitions/values" },
                "excludedValues": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/values" }
                },
                "idSuffix": { "type": "integer" },
                "valueDataItem": { "$ref": "schemaDefs.json#/definitions/modelId" },
                "aggregationType": { "$ref": "#/definitions/aggregationType" },
                "preOrPost": {
                    "type": "string",
                    "enum": ["pre", "post"]
                },
                "conditions": {
                    "type": "object",
                    "properties": {
                        "operator": { "$ref": "#/definitions/operatorType" },
                        "itemId": { "$ref": "schemaDefs.json#/definitions/queryId" },
                        "ignoreCase": { "type": "boolean" },
                        "values": { "$ref": "#/definitions/values" },
                        "valueType": {
                            "type": "string",
                            "enum": ["display"]
                        },
                        "and" : {
                            "type": "array",
                            "minItems": 2,
                            "items": {
                                "operator": { "$ref": "#/definitions/operatorType" },
                                "itemId": { "$ref": "schemaDefs.json#/definitions/queryId" },
                                "ignoreCase": { "type": "boolean" },
                                "values": { "$ref": "#/definitions/values" },
                                "valueType": {
                                    "type": "string",
                                    "enum": ["display"]
                                }
                            }
                        },
                        "or" : {
                            "type": "array",
                            "minItems": 2,
                            "items": {
                                "operator": { "$ref": "#/definitions/operatorType" },
                                "itemId": { "$ref": "schemaDefs.json#/definitions/queryId" },
                                "ignoreCase": { "type": "boolean" },
                                "values": { "$ref": "#/definitions/values" },
                                "valueType": {
                                    "type": "string",
                                    "enum": ["display"]
                                }
                            }
                        }
                    }
                },
                "overrideHierarchyDefaultSelection": { "type": "boolean" },
                "visualizationId": { "$ref": "schemaDefs.json#/definitions/id" }
            }
        },
        "slotmapping": {
            "type": "object",
            "properties": {
                "slots": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "name": { "$ref": "schemaDefs.json#/definitions/name" },
                            "caption": { "$ref": "schemaDefs.json#/definitions/name" },
                            "id": { "$ref": "schemaDefs.json#/definitions/name" },
                            "layerId": { "$ref": "schemaDefs.json#/definitions/name" },
                            "dataItems": {
                                "type": "array",
                                "items": { "$ref": "schemaDefs.json#/definitions/modelId" }
                            },
                            "type": {
                                "type": "string",
                                "enum": ["categorical", "ordinal", "any"]
                            }
                        }
                    }
                }
            }
        },
        "possibleKeyDrivers": {
            "type": "array",
            "items": {
                "$ref": "schemaDefs.json#/definitions/queryId"
            }
        },
        "localFilters": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/filterEntry"
            }
        },
        "aggregationType": {
            "type": "string",
            "enum": ["avg", "sum", "min", "max", "count", "countdistinct"]
        },
        "operatorType": {
            "type": "string",
            "enum": ["containsignorecase", "eq", "beginswith", "endswith", "in", "notin", "between", "notbetween", "or", "not", "gt", "lt"]
        },
        "values": {
            "anyOf": [ {
                "$ref": "schemaDefs.json#/definitions/strArray"
            },
            {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "u": {"type": ["string", "number"] },
                        "d": {"type": ["string", "number"] }
                    }
                }
            } ]
        },
        "data" :{
            "type": "object",
            "properties": {
                "dataViews": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "id": { "$ref": "schemaDefs.json#/definitions/modelId" },
                            "modelRef": { "$ref": "schemaDefs.json#/definitions/modelId" },
                            "dataItems": {
                                "type": "array",
                                "items": { "$ref": "#/definitions/widgetData" }
                            }
                        }
                    }
                }
            }
        }
    },
    "type": "object",
    "patternProperties": {
        "[0-9,a-z,-,_]*": {
            "type": "object",
            "allOf": [
                { "$ref": "widgetsTemplateSchema.json#/definitions/widget" },
                {
                    "properties": {
                        "data": { "$ref": "#/definitions/data" },
                        "slotmapping": { "$ref": "#/definitions/slotmapping" },
                        "possibleKeyDrivers": { "$ref": "#/definitions/possibleKeyDrivers" },
                        "localFilters": { "$ref": "#/definitions/localFilters" }
                    }
                }
            ]
        }
    }
}
