Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wp-graphql domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/wp-includes/functions.php on line 6114
How To Define Node Templates - SingerLinks

How To Define Node Templates

Node Template Editor

Video – How To Create A Node Template

The NodeEra Node Template Editor provides the mechanism for defining Neo4j Node Types. The Node Template defines the combination of Labels, Properties, and Constraints that define a certain “type” of node. You can think of this as something like a “table” definition in a relational database. Neo4j doesn’t have any notion of defining types of nodes so this only occurs in your design model. Node Templates have a number of uses within NodeEra:

  • Provide an understanding of the business data definitions in your graph model
    • Create diagrams that illustrate the design of your graph
    • Add additional description metadata
  • Allow smart data editing of nodes based on the node template
  • Automatically generate Cypher queries based on the node template

How to access the node template editor

Figure 1: Create a new node template

In the Project Items tree view you can add a new Node Template by right clicking on the Node Template heading.

For existing node templates:

Double click on the name and the node template editor will open.

right click on the name and you will get the pop-up menu shown above.

  • Properties… – this will display the node template editor.
  • Rename… – this will display the rename object dialog.
  • Delete… – this will display the delete object dialog.
  • Where Used… – this will display the where used dialog.
  • Generate Cypher Match – This will generate a cypher match statement based on the node template and display it in the Schema Cypher editor where you can run the query.
Figure 2: Add New Node Template On The Template Diagram

With a Template Diagram open, you can click on the Add New Node Template button. This will open the node template editor and place the new node template on the diagram. See the Template Diagram Tutorial for more help on creating template diagrams.

How To Define a Node Template

The node template editor has several tabs that allow you to define your node template. The tabs are:

  • Definition – define the labels and properties
  • Constraint – define any property constraints and custom indexes
  • Description – provide additional text metadata
  • Formats – define display formats used on diagrams
  • Data – query, add new, delete, or edit nodes in the database
Figure 3: Definition Tab

The definition tab defines the node labels and properties.

The fields on the dialog are defined as follows:Name: This is the name of the node template in NodeEra.
Labels Grid: The Labels grid allows you to define the labels for the node. The grid has the following buttons that control actions in the grid:
Add: This button will add a new row to the grid. Once the row is added you can edit the columns in the row (see section below).
Remove: This will remove the selected property from the grid. This does not remove properties from nodes in the databases.
Up: This moves the selected property up one row in the grid.
Down: This moves the selected property down one row in the grid.

Columns in the Label Grid

After you add a row to the label grid you enter each column in the grid itself. The columns are described below.Label: This is the label name used in Cypher queries. You can select from existing label names or enter a new label name.
Required: This checkbox allows you to define the label as being required without creating a NodeKey constraint. NodeEra will respect this when using the Data tab to add/update/delete node data.
Node Key: The checkbox indicates if this label participates in a Node Key constraint defined on it. See the “Constraints” tab for how to create the constraint. The checkbox is read only.

Properties Grid: The properties grid allows you to define properties for the node. The grid has the following buttons that control actions in the grid:Add: This button will add a new row to the grid. Once the row is added you can edit the columns in the row (see section below).
Remove: This will remove the selected property from the grid. This does not remove properties from nodes in the databases.
Set Default Null: If you have provided a default value for a property in the grid and then change your mind, you cannot simply clear the default value column. That will be seen as a default value of “empty string”. You need to select the property in question and click the “Set Default Null” button to remove the default value.
Up: This moves the selected property up one row in the grid.
Down: This moves the selected property down one row in the grid.
Columns in the Property Grid

After you add a row to the property grid you enter each column in the grid itself. The columns are described below.Property: This is the property name used in Cypher queries. You can select from existing property names or enter a new property name.
Data Type: If you have entered a property name that isn’t defined in the project you can specify the data type by selecting one from the list. If you property is already defined in the project, the system will select the correct one for you. You can’t change the datatype here, you must edit the property itself from the project tree view.
Required: This checkbox allows you to define the property as being required without creating an exists constraint. NodeEra will respect this when using the Data tab to add/update/delete relationship data.
Default Value: This allows you to define a default value which NodeEra will use when using the Data tab to add/update/delete relationship data.
Exists/Unique/Node Key: The checkboxes indicate if this property participates in a constraint defined on it. See the “Constraints” tab for how to create the constraint. The checkbox is read only.

How To Define A Neo4j Constraint

Figure 4: Constraint Tab

The Constraint Grid
The constraint grid provides the ability to define constraints on nodes. Once you have defined constraints in your project model, you can generate Cypher create statements using the Project – Forward Engineer menu option.

The grid has the following buttons that control actions in the grid:Add: This will add a new row to the constraints grid.
Remove: This will remove the selected row from the constraints grid.

Columns in the Constraint Grid

