Schema Template Tutorial

Item:OSW18201c9a18f64574a12d97efdeb2f953
Schema Template Tutorial [OSW18201c9a18f64574a12d97efdeb2f953]
ID OSW18201c9a18f64574a12d97efdeb2f953
UUID 18201c9a-18f6-4574-a12d-97efdeb2f953
Label Schema Template Tutorial
Machine compatible name SchemaTemplateTutorial
Ontology equivalents
Statements (outgoing)
Statements (incoming)
Keywords

Description

No description found
Item
Type(s)/Category(s) Tutorial
CreativeWork
Article
Tutorial
Prerequisites (required) Handlebars Templates
Prerequisites (optional)
Follow-up (recommended)

View as slide show

Step1: Generate a Template JSON

Template-Schema
    "title": "Generic Model",
    "properties": {
        "parameters": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    }
                }
            }
        },
        "submodels": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "parameters": {
                        "$ref": "#/properties/parameters"
                    },
                    "submodels": {
                        "$ref": "#/properties/submodels"
                    }
                }
            }
        }
    }
}
Template-JSON
{
    "name": "BattmoModel"
    "submodels": [
        {
            "name": "Geometrie",
            "parameters": [
                {
                    "name": "FaceArea"
                }
            ],
            "submodels": [
                {
                    "name": "NegativeElectrode",
                    "parameters": [],
                    "submodels": [
                        {
                            "name": "ActiveMaterial",
                            "parameters": [
                                {
                                    "name": "thickness"
                                }
                            ],
                            "submodels": []
                        }
                    ]
                },
                {
                    "name": "PositiveElectrode",
                    "parameters": [],
                    "submodels": [
                        {
                            "name": "ActiveMaterial",
                            "parameters": [
                                {
                                    "name": "thickness"
                                }
                            ],
                            "submodels": []
                        }
                    ]
                }
            ]
        }
    ]
}

Step2: Generate the schema

Template-JSON
{
    "name": "BattmoModel"
    "submodels": [
        {
            "name": "Geometrie",
            "parameters": [
                {
                    "name": "FaceArea"
                }
            ],
            "submodels": [
                {
                    "name": "NegativeElectrode",
                    "parameters": [],
                    "submodels": [
                        {
                            "name": "ActiveMaterial",
                            "parameters": [
                                {
                                    "name": "thickness"
                                }
                            ],
                            "submodels": []
                        }
                    ]
                },
                {
                    "name": "PositiveElectrode",
                    "parameters": [],
                    "submodels": [
                        {
                            "name": "ActiveMaterial",
                            "parameters": [
                                {
                                    "name": "thickness"
                                }
                            ],
                            "submodels": []
                        }
                    ]
                }
            ]
        }
    ]
}
Template
{ 
    "name": "{{{name}}}", 
    "properties": { 
        {{#each parameters}}
        "{{{name}}}": {}{{#unless @last}},{{/unless}}
        {{/each}}{{#if parameters}}{{#if submodels}},{{/if}}{{/if}}
        {{#each submodels}}
        "{{{name}}}":
            {{> self}}{{#unless @last}},{{/unless}}
        {{/each}} 
    } 
}
Schema
{
    "name":"BattmoModel",
    "properties": {
        "Geometrie":{
            "name":"Geometrie",
            "properties":
            {
                "FaceArea":{},
                "NegativeElectrode":{
                    "name":"NegativeElectrode",
                    "properties":{
                        "ActiveMaterial":{
                            "name":"ActiveMaterial",
                            "properties":{
                                "thickness":{}
                            }
                        }
                    }
                },
                "PositiveElectrode": {
                    "name":"PositiveElectrode",
                    "properties":{
                        "ActiveMaterial":{
                            "name":"ActiveMaterial",
                            "properties": {
                                "thickness":{}
                            }
                        }
                    }
                }
            }
        }
    }
}

Step3: Generate the target JSON

Schema
{
    "name":"BattmoModel",
    "properties": {
        "Geometrie":{
            "name":"Geometrie",
            "properties":
            {
                "FaceArea":{},
                "NegativeElectrode":{
                    "name":"NegativeElectrode",
                    "properties":{
                        "ActiveMaterial":{
                            "name":"ActiveMaterial",
                            "properties":{
                                "thickness":{}
                            }
                        }
                    }
                },
                "PositiveElectrode": {
                    "name":"PositiveElectrode",
                    "properties":{
                        "ActiveMaterial":{
                            "name":"ActiveMaterial",
                            "properties": {
                                "thickness":{}
                            }
                        }
                    }
                }
            }
        }
    }
}
JSON
{
    "name": "MyModel1",
    "geometry": {
        "format": "1D",
        "faceArea": "0.0001",
        "NegativeElectrode": {
            "ActiveMaterial": {
                "thickness": "0.000064"
            }
        },
        "PositiveElectrode": {
            "ActiveMaterial": {
                "thickness": "0.000057"
            }
        },
        "Electrolyte": {
            "Separator": {
                "thickness": "0.000015"
            }
        }
    }
}
jsondata
type
"Category:OSW494f660e6a714a1a9681c517bbb975da"
uuid"18201c9a-18f6-4574-a12d-97efdeb2f953"
name"SchemaTemplateTutorial"
label
text"Schema Template Tutorial"
lang"en"
required_predecessor
"Item:OSW6df03625b42e4b44bd9f2dfa77387887"