Skip to content

Commit 3be51b8

Browse files
fixed #271
1 parent 6e78a7a commit 3be51b8

29 files changed

+199
-183
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.woehlke.twitterwall.frontend.content;
2+
3+
import org.springframework.ui.Model;
4+
import org.springframework.web.servlet.ModelAndView;
5+
6+
/**
7+
* Created by tw on 18.07.17.
8+
*/
9+
public interface ContentFactory {
10+
11+
int FIRST_PAGE_NUMBER = 0;
12+
13+
ModelAndView setupPage(ModelAndView mav, String title, String subtitle, String symbol);
14+
15+
Model setupPage(Model model, String title, String subtitle, String symbol);
16+
}

src/main/java/org/woehlke/twitterwall/frontend/common/impl/ControllerHelperImpl.java renamed to src/main/java/org/woehlke/twitterwall/frontend/content/impl/ContentFactoryImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.woehlke.twitterwall.frontend.common.impl;
1+
package org.woehlke.twitterwall.frontend.content.impl;
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
@@ -8,14 +8,14 @@
88
import org.springframework.web.servlet.ModelAndView;
99
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
1010
import org.woehlke.twitterwall.conf.properties.FrontendProperties;
11-
import org.woehlke.twitterwall.frontend.common.ControllerHelper;
11+
import org.woehlke.twitterwall.frontend.content.ContentFactory;
1212
import org.woehlke.twitterwall.frontend.content.Page;
1313

