1
00:00:00,005 --> 00:00:02,009
- [Instructor] Now that the login use case is ready,

2
00:00:02,009 --> 00:00:05,006
we can complete the two dependent use cases,

3
00:00:05,006 --> 00:00:08,003
record a meal and view diet log.

4
00:00:08,003 --> 00:00:10,004
Let us take a look at the UI mock-up

5
00:00:10,004 --> 00:00:12,001
to plan its workflow.

6
00:00:12,001 --> 00:00:18,006
After logging in, when I choose record meal option,

7
00:00:18,006 --> 00:00:19,009
it takes me to a page

8
00:00:19,009 --> 00:00:22,004
where I can enter meal date, time

9
00:00:22,004 --> 00:00:24,004
and meal type.

10
00:00:24,004 --> 00:00:29,005
If you recall, we decided that meal type can be breakfast,

11
00:00:29,005 --> 00:00:32,001
lunch, dinner or snack.

12
00:00:32,001 --> 00:00:34,000
Then we enter some search string

13
00:00:34,000 --> 00:00:35,002
to find the product

14
00:00:35,002 --> 00:00:36,009
that was served in the meal.

15
00:00:36,009 --> 00:00:38,006
I see a list of products

16
00:00:38,006 --> 00:00:42,001
with each product having a radio button to select.

17
00:00:42,001 --> 00:00:44,000
Once I select a product,

18
00:00:44,000 --> 00:00:46,004
I need to specify its quantity

19
00:00:46,004 --> 00:00:48,000
and unit of measure.

20
00:00:48,000 --> 00:00:50,002
The unit of measure is a product's property

21
00:00:50,002 --> 00:00:52,004
so it will be displayed.

22
00:00:52,004 --> 00:00:55,001
Then we add it to the meal.

23
00:00:55,001 --> 00:00:56,006
We can add more products,

24
00:00:56,006 --> 00:00:59,005
each product as a serving,

25
00:00:59,005 --> 00:01:01,006
and then save the meal.

26
00:01:01,006 --> 00:01:03,003
After having saved the meals,

27
00:01:03,003 --> 00:01:06,002
I can choose view diet log

28
00:01:06,002 --> 00:01:10,007
and it shows all meals recorded between certain dates.

29
00:01:10,007 --> 00:01:13,005
Now let us take a look at sequence diagram.

30
00:01:13,005 --> 00:01:17,004
As usual, starting from the user selecting the option

31
00:01:17,004 --> 00:01:19,009
to add meal from index JSP,

32
00:01:19,009 --> 00:01:22,004
the meal controller gets the session

33
00:01:22,004 --> 00:01:25,008
and then creates a new empty meal object.

34
00:01:25,008 --> 00:01:27,003
It initializes the meal

35
00:01:27,003 --> 00:01:28,008
with username and then waits

36
00:01:28,008 --> 00:01:31,004
for user to provide more inputs.

37
00:01:31,004 --> 00:01:35,000
User creates meal with date, time and meal type,

38
00:01:35,000 --> 00:01:37,007
which them goes to meal initializer

39
00:01:37,007 --> 00:01:40,004
which then forwards it to mealProducts JSP.

40
00:01:40,004 --> 00:01:43,004
MealProducts JSP opens up the options

41
00:01:43,004 --> 00:01:46,007
to input food products or servings.

42
00:01:46,007 --> 00:01:48,002
Continuing with the flow,

43
00:01:48,002 --> 00:01:50,008
now user adds different products

44
00:01:50,008 --> 00:01:53,003
and their quantities in a loop.

45
00:01:53,003 --> 00:01:55,001
User enters a search string

46
00:01:55,001 --> 00:01:57,003
to search for food product

47
00:01:57,003 --> 00:01:59,007
and selects a product from the list along

48
00:01:59,007 --> 00:02:01,007
with entering the quantity.

49
00:02:01,007 --> 00:02:05,002
Once the user submits it as a serving,

50
00:02:05,002 --> 00:02:07,004
mealProducts JSP passes the control

51
00:02:07,004 --> 00:02:11,003
to serving adder, which then creates a new serving

52
00:02:11,003 --> 00:02:12,008
and adds it to the meal.

53
00:02:12,008 --> 00:02:14,005
This goes on in a loop

54
00:02:14,005 --> 00:02:17,008
until user chooses to save the meal,

55
00:02:17,008 --> 00:02:20,001
which goes to meal saver,