After you add a row to the constraint grid you enter each column in the grid itself. The columns are described below.Constraint Type: There is only one constraint type for relationship properties – “Property Exists”.
Label: The dropdown will show you all labels defined for this node template. Select one to define the constraint.
Property: The dropdown will show you all the properties defined for this node template. Select one or more to define the constraint.

Figure 5: Node Key Constraint

In the example above, a Node Key constraint has been defined using the “Person” label and the “firstName” and “lastName” properties.

Indexes Grid

The indexes grid provides the ability to define indexes on nodes. Once you have defined indexes in your project model, you can generate Cypher create statements using the Project – Forward Engineer menu option. Indexes associated with constraints are automatically added to the grid for you.

The grid has the following buttons that control actions in the grid:

Add: This will add a new row to the indexes grid.

Remove: This will remove the selected row from the indexes grid. You cannot remove “Auto Generated” indexes from the grid as they are associated with a constraint. Removing the constraint will automatically remove the index.

Columns in the Index Grid

After you add a row to the index grid you enter each column in the grid itself. The columns are described below.

Auto Generated: This indicates if the index is automatically generated by virtue of creating a constraint defined in the constraint grid.

“Yes” means the index is automatically generated

“No” means this is an index you defined

Label: The dropdown will show you all labels defined for this node template. Select one to define the index.

Property: The dropdown will show you all the properties defined for this node template. Select one or more to define the index.

Figure 6: Constraint Checkboxes

Once you have defined constraints on the Constraints tab, the Definition tab will check the appropriate checkboxes to indicate the constraint exists.

How To Describe The Node Template

Figure 7: Definition Tab

This tab provides descriptive metadata for the node template. You can enter a description at the top of the form. The “Generated Description” section of the form shows all the descriptive metadata from the labels, properties, and relationships that make up the node definition.

The descriptions will be used for the generated HTML pages. See Project – Generate HTML menu option.

How To Define Display Formats For Node Templates

Figure 8: Node Template Formats

You can define various display characteristics that control how templates/instances are displayed on diagrams. See the Display Format Tutorial for more details.Node Template Format – this section controls how Node templates will be displayed on a template diagram.
•  Click the “Custom Format” radio button and then the “Define Format” button to create a custom display format.
•  Click the “Default Format” radio button to use the display format defined in Project Settings. Node Instance Format – this section controls how instance nodes that are based on this Node template will be displayed on an instance diagram.
•  Click the “Custom Format” radio button and then the “Define Format” button to create a custom display format.
•  Click the “Default Format” radio button to use the display format defined in Project Settings.

How To Add, Modify, and Delete Nodes Based On The Node Template

Figure 9: Data Editor

The Data tab provides a data entry facility based on the node template. You can add/edit/delete nodes in the Neo4j database that match the template definition. When you click on the Data tab, NodeEra will automatically generate a Cypher query and retrieve all matching nodes and display them in the grid.

Columns in the Node Editor Grid

The columns in the data editor grid are based on the node template.

nodeID: This is the Neo4j node id. It cannot be edited.

labels: The next columns will be for each label in the template. They are represented by checkboxes. Required labels will always be checked and cannot be changed. Optional labels (i.e. labels that do not have the required checkbox checked on the definition tab) can be edited. You can check or uncheck these labels in the grid which will update the node in the database.

Properties: Any properties defined for the node template will be shown after the label columns described above. These properties can be edited right in the grid.

Buttons on the Node Editor Grid

The standard navigation buttons are described in the Cypher Data Grid Tutorial. On the right hand side are three new buttons described below.

Add New: This button will bring up the add new node dialog described below.

Delete: This button will delete the node selected in the grid.

Set Value Null: This button will set the selected property value null in the database. Note that Neo4j does not support “null values” so what actually happens is the property is removed from the node in the database.

New Node Dialog

Figure 10: Add New Node

The Add New Node dialog provides a facility for adding nodes to the Neo4j database that are consistent with the node template.

The label grid shows each label defined for the node template. Required labels are checked and cannot be changed. Optional labels are initially unchecked but can be checked to indicate their occurrence in this node.

The property grid shows each property defined for the node template. You can enter a value for each property in the Value column. If you enter a value and then decide you would rather leave the property null use the “Set Value Null” button on the right.

When you have completed entering the data, press the “Add New Node” button. NodeEra will create a new node in the Neo4j database. Note that if you click the button again, NodeEra will create another node that will be exactly the same.

Total
0
Shares
Previous Post

NodeEra Cypher Editor and Data Grid


Notice: Function wpdb::prepare was called incorrectly. The query does not contain the correct number of placeholders (6) for the number of arguments passed (4). Please see Debugging in WordPress for more information. (This message was added in version 4.8.3.) in /var/www/wp-includes/functions.php on line 6114
Next Post

How To Define Relationship Templates

Related Posts