6 Developing an application

 

This chapter covers

  • Setting up a project
  • Choosing the database driver and connecting to the database
  • Translating recursive and pathfinding traversals into Java methods
  • Processing traversal results within an application

In chapters 3, 4, and 5, we covered the process of writing traversals. But writing traversals is only part of what is required to create an application. Applications also require handling tasks, such as connecting to a database, managing user input, and processing the traversal results into a usable form. While the process for doing these is similar to how we work with relational databases, there are a few critical differences, so let’s find out how to approach these tasks when working with graph databases.

In this chapter, we’ll use the traversals we built in the earlier chapters to demonstrate the process for translating these into a console application written in Java. We’ll start by setting up our project, including selecting the proper graph database driver. Next, we’ll walk through how to connect to our graph database. Finally, we’ll show how to translate our Gremlin traversals into the equivalent Java code and process the results. By the end of this chapter, we’ll have a fully functioning application based on our DiningByFriends social network.

6.1 Starting the project

6.1.1 Selecting our tools

6.1.2 Setting up the project

6.1.3 Obtaining a driver

6.1.4 Preparing the database server Instance

6.2 Connecting to our database

6.2.1 Building the cluster configuration

6.2.2 Setting up the GraphTraversalSource

6.3 Retrieving data

6.3.1 Retrieving a vertex

6.3.2 Using Gremlin language variants (GLVs)

6.3.3 Adding terminal steps

6.3.4 Creating the Java method in our application

6.4 Adding, modifying, and deleting data

6.4.1 Adding vertices

6.4.2 Adding edges

6.4.3 Updating properties

6.4.4 Deleting elements

6.5 Translating our list and path traversals

6.5.1 Getting a list of results

6.5.2 Implementing recursive traversals