Skip to content

Commit 066a369

Browse files
fixed #240
1 parent 00011b0 commit 066a369

File tree

11 files changed

+279
-2
lines changed

11 files changed

+279
-2
lines changed

src/main/java/org/woehlke/twitterwall/frontend/controller/UserController.java

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public String getUserForScreeName(
7373
@RequestParam(name= "page", defaultValue=""+ControllerHelper.FIRST_PAGE_NUMBER) int page,
7474
@PathVariable String screenName, Model model
7575
) {
76-
7776
if (User.isValidScreenName(screenName)) {
7877
User user = userService.findByScreenName(screenName);
7978
if(user==null){
@@ -240,6 +239,60 @@ public String getNotYetOnList(
240239
return "user/list/onlistNotYet";
241240
}
242241

242+
@RequestMapping("/list/usersWhoAreFollowersButNotFriends")
243+
public String findUsersWhoAreFollowersButNotFriends(
244+
@RequestParam(name= "page", defaultValue=""+ControllerHelper.FIRST_PAGE_NUMBER) int page,
245+
Model model
246+
){
247+
Pageable pageRequest = new PageRequest(
248+
page,
249+
frontendProperties.getPageSize(),
250+
Sort.Direction.ASC,
251+
"screenName"
252+
);
253+
model.addAttribute("users", userService.findUsersWhoAreFollowersButNotFriends(pageRequest));
254+
String symbol = Symbols.USER_CONNECTIONS.toString();
255+
String subtitle = "Users who are Followers but not Friends";
256+
model = controllerHelper.setupPage(model, title, subtitle, symbol);
257+
return "user/list/usersWhoAreFollowersButNotFriends";
258+
}
259+
260+
@RequestMapping("/list/usersWhoAreFollowersAndFriends")
261+
public String findUsersWhoAreFollowersAndFriends(
262+
@RequestParam(name= "page", defaultValue=""+ControllerHelper.FIRST_PAGE_NUMBER) int page,
263+
Model model
264+
){
265+
Pageable pageRequest = new PageRequest(
266+
page,
267+
frontendProperties.getPageSize(),
268+
Sort.Direction.ASC,
269+
"screenName"
270+
);
271+
model.addAttribute("users", userService.findUsersWhoAreFollowersAndFriends(pageRequest));
272+
String symbol = Symbols.USER_CONNECTIONS.toString();
273+
String subtitle = "Users who are Followers AND Friends";
274+
model = controllerHelper.setupPage(model, title, subtitle, symbol);
275+
return "user/list/usersWhoAreFollowersAndFriends";
276+
}
277+
278+
@RequestMapping("/list/usersWhoAreFriendsButNotFollowers")
279+
public String findUsersWhoAreFriendsButNotFollowers(
280+
@RequestParam(name= "page", defaultValue=""+ControllerHelper.FIRST_PAGE_NUMBER) int page,
281+
Model model
282+
){
283+
Pageable pageRequest = new PageRequest(
284+
page,
285+
frontendProperties.getPageSize(),
286+
Sort.Direction.ASC,
287+
"screenName"
288+
);
289+
model.addAttribute("users", userService.findUsersWhoAreFriendsButNotFollowers(pageRequest));
290+
String symbol = Symbols.USER_CONNECTIONS.toString();
291+
String subtitle = "Users who are Friends but not Followers";
292+
model = controllerHelper.setupPage(model, title, subtitle, symbol);
293+
return "user/list/usersWhoAreFriendsButNotFollowers";
294+
}
295+
243296
private static final Logger log = LoggerFactory.getLogger(UserController.class);
244297

245298
private final UserService userService;

src/main/java/org/woehlke/twitterwall/frontend/controller/common/Symbols.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public enum Symbols {
1616
EXCEPTION("<i class=\"fa fa-bolt\" aria-hidden=\"true\"></i>"),
1717
LEAF("<i class=\"fa fa-leaf\" aria-hidden=\"true\"></i>"),
1818
DATABASE("<i class=\"fa fa-database\" aria-hidden=\"true\"></i>"),
19-
USER_NOT_YET_ON_LIST("<i class=\"fa fa-handshake-o\" aria-hidden=\"true\"></i>\n"),
19+
USER_NOT_YET_ON_LIST("<i class=\"fa fa-handshake-o\" aria-hidden=\"true\"></i>"),
20+
USER_CONNECTIONS("<i class=\"fa fa-handshake-o\" aria-hidden=\"true\"></i>"),
2021
USER_FRIENDS("<i class=\"fa fa-users\" aria-hidden=\"true\"></i>"),
2122
USER_FOLLOWER("<i class=\"fa fa-users\" aria-hidden=\"true\"></i>"),
2223
TASK("<i class=\"fa fa-check-square\" aria-hidden=\"true\"></i>"),

src/main/java/org/woehlke/twitterwall/oodm/entities/User.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@
7878
@NamedQuery(
7979
name="User.findByUniqueId",
8080
query="select t from User as t where t.idTwitter=:idTwitter and t.screenNameUnique=:screenNameUnique"
81+
),
82+
@NamedQuery(
83+
name="User.findUsersWhoAreFriendsButNotFollowers",
84+
query="select t from User as t where t.taskInfo.fetchFollower=false and t.taskInfo.fetchFriends=true"
85+
),
86+
@NamedQuery(
87+
name="User.findUsersWhoAreFollowersAndFriends",
88+
query="select t from User as t where t.taskInfo.fetchFollower=true and t.taskInfo.fetchFriends=true"
89+
),
90+
@NamedQuery(
91+
name="User.findUsersWhoAreFollowersButNotFriends",
92+
query="select t from User as t where t.taskInfo.fetchFollower=true and t.taskInfo.fetchFriends=false"
8193
)
8294
})
8395
@NamedNativeQueries({

src/main/java/org/woehlke/twitterwall/oodm/repositories/UserRepository.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ public interface UserRepository extends DomainRepository<User>,UserRepositoryCus
5151
)
5252
Page<User> findUsersForHashTag(@Param("hashtagText") String hashtagText, Pageable pageRequest);
5353

54+
@Query(name="User.findUsersWhoAreFriendsButNotFollowers")
55+
Page<User> findUsersWhoAreFriendsButNotFollowers(Pageable pageRequest);
56+
57+
@Query(name="User.findUsersWhoAreFollowersAndFriends")
58+
Page<User> findUsersWhoAreFollowersAndFriends(Pageable pageRequest);
59+
60+
@Query(name="User.findUsersWhoAreFollowersButNotFriends")
61+
Page<User> findUsersWhoAreFollowersButNotFriends(Pageable pageRequest);
62+
5463
@Query(name="User.countAllUser2HashTag",nativeQuery=true)
5564
long countAllUser2HashTag();
5665

src/main/java/org/woehlke/twitterwall/oodm/service/UserService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public interface UserService extends DomainObjectWithEntitiesService<User>,Domai
3434

3535
Page<User> getNotYetOnList(Pageable pageRequest);
3636

37+
Page<User> findUsersWhoAreFriendsButNotFollowers(Pageable pageRequest);
38+
39+
Page<User> findUsersWhoAreFollowersAndFriends(Pageable pageRequest);
40+
41+
Page<User> findUsersWhoAreFollowersButNotFriends(Pageable pageRequest);
42+
3743
Page<Object2Entity> findAllUser2HashTag(Pageable pageRequest);
3844

3945
Page<Object2Entity> findAllUser2Media(Pageable pageRequest);

src/main/java/org/woehlke/twitterwall/oodm/service/impl/UserServiceImpl.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ public Page<User> getNotYetOnList(Pageable pageRequest) {
6161
return userRepository.findNotYetOnList(pageRequest);
6262
}
6363

64+
@Override
65+
public Page<User> findUsersWhoAreFriendsButNotFollowers(Pageable pageRequest) {
66+
return userRepository.findUsersWhoAreFriendsButNotFollowers(pageRequest);
67+
}
68+
69+
@Override
70+
public Page<User> findUsersWhoAreFollowersAndFriends(Pageable pageRequest) {
71+
return userRepository.findUsersWhoAreFollowersAndFriends(pageRequest);
72+
}
73+
74+
@Override
75+
public Page<User> findUsersWhoAreFollowersButNotFriends(Pageable pageRequest) {
76+
return userRepository.findUsersWhoAreFollowersButNotFriends(pageRequest);
77+
}
78+
6479
@Override
6580
public Page<User> getOnList(Pageable pageRequest) {
6681
return userRepository.findOnList(pageRequest);

src/main/resources/templates/application/management.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ <h3>Your Options:</h3>
8787
<i class="fa fa-user" aria-hidden="true"></i>
8888
<span>List Users, who are Friends</span>
8989
</a>
90+
<a class="list-group-item" href="/user/list/usersWhoAreFollowersButNotFriends" th:href="@{/user/list/usersWhoAreFollowersButNotFriends}">
91+
<i class="fa fa-handshake-o" aria-hidden="true"></i>
92+
<span>Users, who are Followers but not Friends</span>
93+
</a>
94+
<a class="list-group-item" href="/user/list/usersWhoAreFriendsButNotFollowers" th:href="@{/user/list/usersWhoAreFriendsButNotFollowers}">
95+
<i class="fa fa-handshake-o" aria-hidden="true"></i>
96+
<span>Users, who are Friends but not Followers</span>
97+
</a>
98+
<a class="list-group-item" href="/user/list/usersWhoAreFollowersAndFriends" th:href="@{/user/list/usersWhoAreFollowersAndFriends}">
99+
<i class="fa fa-handshake-o" aria-hidden="true"></i>
100+
<span>Users, who are Followers and Friends</span>
101+
</a>
90102
<a class="list-group-item" href="/user/list/notyetfriends" th:href="@{/user/list/notyetfriends}">
91103
<i class="fa fa-user" aria-hidden="true"></i>
92104
<span>List Users, who are Not Yet Friends</span>

src/main/resources/templates/layoutMain.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,25 @@
199199
</a>
200200
</li>
201201
<li role="separator" class="divider"></li>
202+
<li>
203+
<a href="/user/list/usersWhoAreFollowersButNotFriends" th:href="@{/user/list/usersWhoAreFollowersButNotFriends}">
204+
<i class="fa fa-handshake-o" aria-hidden="true"></i>
205+
<span>Users, who are Followers but not Friends</span>
206+
</a>
207+
</li>
208+
<li>
209+
<a href="/user/list/usersWhoAreFriendsButNotFollowers" th:href="@{/user/list/usersWhoAreFriendsButNotFollowers}">
210+
<i class="fa fa-handshake-o" aria-hidden="true"></i>
211+
<span>Users, who are Friends but not Followers</span>
212+
</a>
213+
</li>
214+
<li>
215+
<a href="/user/list/usersWhoAreFollowersAndFriends" th:href="@{/user/list/usersWhoAreFollowersAndFriends}">
216+
<i class="fa fa-handshake-o" aria-hidden="true"></i>
217+
<span>Users, who are Followers and Friends</span>
218+
</a>
219+
</li>
220+
<li role="separator" class="divider"></li>
202221
<li>
203222
<a href="/user/list/onlist" th:href="@{/user/list/onlist}">
204223
<i class="fa fa-user" aria-hidden="true"></i>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml"
3+
xmlns:th="http://www.thymeleaf.org"
4+
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
5+
<head th:include="layoutMain :: tw-head">
6+
</head>
7+
<body id="page-top" class="page-2" style="padding-top:50px; padding-bottom:200px;">
8+
<header th:include="layoutMain :: tw-header" ></header>
9+
<main class="page-content">
10+
<div class="container">
11+
<div class="tw-pager-above">
12+
<div class="row">
13+
<div class="col-md-12">
14+
<span class="tw-pager-arrow tw-pager-up" th:if="${users.hasPrevious()}">
15+
<a href="" th:href="@{|/user/list/usersWhoAreFollowersAndFriends?page=${users.previousPageable().pageNumber}|}">
16+
<span>
17+
<i class="fa fa-chevron-circle-up" aria-hidden="true"></i>
18+
</span>
19+
</a>
20+
</span>
21+
</div>
22+
<div class="col-md-12">
23+
<hr />
24+
</div>
25+
</div>
26+
</div>
27+
<div th:include="layoutUserList :: tw-user-list" ></div>
28+
<div class="tw-pager-below">
29+
<div class="row">
30+
<div class="col-md-12">
31+
<span class="tw-pager-arrow tw-pager-down" th:if="${users.hasNext()}">
32+
<a href="" th:href="@{|/user/list/usersWhoAreFollowersAndFriends?page=${users.nextPageable().pageNumber}|}" >
33+
<span>
34+
<i class="fa fa-chevron-circle-down" aria-hidden="true"></i>
35+
</span>
36+
</a>
37+
</span>
38+
</div>
39+
</div>
40+
</div>
41+
</div>
42+
</main>
43+
44+
<section th:include="layoutMain :: tw-history-back-section" >
45+
</section>
46+
47+
<footer th:include="layoutMain :: footer" >
48+
</footer>
49+
</body>
50+
</html>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml"
3+
xmlns:th="http://www.thymeleaf.org"
4+
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
5+
<head th:include="layoutMain :: tw-head">
6+
</head>
7+
<body id="page-top" class="page-2" style="padding-top:50px; padding-bottom:200px;">
8+
<header th:include="layoutMain :: tw-header" ></header>
9+
<main class="page-content">
10+
<div class="container">
11+
<div class="tw-pager-above">
12+
<div class="row">
13+
<div class="col-md-12">
14+
<span class="tw-pager-arrow tw-pager-up" th:if="${users.hasPrevious()}">
15+
<a href="" th:href="@{|/user/list/usersWhoAreFollowersAndFriends?page=${users.previousPageable().pageNumber}|}">
16+
<span>
17+
<i class="fa fa-chevron-circle-up" aria-hidden="true"></i>
18+
</span>
19+
</a>
20+
</span>
21+
</div>
22+
<div class="col-md-12">
23+
<hr />
24+
</div>
25+
</div>
26+
</div>
27+
<div th:include="layoutUserList :: tw-user-list" ></div>
28+
<div class="tw-pager-below">
29+
<div class="row">
30+
<div class="col-md-12">
31+
<span class="tw-pager-arrow tw-pager-down" th:if="${users.hasNext()}">
32+
<a href="" th:href="@{|/user/list/usersWhoAreFollowersAndFriends?page=${users.nextPageable().pageNumber}|}" >
33+
<span>
34+
<i class="fa fa-chevron-circle-down" aria-hidden="true"></i>
35+
</span>
36+
</a>
37+
</span>
38+
</div>
39+
</div>
40+
</div>
41+
</div>
42+
</main>
43+
44+
<section th:include="layoutMain :: tw-history-back-section" >
45+
</section>
46+
47+
<footer th:include="layoutMain :: footer" >
48+
</footer>
49+
</body>
50+
</html>

0 commit comments

Comments
 (0)