Skip to content

Exporter for Graphical DSL Instance

Sebi1006 edited this page Jun 25, 2021 · 4 revisions

General

The data schema described here is expected for the transfer of an instance of the graphical DSL instance from the frontend to the backend.

Graphical DSL Instance

The model used for the generation is then filled from this predefined data structure in the backend. The data to be transported is read from the UI state of the JointJS framework used in the frontend.

Exporter Structure

Basically, the data is transmitted in a JSON format, which has the in basic structure defined entities at the top level.

Basic Structure

Definition of the top level of the graphical DSL instance.

{
   "name": "String",
   "classes": [],
   "references": [],
   "enums": [],
   "attributes": [],
   "methods": [],
   "uiState":"{json}"
}
Definition:
Key Type Description
name String Name of the graphical DSL instance
classes List of Nodes List of all in the graphical DSL instance modeled nodes
references List of Edges List of all in the graphical DSL instance modeled edges
enums Empty list Deprecated data structures
attributes Empty list Deprecated data structures
methods empty list Deprecated data structures
uiState JSON structure Actually: Empty. In Future: The UI state of the (yFiles) graph

Deprecated Data Structures

At the highest level, the definitions of enums, attributes and methods are no longer supported by the backend. However, since the model in the backend still expects the entities, an empty placeholder must also be passed.

Nodes

Nodes represent the instances of entities defined in the concept.

"nodes": [
   {
      "name": "String",
      "className": "String",
      "outputEdgeNames": ["String"],
      "inputEdgeNames": ["String"],
      "attributes": [],
      "attributeValues": {},
      "methods": []
   }
]
Definition of a node:
Key Type Description
name String Name of the node
className String Name of the concept entity that is instantiated by the node
outputEdgeNames Strings List of all edges starting from the node
inputEdgeNames Strings List of all edges that go into the node
attributes List of Attributes List of definitions of the properties of the attributes that are used
attributeValues Object Values of the attributes
methods empty list Deprecated data structures

Edges

Edges represent the instances of references defined in the concept for specific entities.

"edges": [
   {
      "name": "String",
      "referenceName": "String",
      "sourceNodeName": "String",
      "targetNodeName": "String",
      "attributes": [],
      "attributeValues": {},
      "methods": []
   }
]
Definition of an edge:
Key Type Description
name String Name of the Edge
referenceName String Name of the concept reference that is instantiated by the Edge
sourceNodeName Strings ID of the source node
targetNodeName Strings ID of the target node
attributes List of Attributes List of definitions of the properties of the attributes that are used
attributeValues Object Values of the attributes
methods empty list Deprecated data structures

Attributes

The definition of an attribute is divided into two areas. On the one hand, "attributes" defines the properties of an attribute, while "attributeValues" stores the values belonging to the respective attributes.

The connection between those two areas is made using the name of the attribute. The name is defined in "attributes" and used as a key in "attributeValues". These must match.

attributes

"attributes" defines the properties required for the specific attribute. These can differ from the properties defined in the concept and must therefore be specified individually for each attribute.

"attributes": [
   {
      "name": "AttributName",
      "globalUnique": "Boolean",
      "localUnique": "Boolean",
      "type": "String",
      "default": {
         "value": "String",
         "type": "String"
      },
      "constant": "Boolean",
      "singleAssignment": "Boolean",
      "expression": "String",
      "ordered": "Boolean",
      "transient": "Boolean"
   }
]
Definition of an attribute:
Key Type Description
name String Name of the Attribute
globalUnique Boolean Deprecated propertie
Defines whether the attribute should be globally unique
localUnique Boolean Deprecated propertie
Defines whether the attribute should be locally unique.
type Strings Type of the Attribute
default Object Default value for the attribute.
Corresponds to the structure of an attributeValue
constant Boolean Deprecated propertie
singleAssignment Boolean Deprecated propertie
expression String Deprecated propertie
ordered Boolean Deprecated propertie
transient Boolean Deprecated propertie

attributeValues

"attributeValues" is defined by the name of the attribute that contains a list of values. Each value must define the type of the attribute again in addition to the actual value. Regardless of whether the multiline property of the attribute is set or not, a list of attributes is always expected.

"attributeValues": {
   "anAttributeValueName": [
      {
         "value": "String",
         "type": "String"
      }
   ]
}
Definition of an attribute value:
Key Type Description
value String Value of the Attribute
type String Type of the Attribute

An attribute always returns a list of values, regardless of whether multiline is set in the properties or not.

The type information is defined both in "attributes" and in "attributeValues", which leads to redundancy. Therefore, care should be taken to always use the same type. Or it is recommended to resolve this redundancy in the future.

Example

Example:
{
  "name": "exampleGrapicalDslInstance",
  "graphicalDslId": "543efc93-6501-4bcf-8fa1-15ea2444fc53",
  "nodes": [
    {
      "name": "0b82ac75-5255-4c1a-a4a4-5c0d14036e28",
      "className": "Klasse",
      "outputEdgeNames": [],
      "inputEdgeNames": ["2c4a2b20-b816-471a-9d5c-901a2088c4d0"],
      "attributes": [
        {
          "name": "anAttibute",
          "globalUnique": false,
          "localUnique": false,
          "type": "String",
          "default": {
            "value": "",
            "type": "String"
          },
          "constant": false,
          "singleAssignment": false,
          "expression": "",
          "ordered": false,
          "transient": false
        }, {
          "name": "anotherAttribute",
          "globalUnique": false,
          "localUnique": false,
          "type": "String",
          "default": {
            "value": "",
            "type": "String"
          },
          "constant": false,
          "singleAssignment": false,
          "expression": "",
          "ordered": false,
          "transient": false
        }
      ],
      "attributeValues": {
        "anAttibute": [
          {
            "value": "anExampleValue",
            "type": "String"
          }
        ],
        "anotherAttribute": [
          {
            "value": "anotherExampleValue",
            "type": "String"
          }
        ]
      },
      "methods": []
    },
    {
      "name": "d3af3baa-0567-476f-b1a6-7fb2b3625aab",
      "className": "Klasse",
      "outputEdgeNames": ["2c4a2b20-b816-471a-9d5c-901a2088c4d0"],
      "inputEdgeNames": [],
      "attributes": [],
      "attributeValues": {},
      "methods": []
    }
  ],
  "edges": [
    {
      "name": "2c4a2b20-b816-471a-9d5c-901a2088c4d0",
      "referenceName": "hasReference",
      "sourceNodeName": "d3af3baa-0567-476f-b1a6-7fb2b3625aab",
      "targetNodeName": "0b82ac75-5255-4c1a-a4a4-5c0d14036e28",
      "attributes": [
        {
          "name": "edgeAttribute",
          "globalUnique": false,
          "localUnique": false,
          "type": "String",
          "default": {
            "value": "",
            "type": "String"
          },
          "constant": false,
          "singleAssignment": false,
          "expression": "",
          "ordered": false,
          "transient": false
        }
      ],
      "attributeValues": {
        "edgeAttribute": [
          {
            "value": "ExampleValueInEdges",
            "type": "String"
          }
        ]
      },
      "methods": []
    }
  ],
  "attributes": [],
  "attributeValues": {},
  "methods": []
}