1414
/**
1515
* Created by tw on 18.07.17.
1616
*/
1717
@Component
18-
public class ControllerHelperImpl implements ControllerHelper {
18+
public class ContentFactoryImpl implements ContentFactory {
1919

2020
private Page setupPage(Page page, String title, String subtitle, String symbol) {
2121
page.setTitle(title);
@@ -56,7 +56,7 @@ public Model setupPage(Model model, String title, String subtitle, String symbol
5656
return model;
5757
}
5858

59-
private static final Logger log = LoggerFactory.getLogger(ControllerHelperImpl.class);
59+
private static final Logger log = LoggerFactory.getLogger(ContentFactoryImpl.class);
6060

6161
private final FrontendProperties frontendProperties;
6262

@@ -74,7 +74,7 @@ public Model setupPage(Model model, String title, String subtitle, String symbol
7474

7575

7676
@Autowired
77-
public ControllerHelperImpl(
77+
public ContentFactoryImpl(
7878
FrontendProperties frontendProperties,
7979
TwitterProperties twitterProperties
8080
) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.springframework.web.bind.annotation.RequestMapping;
77
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
88
import org.woehlke.twitterwall.frontend.content.Symbols;
9-
import org.woehlke.twitterwall.frontend.common.ControllerHelper;
9+
import org.woehlke.twitterwall.frontend.content.ContentFactory;
1010

1111
/**
1212
* Created by tw on 03.07.17.
@@ -21,19 +21,19 @@ public String managementPage(Model model) {
2121
String title = "Application Management";
2222
String subtitle = twitterProperties.getSearchQuery();
2323
String symbol = Symbols.DATABASE.toString();
24-
model = controllerHelper.setupPage(model,title,subtitle,symbol);
24+
model = contentFactory.setupPage(model,title,subtitle,symbol);
2525
return "application/management";
2626
}
2727

28-
private final ControllerHelper controllerHelper;
28+
private final ContentFactory contentFactory;
2929

3030
private final TwitterProperties twitterProperties;
3131

3232
@Autowired
3333
public ApplicationController(
34-
ControllerHelper controllerHelper,
34+
ContentFactory contentFactory,
3535
TwitterProperties twitterProperties) {
36-
this.controllerHelper = controllerHelper;
36+
this.contentFactory = contentFactory;
3737
this.twitterProperties = twitterProperties;
3838
}
3939

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.woehlke.twitterwall.conf.properties.FrontendProperties;
1212
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
1313
import org.woehlke.twitterwall.frontend.content.Symbols;
14-
import org.woehlke.twitterwall.frontend.common.ControllerHelper;
14+
import org.woehlke.twitterwall.frontend.content.ContentFactory;
1515
import org.woehlke.twitterwall.oodm.model.*;
1616
import org.woehlke.twitterwall.oodm.model.parts.CountedEntities;
1717
import org.woehlke.twitterwall.oodm.model.transients.Object2Entity;
@@ -35,7 +35,7 @@ public String domainCount(Model model) {
3535
String title = "Counted Entities";
3636
String subtitle = twitterProperties.getSearchQuery();
3737
String symbol = Symbols.DATABASE.toString();
38-
model = controllerHelper.setupPage(model,title,subtitle,symbol);
38+
model = contentFactory.setupPage(model,title,subtitle,symbol);
3939
CountedEntities countedEntities =this.countedEntitiesService.countAll();
4040
model.addAttribute("countedEntities", countedEntities);
4141
return "application/domain/count";
@@ -47,15 +47,15 @@ public String domainDeleteAll(Model model) {
4747
String title = "Counted Entities";
4848
String subtitle = twitterProperties.getSearchQuery();
4949
String symbol = Symbols.DATABASE.toString();
50-
model = controllerHelper.setupPage(model,title,subtitle,symbol);
50+
model = contentFactory.setupPage(model,title,subtitle,symbol);
5151
CountedEntities countedEntities =this.countedEntitiesService.deleteAll();
5252
model.addAttribute("countedEntities", countedEntities);
5353
return "application/domain/count";
5454
}
5555

5656
@RequestMapping(path="/tweet/hashtag")
5757
public String domainCountTweet2hashtag(
58-
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
58+
@RequestParam(name= "page", defaultValue=""+ ContentFactory.FIRST_PAGE_NUMBER) int page,
5959
Model model
6060
) {
6161
String title = "Tweet -> HashTag";
@@ -79,7 +79,7 @@ public String domainCountTweet2hashtag(
7979

8080
@RequestMapping(path="/tweet/media")
8181
public String domainCountTweet2media(
82-
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
82+
@RequestParam(name= "page", defaultValue=""+ ContentFactory.FIRST_PAGE_NUMBER) int page,
8383
Model model
8484
) {
8585
String title = "Tweet -> Media";
@@ -103,7 +103,7 @@ public String domainCountTweet2media(
103103

104104
@RequestMapping(path="/tweet/mention")
105105
public String domainCountTweet2mention(
106-
@RequestParam(name= "page" ,defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
106+
@RequestParam(name= "page" ,defaultValue=""+ ContentFactory.FIRST_PAGE_NUMBER) int page,
107107
Model model
108108
) {
109109
String title = "Tweet -> Mention";
@@ -127,7 +127,7 @@ public String domainCountTweet2mention(
127127

128128
@RequestMapping(path="/tweet/tickersymbol")
129129
public String domainCountTweet2tickersymbol(
130-
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
130+
@RequestParam(name= "page", defaultValue=""+ ContentFactory.FIRST_PAGE_NUMBER) int page,
131131
Model model
132132
) {
133133
String title = "Tweet -> TickerSymbol";
@@ -151,7 +151,7 @@ public String domainCountTweet2tickersymbol(
151151

152152
@RequestMapping(path="/tweet/url")
153153
public String domainCountTweet2url(
154-
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
154+
@RequestParam(name= "page", defaultValue=""+ ContentFactory.FIRST_PAGE_NUMBER) int page,
155155
Model model
156156
) {
157157
String title = "Tweet -> Url";
@@ -175,7 +175,7 @@ public String domainCountTweet2url(
175175

176176
@RequestMapping(path="/user/hashtag")
177177
public String domainCountUserprofile2hashtag(
178-
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
178+
@RequestParam(name= "page", defaultValue=""+ ContentFactory.FIRST_PAGE_NUMBER) int page,
179179
Model model
180180
) {
181181
String title = "UserProfile -> HashTag";
@@ -199,7 +199,7 @@ public String domainCountUserprofile2hashtag(
199199

200200
@RequestMapping(path="/user/media")
201201
public String domainCountUserprofile2media(
202-
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
202+
@RequestParam(name= "page", defaultValue=""+ ContentFactory.FIRST_PAGE_NUMBER) int page,
203203
Model model
204204
) {
205205
String title = "UserProfile -> Media";
@@ -223,7 +223,7 @@ public String domainCountUserprofile2media(
223223

224224
@RequestMapping(path="/user/mention")
225225
public String domainCountUserprofile2mention(
226-
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
226+
@RequestParam(name= "page", defaultValue=""+ ContentFactory.FIRST_PAGE_NUMBER) int page,
227227
Model model
228228
) {
229229
String title = "UserProfile -> Mention";
@@ -247,7 +247,7 @@ public String domainCountUserprofile2mention(
247247

248248
@RequestMapping(path="/user/tickersymbol")
249249
public String domainCountUserprofile2Tickersymbol(
250-
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
250+
@RequestParam(name= "page", defaultValue=""+ ContentFactory.FIRST_PAGE_NUMBER) int page,
251251
Model model
252252
) {
253253
String title = "UserProfile -> TickerSymbol";
@@ -271,7 +271,7 @@ public String domainCountUserprofile2Tickersymbol(
271271

272272
@RequestMapping(path="/user/url")
273273
public String domainCountUserprofile2Url(
274-
@RequestParam(name= "page", defaultValue=""+ ControllerHelper.FIRST_PAGE_NUMBER) int page,
274+
@RequestParam(name= "page", defaultValue=""+ ContentFactory.FIRST_PAGE_NUMBER) int page,
275275
Model model
276276
) {
277277
String title = "UserProfile -> Url";
@@ -296,13 +296,13 @@ public String domainCountUserprofile2Url(
296296
private void setUpThisPage(String title,Model model){
297297
String subtitle = "Counted Entities";
298298
String symbol = Symbols.DATABASE.toString();
299-
model = controllerHelper.setupPage(model,title,subtitle,symbol);
299+
model = contentFactory.setupPage(model,title,subtitle,symbol);
300300
}
301301

302302

303303
private final FrontendProperties frontendProperties;
304304

305-
private final ControllerHelper controllerHelper;
305+
private final ContentFactory contentFactory;
306306

307307
private final TweetService tweetService;
308308

@@ -325,7 +325,7 @@ private void setUpThisPage(String title,Model model){
325325
@Autowired
326326
public CountedEntitiesController(
327327
FrontendProperties frontendProperties,
328-
ControllerHelper controllerHelper,
328+
ContentFactory contentFactory,
329329
TweetService tweetService,
330330
UserService userService,
331331
HashTagService hashTagService,
@@ -335,7 +335,7 @@ public CountedEntitiesController(
335335
UrlService urlService,
336336
CountedEntitiesService countedEntitiesService, TwitterProperties twitterProperties) {
337337
this.frontendProperties = frontendProperties;
338-
this.controllerHelper = controllerHelper;
338+
this.contentFactory = contentFactory;
339339
this.tweetService = tweetService;
340340
this.userService = userService;
341341
this.hashTagService = hashTagService;

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
1616
import org.woehlke.twitterwall.conf.properties.FrontendProperties;
1717
import org.woehlke.twitterwall.frontend.content.Symbols;
18-
import org.woehlke.twitterwall.frontend.common.ControllerHelper;
18+
import org.woehlke.twitterwall.frontend.content.ContentFactory;
1919
import org.woehlke.twitterwall.oodm.model.transients.HashTagCounted;
2020
import org.woehlke.twitterwall.oodm.model.Tweet;
2121
import org.woehlke.twitterwall.oodm.model.User;
@@ -28,7 +28,7 @@
2828
import java.util.regex.Matcher;
2929
import java.util.regex.Pattern;
3030

31-
import static org.woehlke.twitterwall.frontend.common.ControllerHelper.FIRST_PAGE_NUMBER;
31+
import static org.woehlke.twitterwall.frontend.content.ContentFactory.FIRST_PAGE_NUMBER;
3232
import static org.woehlke.twitterwall.oodm.model.HashTag.HASHTAG_TEXT_PATTERN;
3333

3434
/**
@@ -46,7 +46,7 @@ public String getAll(
4646
String subtitle = "all";
4747
String title = "HashTag";
4848
String symbol = Symbols.HASHTAG.toString();
49-
model = controllerHelper.setupPage(model,title,subtitle,symbol);
49+
model = contentFactory.setupPage(model,title,subtitle,symbol);
5050
Pageable pageRequest = new PageRequest(
5151
page,
5252
frontendProperties.getPageSize(),
@@ -76,7 +76,7 @@ public String findHashTagById(
7676
String subtitle = "Tweets und User für HashTag";
7777
String title = hashTag.getText();
7878
String symbol = Symbols.HASHTAG.toString();
79-
model = controllerHelper.setupPage(model, title, subtitle, symbol);
79+
model = contentFactory.setupPage(model, title, subtitle, symbol);
8080
model.addAttribute("hashTag",hashTag);
8181
log.debug(msg+" try to: tweetService.findTweetsForHashTag: ");
8282
Page<Tweet> tweets = tweetService.findTweetsForHashTag(hashTag,pageRequestTweet);
@@ -107,7 +107,7 @@ public String hashTagFromTweetsAndUsers(
107107
String subtitle = "Tweets und User für HashTag";
108108
String title = text;
109109
String symbol = Symbols.HASHTAG.toString();
110-
model = controllerHelper.setupPage(model, title, subtitle, symbol);
110+
model = contentFactory.setupPage(model, title, subtitle, symbol);
111111
log.debug(msg + " try to: hashTagService.findByText ");
112112
HashTag hashTag = hashTagService.findByText(text);
113113
model.addAttribute("hashTag",hashTag);
@@ -136,7 +136,7 @@ public String hashTagsOverview(
136136
String title = "HashTags";
137137
String subtitle = twitterProperties.getSearchQuery();
138138
String symbol = Symbols.HASHTAG.toString();
139-
model = controllerHelper.setupPage(model,title,subtitle,symbol);
139+
model = contentFactory.setupPage(model,title,subtitle,symbol);
140140
int size= frontendProperties.getPageSize() * 2;
141141
Pageable pageRequestTweets = new PageRequest(pageTweet,size);
142142
Pageable pageRequestUsers = new PageRequest(pageUser,size);
@@ -159,7 +159,7 @@ public String hashTagsOverview(
159159

160160
private final UserService userService;
161161

162-
private final ControllerHelper controllerHelper;
162+
private final ContentFactory contentFactory;
163163

164164
@Autowired
165165
public HashTagController(
@@ -168,14 +168,14 @@ public HashTagController(
168168
HashTagService hashTagService,
169169
TweetService tweetService,
170170
UserService userService,
171-
ControllerHelper controllerHelper
171+
ContentFactory contentFactory
172172
) {
173173
this.frontendProperties = frontendProperties;
174174
this.twitterProperties = twitterProperties;
175175
this.hashTagService = hashTagService;
176176
this.tweetService = tweetService;
177177
this.userService = userService;
178-
this.controllerHelper = controllerHelper;
178+
this.contentFactory = contentFactory;
179179
}
180180

181181
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.springframework.web.bind.annotation.RequestMapping;
99
import org.woehlke.twitterwall.conf.properties.FrontendProperties;
1010
import org.woehlke.twitterwall.frontend.content.Symbols;
11-
import org.woehlke.twitterwall.frontend.common.ControllerHelper;
11+
import org.woehlke.twitterwall.frontend.content.ContentFactory;
1212
import org.woehlke.twitterwall.oodm.model.User;
1313
import org.woehlke.twitterwall.scheduled.mq.endpoint.tasks.StartTask;
1414

@@ -25,7 +25,7 @@ public String imprint(Model model) {
2525
String symbol = Symbols.IMPRINT.toString();
2626
String title = "Imprint";
2727
String subtitle = frontendProperties.getImprintSubtitle();
28-
model = controllerHelper.setupPage(model, title, subtitle, symbol);
28+
model = contentFactory.setupPage(model, title, subtitle, symbol);
2929
User user = startTask.createImprintUser();
3030
model.addAttribute("user", user);
3131
log.info("-----------------------------------------");
@@ -38,17 +38,17 @@ public String imprint(Model model) {
3838

3939
private final StartTask startTask;
4040

41-
private final ControllerHelper controllerHelper;
41+
private final ContentFactory contentFactory;
4242

4343
@Autowired
4444
public ImprintController(
4545
FrontendProperties frontendProperties,
4646
StartTask startTask,
47-
ControllerHelper controllerHelper
47+
ContentFactory contentFactory
4848
) {
4949
this.frontendProperties = frontendProperties;
5050
this.startTask = startTask;
51-
this.controllerHelper = controllerHelper;
51+
this.contentFactory = contentFactory;
5252
}
5353

5454
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.springframework.stereotype.Controller;
77
import org.springframework.ui.Model;
88
import org.springframework.web.bind.annotation.RequestMapping;
9-
import org.woehlke.twitterwall.frontend.common.ControllerHelper;
9+
import org.woehlke.twitterwall.frontend.content.ContentFactory;
1010
import org.woehlke.twitterwall.frontend.content.Symbols;
1111

1212
@Controller
@@ -18,19 +18,19 @@ public String login(Model model) {
1818
String symbol = Symbols.LOGIN.toString();
1919
String title = "Login";
2020
String subtitle = "Enter your Credentials";
21-
model = controllerHelper.setupPage(model, title, subtitle, symbol);
21+
model = contentFactory.setupPage(model, title, subtitle, symbol);
2222
log.info("-----------------------------------------");
2323
return "login/login";
2424
}
2525

2626
private static final Logger log = LoggerFactory.getLogger(LoginController.class);
2727

28-
private final ControllerHelper controllerHelper;
28+
private final ContentFactory contentFactory;
2929

3030
@Autowired
3131
public LoginController(
32-
ControllerHelper controllerHelper
32+
ContentFactory contentFactory
3333
) {
34-
this.controllerHelper = controllerHelper;
34+
this.contentFactory = contentFactory;
3535
}
3636
}

0 commit comments

Comments
 (0)