🔍 Code Extractor

class NodeLabels_v1

Maturity: 34

A constants class that defines string labels for Neo4j graph database node types used in a controlled document management system (CDocs).

File:
/tf/active/vicechatdev/CDocs single class/db/schema_manager.py
Lines:
20 - 38
Complexity:
simple

Purpose

NodeLabels serves as a centralized registry of node type labels for a Neo4j graph database schema. It provides consistent string constants for identifying different entity types in a document control system, including documents, reviews, approvals, users, departments, and audit trails. This class ensures type safety and prevents typos when creating or querying nodes in the graph database.

Source Code

class NodeLabels:
    CDOCS = "CDocs"
    CONTROLLED_DOCUMENT = "ControlledDocument"
    DOCUMENT_VERSION = "DocumentVersion"
    REVIEW_CYCLE = "ReviewCycle"
    REVIEWER_ASSIGNMENT = "ReviewerAssignment"
    REVIEW_COMMENT = "ReviewComment"
    APPROVAL = "Approval"
    APPROVAL_STEP = "ApprovalStep"
    APPROVER = "Approver"
    APPROVAL_WORKFLOW = "ApprovalWorkflow"
    APPROVAL_WORKFLOW_TYPE = "ApprovalWorkflowType"
    USER = "User"
    PEOPLE = "People"  # Legacy support
    CDOCS_ROLE = "CDocs_Role"
    DEPARTMENT = "Department"
    DOCUMENT_TYPE = "DocumentType"
    AUDIT_TRAIL = "AuditTrail"
    AUDIT_EVENT = "AuditEvent"

Parameters

Name Type Default Kind
bases - -

Parameter Details

bases: The base classes for NodeLabels. Since no explicit base class is defined in the source, this defaults to 'object'. This parameter is automatically provided by Python's class creation mechanism and is not user-specified.

Return Value

Instantiating NodeLabels returns a NodeLabels object, though this class is designed to be used as a namespace for constants rather than being instantiated. All attributes are class-level string constants that can be accessed directly via the class name (e.g., NodeLabels.CDOCS).

Class Interface

Attributes

Name Type Description Scope
CDOCS str Label for the root CDocs system node class
CONTROLLED_DOCUMENT str Label for controlled document nodes in the system class
DOCUMENT_VERSION str Label for document version nodes, representing different versions of a controlled document class
REVIEW_CYCLE str Label for review cycle nodes, representing a review process for a document class
REVIEWER_ASSIGNMENT str Label for reviewer assignment nodes, linking reviewers to review cycles class
REVIEW_COMMENT str Label for review comment nodes, containing feedback from reviewers class
APPROVAL str Label for approval nodes, representing an approval decision class
APPROVAL_STEP str Label for approval step nodes, representing individual steps in an approval workflow class
APPROVER str Label for approver nodes, representing users who can approve documents class
APPROVAL_WORKFLOW str Label for approval workflow nodes, defining the approval process structure class
APPROVAL_WORKFLOW_TYPE str Label for approval workflow type nodes, categorizing different workflow templates class
USER str Label for user nodes, representing system users class
PEOPLE str Legacy label for user/people nodes, maintained for backward compatibility. Prefer using USER for new code. class
CDOCS_ROLE str Label for role nodes in the CDocs system, defining user permissions and responsibilities class
DEPARTMENT str Label for department nodes, representing organizational units class
DOCUMENT_TYPE str Label for document type nodes, categorizing documents by type class
AUDIT_TRAIL str Label for audit trail nodes, tracking changes and actions in the system class
AUDIT_EVENT str Label for audit event nodes, representing individual auditable events class

Usage Example

# Access node labels as class attributes
from module_name import NodeLabels

# Use in Neo4j Cypher queries
query = f"CREATE (d:{NodeLabels.CONTROLLED_DOCUMENT} {{id: $id}})"

# Use for node type checking
if node.labels[0] == NodeLabels.USER:
    print("This is a user node")

# Use in graph database operations
def create_document(session, doc_id):
    session.run(
        f"CREATE (d:{NodeLabels.CONTROLLED_DOCUMENT}) SET d.id = $id",
        id=doc_id
    )

# Access all available labels
print(NodeLabels.DOCUMENT_VERSION)
print(NodeLabels.REVIEW_CYCLE)
print(NodeLabels.APPROVAL_WORKFLOW)

Best Practices

  • Do not instantiate this class - use it as a static namespace for constants by accessing attributes directly via the class name (e.g., NodeLabels.USER)
  • Use these constants instead of hardcoded strings when working with Neo4j nodes to prevent typos and ensure consistency
  • The PEOPLE label is marked as legacy support - prefer using USER for new code
  • These labels should match the actual node labels in your Neo4j database schema
  • Consider this class immutable - do not modify or add attributes at runtime
  • Import this class wherever you need to reference node types in Cypher queries or graph operations
  • This class has no methods or state - it serves purely as a constant container

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class NodeLabels 97.6% similar

    A constants class that defines string labels for different node types in a Neo4j graph database schema for a document management system (CDocs).

    From: /tf/active/vicechatdev/CDocs/db/schema_manager.py
  • function get_node_labels 71.0% similar

    Retrieves all non-private attributes from the NodeLabels class as a dictionary, filtering out attributes that start with underscore.

    From: /tf/active/vicechatdev/CDocs/db/schema_manager.py
  • class RelTypes_v1 67.3% similar

    A constants class that defines string constants for relationship types used in a graph database (Neo4j) for a document management system.

    From: /tf/active/vicechatdev/CDocs single class/db/schema_manager.py
  • class RelTypes 66.2% similar

    A constants class that defines string literals representing relationship types used in a graph database (Neo4j) for document management and approval workflows.

    From: /tf/active/vicechatdev/CDocs/db/schema_manager.py
  • function create_node_v1 59.1% similar

    Creates a node in a Neo4j graph database with a specified label and properties, automatically generating a unique ID and timestamp if not provided.

    From: /tf/active/vicechatdev/CDocs/db/db_operations.py
← Back to Browse