56
00:02:20,001 --> 00:02:23,008
which asks now to save the meal in Red30 DB.

57
00:02:23,008 --> 00:02:28,003
The flow and sequence diagram gives us this class diagram,

58
00:02:28,003 --> 00:02:30,006
with two new beans,

59
00:02:30,006 --> 00:02:33,005
one new method in dow to save the meal

60
00:02:33,005 --> 00:02:39,003
and several servlets to record meal as a use case.

61
00:02:39,003 --> 00:02:40,009
The dotted arrows

62
00:02:40,009 --> 00:02:44,005
between packages indicate package dependencies.

63
00:02:44,005 --> 00:02:46,005
So record meal package depends

64
00:02:46,005 --> 00:02:50,006
on beans and dow to implement its functionality.

65
00:02:50,006 --> 00:02:53,004
The data mode has two new tables,

66
00:02:53,004 --> 00:02:56,004
meal and serving, showing the relationship

67
00:02:56,004 --> 00:02:59,004
that a meal can belong to only one user

68
00:02:59,004 --> 00:03:02,003
and a meal can have many servings.

69
00:03:02,003 --> 00:03:06,003
The last use case to view diet log is fairly simple.

70
00:03:06,003 --> 00:03:08,009
User chooses the view diet log option.

71
00:03:08,009 --> 00:03:11,002
And enters the date range.

72
00:03:11,002 --> 00:03:14,009
The diet log controller asks dow to find the meal data

73
00:03:14,009 --> 00:03:17,006
from Red30 DB, which is then displayed

74
00:03:17,006 --> 00:03:20,000
by dietLogResults JSP.

75
00:03:20,000 --> 00:03:24,007
Finally, the class diagram shows a new package, dietlog

76
00:03:24,007 --> 00:03:26,005
with just one servlet added

77
00:03:26,005 --> 00:03:29,007
and one new method, find meals in dow.

78
00:03:29,007 --> 00:03:31,008
As usual, I have been writing code

79
00:03:31,008 --> 00:03:33,006
while building these models.

80
00:03:33,006 --> 00:03:35,008
So if you have been following my previous lessons,

81
00:03:35,008 --> 00:03:38,009
you can now understand the code I've provided.

82
00:03:38,009 --> 00:03:41,009
So let us just go ahead and run the code.

83
00:03:41,009 --> 00:03:44,008
The application is up and running

84
00:03:44,008 --> 00:03:49,009
and so I can go to the browser, log in as Carla

85
00:03:49,009 --> 00:03:52,007
and I've already added some records

86
00:03:52,007 --> 00:03:55,008
just to test the functionality.

87
00:03:55,008 --> 00:03:57,008
So if I go to view diet log,

88
00:03:57,008 --> 00:04:00,001
I can see some records have been added.

89
00:04:00,001 --> 00:04:02,000
Let me add one more meal

90
00:04:02,000 --> 00:04:05,000
so that we can test the functionality one more time.

91
00:04:05,000 --> 00:04:07,008
So for that, I go to record meal.

92
00:04:07,008 --> 00:04:11,004
Pick up a date, so let's say I chose March 3rd.

93
00:04:11,004 --> 00:04:13,006
Time.

94
00:04:13,006 --> 00:04:15,005
12:30 p.m.

95
00:04:15,005 --> 00:04:17,006
Meal, lunch.

96
00:04:17,006 --> 00:04:20,004
And here I say salad.

97
00:04:20,004 --> 00:04:22,007
We can see several salads here.

98
00:04:22,007 --> 00:04:25,006
Let me pick this one.

99
00:04:25,006 --> 00:04:27,006
And you can see that the product unit

100
00:04:27,006 --> 00:04:30,005
is already getting displayed here.

101
00:04:30,005 --> 00:04:33,006
Some quantity, add to meal.

102
00:04:33,006 --> 00:04:38,000
Let me add one more.

103
00:04:38,000 --> 00:04:41,000
And then add some juice.

104
00:04:41,000 --> 00:04:43,009
This displays the quantity as milliliter.

105
00:04:43,009 --> 00:04:45,008
Add to meal.

106
00:04:45,008 --> 00:04:47,004
And then save.

107
00:04:47,004 --> 00:04:50,002
We can see that the meal has been saved.

108
00:04:50,002 --> 00:04:51,009
I go to view diet log

