1
00:00:01,004 --> 00:00:05,006
(upbeat music)

2
00:00:05,006 --> 00:00:08,003
- [Instructor] In this challenge you were to do two things:

3
00:00:08,003 --> 00:00:10,008
Implement track nutrition use case

4
00:00:10,008 --> 00:00:12,008
and then refactor the data layer

5
00:00:12,008 --> 00:00:15,008
by splitting the DAO class into multiple DAOs.

6
00:00:15,008 --> 00:00:19,004
Let us first go to this sprint for tracking nutrition.

7
00:00:19,004 --> 00:00:21,002
The user story is,

8
00:00:21,002 --> 00:00:23,006
"As a user, I want to see a trend

9
00:00:23,006 --> 00:00:27,008
in the consumption of a nutrient in my meals over time."

10
00:00:27,008 --> 00:00:31,004
The UI Mockup I came up with looks like this.

11
00:00:31,004 --> 00:00:34,005
Given a range of dates and a nutrient,

12
00:00:34,005 --> 00:00:37,002
the UI will show some kind of trend line

13
00:00:37,002 --> 00:00:40,004
showing nutrient consumption over time.

14
00:00:40,004 --> 00:00:43,005
The sequence diagram has one new servlet,

15
00:00:43,005 --> 00:00:45,002
track nutrition controller

16
00:00:45,002 --> 00:00:49,000
and one new GSP, track daily nutrients.

17
00:00:49,000 --> 00:00:51,007
You will find this flow now very familiar

18
00:00:51,007 --> 00:00:55,002
where a user selects track nutrition functionality,

19
00:00:55,002 --> 00:00:58,006
which takes the control to track nutrition controller,

20
00:00:58,006 --> 00:01:01,007
which takes session attributes from requests

21
00:01:01,007 --> 00:01:05,001
and forwards them to track nutrients GSP.

22
00:01:05,001 --> 00:01:09,004
Then user provides inputs for the nutrient and dates.

23
00:01:09,004 --> 00:01:11,002
JSP asks the controller,

24
00:01:11,002 --> 00:01:13,008
which then asks DAO to find nutrition

25
00:01:13,008 --> 00:01:16,005
for meals between the given dates.

26
00:01:16,005 --> 00:01:18,004
And finally the chart is displayed

27
00:01:18,004 --> 00:01:22,004
based on the nutrition map returned by DAO.

28
00:01:22,004 --> 00:01:26,001
The class diagram has one new package, track nutrition,

29
00:01:26,001 --> 00:01:29,002
with each track nutrition controller servlet.

30
00:01:29,002 --> 00:01:32,001
Now let us go to the code.

31
00:01:32,001 --> 00:01:33,009
The code that I'm going to show you

32
00:01:33,009 --> 00:01:36,009
has the code from our implementation

33
00:01:36,009 --> 00:01:38,007
of track nutrition use case,

34
00:01:38,007 --> 00:01:42,000
as well as the refactored data layer.

35
00:01:42,000 --> 00:01:45,007
So here you can see that I have all these packages,

36
00:01:45,007 --> 00:01:47,007
one of which is track nutrition

37
00:01:47,007 --> 00:01:50,004
which has the track nutrition controller.

38
00:01:50,004 --> 00:01:53,000
In GSP I have a new folder, track,

39
00:01:53,000 --> 00:01:56,003
that has track daily nutrients JSP.

40
00:01:56,003 --> 00:02:00,001
For refactoring, I have a new data layer package

41
00:02:00,001 --> 00:02:05,007
that has DAO, meal DAO, USDA DAO, and user DAO.

42
00:02:05,007 --> 00:02:11,000
DAO has just the constructor and GET instance method.

43
00:02:11,000 --> 00:02:15,004
All other methods from DAO have been moved to USDA DAO,

44
00:02:15,004 --> 00:02:17,009
meal DAO and user DAO,

45
00:02:17,009 --> 00:02:19,007
relevant to their use cases

46
00:02:19,007 --> 00:02:22,003
as was explained in the previous lesson.

47
00:02:22,003 --> 00:02:25,002
I have also moved data layer in this package

48
00:02:25,002 --> 00:02:27,003
as it is part of a data layer

49
00:02:27,003 --> 00:02:28,006
and because of that

50
00:02:28,006 --> 00:02:31,002
I had to make another important change

51
00:02:31,002 --> 00:02:35,000
and that is in the web XML file.

52
00:02:35,000 --> 00:02:39,000
Web XML has data loader class for load on startup.

53
00:02:39,000 --> 00:02:40,009
I had to change its package name

54
00:02:40,009 --> 00:02:43,005
as it is now in data layer package

55
00:02:43,005 --> 00:02:46,001
and you can see that change in line seven.

56
00:02:46,001 --> 00:02:47,002
Now that you're familiar

57
00:02:47,002 --> 00:02:49,009
with the entire DevOps tool chain I created,

58
00:02:49,009 --> 00:02:50,008
taking the code

59
00:02:50,008 --> 00:02:53,007
from Git to Jenkins and then to production.

60
00:02:53,007 --> 00:02:55,005
I already completed that part

61
00:02:55,005 --> 00:02:58,004
and now it's time to run the application.

62
00:02:58,004 --> 00:03:01,008
So I'm production now logged in as Carla.

63
00:03:01,008 --> 00:03:04,003
Let me first look at the diet log,

64
00:03:04,003 --> 00:03:06,002
and you can see that there is some data

65
00:03:06,002 --> 00:03:09,006
starting from 4th of March to 6th of March.

66
00:03:09,006 --> 00:03:12,001
Now if I go into track nutrition,

67
00:03:12,001 --> 00:03:15,005
I can see that by default it is picking up protein

68
00:03:15,005 --> 00:03:19,000
for dates based on the data available

69
00:03:19,000 --> 00:03:21,000
as showing some kind of trend.

70
00:03:21,000 --> 00:03:26,003
I can take any other nutrient from this dropdown.

71
00:03:26,003 --> 00:03:28,009
Let's say I pick

72
00:03:28,009 --> 00:03:32,008
calcium and submit.

73
00:03:32,008 --> 00:03:36,002
And you can see the trend line looks very similar.

74
00:03:36,002 --> 00:03:38,003
Let me try

75
00:03:38,003 --> 00:03:41,005
carbohydrate and there is some difference.

76
00:03:41,005 --> 00:03:43,009
So this is how we are currently

77
00:03:43,009 --> 00:03:47,002
implementing the track nutrition use case.

78
00:03:47,002 --> 00:03:51,000
This brings us to the end of this functionality.

