@@ -11,7 +11,7 @@ or none.
11
11
12
12
## The impl\app directory
13
13
14
- ** This directory contains the current codebase.**
14
+ ** This directory contains the Python codebase.**
15
15
16
16
It contains these directories:
17
17
@@ -24,10 +24,11 @@ It contains these directories:
24
24
25
25
## The impl\app directory
26
26
27
- This is where the implementation code and scripts are. It contains these directories.
27
+ This is where the Python implementation code and scripts are.
28
+ It contains these directories.
28
29
29
30
```
30
- ├── docker Dockerfiles and docker-compose. yml
31
+ ├── docker Dockerfiles and docker-compose yml files
31
32
├── keys Future use
32
33
├── ontologies OWL schema files, with *.owl file suffix
33
34
├── rdf RDF graph data files in "triples" format, with *.nt file suffix
@@ -275,3 +276,127 @@ personal coding style preferences. In addition to reformatting the source
275
276
code, black can also identify some problems/errors in the code.
276
277
277
278
See the ** code-reformat.ps1** and ** code-reformat.sh** scripts in the impl directory.
279
+
280
+ ---
281
+
282
+ ## The impl\java_jena_graph_websvc directory
283
+
284
+ This directory contains the newer Graph Microservice implemented
285
+ with Java, Spring Boot, and Apache Jena. Gradle is used as the
286
+ build tool.
287
+
288
+ Please see the readme.md file in this directory regarding
289
+ building and executing this version of the Graph Microservice.
290
+
291
+ It contains these directories:
292
+
293
+ ```
294
+ ├── build Output of the Gradle-based compilation and packaging process
295
+ ├── data
296
+ ├── data/cosmosdb_documents.json
297
+ ├── ontologies
298
+ ├── rdf RDF files optionally used to load the graph
299
+ ├── src Standard Java source code directory structure
300
+ │ ├── main
301
+ │ └── test
302
+ └── tmp Create this directory if it doesn't already exist
303
+ ```
304
+
305
+ ### Key Classes in the Java/Jena implementation
306
+
307
+ This section describes the primary Java classes in the Java/Jena implementation.
308
+
309
+ #### com.microsoft.cosmosdb.caig.WebApp
310
+
311
+ This is the Spring Boot entry point for the application, per the
312
+ @SpringBootApplication annotation.
313
+
314
+ #### com.microsoft.cosmosdb.caig.web.GraphRestController
315
+
316
+ Spring @RestController that implements the ** /sparql_query** HTTP endpoint.
317
+ This endpoint is invoked by the Python-based Web UI when
318
+ executing graph queries.
319
+
320
+ #### com.microsoft.cosmosdb.caig.web.HealthRestController
321
+
322
+ Spring @RestController that implements the ** /health** HTTP endpoint.
323
+ This endpoint that can optionally be invoked by your container
324
+ orchestrator runtime environment - such as Azure Container Apps (ACA)
325
+ or Azure Kubernetes Service (AKS).
326
+
327
+ #### com.microsoft.cosmosdb.caig.web.PingRestController
328
+
329
+ Spring @RestController that implements the ** /** and ** /ping** HTTP endpoints.
330
+ The / endpoint simply returns the epoch time, while /ping returns
331
+ uptime and JVM memory information.
332
+
333
+ #### com.microsoft.cosmosdb.caig.web.AppStartup
334
+
335
+ This contains the application startup logic per the Spring
336
+ ApplicationListener interface. It contains this logic which
337
+ loads the in-memory graph in class AppGraph.
338
+
339
+ ```
340
+ AppGraph g = AppGraphBuilder.build(null);
341
+ AppGraph.setSingleton(g);```
342
+ ```
343
+
344
+ #### com.microsoft.cosmosdb.caig.util.AppConfig
345
+
346
+ This static class returns almost all configuration values for the
347
+ application, such as from ** environment variables** .
348
+
349
+ The environment variables begin with the ** CAIG_ ** prefix and are described
350
+ in the [ Environment Variables] ( environment_variables.md ) page
351
+
352
+ The Spring Boot framework also uses the src/main/resources/application.properties
353
+ file for some configuration values. But all ** application coniguration**
354
+ is done with environment variables and class AppConfig. This approach
355
+ is typically used by Docker containerized applications.
356
+
357
+ #### com.microsoft.cosmosdb.caig.graph.AppGraphBuilder
358
+
359
+ This class creates and populates the in-memory graph object
360
+ which is an instance of class ** org.apache.jena.rdf.model.Model** .
361
+
362
+ AppGraphBuilder can populate the graph from one of several
363
+ sources per the CAIG_GRAPH_SOURCE_TYPE environment variable.
364
+ CAIG_GRAPH_SOURCE_TYPE may have one of the following values:
365
+
366
+ - json_docs_file - the graph is sourced from ile cosmosdb_documents.json in the repo
367
+ - rdf_file - the graph is sourced from the file specified in CAIG_GRAPH_SOURCE_RDF_FILENAME
368
+ - cosmos_nosql - the graph is sourced from your Cosmos DB NoSQL account
369
+ - cosmos_vcore - the graph is sourced from your Cosmos DB Mongo vCore account
370
+
371
+ After the Jena graph is populated, you can optionally dump that
372
+ graph to a file per the CAIG_GRAPH_DUMP_UPON_BUILD and CAIG_GRAPH_DUMP_OUTFILE
373
+ environment variables.
374
+
375
+ #### com.microsoft.cosmosdb.caig.graph.AppGraph
376
+
377
+ This class contains the singleton instance of class
378
+ org.apache.jena.rdf.model.Model in the Apache Jena SDK.
379
+
380
+ It implements this primary message signature:
381
+
382
+ ```
383
+ public synchronized SparqlQueryResponse query(SparqlQueryRequest request) {
384
+ }
385
+ ```
386
+
387
+ The method is ** synchronized** so as to be thread safe. Each HTTP request
388
+ to the Spring Boot application runs in its' own Thread.
389
+
390
+ Classes SparqlQueryRequest and SparqlQueryResponse are simple
391
+ JSON serializable classes used to receive the HTTP POSTed query
392
+ and to return the JSON response to the query.
393
+
394
+ #### com.microsoft.cosmosdb.caig.graph.LibrariesGraphTriplesBuilder
395
+
396
+ For the cases where AppGraphBuilder sources the graph from Cosmos DB,
397
+ instances of LibrariesGraphTriplesBuilder are uses to populate the
398
+ graph from each appropriate Cosmos DB document.
399
+
400
+ Customers should implement their own GraphTriplesBuilder class for
401
+ their needs and implement as necessary per the shape of your Cosmos DB
402
+ documents and graph schema.
0 commit comments