Skip to content

Commit fbd1bba

Browse files
working on #138
1 parent 318aa83 commit fbd1bba

24 files changed

+288
-278
lines changed

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

Lines changed: 1 addition & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -75,61 +75,6 @@ public class Task implements DomainObjectMinimal<Task> {
7575
@Column(name="time_finished")
7676
private Date timeFinished = null;
7777

78-
@NotNull
79-
@OneToMany(cascade = {DETACH, REFRESH, REMOVE}, fetch = EAGER,orphanRemoval=true, mappedBy="task")
80-
private List<TaskHistory> history = new ArrayList<>();
81-
82-
@NotNull
83-
@Embedded
84-
@AttributeOverrides({
85-
@AttributeOverride(name = "countUser", column = @Column(name = "start_count_user",nullable=false)),
86-
@AttributeOverride(name = "countTweets", column = @Column(name = "start_count_tweets",nullable=false)),
87-
@AttributeOverride(name = "countHashTags", column = @Column(name = "start_count_hashtags",nullable=false)),
88-
@AttributeOverride(name = "countMedia", column = @Column(name = "start_count_media",nullable=false)),
89-
@AttributeOverride(name = "countMention", column = @Column(name = "start_count_mention",nullable=false)),
90-
@AttributeOverride(name = "countTickerSymbol", column = @Column(name = "start_count_tickersymbol",nullable=false)),
91-
@AttributeOverride(name = "countUrl", column = @Column(name = "start_count_url",nullable=false)),
92-
@AttributeOverride(name = "countUrlCache", column = @Column(name = "start_count_urlcache",nullable=false)),
93-
@AttributeOverride(name = "countTask", column = @Column(name = "start_count_task",nullable=false)),
94-
@AttributeOverride(name = "countTaskHistory", column = @Column(name = "start_count_task_history",nullable=false)),
95-
@AttributeOverride(name = "tweet2hashtag", column = @Column(name = "start_count_tweet2hashtag",nullable=false)),
96-
@AttributeOverride(name = "tweet2media", column = @Column(name = "start_count_tweet2media",nullable=false)),
97-
@AttributeOverride(name = "tweet2mention", column = @Column(name = "start_count_tweet2mention",nullable=false)),
98-
@AttributeOverride(name = "tweet2tickersymbol", column = @Column(name = "start_count_tweet2tickersymbol",nullable=false)),
99-
@AttributeOverride(name = "tweet2url", column = @Column(name = "start_count_tweet2url",nullable=false)),
100-
@AttributeOverride(name = "userprofile2hashtag", column = @Column(name = "start_count_userprofile2hashtag",nullable=false)),
101-
@AttributeOverride(name = "userprofile2media", column = @Column(name = "start_count_userprofile2media",nullable=false)),
102-
@AttributeOverride(name = "userprofile2mention", column = @Column(name = "start_count_userprofile2mention",nullable=false)),
103-
@AttributeOverride(name = "userprofile2tickersymbol", column = @Column(name = "start_count_userprofile2tickersymbol",nullable=false)),
104-
@AttributeOverride(name = "userprofile2url", column = @Column(name = "start_count_userprofile2url",nullable=false))
105-
})
106-
private CountedEntities countedEntitiesAtStart;
107-
108-
@Embedded
109-
@AttributeOverrides({
110-
@AttributeOverride(name = "countUser", column = @Column(name = "done_count_user")),
111-
@AttributeOverride(name = "countTweets", column = @Column(name = "done_count_tweets")),
112-
@AttributeOverride(name = "countHashTags", column = @Column(name = "done_count_hashtags")),
113-
@AttributeOverride(name = "countMedia", column = @Column(name = "done_count_media")),
114-
@AttributeOverride(name = "countMention", column = @Column(name = "done_count_mention")),
115-
@AttributeOverride(name = "countTickerSymbol", column = @Column(name = "done_count_tickersymbol")),
116-
@AttributeOverride(name = "countUrl", column = @Column(name = "done_count_url")),
117-
@AttributeOverride(name = "countUrlCache", column = @Column(name = "done_count_urlcache")),
118-
@AttributeOverride(name = "countTask", column = @Column(name = "done_count_task")),
119-
@AttributeOverride(name = "countTaskHistory", column = @Column(name = "done_count_task_history")),
120-
@AttributeOverride(name = "tweet2hashtag", column = @Column(name = "done_count_tweet2hashtag")),
121-
@AttributeOverride(name = "tweet2media", column = @Column(name = "done_count_tweet2media")),
122-
@AttributeOverride(name = "tweet2mention", column = @Column(name = "done_count_tweet2mention")),
123-
@AttributeOverride(name = "tweet2tickersymbol", column = @Column(name = "done_count_tweet2tickersymbol")),
124-
@AttributeOverride(name = "tweet2url", column = @Column(name = "done_count_tweet2url")),
125-
@AttributeOverride(name = "userprofile2hashtag", column = @Column(name = "done_count_userprofile2hashtag")),
126-
@AttributeOverride(name = "userprofile2media", column = @Column(name = "done_count_userprofile2media")),
127-
@AttributeOverride(name = "userprofile2mention", column = @Column(name = "done_count_userprofile2mention")),
128-
@AttributeOverride(name = "userprofile2tickersymbol", column = @Column(name = "done_count_userprofile2tickersymbol")),
129-
@AttributeOverride(name = "userprofile2url", column = @Column(name = "done_count_userprofile2url"))
130-
})
131-
private CountedEntities countedEntitiesAtFinish;
132-
13378
private Task() {
13479
}
13580

@@ -138,16 +83,13 @@ public Task(String description,TaskType taskType) {
13883
this.description = description;
13984
}
14085

141-
public Task(String description, TaskType taskType, TaskStatus taskStatus, Date timeStarted, Date timeLastUpdate, Date timeFinished, List<TaskHistory> history, CountedEntities countedEntitiesAtStart, CountedEntities countedEntitiesAtFinish) {
86+
public Task(String description, TaskType taskType, TaskStatus taskStatus, Date timeStarted, Date timeLastUpdate, Date timeFinished) {
14287
this.description = description;
14388
this.taskType = taskType;
14489
this.taskStatus = taskStatus;
14590
this.timeStarted = timeStarted;
14691
this.timeLastUpdate = timeLastUpdate;
14792
this.timeFinished = timeFinished;
148-
this.history = history;
149-
this.countedEntitiesAtStart = countedEntitiesAtStart;
150-
this.countedEntitiesAtFinish = countedEntitiesAtFinish;
15193
}
15294

15395
@Override
@@ -189,22 +131,6 @@ public void setTimeFinished(Date timeFinished) {
189131
this.timeFinished = timeFinished;
190132
}
191133

192-
public CountedEntities getCountedEntitiesAtStart() {
193-
return countedEntitiesAtStart;
194-
}
195-
196-
public void setCountedEntitiesAtStart(CountedEntities countedEntitiesAtStart) {
197-
this.countedEntitiesAtStart = countedEntitiesAtStart;
198-
}
199-
200-
public CountedEntities getCountedEntitiesAtFinish() {
201-
return countedEntitiesAtFinish;
202-
}
203-
204-
public void setCountedEntitiesAtFinish(CountedEntities countedEntitiesAtFinish) {
205-
this.countedEntitiesAtFinish = countedEntitiesAtFinish;
206-
}
207-
208134
public TaskStatus getTaskStatus() {
209135
return taskStatus;
210136
}
@@ -221,18 +147,6 @@ public void setDescription(String description) {
221147
this.description = description;
222148
}
223149

224-
public List<TaskHistory> getHistory() {
225-
return history;
226-
}
227-
228-
public void setHistory(List<TaskHistory> history) {
229-
this.history = history;
230-
}
231-
232-
public void addHistory(TaskHistory history) {
233-
this.history.add(history);
234-
}
235-
236150
public Date getTimeLastUpdate() {
237151
return timeLastUpdate;
238152
}
@@ -248,23 +162,13 @@ public void setTimeLastUpdate() {
248162

249163
@Override
250164
public String toString() {
251-
String countedEntitiesAtFinishStr = "null";
252-
if(countedEntitiesAtFinish != null){
253-
countedEntitiesAtFinishStr = countedEntitiesAtFinish.toString();
254-
}
255-
String countedEntitiesAtStartStr = "null";
256-
if(countedEntitiesAtStart != null){
257-
countedEntitiesAtStartStr = countedEntitiesAtStart.toString();
258-
}
259165
return "Task{" +
260166
"id=" + id +
261167
", taskType=" + taskType +
262168
", taskStatus=" +taskStatus +
263169
", timeStarted=" + timeStarted +
264170
", timeLastUpdate=" + timeLastUpdate +
265171
", timeFinished=" + timeFinished +
266-
", countedEntitiesAtStart=" + countedEntitiesAtStartStr +
267-
", countedEntitiesAtFinish=" + countedEntitiesAtFinishStr +
268172
'}';
269173
}
270174

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

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.hibernate.validator.constraints.SafeHtml;
44
import org.woehlke.twitterwall.oodm.entities.common.DomainObjectMinimal;
5+
import org.woehlke.twitterwall.oodm.entities.parts.CountedEntities;
56
import org.woehlke.twitterwall.oodm.entities.parts.TaskStatus;
67
import org.woehlke.twitterwall.oodm.entities.listener.TaskHistoryListener;
78

@@ -66,16 +67,44 @@ public class TaskHistory implements DomainObjectMinimal<TaskHistory> {
6667
@JoinColumn(name="task_id")
6768
private Task task;
6869

70+
//@NotNull
71+
@Embedded
72+
@AttributeOverrides({
73+
@AttributeOverride(name = "countUser", column = @Column(name = "count_user",nullable=false)),
74+
@AttributeOverride(name = "countTweets", column = @Column(name = "count_tweets",nullable=false)),
75+
@AttributeOverride(name = "countHashTags", column = @Column(name = "count_hashtags",nullable=false)),
76+
@AttributeOverride(name = "countMedia", column = @Column(name = "count_media",nullable=false)),
77+
@AttributeOverride(name = "countMention", column = @Column(name = "count_mention",nullable=false)),
78+
@AttributeOverride(name = "countTickerSymbol", column = @Column(name = "count_tickersymbol",nullable=false)),
79+
@AttributeOverride(name = "countUrl", column = @Column(name = "count_url",nullable=false)),
80+
@AttributeOverride(name = "countUrlCache", column = @Column(name = "count_urlcache",nullable=false)),
81+
@AttributeOverride(name = "countTask", column = @Column(name = "count_task",nullable=false)),
82+
@AttributeOverride(name = "countTaskHistory", column = @Column(name = "count_task_history",nullable=false)),
83+
@AttributeOverride(name = "tweet2hashtag", column = @Column(name = "count_tweet2hashtag",nullable=false)),
84+
@AttributeOverride(name = "tweet2media", column = @Column(name = "count_tweet2media",nullable=false)),
85+
@AttributeOverride(name = "tweet2mention", column = @Column(name = "count_tweet2mention",nullable=false)),
86+
@AttributeOverride(name = "tweet2tickersymbol", column = @Column(name = "count_tweet2tickersymbol",nullable=false)),
87+
@AttributeOverride(name = "tweet2url", column = @Column(name = "count_tweet2url",nullable=false)),
88+
@AttributeOverride(name = "userprofile2hashtag", column = @Column(name = "count_userprofile2hashtag",nullable=false)),
89+
@AttributeOverride(name = "userprofile2media", column = @Column(name = "count_userprofile2media",nullable=false)),
90+
@AttributeOverride(name = "userprofile2mention", column = @Column(name = "count_userprofile2mention",nullable=false)),
91+
@AttributeOverride(name = "userprofile2tickersymbol", column = @Column(name = "count_userprofile2tickersymbol",nullable=false)),
92+
@AttributeOverride(name = "userprofile2url", column = @Column(name = "count_userprofile2url",nullable=false))
93+
})
94+
private CountedEntities countedEntities = new CountedEntities();
95+
6996
private TaskHistory() {
7097
}
7198

72-
public TaskHistory(String description, TaskStatus taskStatusBefore, TaskStatus taskStatusNow) {
99+
public TaskHistory(String description, TaskStatus taskStatusBefore, TaskStatus taskStatusNow, CountedEntities countedEntities) {
100+
this.countedEntities = countedEntities;
73101
this.description = description;
74102
this.taskStatusBefore = taskStatusBefore;
75103
this.taskStatusNow = taskStatusNow;
76104
}
77105

78-
public TaskHistory(String description, TaskStatus taskStatusBefore, TaskStatus taskStatusNow, Date timeEvent, Task task) {
106+
public TaskHistory(String description, TaskStatus taskStatusBefore, TaskStatus taskStatusNow, Date timeEvent, Task task, CountedEntities countedEntities) {
107+
this.countedEntities = countedEntities;
79108
this.description = description;
80109
this.taskStatusBefore = taskStatusBefore;
81110
this.taskStatusNow = taskStatusNow;
@@ -144,6 +173,14 @@ public void setIdTask(Long idTask) {
144173
this.idTask = idTask;
145174
}
146175

176+
public CountedEntities getCountedEntities() {
177+
return countedEntities;
178+
}
179+
180+
public void setCountedEntities(CountedEntities countedEntities) {
181+
this.countedEntities = countedEntities;
182+
}
183+
147184
@Override
148185
public int compareTo(TaskHistory other) {
149186
return getUniqueId().compareTo(other.getUniqueId());
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.woehlke.twitterwall.oodm.service;
22

33
import org.woehlke.twitterwall.oodm.entities.Task;
4+
import org.woehlke.twitterwall.oodm.entities.parts.CountedEntities;
45
import org.woehlke.twitterwall.oodm.entities.parts.TaskType;
56
import org.woehlke.twitterwall.oodm.service.common.DomainObjectMinimalService;
67

@@ -9,25 +10,25 @@
910
*/
1011
public interface TaskService extends DomainObjectMinimalService<Task> {
1112

12-
Task create(String msg,TaskType type);
13+
Task findById(long id);
1314

14-
Task done(Task task);
15+
Task create(String msg,TaskType type,CountedEntities countedEntities);
1516

16-
Task error(Task task, Exception e);
17+
Task done(Task task,CountedEntities countedEntities);
1718

18-
Task error(Task task, Exception e, String msg);
19+
Task error(Task task, Exception e,CountedEntities countedEntities);
1920

20-
Task warn(Task task, Exception e);
21+
Task error(Task task, Exception e, String msg,CountedEntities countedEntities);
2122

22-
Task warn(Task task, Exception e, String msg);
23+
Task warn(Task task, Exception e,CountedEntities countedEntities);
2324

24-
Task event(Task task, String msg);
25+
Task warn(Task task, Exception e, String msg,CountedEntities countedEntities);
2526

26-
Task warn(Task task, String msg);
27+
Task event(Task task, String msg,CountedEntities countedEntities);
2728

28-
Task error(Task task, String msg);
29+
Task warn(Task task, String msg,CountedEntities countedEntities);
2930

30-
Task findById(long id);
31+
Task error(Task task, String msg,CountedEntities countedEntities);
3132

32-
Task start(Task task);
33+
Task start(Task task,CountedEntities countedEntities);
3334
}

0 commit comments

Comments
 (0)