Class MaterializeRDFViewOfLPG

java.lang.Object
org.apache.jena.cmd.CommandLineBase
org.apache.jena.cmd.CmdLineArgs
org.apache.jena.cmd.CmdMain
org.apache.jena.cmd.CmdArgModule
org.apache.jena.cmd.CmdGeneral
arq.cmdline.CmdARQ
se.liu.ida.hefquin.cli.MaterializeRDFViewOfLPG

public class MaterializeRDFViewOfLPG extends arq.cmdline.CmdARQ
A command-line tool to materialize an RDF view of a labeled property graph (LPG) retrieved from a Neo4j endpoint using Cypher queries. This tool takes various configuration options and outputs RDF data that conforms to a given LPG-to-RDF configuration.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    Collects the emitted triples into a graph and writes this graph to the given OutputStream upon calling the MaterializeRDFViewOfLPG.MyCachingStreamRDF.finish() function.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final ModNeo4jEndpoint
     
    protected final arq.cmdline.ModLangOutput
     
    protected final ModLPG2RDFConfiguration
     
    protected final arq.cmdline.ModTime
     

    Fields inherited from class arq.cmdline.CmdARQ

    cmdStrictMode, modContext

    Fields inherited from class org.apache.jena.cmd.CmdGeneral

    cmdName, modGeneral, modVersion

    Fields inherited from class org.apache.jena.cmd.CmdLineArgs

    argMap, args, positionals
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructor that initializes the command-line tool with necessary argument modules for endpoint configuration, output format, and timing options.
  • Method Summary

    Modifier and Type
    Method
    Description
    Builds and returns the Cypher query used to retrieve edges from the Neo4j database.
    Builds and returns the Cypher query used to retrieve nodes from the Neo4j database.
    protected void
    Retrieves nodes and edges from a Neo4j database, converts them to RDF triples, and writes the triples to the output stream System.out.
    protected List<TableRecord>
    execQuery(CypherQuery query, String endpoint, String username, String password)
    Executes the given Cypher query against the Neo4j database using the provided connection details.
    protected String
    Returns the command name used to invoke the tool.
    protected String
    Returns the usage summary string of the command, showing the required and optional arguments.
    static void
    main(String[] args)
    Main entry point of the tool, accepting command-line arguments to specify the Neo4j connection details and output format options.
    protected org.apache.jena.riot.system.StreamRDF
    Sets up the output stream for writing RDF data.
    protected void
    writeTriplesForEdges(List<TableRecord> edgesResponse, LPG2RDFConfiguration l2rConf, org.apache.jena.riot.system.StreamRDF rdfOutStream)
    Writes RDF triples representing the edges retrieved from the Neo4j database to the provided stream.
    protected void
    writeTriplesForNodes(List<TableRecord> nodesResponse, LPG2RDFConfiguration l2rConf, org.apache.jena.riot.system.StreamRDF rdfOutStream)
    Writes RDF triples representing the nodes retrieved from the Neo4j database to the provided stream.
    protected void
    writeTriplesForProperties(org.apache.jena.graph.Node subject, PropertyMap properties, LPG2RDFConfiguration l2rConf, org.apache.jena.riot.system.StreamRDF rdfOutStream)
    Creates and writes a triple for each of the properties of the given PropertyMap using the given subject for these triples.

    Methods inherited from class arq.cmdline.CmdARQ

    processModulesAndArgs

    Methods inherited from class org.apache.jena.cmd.CmdGeneral

    add, addModule, getUsage, help, isDebug, isQuiet, isVerbose, printHelp, usage, usage

    Methods inherited from class org.apache.jena.cmd.CmdArgModule

    process

    Methods inherited from class org.apache.jena.cmd.CmdMain

    cmdError, cmdError, mainAndExit, mainMethod, mainRun, mainRun, mainRun

    Methods inherited from class org.apache.jena.cmd.CmdLineArgs

    add, add, add, addArg, addArg, addPositional, contains, contains, containsMultiple, containsMultiple, getArg, getArg, getNumPositional, getPositional, getPositionalArg, getPositionalOrStdin, getValue, getValue, getValues, getValues, handleUnrecognizedArg, hasArg, hasArg, hasArgs, hasPositional, hasValueOfFalse, hasValueOfTrue, indirect, indirect, matchesIndirect, matchesIndirect, toString

    Methods inherited from class org.apache.jena.cmd.CommandLineBase

    apply, getArg, getArgList, setArgs

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • modEndpoint

      protected final ModNeo4jEndpoint modEndpoint
    • modTime

      protected final arq.cmdline.ModTime modTime
    • modLangOut

      protected final arq.cmdline.ModLangOutput modLangOut
    • modLPG2RDFConfiguration

      protected final ModLPG2RDFConfiguration modLPG2RDFConfiguration
  • Constructor Details

    • MaterializeRDFViewOfLPG

      protected MaterializeRDFViewOfLPG(String[] argv)
      Constructor that initializes the command-line tool with necessary argument modules for endpoint configuration, output format, and timing options.
      Parameters:
      argv - Command-line arguments.
  • Method Details

    • main

      public static void main(String[] args)
      Main entry point of the tool, accepting command-line arguments to specify the Neo4j connection details and output format options.
      Parameters:
      args - Command-line arguments.
    • getSummary

      protected String getSummary()
      Returns the usage summary string of the command, showing the required and optional arguments.
      Specified by:
      getSummary in class org.apache.jena.cmd.CmdGeneral
      Returns:
      A string that describes the usage of the command.
    • getCommandName

      protected String getCommandName()
      Returns the command name used to invoke the tool.
      Overrides:
      getCommandName in class arq.cmdline.CmdARQ
      Returns:
      The name of the command.
    • exec

      protected void exec()
      Retrieves nodes and edges from a Neo4j database, converts them to RDF triples, and writes the triples to the output stream System.out.
      Specified by:
      exec in class org.apache.jena.cmd.CmdMain
    • buildGetNodesQuery

      public CypherQuery buildGetNodesQuery()
      Builds and returns the Cypher query used to retrieve nodes from the Neo4j database.
      Returns:
      A CypherQuery for retrieving nodes.
    • buildGetEdgesQuery

      public CypherQuery buildGetEdgesQuery()
      Builds and returns the Cypher query used to retrieve edges from the Neo4j database.
      Returns:
      A CypherQuery for retrieving edges.
    • execQuery

      protected List<TableRecord> execQuery(CypherQuery query, String endpoint, String username, String password)
      Executes the given Cypher query against the Neo4j database using the provided connection details.
      Parameters:
      query - The Cypher query to be executed.
      endpoint - The URI of the Neo4j endpoint.
      username - The username for the Neo4j endpoint.
      password - The password for the Neo4j endpoint.
      Returns:
      A list of table records containing the results of the query.
    • writeTriplesForNodes

      protected void writeTriplesForNodes(List<TableRecord> nodesResponse, LPG2RDFConfiguration l2rConf, org.apache.jena.riot.system.StreamRDF rdfOutStream)
      Writes RDF triples representing the nodes retrieved from the Neo4j database to the provided stream.
      Parameters:
      nodesResponse - The list of table records containing the nodes.
      lpg2rdfConf - The LPG-to-RDF configuration used for conversion.
      rdfOutStream - The output stream to write the RDF triples to.
    • writeTriplesForEdges

      protected void writeTriplesForEdges(List<TableRecord> edgesResponse, LPG2RDFConfiguration l2rConf, org.apache.jena.riot.system.StreamRDF rdfOutStream)
      Writes RDF triples representing the edges retrieved from the Neo4j database to the provided stream.
      Parameters:
      edgesResponse - The list of table records containing the edges.
      lpg2rdfConf - The LPG-to-RDF configuration used for conversion.
      rdfOutStream - The output stream to write the RDF triples to.
    • writeTriplesForProperties

      protected void writeTriplesForProperties(org.apache.jena.graph.Node subject, PropertyMap properties, LPG2RDFConfiguration l2rConf, org.apache.jena.riot.system.StreamRDF rdfOutStream)
      Creates and writes a triple for each of the properties of the given PropertyMap using the given subject for these triples.
      Parameters:
      subject - - used as subject of the created triples
      properties - - the properties for which the triples are created
      l2rConf - - LPG-to-RDF configuration that specifies the IRIs for the property names
      rdfOutStream - - stream to which the created triples are written
    • setupOutputStream

      protected org.apache.jena.riot.system.StreamRDF setupOutputStream(OutputStream outStreamBase)
      Sets up the output stream for writing RDF data. If the output should be compressed, a GZIP stream is created. The RDF format for output is determined by the configuration.
      Parameters:
      outStreamBase - The base output stream (e.g., System.out).
      Returns:
      The StreamRDF configured for the appropriate RDF format and compression.