Skip to content

Commit 7648661

Browse files
new use cases
1 parent fb33f26 commit 7648661

37 files changed

+559
-268
lines changed

src/main/java/org/woehlke/twitterwall/ScheduledTasks.java

Lines changed: 76 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -15,79 +15,34 @@
1515
@Component
1616
public class ScheduledTasks {
1717

18-
@Scheduled(initialDelay= TEN_SECONDS, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS)
18+
@Scheduled(initialDelay= TEN_SECONDS, fixedRate = ONE_DAY)
19+
public void createImprintUserAsync(){
20+
String msg = "create Imprint User (Async) ";
21+
if(!schedulerProperties.getSkipFortesting()) {
22+
Task task = asyncStartTask.createImprintUserAsync();
23+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
24+
}
25+
}
26+
27+
@Scheduled(initialDelay= TEN_SECONDS * 2, fixedRate = FIVE_MINUTES)
1928
public void fetchTweetsFromTwitterSearch() {
2029
String msg = "fetch Tweets From TwitterSearch ";
21-
if((schedulerProperties.getAllowUpdateTweets()) && (!schedulerProperties.getSkipFortesting())) {
30+
if((schedulerProperties.getAllowFetchTweetsFromTwitterSearch()) && (!schedulerProperties.getSkipFortesting())) {
2231
Task task = asyncStartTask.fetchTweetsFromSearch();
2332
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
2433
}
2534
}
2635

27-
@Scheduled(initialDelay= TEN_SECONDS *2, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_USER_LIST)
36+
@Scheduled(initialDelay= TEN_SECONDS * 3, fixedRate = TWELVE_HOURS)
2837
public void fetchUsersFromDefinedUserList(){
2938
String msg = "fetch Users from Defined User List ";
30-
if((schedulerProperties.getFetchUserListAllow()) && (!schedulerProperties.getSkipFortesting())) {
39+
if((schedulerProperties.getFetchUsersFromDefinedUserListAllow()) && (!schedulerProperties.getSkipFortesting())) {
3140
Task task = asyncStartTask.fetchUsersFromList();
3241
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
3342
}
3443
}
3544

36-
@Scheduled(initialDelay= TEN_SECONDS *3, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_FOLLOWER)
37-
public void fetchFollower(){
38-
String msg = "fetch Follower ";
39-
if((schedulerProperties.getFetchFollowerAllow()) && (!schedulerProperties.getSkipFortesting())) {
40-
Task task = asyncStartTask.fetchFollower();
41-
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
42-
}
43-
}
44-
45-
@Scheduled(initialDelay= TEN_SECONDS *4, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_FRIENDS)
46-
public void fetchFriends(){
47-
String msg = "fetch Friends ";
48-
if((schedulerProperties.getFetchFriendsAllow()) && (!schedulerProperties.getSkipFortesting())) {
49-
Task task = asyncStartTask.fetchFriends();
50-
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
51-
}
52-
}
53-
54-
@Scheduled(initialDelay= TEN_SECONDS *5, fixedRate = FIXED_RATE_FOR_SCHEDULAR_REMOVE_OLD_DATA_FROM_STORAGE)
55-
public void removeOldDataFromStorage(){
56-
String msg = "remove Old Data From Storage: ";
57-
if((schedulerProperties.getRemoveOldDataFromStorageAllow()) && (!schedulerProperties.getSkipFortesting())) {
58-
Task task = asyncStartTask.removeOldDataFromStorage();
59-
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
60-
}
61-
}
62-
63-
@Scheduled(initialDelay= TEN_SECONDS *6, fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER_BY_MENTION)
64-
public void updateUserProfilesFromMentions(){
65-
String msg = "update User Profiles From Mentions";
66-
if((schedulerProperties.getAllowUpdateUserProfilesFromMention()) && (!schedulerProperties.getSkipFortesting())) {
67-
Task task = asyncStartTask.updateUsersFromMentions();
68-
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
69-
}
70-
}
71-
72-
@Scheduled(initialDelay= TEN_SECONDS *7, fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_TWEETS)
73-
public void updateTweets() {
74-
String msg = "update Tweets ";
75-
if((schedulerProperties.getAllowUpdateTweets()) && (!schedulerProperties.getSkipFortesting())){
76-
Task task = asyncStartTask.updateTweets();
77-
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
78-
}
79-
}
80-
81-
@Scheduled(initialDelay= TEN_SECONDS *8, fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER)
82-
public void updateUserProfiles() {
83-
String msg = "update User Profiles ";
84-
if((schedulerProperties.getAllowUpdateUserProfiles()) && (!schedulerProperties.getSkipFortesting())) {
85-
Task task = asyncStartTask.updateUsers();
86-
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
87-
}
88-
}
89-
90-
@Scheduled(initialDelay= TEN_SECONDS *9, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_HOME_TIMELINE)
45+
@Scheduled(initialDelay= TEN_SECONDS * 4, fixedRate = TWELVE_HOURS)
9146
public void getHomeTimeline() {
9247
String msg = "get Home Timeline Tweets ";
9348
if((schedulerProperties.getAllowGetHomeTimeline()) && (!schedulerProperties.getSkipFortesting())) {
@@ -96,7 +51,7 @@ public void getHomeTimeline() {
9651
}
9752
}
9853

99-
@Scheduled(initialDelay= TEN_SECONDS *10, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_USER_TIMELINE)
54+
@Scheduled(initialDelay= TEN_SECONDS * 5, fixedRate = TWELVE_HOURS)
10055
public void getUserTimeline() {
10156
String msg = " get User Timeline Tweets ";
10257
if((schedulerProperties.getAllowGetUserTimeline()) && (!schedulerProperties.getSkipFortesting())) {
@@ -105,7 +60,7 @@ public void getUserTimeline() {
10560
}
10661
}
10762

108-
@Scheduled(initialDelay= TEN_SECONDS *11, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_MENTIONS)
63+
@Scheduled(initialDelay= TEN_SECONDS * 6, fixedRate = TWELVE_HOURS)
10964
public void getMentions() {
11065
String msg = " get Mentions ";
11166
if((schedulerProperties.getAllowGetMentions()) && (!schedulerProperties.getSkipFortesting())) {
@@ -114,7 +69,7 @@ public void getMentions() {
11469
}
11570
}
11671

117-
@Scheduled(initialDelay= TEN_SECONDS *12, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_FAVORITES)
72+
@Scheduled(initialDelay= TEN_SECONDS * 7, fixedRate = TWELVE_HOURS)
11873
public void getFavorites() {
11974
String msg = " get Favorites ";
12075
if((schedulerProperties.getAllowGetFavorites()) && (!schedulerProperties.getSkipFortesting())) {
@@ -123,7 +78,7 @@ public void getFavorites() {
12378
}
12479
}
12580

126-
@Scheduled(initialDelay= TEN_SECONDS *13, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_RETWEETS_OF_ME)
81+
@Scheduled(initialDelay= TEN_SECONDS * 8, fixedRate = TWELVE_HOURS)
12782
public void getRetweetsOfMe() {
12883
String msg = " get Retweets Of Me ";
12984
if((schedulerProperties.getAllowGetRetweetsOfMe()) && (!schedulerProperties.getSkipFortesting())) {
@@ -132,7 +87,7 @@ public void getRetweetsOfMe() {
13287
}
13388
}
13489

135-
@Scheduled(initialDelay= TEN_SECONDS *14, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_USER_LISTS)
90+
@Scheduled(initialDelay= TEN_SECONDS * 9, fixedRate = TWELVE_HOURS)
13691
public void getLists() {
13792
String msg = " get Lists ";
13893
if((schedulerProperties.getAllowGetLists()) && (!schedulerProperties.getSkipFortesting())) {
@@ -141,6 +96,60 @@ public void getLists() {
14196
}
14297
}
14398

99+
@Scheduled(initialDelay= TEN_SECONDS * 10, fixedRate = ONE_DAY)
100+
public void fetchFollower(){
101+
String msg = "fetch Follower ";
102+
if((schedulerProperties.getFetchFollowerAllow()) && (!schedulerProperties.getSkipFortesting())) {
103+
Task task = asyncStartTask.fetchFollower();
104+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
105+
}
106+
}
107+
108+
@Scheduled(initialDelay= TEN_SECONDS * 11, fixedRate = ONE_DAY)
109+
public void fetchFriends(){
110+
String msg = "fetch Friends ";
111+
if((schedulerProperties.getFetchFriendsAllow()) && (!schedulerProperties.getSkipFortesting())) {
112+
Task task = asyncStartTask.fetchFriends();
113+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
114+
}
115+
}
116+
117+
@Scheduled(initialDelay= TEN_SECONDS * 12, fixedRate = ONE_HOUR)
118+
public void removeOldDataFromStorage(){
119+
String msg = "remove Old Data From Storage: ";
120+
if((schedulerProperties.getRemoveOldDataFromStorageAllow()) && (!schedulerProperties.getSkipFortesting())) {
121+
Task task = asyncStartTask.removeOldDataFromStorage();
122+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
123+
}
124+
}
125+
126+
@Scheduled(initialDelay= TEN_SECONDS * 13, fixedRate = ONE_HOUR)
127+
public void updateUserProfilesFromMentions(){
128+
String msg = "update User Profiles From Mentions";
129+
if((schedulerProperties.getAllowUpdateUserProfilesFromMention()) && (!schedulerProperties.getSkipFortesting())) {
130+
Task task = asyncStartTask.updateUsersFromMentions();
131+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
132+
}
133+
}
134+
135+
@Scheduled(initialDelay= TEN_SECONDS * 14, fixedRate = ONE_DAY)
136+
public void updateTweets() {
137+
String msg = "update Tweets ";
138+
if((schedulerProperties.getAllowUpdateTweets()) && (!schedulerProperties.getSkipFortesting())){
139+
Task task = asyncStartTask.updateTweets();
140+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
141+
}
142+
}
143+
144+
@Scheduled(initialDelay= TEN_SECONDS * 15, fixedRate = ONE_DAY)
145+
public void updateUserProfiles() {
146+
String msg = "update User Profiles ";
147+
if((schedulerProperties.getAllowUpdateUserProfiles()) && (!schedulerProperties.getSkipFortesting())) {
148+
Task task = asyncStartTask.updateUsers();
149+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
150+
}
151+
}
152+
144153
@Autowired
145154
public ScheduledTasks(SchedulerProperties schedulerProperties, AsyncStartTask mqAsyncStartTask) {
146155
this.schedulerProperties = schedulerProperties;
@@ -151,37 +160,13 @@ public ScheduledTasks(SchedulerProperties schedulerProperties, AsyncStartTask mq
151160

152161
public final static long ONE_MINUTE = 60 * 1000;
153162

163+
public final static long FIVE_MINUTES = 5 * ONE_MINUTE;
164+
154165
public final static long ONE_HOUR = 60 * ONE_MINUTE;
155166

156167
public final static long TWELVE_HOURS = 12 * ONE_HOUR;
157168

158-
private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS = ONE_HOUR;
159-
160-
private final static long FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER = TWELVE_HOURS;
161-
162-
private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_FOLLOWER = TWELVE_HOURS;
163-
164-
private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_FRIENDS = TWELVE_HOURS;
165-
166-
private final static long FIXED_RATE_FOR_SCHEDULAR_UPDATE_TWEETS = TWELVE_HOURS;
167-
168-
private final static long FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER_BY_MENTION = ONE_HOUR;
169-
170-
private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_USER_LISTS = TWELVE_HOURS;
171-
172-
private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_FAVORITES = TWELVE_HOURS;
173-
174-
private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_RETWEETS_OF_ME = TWELVE_HOURS;
175-
176-
private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_MENTIONS = TWELVE_HOURS;
177-
178-
private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_USER_TIMELINE = TWELVE_HOURS;
179-
180-
private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS_HOME_TIMELINE = TWELVE_HOURS;
181-
182-
private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_USER_LIST = TWELVE_HOURS;
183-
184-
private final static long FIXED_RATE_FOR_SCHEDULAR_REMOVE_OLD_DATA_FROM_STORAGE = ONE_HOUR;
169+
public final static long ONE_DAY = 24 * ONE_HOUR;
185170

186171
private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
187172

src/main/java/org/woehlke/twitterwall/conf/properties/SchedulerProperties.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public class SchedulerProperties {
3131
private Boolean skipFortesting;
3232

3333
@NotNull
34-
private Boolean fetchUserListAllow;
34+
private Boolean fetchUsersFromDefinedUserListAllow;
3535

3636
@NotNull
37-
private String fetchUserListName;
37+
private String fetchUsersFromDefinedUserListName;
3838

3939
@NotNull
4040
private Boolean removeOldDataFromStorageAllow;
@@ -111,20 +111,20 @@ public void setSkipFortesting(Boolean skipFortesting) {
111111
this.skipFortesting = skipFortesting;
112112
}
113113

114-
public Boolean getFetchUserListAllow() {
115-
return fetchUserListAllow;
114+
public Boolean getFetchUsersFromDefinedUserListAllow() {
115+
return fetchUsersFromDefinedUserListAllow;
116116
}
117117

118-
public void setFetchUserListAllow(Boolean fetchUserListAllow) {
119-
this.fetchUserListAllow = fetchUserListAllow;
118+
public void setFetchUsersFromDefinedUserListAllow(Boolean fetchUsersFromDefinedUserListAllow) {
119+
this.fetchUsersFromDefinedUserListAllow = fetchUsersFromDefinedUserListAllow;
120120
}
121121

122-
public String getFetchUserListName() {
123-
return fetchUserListName;
122+
public String getFetchUsersFromDefinedUserListName() {
123+
return fetchUsersFromDefinedUserListName;
124124
}
125125

126-
public void setFetchUserListName(String fetchUserListName) {
127-
this.fetchUserListName = fetchUserListName;
126+
public void setFetchUsersFromDefinedUserListName(String fetchUsersFromDefinedUserListName) {
127+
this.fetchUsersFromDefinedUserListName = fetchUsersFromDefinedUserListName;
128128
}
129129

130130
public Boolean getRemoveOldDataFromStorageAllow() {

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

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
88
import org.woehlke.twitterwall.frontend.controller.common.Symbols;
99
import org.woehlke.twitterwall.frontend.controller.common.ControllerHelper;
10-
import org.woehlke.twitterwall.oodm.entities.parts.CountedEntities;
11-
import org.woehlke.twitterwall.oodm.service.CountedEntitiesService;
1210

1311
/**
1412
* Created by tw on 03.07.17.
@@ -17,18 +15,6 @@
1715
@RequestMapping(path="/application")
1816
public class ApplicationController {
1917

20-
@RequestMapping(path="/domain/count")
21-
public String domainCount(Model model) {
22-
String msg = "/application/domain/count: ";
23-
String title = "Counted Entities";
24-
String subtitle = twitterProperties.getSearchQuery();
25-
String symbol = Symbols.DATABASE.toString();
26-
model = controllerHelper.setupPage(model,title,subtitle,symbol);
27-
CountedEntities countedEntities =this.countedEntitiesService.countAll();
28-
model.addAttribute("countedEntities", countedEntities);
29-
return "application/domain/count";
30-
}
31-
3218
@RequestMapping(path="/management")
3319
public String managementPage(Model model) {
3420
String msg = "/application/domain/count: ";
@@ -39,30 +25,14 @@ public String managementPage(Model model) {
3925
return "application/management";
4026
}
4127

42-
@RequestMapping(path="/domain/delete/all")
43-
public String domainDeleteAll(Model model) {
44-
String msg = "/application/domain/delete/all: ";
45-
String title = "Counted Entities";
46-
String subtitle = twitterProperties.getSearchQuery();
47-
String symbol = Symbols.DATABASE.toString();
48-
model = controllerHelper.setupPage(model,title,subtitle,symbol);
49-
CountedEntities countedEntities =this.countedEntitiesService.deleteAll();
50-
model.addAttribute("countedEntities", countedEntities);
51-
return "application/domain/count";
52-
}
53-
54-
private final CountedEntitiesService countedEntitiesService;
55-
5628
private final ControllerHelper controllerHelper;
5729

5830
private final TwitterProperties twitterProperties;
5931

6032
@Autowired
6133
public ApplicationController(
62-
CountedEntitiesService countedEntitiesService,
6334
ControllerHelper controllerHelper,
6435
TwitterProperties twitterProperties) {
65-
this.countedEntitiesService = countedEntitiesService;
6636
this.controllerHelper = controllerHelper;
6737
this.twitterProperties = twitterProperties;
6838
}

0 commit comments

Comments
 (0)