Database Reference
In-Depth Information
setTitle("Thank you!");
return SUCCESS;
}
else {
setTitle("Home");
return "userExists";
}
}
catch (Exception e) {
log.error(e);
return ERROR;
}
}
Adding a User
In each part of the five graph areas covered in the chapter, the domain object, such as a User, will have a
corresponding DAO class to manage the persistence operations within the database. In this case, the UserDAO class
covers the management of the application's user nodes by executing cypher queries.
To save a node and label it as a User, the save method, shown in Listing 12-18, makes use of the CREATE clause
by passing the user object through a convenience method called objectAsMap .
Listing 12-18. The save Method in the UserDAO Class
public GraphStory save(GraphStory graphStory) throws Exception {
// no user match, so proceed with the saving
if (userExists(graphStory.getUser()) == false) {
// give user an id
graphStory.getUser().setUserId(uuidGenWithTimeStamp());
cypher.iteratorQuery(" CREATE (user:User {1}) ", map("1",
objectAsMap (graphStory.getUser())));
} else {
graphStory.getErrorMsgs().add(" The username you entered already exists. ");
}
return graphStory;
}
Login
Next, I will review the login process for the sample application. To execute the login process, you will use the login
route and the UserDAO class. Before I review the controller and service layer, I will take a quick look at the front-end
code for the login view.
 
Search WWH ::




Custom Search