API Docs for: 1.0.0
Show:

Codec Class

Defined in: src\codec.js:1

This class converts the Editor's XML format into a flat javascript format which is inserted into the Neo4j database.

 1. Load XML
 2. Add all nodes as children to the layers (unpack the <mxCell> from the <object> tag)
     the <object> tag is used to wrap an mxCell with its attributes
 3. Remove groups
 4. Edges (There will be no edge without token -> drop layer information)
     - edges don't work inter groups, but they can be intra groups
         -> they have to be unwrapped as well
 5. Flatten the hierarchical tree
     - merge mxCells with their layers to obtain the layer-attributes
 6. Collect all possible attributes

 (1) Drop following attributes

 - Graph
     - grid
     - gridSize
     - guides
     - toolTips
     - connect
     - arrows
     - fold
     - page
     - pageScale


 (2) Parse the style attribute in order to retrieve the following attributes

  - MxCell
     - tokenType


  -> first: read the saved mxgraph with xml2js into a javscript object
  -> then make the validity checks
     - is the structure of the xml correct
         - mxGraph
             - root
                 - cell
                     - geometry
                 - object
                     - cell
                         - geometry

     - are all necessary attributes at hand
         - mxGraphModel
             - dx
             - dy
             - pageWidth
             - pageHeight
         - mxCell
             - id
             - parent
  -> then drop unnecessary attributes
  -> export as GraphML (http://graphml.graphdrawing.org/primer/graphml-primer.html)


 This class was developed by Test Driven Development.

Methods

add_all_completed_fragments_to_neo4j

() Promise

Defined in src\codec.js:451

Adds all fragments that have the flag completed set to true to the database There is SHA1 hash comparing done here in order to eliminate unnecessary computations.

Returns:

Promise:

get_node_by_id

(
  • root
  • id
)
Node

Defined in src\codec.js:186

Works on a mxGraph xml2js-object Finds a node given an id

Parameters:

  • root Object

    mxGraph tree

  • id Object

Returns:

Node:

get_nodes_by_parent_id

(
  • root
  • parent_id
)
Array

Defined in src\codec.js:204

Works on a mxGraph xml2js-object Gets all nodes with a given parent

Parameters:

  • root Object
  • parent_id Object

Returns:

Array:

mxgraph_to_flattened_object

(
  • filename
)

Defined in src\codec.js:258

Converts an mxGraph to a flat object structured as follows

graph.mxGraphModel.data.token1 graph.mxGraphModel.data.token2 graph.mxGraphModel.data.edge1

Parameters:

  • filename Object

mxgraph_to_graphml

(
  • filename
)

Defined in src\codec.js:303

Converts a mxGraph into the GraphML format

It removes groups and is not necessary for the code Only nice to have

Parameters:

  • filename Object

mxgraph_to_layered_object

(
  • filename
)

Defined in src\codec.js:225

Converts the mxGraph to an object structured ad follows

obj.mxGraphModel.layer1.node1

It removes groups

Parameters:

  • filename Object

mxgraph_to_neo4j

(
  • image_id
  • fragment_id
  • overwrite_xml_path
)

Defined in src\codec.js:497

Loads an mxGraph over the flat xml2js-object into the neo4j database

Parameters:

  • image_id Object
  • fragment_id Object
  • overwrite_xml_path Object

    if you don't want to load the standard xml file_path for the fragment use this

mxgraph_to_object

(
  • filename
)

Defined in src\codec.js:94

Parses the mxGraph XML file into a javascript object

Parameters:

  • filename Promise

    the resource to load return

Properties

builder

Object

Defined in src\codec.js:82

The xml2js builder

This object can create xml files

parser

Object

Defined in src\codec.js:74

The xml2js parser