mobo logo

Complex Data Model Generation with mobo

Simon Heimler (www.fannon.de)
University of Applied Sciences Augsburg, Germany
Computer Bauer GmbH, Munich, Germany

Preface

  • Prototype in action
  • Uses a very different approach than current solutions.
  • Open Source and open to discussion!

Appetizer first

Outline

Using JSON Schema...

...for an object oriented...

...model development...

...workflow...

...in Semantic MediaWiki.

Conclusion & Live-Demo

USING JSON Schema

JSON Schema

  • Data format for describing data formats / objects
  • Easy to read/write for both humands and machines
  • Published draft at IETF (Internet Engineering Task Force)
  • Similar to XML Schema, but based on JSON

Example File


{
    "firstName": "Simon",
    "lastName": "Heimler",
    "age": 27
}
                

Example JSON Schema


{
    "title": "Person",
    "type": "object",
    "properties": {
        "firstName": {
            "type": "string"
        },
        "lastName": {
            "type": "string"
        },
        "age": {
            "description": "Age in years",
            "type": "integer",
            "minimum": 0
        }
    },
    "required": ["firstName", "lastName"]
}
                

Use cases

json-schema.org

http://json-schema.org/

object-oriented

Object orientation

  • More complex SMW models tend to have much redundancy
  • This can lead to inconsistency - fast
  • Inheritance can keep the model DRY (Dont Repeat Yourself)
  • The OO paradigma is simple and well understood

Object-oriented JSON Schema

  • JSON Schema uses "$ref" to include and reuse schemas
  • BUT: There is no inheritance behaviour defined!

Own implementation

  • Implemented custom, more explicit "$extend" attribute which does proper inheritance
  • Through "$extend" the relationship between the objects are defined, too
  • This leads to a (graph) database model that fits SMW well

SMW Specifics

  • Uses Fields, Models and Forms that roughly equivalent SMWs Attributes, Templates and Forms
  • Additional schema attributes that reflect SMW/SF settings
  • Form settings can be defined as low as in Fields and are inherited / overwritten on the way up

Concept

Object-oriented modeling concept

/model/_Shape.json


{
    "$schema": "http://json-schema.org/draft-04/schema#",

    "title": "Shape",
    "description": "Generic Shape",
    "type": "object",

    "properties": {
        "x": {
            "type": "integer"
        },
        "y": {
            "type": "integer"
        }
    },
    "required": ["x", "y"],

    "abstract": true
}
                

/model/Circle.json


{
    "$extend": "/model/_Shape.json",

    "title": "Circle",
    "type": "object",

    "properties": {
        "radius": { "$extend": "/field/radius.json" },
    },
    "required": ["x", "y", "radius"],

    "abstract": false
}
                

/field/radius.json


{
    "title": "radius",
    "description": "The radius of a shape",

    "type": "number",
    "minimum": 0,

    "smw_form": {
        "input type": "text with autocomplete"
    }
}
                

model development

The model is a collection of folders and JSON files on your filesystem.
Use your favorite text editor and VCS!
  • It is possible to split the model into several modular, reusable sub-projects.
  • With VCS its possible to go back and forward in the development state in seconds.
  • With VCS the model can be developed and synced between many persons.
Web based GUI for browsing/viewing the final, inherited model state
... and the wikitext results
Interactive model graph explorer

workflow

GETTING STARTED

  • npm install mobo -g
    Installs mobo as a global NPM (Node.js) package
  • mkdir new_project && cd new_project
    Creates a new directory and enters it
  • mobo --init
    Initializes a new (barebone) project
  • nano settings.json
    Adjust settings.json (login data!)

Using mobo

  • mobo

Interactive Workflow

  1. A file of the development model is changed / added
  2. mobo detects the change and re-generates the model
  3. Model is validated. Errors and warnings will be displayed
  4. The result is compared to last upload state and only the changed sites will be uploaded via a Bot account

Semantic MediaWiki

Target Installation

  • Semantic MediaWiki and Semantic Forms are required
  • HeaderTabs Extension is supported
  • Visual Editor TemplateData Extension is supported;
    will be used for template documentation
Form with HeaderTabs
Site with HeaderTabs
Documentation and usage snippet is auto generated
A report is generated and uploaded

Conclusion

  • Very useful toolset for my own model development process
  • Great at keeping the model consistent, possible to update dozends of wiki sites in a minute.
  • Works well with prototyping / iterative development process.
  • SMW/SF doesn't support some features that would come cheap (HTML5 front-end validation!)
  • Completely independent from SMW/SF
  • Adds to the learning curve of SMW
  • Model needs to have a certain complexity to make using the toolset viable
  • No GUI for editing

Project state

  • Working Prototype
  • Currently tailored to the specific needs of a specific project,
    but this might change.
  • Open Source at github.com/Fannon/mobo

DEMO

Questions?

Thanks for listening!

If you've got feedback or questions, just talk to me!

www.fannon.de/p/jsonmodel

Excursus

WHY NO OWLs?

  • OWL is more flexible and powerful
  • OWL supports reasoning / inference
  • OWL is much more difficult than JSON Schema
  • Simple things like hard validation are difficult with OWL.
    It requires another complex layer on top of a already complex system. (e.g. Pellet Integrity Constraints)

My personal philosophy

The foundations should be as easy and barebone as possible while beeing still highly flexible / modular

More complex features should come on top of that

Excursus

How about
Page Schemas?

  • Schema editor in the browser
  • Easy to understand / use
  • Requires no additonal technologies
  • Tightly integrated in SMW
  • Supports no inheritance
  • No Validation
  • Slower Workflow