OK now let's convert the remaining part of the share functionality and before doing that let's just 2
boost like refactoring your far the previous feature which is marking as kid friendly. 3
So we have some logic here. 4
So let's actually do some changes here so that we move some of the logic into into controller and also 5
into our manager classes. 6
OK. 7
So we have this here. 8
Here's where the get friendly functionality starts so let's do this. 9
Copy it from here. 10
OK so here we are testing if bookmark is easy kid friendly eligible. 11
And if the status is the status equals unknown for the kid friendly status then we are getting the kid 12
friendly status information. 13
So which means we are using randomisation but you can think that the user is actually giving giving 14
his decision his or her decision. 15
Now let's move this particular fart's functionality here. 16
It's a very simple statement but let's do this and controller actually in manager. 17
OK. 18
So we are doing it in the view which is not right. 19
So to do it the right way needs to be done in the back and not in the front. 20
So let's So that's the reason why I want to refactor this. 21
So let's just do that. 22
Let's call them a second term illustrators let's use the same name 23
and let's pass it friendly status 24
as well as the bookmark. 25
Now that's added automatically. 26
So create matter. 27
No let's just simply relayed this in to our manager because we shouldn't have too much of business logic 28
. 29
In fact we shouldn't have any business like logic here. 30
So let's say 31
. 32
So in this year. 33
And let's ontogeny that template. 34
Now let's go back and go. 35
View-Master let's just copy this whole thing. 36
And that's just simply more work. 37
So that said. 38
So we are good with this. 39
Me Yes we are good with this. 40
And just you're on this 41
seems fine. 42
Now let's just do one more tang. 43
So let's also do some bookkeeping. 44
So here there is this user who is marking your desk friendly. 45
Let's also save this information. 46
Typically when you are implementing any software or any web application you would this kind of an application 47
. 48
You would also save who the user is who who though who is the user that has performed this action. 49
So in this case there is a certain editor or a chief editor who is marking this particular item as kid 50
friendly and it would be nice to him to also save that information who that particular users who's doing 51
the marking action. 52
So let's just go into the bookmark class here. 53
So do a control shift our bookmark. 54
So let's just either a new free or irate user let's call it does get friendly mocked by. 55
So this will have a red card of the user who has performed this particular action. 56
And that's also create get in and sergers 57
reduce. 58
So we are good with that. 59
And so now from the weblink in the view class let's pass this information to the controller. 60
So let's just see user. 61
So let's pass this information user. 62
But knowing how to accomplish compulsion Urso that this set change the let's pick this option set kid 63
friendly status and parameter user. 64
So eclipse is going to do the job for us. 65
So let's also do the same for this with a manager class. 66
And once again we will to the same option. 67
So eclipse then automatically update the matter signature here. 68
Now let's say Mark Dodds said he currently MMOG by it's supposed to be user here that's it. 69
Now let's bring this information it into status here let's call it does mark by. 70
Let's bring the user's e-mail. 71
And let's also print just the book mark information and also do a control shift. 72
So that's it. 73
Now let's just go ahead and run this short of you though here. 74
So the 30 was at first and second users are not staff members. 75
The third is a staff member here and here it is. 76
So this is rejected. 77
This particular item is rejected and it is marked by this user user too. 78
And this is of eyeblink information. 79
Now there is a new item that's bookmarked and that item is approved as kid friendly and it was marked 80
by once again the same user. 81
So that's bookmarking and that's bookkeeping information. 82
So now here in the bookmark manager we are simply we are not invoking that Dolliver are typically people 83
invoke the dollar on past this bookmark and then store that information in the database. 84
But in this case let's it's fine because bookmark is an object reference. 85
So the value whatever value is set is is reflected. 86
So just assume that it's also reflected in the database because this and to did it presents arrowing 87
the database just think that it is also. 88
So there is a reference to that particular object in the database anyway so it's not required. 89
That really required that we save it. 90
But you know we can in reality we would actually save it. 91
But for now it is definitely fine. 92
So that's about it. 93
So let's just go ahead and continue our implementation of the shared functionality and let's complete 94
data. 95
So let's go back into our real class. 96
OK so that's marking us get friendly now Ed.. 97
One of the staff members have has to do the sharing operation also so the staff member gets to bookmark 98
. 99
I'm also Marcus kid friendly and not share any bookmarks. 100
So here lots. 101
Since the condition is already here that if the user is an editor or the chief editor or need then the 102
user will be able to market get friendly. 103
Only then the user will be able to perform the shading operation. 104
So let's have the sharing functionality here. 105
And we know that there are some constraints for sharing. 106
And one of them is that the get friendly status has to be approved. 107
So if it is a bookmark that is approved only then we will be able to share it it needs to be a good 108
friendly bookmark. 109
So for that. 110
So we already have this bookmark. 111
Copy this on your differences died instead of unknown. 112
It's supposed to be she approved. 113
OK. 114
So instead of on and on. 115
This is this has to be a pro. 116
No it means that it's a good friendly bookmark. 117
OK. 118
So now the second condition so this is only one of the conditions that it needs to be a good friendly 119
bookmark. 120
But the second constraint is that it needs to be either a book or eyeblink only then it can be shared 121
which means that they are implementing those two kinds of items are implementing shareable. 122
OK. 123
So and this gives the bookmark. 124
So here is a bookmark it needs to be an instance of Shater right. 125
Because both book and weblink are implement being shareable. 126
So. 127
So the way we can ensure that is by using an instance of operator. 128
So now we know that the bookmark is an instance of shareable and only then we will do the shading. 129
So if the bookmarked on site will be movie then we won't do an end run into this if block. 130
Import important. 131
So even after it can be shared it may be that the editor the staff member does not want to share it 132
so it's up to it's up to the staff member whether he or she wants to share it or not. 133
So once again to use randomisation for that and it's good that it's hard to generate this 134
that to use just a simple The same one here this is hybridize Boullion. 135
So not to assign this 136
to a variable called E share not the best name here but I guess it's OK. 137
Now let's see if we share only then we would share it with the third party site. 138
OK. 139
So let's introduce a new method. 140
So let's just assume that a user wants to share this idea he has clicked on the link shared with good 141
snips and then a control will be sent back to the controller so that the necessary actions will be taken 142
in the Bakken. 143
So let's say Get instance and that's created a share here 144
and we would also be doing some bookoo bookkeeping just like the way we have done for kid friendly status 145
. 146
So we want to know which user is sharing the item. 147
OK so we're going to do that. 148
So let's also pass that and let's pass the bookmark. 149
OK. 150
So we are sharing this you this user is sharing this bookmark. 151
OK. 152
So it is. 153
And as always this one simply release to the bookmark manager 154
and let's all go create this method. 155
OK. 156
So let's go back into this bookmark class and for bookkeeping Let's introduce a new variable which is 157
of type user and let's say shared by. 158
So it's very similar to good for me my bye. 159
And let's also generally the getters and setters. 160
OK there you go. 161
Save it. 162
Go back to manicure. 163
Let's just say. 164
So that's the user's information that's who's sharing. 165
And let's put a system not a out statement here 166
. 167
So here is a bookmark but we don't know whether it is an instance of book of eyeblink. 168
Right. 169
We need to get the data that we need to invoke to get some data so far that we need to do or don't cast 170
cast here. 171
So because we need to share that we need to get that data and then we need to share it with the third 172
party website. 173
So let's just do this first let's check whether it is an instance of book or whether it's an instance 174
of eyeblink sofort is an instance of book. 175
You know we can pass the we can get item didn't diameter we can do this we can see a book bookmark so 176
we can type. 177
And then we can invoke the get item radiometer 178
here and into this. 179
So in this sense we there is not a real third party website it's just a fictitious website but we don't 180
have it. 181
So we are all we can do is let's just print it here probably in future we can just write it into a file 182
so that some other you know some kind of a job of some kind of a scope will actually send that information 183
to the third party website. 184
Sometimes it's done that way or sometimes you may. 185
The third party website might have a web service and we may pass this information directly programmatically 186
using that web service soby but pass this information to that Web site was in a program category. 187
Now let's also do as of just copy this here let's copy the whole thing in sternal instead instance of 188
weblink. 189
And here also eyeblink get our number. 190
So we're invoking the get item radiometer. 191
So that's right here. 192
And it's just time to run this. 193
It's just go ahead and run the launch. 194
Let's just look at the 30 user here to get friendly straight as is proved. 195
But maybe that the data will be shared. 196
The randomisation function maybe or did not or did not it done True which means that they should not 197
be share on Hensick was not shared. 198
So in this case it was movie. 199
It was rejected movie approved but movie is something that we should not be shared. 200
So we don't have that now. 201
Here you can see that this is a book and it is approved and that is here is the day that is to be shared 202
. 203
So this is the XM string which God created and that thing that we are passing this information to our 204
partnerships right now here is the term user. 205
Same thing your good friend Mr. does is approved. 206
And it is have a blank. 207
And I share so only book and book and ramblings can be shared. 208
OK now 209
so in future we are going to extend this right now the decisions are made by RR and a musician but in 210
future we will get that we take the input. 211
These methods will take input from the user itself and we will do it after completing the Iowa chapter 212
so we can write it to here. 213
Which means that we will be doing that in future. 214
So I will say below methods thats 215
simulate user and book score. 216
I also read the book. 217
Wow. 218
Answer. 219
OK. 220
So thats a good Dudack. 221
But the nice thing about this is this Dagget itself as something that Eclipse keeps track of. 222
So if you want to see what all you do ask you how are unique gurus going to Windows show you and set 223
tasks and he added this is here this is the one which we just brought. 224
So that way you can easily find all the clues that you how it will show all the clues here. 225
And that way you can go back and look at what youre interested in and then now. 226
So if you think you're ready you can just go ahead and fill in the new implementation. 227
Okay so that's a nice thing about to do and you may note is that we did not implement DDT for the last 228
two features at least for this feature. 229
We have done it for IIS good friendly eligible. 230
That's because the logic is too simple here. 231
For example in this case we are just taking an input from the user order. 232
Here we are using randomisation. 233
And it's just too simple process. 234
In fact it doesn't even fit well for TDD. 235
So we that's why we did not have DDD and the rest of the logic also and bookmark manager are very very 236
it's very simple logic. 237
So since it is so simple we did not use TDD approach. 238
So we were used to really only if it is really required because if you think if we think that it's going 239
to be you know the logic might break it has a possibility to break on lead then we would use DDT. 240
But if it is very simple simple setting and you know using a set or Gurjars then we don't have to use 241
DDT. 242
OK so that's about it. 243
And that's the final feature which we have implemented. 244
And please go ahead and implement whatever we have implemented in this lesson. 245
OK. 246
Happy coding. 247
Thank you.