Database Reference
In-Depth Information
// no errors occurred, so send to the thank you page
if (CollectionUtils.isEmpty(graphStory.getErrorMsgs())) {
modelAndView = new ModelAndView("redirect:/msg");
modelAndView.addObject("msg", "Thank you, " + graphStory.getUser().
getUsername());
// send the errors that occurred to the view
} else {
modelAndView = new ModelAndView("/mustache/html/home/index.html");
modelAndView.addObject("title", "Home");
modelAndView.addObject(graphStory.getErrorMsgs());
}
return modelAndView;
}
catch (Exception e) {
log.error(e);
return null;
}
}
Adding the User
Each domain object has a corresponding interface and implementation to manage the object. As a part of the
architecture, each interface is part of the main service layer created with the GraphStoryImpl class, which implements
the GraphStoryInterface . In addition, each of the implementation classes extends a class called GraphStoryService
in order to have access to commonly used beans and methods, such as the Spring Data repositories and the
Neo4jOperations class.
In this case, the UserImpl class implements the methods found in UserInterface , both of which are located in
the com.practicalneo4j.graphstory.service.main package. An abbreviated version of UserInterface is shown in
Listing 11-20.
Listing 11-20. UserInterface
public interface UserInterface {
...
public GraphStory save (GraphStory graphStory) throws Exception;
...
}
This chapter does not dive into the details of the GraphStoryService and GraphStoryImpl classes , but both
of these service classes will be reused throughout the application. The GraphStoryImpl class is used for convenience in
order to have access to each specific interface by using a single service interface.
Note
 
 
Search WWH ::




Custom Search