109
00:04:51,009 --> 00:04:55,003
and shows the meal that was just saved.

110
00:04:55,003 --> 00:04:59,003
Now, these two use cases need much more refinement

111
00:04:59,003 --> 00:05:01,001
in terms of functionalities.

112
00:05:01,001 --> 00:05:03,005
For example, what if the user adds more

113
00:05:03,005 --> 00:05:05,006
than one lunch in a day?

114
00:05:05,006 --> 00:05:09,004
Should Red30 give a warning or just go ahead?

115
00:05:09,004 --> 00:05:12,004
Also, we need to write many more test cases

116
00:05:12,004 --> 00:05:14,007
for unit testing, integration testing,

117
00:05:14,007 --> 00:05:18,003
load testing, security testing, and so on.

118
00:05:18,003 --> 00:05:20,006
Such a system needs significant effort

119
00:05:20,006 --> 00:05:23,009
in planning and conducting testing activities

120
00:05:23,009 --> 00:05:26,006
before we can move it to production.

121
00:05:26,006 --> 00:05:29,000
For this case study, let us go ahead

122
00:05:29,000 --> 00:05:31,000
and check the code into Git.

123
00:05:31,000 --> 00:05:32,009
I'm back in Eclipse.

124
00:05:32,009 --> 00:05:34,006
And if I go into Git staging,

125
00:05:34,006 --> 00:05:37,006
I can see all the new files that have been added

126
00:05:37,006 --> 00:05:40,008
plus some changes made in older files.

127
00:05:40,008 --> 00:05:43,003
Let me stage all of them.

128
00:05:43,003 --> 00:05:48,005
And I'm checking into 04-03e.

129
00:05:48,005 --> 00:05:52,007
All use cases.

130
00:05:52,007 --> 00:05:57,001
Commit and push.

131
00:05:57,001 --> 00:06:00,004
Now, I need to merge my new branch into the master.

132
00:06:00,004 --> 00:06:02,004
So I'm in my Git folder.

133
00:06:02,004 --> 00:06:11,002
Here I say git checkout master.

134
00:06:11,002 --> 00:06:14,006
This has pulled the master already up to date

135
00:06:14,006 --> 00:06:19,003
and I say git merge 04-03,

136
00:06:19,003 --> 00:06:22,002
which is the branch I just now created.

137
00:06:22,002 --> 00:06:29,003
And then git push origin master.

138
00:06:29,003 --> 00:06:32,005
Now one last thing, Jenkins.

139
00:06:32,005 --> 00:06:34,004
Now I'm in Jenkins

140
00:06:34,004 --> 00:06:37,002
in DeployRed30 project.

141
00:06:37,002 --> 00:06:41,002
I simply say build now.

142
00:06:41,002 --> 00:06:44,000
Excellent, our build is successful.

143
00:06:44,000 --> 00:06:46,000
Let me go to my production URL.

144
00:06:46,000 --> 00:06:50,006
This is the DNS which I got from my EC2 management console.

145
00:06:50,006 --> 00:06:52,002
I log in here.

146
00:06:52,002 --> 00:06:55,003
I've already created the database tables

147
00:06:55,003 --> 00:06:57,008
so the user that I had been using

148
00:06:57,008 --> 00:07:01,002
in dev is available here as well.

149
00:07:01,002 --> 00:07:04,004
So Carla is logged in.

150
00:07:04,004 --> 00:07:07,006
I will go ahead and record a meal.

151
00:07:07,006 --> 00:07:12,008
And let's say this is for March 4th.

152
00:07:12,008 --> 00:07:14,006
Breakfast.

153
00:07:14,006 --> 00:07:19,000
And create a meal.

154
00:07:19,000 --> 00:07:22,000
And let me just pick.

155
00:07:22,000 --> 00:07:23,009
Buttermilk pancakes.

156
00:07:23,009 --> 00:07:26,000
Say 50 grams.

157
00:07:26,000 --> 00:07:31,008
Add to meal so you can see it is now a serving in my meal.

158
00:07:31,008 --> 00:07:33,008
And then I say save meal.

159
00:07:33,008 --> 00:07:35,001
The meal is saved.

160
00:07:35,001 --> 00:07:36,007
I go to view diet log

161
00:07:36,007 --> 00:07:39,002
and I can see the meal has been added.

162
00:07:39,002 --> 00:07:44,000
Now we have successful deployed our next product increment.

