


#------------------------------------------------------------------#
#      NEO4J SETTINGS                                              #
#------------------------------------------------------------------#

  # This is a minor safety switch. It must be set to TRUE in order
  #   to allow for all NODES & RELS to be deleted
  ## TODO:  Is this still even needed given the `clearDB` possibility?
  ##        Especially considering this takes forever
  deleteALL.allowed <- FALSE

  # URL's & CURL OPTIONS
  u.base   <- "http://localhost:7474/db/data/"
  u.cypher <- as.path(u.base, "cypher")
  u.node   <- as.path(u.base, "node")
  u.rel    <- as.path(u.base, "relationship")
  u.batch  <- as.path(u.base, "batch")

  # options for CURL
  jsonHeader <- c("Content-Type" = "application/json", "Accept" = "application/json")
  streamOn   <- c("X-Stream" = "true")
  streamOff  <- c("X-Stream" = "false")  # this is the value by defaault, I dont think there will be much need to use this explicitly
#------------------------------------------------------------------#

#------------------------------------------------------------------#
#      NEO4J SETUP                                                 #
#------------------------------------------------------------------#
{
  ## Source helpfer functions before reloading the neo utils
  sourceSupportFns(neoSrc)

  ## Set the NEO4J_HOME folder
  neoSetHome(neoVersion)

  ## Re load the spotify files  (using this until setup as proper package)
  if (ReSource_R2neo4j) {
    ## Update files, via git pull
    .g()

    # An explicit lists of which r2neo4j files to source
    # This of course will not be needed once converted to a package
    FilesToSource.neo <- c( "00a - Params for neo4j.R"
                          , "00b - Support Functions.r"
                          , "01 - Relationships_Nodes_Functions.R"
                          , "03 - batchCreateFromDT.R" 
                          )

    ## Source in the files
    for (f in as.path(neoSrc, FilesToSource.neo)) 
        suppressWarnings(invisible( source(f) ))
  }


  ## NOTE: neoDataDir is different from  NEO4J_HOME and is dependent on neo4j.DB.name
  ##       'NEO4J_HOME' is the primary folder where all of the neo4j files are located on the system
  ##       'neoDataDir' is the specific folder containing the database. It is normally in $NEO4J_HOME/data/Name.db


  ## Confrim that neo4j.DB.name is a valid string, then set the neoDataDir, then force it  
  if (!nchar(neo4j.DB.name)) {
      stop("neo4j.DB.name has value '", neo4j.DB.name,"' which is not vlaid.")
  } else {
      options("neoDataDir"=as.path(getOption("NEO4J_HOME"), "data", neo4j.DB.name))
      force(getOption("neoDataDir"))
  }
  

  ## neo4j has a config file that needs to point to the .db folder in order for that .db to be used 
  ##   when starting up neo4j.  This function modifies the config file to point to (the value of) neo4j.DB.name
  neo_setDB_in_config_file(neo4j.DB.name)

  #### ------------- REMOVE THE .db FOLDER ------------- ####
  if (clearDB)
    clear.neo4jDB(DB.name=getOption("neoDataDir"), confirm=clearDB, failOnMissing=FALSE, failOnCantStop=TRUE, verbose=TRUE)

  ## Start it up
  ## ...  actually, do NOT start it until ready to load. Otherwise, this will use up resources
  ##      It will get started during 'neoCheckAndStart()' when exporting
  ## neoStart()
  }
#------------------------------------------------------------------#


