All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kodekutters.StixToNeoDB.scala Maven / Gradle / Ivy

There is a newer version: 0.5
Show newest version
//package com.kodekutters
//
//import com.kodekutters.neo4j.Neo4jFileLoader
//import java.io.File
//
//import com.typesafe.scalalogging.Logger
//import org.slf4j.helpers.NOPLogger
//
//import scala.language.implicitConversions
//import scala.language.postfixOps
//
///**
//  * loads a file containing STIX-2 objects (in json format), or
//  * a zip file of such, into a Neo4j graph database
//  *
//  * @author R. Wathelet June 2017, revised December 2017
//  *
//  */
//object StixToNeoDB {
//
//  val usage =
//    """Usage:
//       java -jar stixtoneodb-2.0.jar -f stix_file db_dir
//       or
//       java -jar stixtoneodb-2.0.jar -x stix_file db_dir""".stripMargin
//
//  /**
//    * loads a file containing STIX-2 objects, or
//    * a zip file containing one or more such entry files,
//    * into a neo4j graph database
//    */
//  def main(args: Array[String]) {
//    if (args.length < 2)
//      println(usage)
//    else {
//      implicit val logger = Logger("StixToNeoLib")
//      // the input file
//      val infile = new File(args(1))
//      // the Neo4j db directory
//      val dbDir = if (args.length == 3) args(2).trim else ""
//      // if nothing default is to create a new db in
//      // the current directory with name stixdb
//      val dbFile = if (dbDir.isEmpty) new java.io.File(".").getCanonicalPath + "/stixdb" else dbDir
//      // Neo4jLoader and Neo4jFileLoader can take an implicit logger
//      val neoLoader = new Neo4jFileLoader(dbFile)
//      args(0) match {
//        case "-f" =>
//          if (infile.getName.endsWith(".zip")) neoLoader.loadBundleZipFile(infile)
//          else neoLoader.loadBundleFile(infile)
//        case "-x" =>
//          if (infile.getName.endsWith(".zip")) neoLoader.loadLargeZipTextFile(infile)
//          else neoLoader.loadLargeTextFile(infile)
//        case x => println("unknown option: " + x + "\n" + usage)
//      }
//    }
//  }
//
//}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy