API Docs for: 1.0.0
Show:

Database Class

Defined in: src\database.js:17

Database

Contains all the database access methods.

Methods

_get_driver

() Driver private

Defined in src\database.js:145

Get the database driver stores the instance in _driver makes use of the development flag in order to use or not use basic auth

Returns:

Driver:

Returns a bolt:// driver instance

_get_session

() Session private

Defined in src\database.js:161

Get a session to execute Neo4J Cypher code on

Returns:

Session:

_hygiene

() Promise

Defined in src\database.js:191

Clean up the database on login

  1. remove nodes without edges (-> MetaGroups that are not referenced)

Returns:

Promise:

_remove_constraints

() Promise private

Defined in src\database.js:205

Remove the constraints

Returns:

Promise:

add_comment_to_fragment

(
  • fragment_id
  • comment
)
Promise

Defined in src\database.js:498

Sets the comment attribute of a fragment

Parameters:

  • fragment_id Object
  • comment Object

    string

Returns:

Promise:

add_constraints

() Session

Defined in src\database.js:179

Add the necessary constraints to create something like a schema

  1. The file_path of an image is unique

Returns:

Session:

add_edge

(
  • image_id
  • fragment_id
  • source_enum
  • target_enum
  • edge_attributes
)
Promise

Defined in src\database.js:720

Adds an edge between two nodes in a fragment of an image

Promise:success number_of_created_edges

Parameters:

  • image_id Object
  • fragment_id Object
  • source_enum Object
  • target_enum Object
  • edge_attributes Object

Returns:

Promise:

add_edge

(
  • node_id
  • frame_name
  • groupType
)
Promise

Defined in src\database.js:691

Adds an edge between a frame from a group and a global frame so called 'meta frame'

Also creates the 'meta frame' if it does not exist *

Parameters:

  • node_id Object
  • frame_name Object
  • groupType Object

Returns:

Promise:

add_fragment

(
  • image_id
  • fragment_name
)
Promise

Defined in src\database.js:468

Adds a fragment to an image Every image can have multiple fragments the name of the fragment is unique

Parameters:

  • image_id Object
  • fragment_name Object

    The identifier for the fragment

Returns:

Promise:

add_image

(
  • file_path
  • exif_data
)
Promise

Defined in src\database.js:258

Adds an image to the database Sets attributes according to the exif_data Fallback for upload_date is now in seconds (Math.round(d.getTime()))

The exif_data shall be an objects with the attributes 'exif: { 'ExifImageWidth': ..., 'ExifImageHeight': ..., 'CreateDate': ... }, 'gps: {...}

CreateDate is handled by the parse(...) function

Parameters:

  • file_path String

    The unique identifier for an image

  • exif_data Object

Returns:

Promise:

add_node

(
  • image_id
  • fragment_id
  • node_label
  • node_attributes
)
Promise

Defined in src\database.js:650

Adds a node to a fragment of an image

Promise:success number_of_created_nodes

Parameters:

  • image_id Object
  • fragment_id Object
  • node_label Object
  • node_attributes Object

Returns:

Promise:

get_all_completed_fragments

() | Promise

Defined in src\database.js:838

Get all completed fragments

Returns:

| Promise:

get_all_fragments

() Promise

Defined in src\database.js:630

Get the fragment of an image by name

Returns:

Promise:

get_all_images

() Promise

Defined in src\database.js:755

Returns a promise with an array of records of images ordered by last_edit_date, upload_date

Returns:

Promise:

Example:

  database.get_all_images().then(function (results) {
       var row_data = [];
       results.forEach(function (r) {
           row_data.push([r.get('ident'), r.get('file_path'), r.get('upload_date'), r.get('completed')]);
       });
       res.render('table',
           {
               title: 'Hey',
               message: 'Hello there!',
               rows: row_data
           });
       }
   );

get_all_property_keys_for_token

(
  • search_string
  • label
  • token_type
)
Promise

