Skip to content

Commit f14f8d8

Browse files
Merge pull request #226 from phasenraum2010/milestone-1.0.21
Milestone 1.0.21
2 parents e804fc2 + 0d5df81 commit f14f8d8

File tree

88 files changed

+1047
-1079
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1047
-1079
lines changed

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

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,71 +5,69 @@
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.scheduling.annotation.Scheduled;
77
import org.springframework.stereotype.Component;
8-
import org.springframework.stereotype.Service;
9-
import org.springframework.transaction.annotation.Propagation;
10-
import org.springframework.transaction.annotation.Transactional;
118
import org.woehlke.twitterwall.conf.properties.SchedulerProperties;
12-
import org.woehlke.twitterwall.scheduled.mq.endpoint.StartTask;
9+
import org.woehlke.twitterwall.oodm.entities.Task;
10+
import org.woehlke.twitterwall.scheduled.mq.endpoint.AsyncStartTask;
1311

1412
/**
1513
* Created by tw on 10.06.17.
1614
*/
17-
1815
@Component
19-
//@Service
20-
//@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
2116
public class ScheduledTasks {
2217

2318
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS)
2419
public void fetchTweetsFromTwitterSearch() {
2520
String msg = "fetch Tweets From TwitterSearch ";
2621
if(schedulerProperties.getAllowUpdateTweets() && !schedulerProperties.getSkipFortesting()) {
27-
startTask.fetchTweetsFromSearch();
22+
Task task = asyncStartTask.fetchTweetsFromSearch();
23+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
2824
}
2925
}
3026

3127
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_TWEETS)
3228
public void updateTweets() {
3329
String msg = "update Tweets ";
3430
if(schedulerProperties.getAllowUpdateTweets() && !schedulerProperties.getSkipFortesting()){
35-
startTask.updateTweets();
31+
Task task = asyncStartTask.updateTweets();
32+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
3633
}
3734
}
3835

3936
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER)
4037
public void updateUserProfiles() {
4138
String msg = "update User Profiles ";
4239
if(schedulerProperties.getAllowUpdateUserProfiles() && !schedulerProperties.getSkipFortesting()) {
43-
startTask.updateUsers();
40+
Task task = asyncStartTask.updateUsers();
41+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
4442
}
4543
}
4644

4745
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER_BY_MENTION)
4846
public void updateUserProfilesFromMentions(){
4947
String msg = "update User Profiles From Mentions";
5048
if(schedulerProperties.getAllowUpdateUserProfilesFromMention() && !schedulerProperties.getSkipFortesting()) {
51-
startTask.updateUsersFromMentions();
49+
Task task = asyncStartTask.updateUsersFromMentions();
50+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
5251
}
5352
}
5453

5554
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_USER_LIST)
5655
public void fetchUsersFromDefinedUserList(){
5756
String msg = "fetch Users from Defined User List ";
5857
if(schedulerProperties.getFetchUserListAllow() && !schedulerProperties.getSkipFortesting()) {
59-
startTask.fetchUsersFromList();
58+
Task task = asyncStartTask.fetchUsersFromList();
59+
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
6060
}
6161
}
6262

