9.2 Loading a Graph Using a JSON Configuration File

In order to load a property graph view into the graph server (PGX), you can create a graph configuration file, which contains the metadata of the graph to be loaded.

The following shows a sample JSON configuration file:

{
  "name": "BANK_GRAPH",
  "source_name": "BANK_GRAPH",
  "source_type": "pg_view",
  "jdbc_url":"jdbc:oracle:thin:@localhost:1521/orclpdb",
  "username":"graphuser",
  "keystore_alias":"database1",
  "vertex_providers":[
        {
            "name":"Accounts",
            "format":"rdbms",
            "database_table_name":"BANK_ACCOUNTS",
            "key_column":"ID",
            "key_type": "integer",
            "parallel_hint_degree": 3,
             "props":[
                {
                        "name":"ID",
                        "type":"integer"

                },
                 {
                        "name":"NAME",
                        "type":"string"
                 }

            ]


        }
    ],
    "edge_providers":[
        {
            "name":"Transfers",
            "format":"rdbms",
            "database_table_name":"BANK_TXNS",
            "key_column":"ID",
            "parallel_hint_degree": 3,
            "source_column":"FROM_ACCT_ID",
            "destination_column":"TO_ACCT_ID",
            "source_vertex_provider":"Accounts",
            "destination_vertex_provider":"Accounts",
            "props":[
                {
                        "name":"FROM_ACCT_ID",
                        "type":"integer"
                },
                {
                        "name":"TXN_AMOUNT",
                        "type":"float",
                        "column":"AMOUNT"
                },
                {
                        "name":"DESCRIPTION",
                        "type":"string"
                },
                {
                        "name":"TO_ACCT_ID",
                        "type":"integer"
                }
            ]
        }
    ]
}

The preceding configuration uses a Java keystore alias to reference the database password that is stored in a keystore file. See Store the Database Password in a Keystore for more information.

Also, the edge property AMOUNT is renamed to TXN_AMT. This implies that when loading a graph into the graph server (PGX), you can optionally rename vertex or edge properties to have different names other than the names of the underlying columns in the database.

See Also:

You can now read the graph into the graph server as shown:

./bin/opg4j --secret_store /etc/oracle/graph/keystore.p12
enter password for keystore /etc/oracle/graph/keystore.p12:
For an introduction type: /help intro
Oracle Graph Server Shell 23.2.0
Variables instance, session, and analyst ready to use
opg4j> var g = session.readGraphWithProperties("<path_to_json_configuration>")
g ==> PgxGraph[name=BANK_GRAPH_NEW,N=999,E=4993,created=1675960224397]
ServerInstance instance = GraphServer.getInstance("https://localhost:7007", <username>, <password>.toCharArray());
PgxSession session = instance.createSession("my-session");
String keystorePath = "/etc/oracle/graph/keystore.p12";
char[] keystorePassword = "<keystore_password>".toCharArray();
session.registerKeystore(keystorePath, keystorePassword);
PgxGraph g = session.readGraphWithProperties("<path_to_json_configuration>");
System.out.println("Graph: " + g);