chapter six

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 went through 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. So let’s find out how to approach these sorts of tasks when working with graph databases, versus doing them with relational databases.

In this chapter we’ll use the traversals we’ve been building to demonstrate the process for translating them into a console application written in Java. We’ll start by setting up our project, including selecting the proper graph database driver. Next we will 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.

If you haven’t done so already, please download the corresponding source code for this chapter available in the repository: https://github.com/bechbd/graph-databases-in-action. The code relevant to this chapter is located in the chapter06 folder.

6.1            Starting the project

6.1.1                     Selecting our Tools

6.1.2                     Software Project Setup

6.1.3                     Obtaining a Driver: Apache TinkerPop’s Gremlin Driver

6.1.4                     Prepare Database Server Instance

6.2            Connecting to our database

6.2.1                     Build the cluster configuration

6.2.2                     Setup the GraphTraversalSource

6.3            Retrieving Data

6.3.1                     Retrieving a Vertex

6.4            Adding/Modifying/Deleting data