User Creation

users_controller.py

parseUsersFile(importDirectory, expiration=365)[source]

Creates new user in the graph database and corresponding node, through the following steps:

  1. Generates new user identifier

  2. Checks if a user with given properties already exists in the database. If not:

  3. Creates new local user (access to graph database)

  4. Saves data to tab-delimited file.

Parameters
  • importDirectory (str) – path to the directory where all the import files are generated.

  • expiration (int) – number of days a user is given access.

Returns

Writes relevant .tsv file for the users in the provided file.

get_user_creation_queries()[source]

Reads the YAML file containing the queries relevant to user creation, parses the given stream and returns a Python object (dict[dict]).

get_new_user_identifier(driver)[source]

Queries the database for the last user identifier and returns a new sequential identifier.

Parameters

driver (py2neo driver) – py2neo driver, which provides the connection to the neo4j graph database.

Returns

User identifier.

Return type

str

check_if_node_exists(driver, node_property, value)[source]

Queries the graph database and checks if a node with a specific property and property value already exists.

Parameters
  • driver (py2neo driver) – py2neo driver, which provides the connection to the neo4j graph database.

  • node_property (str) – property of the node.

  • value (str, int, float or bool) – property value.

Returns

Pandas dataframe with user identifier if User with node_property and value already exists, if User does not exist, returns and empty dataframe.

create_db_user(driver, data)[source]

Creates and assigns role to new graph database user, if user not in list of local users.

Parameters
  • driver (py2neo driver) – py2neo driver, which provides the connection to the neo4j graph database.

  • data (Series) – pandas Series with required user information (see set_arguments()).

GenerateGraphFiles(data, output_file)[source]

Saves pandas dataframe to users.tsv. If file already exists, appends new lines. Else, creates file and writes dataframe to it.

Parameters
  • data – pandas dataframe to be written to .tsv file.

  • output_file (str) – path to output csv file.