6363
@Autowired
64-
public ScheduledTasks(SchedulerProperties schedulerProperties, StartTask startTask) {
64+
public ScheduledTasks(SchedulerProperties schedulerProperties, AsyncStartTask mqAsyncStartTask) {
6565
this.schedulerProperties = schedulerProperties;
66-
this.startTask = startTask;
66+
this.asyncStartTask = mqAsyncStartTask;
6767
}
6868

6969
public final static long EINE_MINUTE = 60 * 1000;
7070

71-
public final static long FUENF_MINUTEN = 5 * EINE_MINUTE;
72-
7371
public final static long EINE_STUNDE = 60 * EINE_MINUTE;
7472

7573
public final static long ZWOELF_STUNDEN = 12 * EINE_STUNDE;
@@ -88,5 +86,5 @@ public ScheduledTasks(SchedulerProperties schedulerProperties, StartTask startTa
8886

8987
private final SchedulerProperties schedulerProperties;
9088

91-
private final StartTask startTask;
89+
private final AsyncStartTask asyncStartTask;
9290
}

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
import org.springframework.web.bind.annotation.RequestParam;
1515
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
1616
import org.woehlke.twitterwall.conf.properties.FrontendProperties;
17-
import org.woehlke.twitterwall.frontend.controller.common.HashTagsOverviewHelper;
17+
//import org.woehlke.twitterwall.frontend.controller.common.HashTagsOverviewHelper;
1818
import org.woehlke.twitterwall.frontend.controller.common.Symbols;
1919
import org.woehlke.twitterwall.frontend.controller.common.ControllerHelper;
20-
import org.woehlke.twitterwall.frontend.model.HashTagOverview;
20+
import org.woehlke.twitterwall.oodm.entities.transients.HashTagCounted;
21+
//import org.woehlke.twitterwall.oodm.entities.transients.HashTagOverview;
2122
import org.woehlke.twitterwall.oodm.entities.Tweet;
2223
import org.woehlke.twitterwall.oodm.entities.User;
2324
import org.woehlke.twitterwall.oodm.entities.HashTag;
25+
//import org.woehlke.twitterwall.oodm.entities.transients.HashTagOverviewPaged;
2426
import org.woehlke.twitterwall.oodm.service.TweetService;
2527
import org.woehlke.twitterwall.oodm.service.UserService;
2628
import org.woehlke.twitterwall.oodm.service.HashTagService;
@@ -124,15 +126,22 @@ public String hashTagFromTweetsAndUsers(
124126
}
125127

126128
@RequestMapping(path="/overview")
127-
public String hashTagsOverview(Model model) {
129+
public String hashTagsOverview(
130+
@RequestParam(name= "pageTweet", defaultValue=""+ FIRST_PAGE_NUMBER) int pageTweet,
131+
@RequestParam(name= "pageUser", defaultValue=""+ FIRST_PAGE_NUMBER) int pageUser,
132+
Model model) {
128133
String msg = "/hashtag/overview ";
129134
String title = "HashTags";
130135
String subtitle = twitterProperties.getSearchQuery();
131136
String symbol = Symbols.HASHTAG.toString();
132137
model = controllerHelper.setupPage(model,title,subtitle,symbol);
133-
HashTagOverview overview = hashTagsOverviewHelper.getHashTagOverview();
134-
model.addAttribute("hashTagsTweets", overview.getHashTagsTweets());
135-
model.addAttribute("hashTagsUsers", overview.getHashTagsUsers());
138+
int size= frontendProperties.getPageSize() * 2;
139+
Pageable pageRequestTweets = new PageRequest(pageTweet,size);
140+
Pageable pageRequestUsers = new PageRequest(pageUser,size);
141+
Page<HashTagCounted> hashTagsTweets = hashTagService.getHashTagsTweets(pageRequestTweets);
142+
Page<HashTagCounted> hashTagsUsers = hashTagService.getHashTagsUsers(pageRequestUsers);
143+
model.addAttribute("hashTagsTweets", hashTagsTweets);
144+
model.addAttribute("hashTagsUsers", hashTagsUsers);
136145
return "hashtag/overview";
137146
}
138147

@@ -150,7 +159,7 @@ public String hashTagsOverview(Model model) {
150159

151160
private final ControllerHelper controllerHelper;
152161

153-
private final HashTagsOverviewHelper hashTagsOverviewHelper;
162+
//private final HashTagsOverviewHelper hashTagsOverviewHelper;
154163

155164
@Autowired
156165
public HashTagController(
@@ -159,16 +168,16 @@ public HashTagController(
159168
HashTagService hashTagService,
160169
TweetService tweetService,
161170
UserService userService,
162-
ControllerHelper controllerHelper,
163-
HashTagsOverviewHelper hashTagsOverviewHelper
171+
ControllerHelper controllerHelper/*,
172+
HashTagsOverviewHelper hashTagsOverviewHelper*/
164173
) {
165174
this.frontendProperties = frontendProperties;
166175
this.twitterProperties = twitterProperties;
167176
this.hashTagService = hashTagService;
168177
this.tweetService = tweetService;
169178
this.userService = userService;
170179
this.controllerHelper = controllerHelper;
171-
this.hashTagsOverviewHelper = hashTagsOverviewHelper;
180+
//this.hashTagsOverviewHelper = hashTagsOverviewHelper;
172181
}
173182

174183
}

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,14 @@ public String getTestData(Model model) {
7878
twitterProperties.getSearchQuery(),
7979
Symbols.GET_TEST_DATA.toString()
8080
);
81-
String msg = PATH+"/start/createTestData: ";
8281
if(frontendProperties.getContextTest()){
83-
84-
List<Tweet> latestTweets = mqStartTask.createTestDataForTweets();
85-
List<User> users = mqStartTask.createTestDataForUser();
86-
87-
model.addAttribute("latestTweets", latestTweets);
88-
model.addAttribute("users",users);
82+
Task taskTweets = mqAsyncStartTask.createTestDataForTweets();
83+
Task taskUsers = mqAsyncStartTask.createTestDataForUser();
84+
model.addAttribute("taskTweets", taskTweets);
85+
model.addAttribute("taskUsers",taskUsers);
8986
} else {
90-
model.addAttribute("latestTweets",null);
91-
model.addAttribute("users",null);
87+
model.addAttribute("taskTweets",null);
88+
model.addAttribute("taskUsers",null);
9289
}
9390
return PATH+"/start/createTestData";
9491
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.woehlke.twitterwall.frontend.controller.common;
22

3-
import org.woehlke.twitterwall.frontend.model.HashTagOverview;
3+
import org.woehlke.twitterwall.oodm.entities.transients.HashTagOverview;
44

55
public interface HashTagsOverviewHelper {
66

src/main/java/org/woehlke/twitterwall/frontend/controller/common/impl/HashTagsOverviewHelperImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.springframework.stereotype.Component;
1010
import org.woehlke.twitterwall.conf.properties.FrontendProperties;
1111
import org.woehlke.twitterwall.frontend.controller.common.HashTagsOverviewHelper;
12-
import org.woehlke.twitterwall.frontend.model.HashTagCounted;
13-
import org.woehlke.twitterwall.frontend.model.HashTagOverview;
12+
import org.woehlke.twitterwall.oodm.entities.transients.HashTagCounted;
13+
import org.woehlke.twitterwall.oodm.entities.transients.HashTagOverview;
1414
import org.woehlke.twitterwall.oodm.entities.HashTag;
1515
import org.woehlke.twitterwall.oodm.entities.Tweet;
1616
import org.woehlke.twitterwall.oodm.entities.User;

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

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.woehlke.twitterwall.oodm.entities.parts.TaskStatus;
66
import org.woehlke.twitterwall.oodm.entities.parts.TaskType;
77
import org.woehlke.twitterwall.oodm.entities.listener.TaskListener;
8+
import org.woehlke.twitterwall.scheduled.mq.msg.SendType;
89

910
import javax.persistence.*;
1011
import javax.validation.constraints.NotNull;
@@ -22,7 +23,8 @@
2223
indexes = {
2324
@Index(name = "idx_task_time_finished", columnList = "time_finished"),
2425
@Index(name = "idx_task_task_status", columnList = "task_status"),
25-
@Index(name = "idx_task_task_type", columnList = "task_type")
26+
@Index(name = "idx_task_task_type", columnList = "task_type"),
27+
@Index(name = "idx_task_send_type", columnList = "send_type"),
2628
}
2729
)
2830
@NamedQueries({
@@ -55,6 +57,11 @@ public class Task implements DomainObjectMinimal<Task> {
5557
@Enumerated(EnumType.STRING)
5658
private TaskStatus taskStatus = TaskStatus.READY;
5759

60+
@NotNull
61+
@Column(name="send_type",nullable = false)
62+
@Enumerated(EnumType.STRING)
63+
private SendType sendType = SendType.NULL;
64+
5865
@NotNull
5966
@Temporal(TemporalType.TIMESTAMP)
6067
@Column(name="time_started",nullable = false)
@@ -72,17 +79,11 @@ public class Task implements DomainObjectMinimal<Task> {
7279
private Task() {
7380
}
7481

75-
/*
76-
public Task(String description,TaskType taskType) {
77-
this.taskType = taskType;
78-
this.description = description;
79-
}
80-
*/
81-
82-
public Task(String description, TaskType taskType, TaskStatus taskStatus, Date timeStarted, Date timeLastUpdate, Date timeFinished) {
82+
public Task(String description, TaskType taskType, TaskStatus taskStatus, SendType sendType, Date timeStarted, Date timeLastUpdate, Date timeFinished) {
8383
this.description = description;
8484
this.taskType = taskType;
8585
this.taskStatus = taskStatus;
86+
this.sendType = sendType;
8687
this.timeStarted = timeStarted;
8788
this.timeLastUpdate = timeLastUpdate;
8889
this.timeFinished = timeFinished;
@@ -154,6 +155,14 @@ public void setTaskStatus(TaskStatus taskStatus) {
154155
this.taskStatus = taskStatus;
155156
}
156157

158+
public SendType getSendType() {
159+
return sendType;
160+
}
161+
162+
public void setSendType(SendType sendType) {
163+
this.sendType = sendType;
164+
}
165+
157166
public String getDescription() {
158167
return description;
159168
}
@@ -178,13 +187,15 @@ public void setTimeLastUpdate() {
178187
@Override
179188
public String toString() {
180189
return "Task{" +
181-
"id=" + id +
182-
", taskType=" + taskType +
183-
", taskStatus=" +taskStatus +
184-
", timeStarted=" + timeStarted +
185-
", timeLastUpdate=" + timeLastUpdate +
186-
", timeFinished=" + timeFinished +
187-
'}';
190+
"id=" + id +
191+
", description='" + description + '\'' +
192+
", taskType=" + taskType +
193+
", taskStatus=" + taskStatus +
194+
", sendType=" + sendType +
195+
", timeStarted=" + timeStarted +
196+
", timeLastUpdate=" + timeLastUpdate +
197+
", timeFinished=" + timeFinished +
198+
'}';
188199
}
189200

190201
@Override

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ public void removeAllEntities(){
239239

240240
@Transient
241241
public String getFormattedText() {
242-
return this.entities.getFormattedText(this.text);
242+
243+
String htmlText = this.entities.getFormattedText(this.text);
244+
245+
return this.entities.getFormattedTextForMentionsForTweets(htmlText);
246+
243247
}
244248

245249
public Long getId() {

src/main/java/org/woehlke/twitterwall/oodm/entities/listener/HashTagListener.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,37 @@ public class HashTagListener {
1515

1616
@PrePersist
1717
public void onPrePersist(HashTag domainObject) {
18-
log.debug("try to Persist: "+domainObject.toString());
18+
log.debug("try to Persist: "+domainObject.getUniqueId());
1919
}
2020

2121
@PreUpdate
2222
public void onPreUpdate(HashTag domainObject) {
23-
log.debug("try to Update: "+domainObject.toString());
23+
log.debug("try to Update: "+domainObject.getUniqueId());
2424
}
2525

2626
@PreRemove
2727
public void onPreRemove(HashTag domainObject) {
28-
log.debug("try to Remove: "+domainObject.toString());
28+
log.debug("try to Remove: "+domainObject.getUniqueId());
2929
}
3030

3131
@PostPersist
3232
public void onPostPersist(HashTag domainObject) {
33-
log.debug("Persisted: "+domainObject.toString());
33+
log.debug("Persisted: "+domainObject.getUniqueId());
3434
}
3535

3636
@PostUpdate
3737
public void onPostUpdate(HashTag domainObject) {
38-
log.debug("Updated: "+domainObject.toString());
38+
log.debug("Updated: "+domainObject.getUniqueId());
3939
}
4040

4141
@PostRemove
4242
public void onPostRemove(HashTag domainObject) {
43-
log.debug("Removed: "+domainObject.toString());
43+
log.debug("Removed: "+domainObject.getUniqueId());
4444
}
4545

4646
@PostLoad
4747
public void onPostLoad(HashTag domainObject) {
48-
log.debug("loaded: "+domainObject.toString());
48+
log.debug("loaded: "+domainObject.getUniqueId());
4949
}
5050

5151

src/main/java/org/woehlke/twitterwall/oodm/entities/listener/MediaListener.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,36 @@ public class MediaListener {
1515

1616
@PrePersist
1717
public void onPrePersist(Media domainObject) {
18-
log.debug("try to Persist: "+domainObject.toString());
18+
log.debug("try to Persist: "+domainObject.getUniqueId());
1919
}
2020

2121
@PreUpdate
2222
public void onPreUpdate(Media domainObject) {
23-
log.debug("try to Update: "+domainObject.toString());
23+
log.debug("try to Update: "+domainObject.getUniqueId());
2424
}
2525

2626
@PreRemove
2727
public void onPreRemove(Media domainObject) {
28-
log.debug("try to Remove: "+domainObject.toString());
28+
log.debug("try to Remove: "+domainObject.getUniqueId());
2929
}
3030

3131
@PostPersist
3232
public void onPostPersist(Media domainObject) {
33-
log.debug("Persisted: "+domainObject.toString());
33+
log.debug("Persisted: "+domainObject.getUniqueId());
3434
}
3535

3636
@PostUpdate
3737
public void onPostUpdate(Media domainObject) {
38-
log.debug("Updated: "+domainObject.toString());
38+
log.debug("Updated: "+domainObject.getUniqueId());
3939
}
4040

4141
@PostRemove
4242
public void onPostRemove(Media domainObject) {
43-
log.debug("Removed: "+domainObject.toString());
43+
log.debug("Removed: "+domainObject.getUniqueId());
4444
}
4545

4646
@PostLoad
4747
public void onPostLoad(Media domainObject) {
48-
log.debug("loaded: "+domainObject.toString());
48+
log.debug("loaded: "+domainObject.getUniqueId());
4949
}
5050
}

0 commit comments

Comments
 (0)