Defined in src\database.js:864

Returns all possible property keys for tokens filtered by search_string Is used for the autocomplete function of the add-property-input

Promise:success: Array of strings

Parameters:

  • search_string String

    Empty string gives all possible values

  • label Object
  • token_type Object

Returns:

Promise:

get_all_property_values_for_token

(
  • property
  • search_string
)
Promise

Defined in src\database.js:908

Returns all distinct values for the given property in a string list in a promise Is used for the autocomplete function of the property values

Promise:success: Array of strings *

Parameters:

  • property String

    the name of a property of tokens

  • search_string String

    that filters the result (empty string is not filter)

Returns:

Promise:

get_fragment

(
  • image_file_path
  • fragment_name
)
Promise

Defined in src\database.js:578

Get the fragment of an image by name

Parameters:

  • image_file_path String

    The unique id for the image

  • fragment_name Object

    The identifier for the fragments

Returns:

Promise:

get_fragment_bounding_box

(
  • token_id
)
Promise

Defined in src\database.js:383

Get the bounding box of a fragment

This method looks for the lowest x and y coordinates of all sibling tokens and for the highest x and y coordinates of all siblings

Used for heat map generation

Parameters:

  • token_id Int

    The unique identifier for a token

Returns:

Promise:

get_fragment_by_id

(
  • image_id
  • fragment_id
)
Promise

Defined in src\database.js:605

Get the fragment of an image by name

Parameters:

  • image_id Object
  • fragment_id Object

Returns:

Promise:

get_fragments_by_image_id

(
  • image_id
)
| Promise

Defined in src\database.js:803

Get all fragments of one image

Parameters:

  • image_id Object

Returns:

| Promise:

get_image

(
  • file_path
)
Promise

Defined in src\database.js:335

Get image from database by file_path

Promise: success: Contains record for the image

Parameters:

  • file_path String

    The unique identifier for an image

Returns:

Promise:

get_image_of_token

(
  • token_id
)
Promise

Defined in src\database.js:360

Get the image of a token

Parameters:

  • token_id Int

    The unique identifier for a token

Returns:

Promise:

init

() Session

Defined in src\database.js:217

Do the initialization on start

  1. drop and then create constraint

Returns:

Session:

log_error_and_close_session

() Error

Defined in src\database.js:136

Generic catch error function for database promises Logs the error and closes the db session

Returns:

Error:

login

(
  • url
  • user
  • password
)
Boolean | Error

Defined in src\database.js:55

Try to fetch a neo4j driver with the given credentials if that works, the Database._driver is not null anymore. It also set the Database.logged_in to true

Parameters:

  • url String

    the endpoint of neo4j

  • user String
  • password String

Returns:

Boolean | Error:

logout

() Boolean

Defined in src\database.js:119

Logout from the current database neo4j session. Delete the saved neo4j session and set the Database.logged_in flag to false.

Returns:

Boolean:

remove_fragment

(
  • image_id
  • fragment_id
  • dont_delete_fragment
)
Promise

Defined in src\database.js:528

Removes a fragment of an image or makes it empty

This method not only deletes the fragment but also its children

Parameters:

  • image_id Object
  • fragment_id Object
  • dont_delete_fragment Object

    Activate this option to delete only the children

Returns:

Promise:

remove_image_by_id

(
  • id_
)
Promise

Defined in src\database.js:420

Removes an image by ID

Parameters:

  • id_ String | Number

Returns:

Promise:

toggle_fragment_completed

() Promise

Defined in src\database.js:232

Toggle the completed status of a fragment The status is used for the batch-add functionality

Returns:

Promise:

Properties

_driver

Driver private

Defined in src\database.js:36

Stores the neo4j-driver for the method <_get_driver>

Default: null

_logged_in

Boolean

Defined in src\database.js:46

Stores whether a successful login took place

Default: false

development

Boolean

Defined in src\database.js:27

The development flag controls the basic auth credentials

Default: false