Skip to content

Commit 4de82b3

Browse files
workin on #161
1 parent 9d4b427 commit 4de82b3

28 files changed

+212
-225
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public String domainCountTweet2hashtag(
4141
Tweet tweet = tweetService.findById(object2Entity.getObjectId());
4242
HashTag hashTag = hashTagService.findById(object2Entity.getEntityId());
4343
object2Entity.setObjectInfo(tweet.getUser().getScreenName().getScreenName());
44-
object2Entity.setEntityInfo(hashTag.getText().getText());
44+
object2Entity.setEntityInfo(hashTag.getHashTagText().getText());
4545
listObject2EntityContent.add(object2Entity);
4646
}
4747
model.addAttribute("listObject2EntityContent",listObject2EntityContent);
@@ -161,7 +161,7 @@ public String domainCountUserprofile2hashtag(
161161
User user = userService.findById(object2Entity.getObjectId());
162162
HashTag hashTag = hashTagService.findById(object2Entity.getEntityId());
163163
object2Entity.setObjectInfo(user.getScreenName().getScreenName());
164-
object2Entity.setEntityInfo(hashTag.getText().getText());
164+
object2Entity.setEntityInfo(hashTag.getHashTagText().getText());
165165
listObject2EntityContent.add(object2Entity);
166166
}
167167
model.addAttribute("listObject2EntityContent",listObject2EntityContent);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public String findById(
7171
Pageable pageRequestTweet = new PageRequest(pageTweet, frontendProperties.getPageSize());
7272
Pageable pageRequestUser = new PageRequest(pageUser, frontendProperties.getPageSize());
7373
String subtitle = "Tweets und User für HashTag";
74-
String title = hashTag.getText().getText();
74+
String title = hashTag.getHashTagText().getText();
7575
String symbol = Symbols.HASHTAG.toString();
7676
model = controllerHelper.setupPage(model, title, subtitle, symbol);
7777
model.addAttribute("hashTag",hashTag);

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@ public HashTagOverview getHashTagOverview() {
4141
for (HashTag hashTag : myPage.getContent()) {
4242
Pageable pageRequestTeets = new PageRequest(0, 1);
4343
Page<Tweet> tweets = tweetService.findTweetsForHashTag(hashTag, pageRequestTeets);
44-
String myMSg = msg + " tweetService.findTweetsForHashTag= " + hashTag.getText();
44+
String myMSg = msg + " tweetService.findTweetsForHashTag= " + hashTag.getHashTagText().getText();
4545
if (tweets == null) {
4646
log.debug(myMSg + " result: null");
4747
} else {
4848
long numberTweets = tweets.getTotalElements();
4949
log.debug(myMSg + " result: numberTweets=" + numberTweets);
5050
if (numberTweets > 0) {
51-
HashTagCounted c = new HashTagCounted(hashTag.getId(),numberTweets, hashTag.getText().getText());
51+
HashTagCounted c = new HashTagCounted(hashTag.getId(),numberTweets, hashTag.getHashTagText().getText());
5252
hashTagsTweets.add(c);
5353
}
5454
}
5555
Pageable pageRequestUsers = new PageRequest(0, 1);
5656
Page<User> users = userService.getUsersForHashTag(hashTag, pageRequestUsers);
57-
myMSg = msg + " userService.getUsersForHashTag= " + hashTag.getText();
57+
myMSg = msg + " userService.getUsersForHashTag= " + hashTag.getHashTagText().getText();
5858
if (users == null) {
5959
log.debug(myMSg + " result: null");
6060
} else {
6161
long numberUsers = users.getTotalElements();
6262
log.debug(myMSg + " result: numberUsers=" + numberUsers);
6363
if (numberUsers > 0) {
64-
HashTagCounted c = new HashTagCounted(hashTag.getId(), numberUsers, hashTag.getText().getText());
64+
HashTagCounted c = new HashTagCounted(hashTag.getId(), numberUsers, hashTag.getHashTagText().getText());
6565
hashTagsUsers.add(c);
6666
}
6767
}

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

+33-30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.woehlke.twitterwall.oodm.entities;
22

3-
import org.hibernate.validator.constraints.SafeHtml;
43
import org.woehlke.twitterwall.oodm.entities.common.DomainObjectEntity;
54
import org.woehlke.twitterwall.oodm.entities.parts.AbstractDomainObject;
65
import org.woehlke.twitterwall.oodm.entities.common.DomainObject;
@@ -11,8 +10,6 @@
1110
import javax.persistence.*;
1211
import java.util.HashMap;
1312
import java.util.Map;
14-
import java.util.regex.Matcher;
15-
import java.util.regex.Pattern;
1613

1714
/**
1815
* Created by tw on 10.06.17.
@@ -27,7 +24,7 @@
2724
@NamedQueries({
2825
@NamedQuery(
2926
name="HashTag.findByUniqueId",
30-
query="select t from HashTag t where t.text=:text"
27+
query="select t from HashTag t where t.hashTagText.text=:text"
3128
)
3229
})
3330
@EntityListeners(HashTagListener.class)
@@ -40,24 +37,24 @@ public class HashTag extends AbstractDomainObject<HashTag> implements DomainObje
4037
protected Long id;
4138

4239
@Embedded
43-
private HashTagText text;
40+
private HashTagText hashTagText;
4441

4542
@Column
4643
private Long numberOfTweets;
4744

4845
@Column
4946
private Long numberOfUsers;
5047

51-
public HashTag(Task createdBy, Task updatedBy, HashTagText text,Long numberOfTweets, Long numberOfUsers) {
48+
public HashTag(Task createdBy, Task updatedBy, HashTagText hashTagText,Long numberOfTweets, Long numberOfUsers) {
5249
super(createdBy,updatedBy);
53-
this.text = text;
50+
this.hashTagText = hashTagText;
5451
this.numberOfTweets = numberOfTweets;
5552
this.numberOfUsers = numberOfUsers;
5653
}
5754

58-
public HashTag(Task createdBy, Task updatedBy, HashTagText text) {
55+
public HashTag(Task createdBy, Task updatedBy, HashTagText hashTagText) {
5956
super(createdBy,updatedBy);
60-
this.text = text;
57+
this.hashTagText = hashTagText;
6158
}
6259

6360
private HashTag() {
@@ -74,24 +71,24 @@ public void setId(Long id) {
7471

7572
@Override
7673
public boolean isValid() {
77-
if(this.text == null){
74+
if(this.hashTagText == null){
7875
return false;
7976
}
80-
if(!text.isValid()){
77+
if(!hashTagText.isValid()){
8178
return false;
8279
}
8380
return true;
8481
}
8582

8683
@Override
8784
public String getUniqueId() {
88-
return this.getText().getText();
85+
return this.getHashTagText().getText();
8986
}
9087

9188
@Override
9289
public Map<String, Object> getParametersForFindByUniqueId() {
9390
Map<String,Object> parameters = new HashMap<>();
94-
parameters.put("text",this.text);
91+
parameters.put("text",this.hashTagText.getText());
9592
return parameters;
9693
}
9794

@@ -100,12 +97,12 @@ public String getQueryNameForFindByUniqueId() {
10097
return "HashTag.findByUniqueId";
10198
}
10299

103-
public HashTagText getText() {
104-
return text;
100+
public HashTagText getHashTagText() {
101+
return hashTagText;
105102
}
106103

107-
public void setText(HashTagText text) {
108-
this.text = text;
104+
public void setHashTagText(HashTagText hashTagText) {
105+
this.hashTagText = hashTagText;
109106
}
110107

111108
public static long getSerialVersionUID() {
@@ -136,30 +133,36 @@ public void increaseNumberOfUsers() {
136133
this.numberOfUsers++;
137134
}
138135

139-
@Override
140-
public String toString() {
141-
return "HashTag{" +
142-
" id=" + id +
143-
", text='" + text + '\'' +
144-
super.toString() +
145-
" }\n";
146-
}
147-
148136
@Override
149137
public boolean equals(Object o) {
150138
if (this == o) return true;
151139
if (!(o instanceof HashTag)) return false;
152140

153141
HashTag hashTag = (HashTag) o;
154142

155-
if (getId() != null ? !getId().equals(hashTag.getId()) : hashTag.getId() != null) return false;
156-
return getText() != null ? getText().equals(hashTag.getText()) : hashTag.getText() == null;
143+
if (id != null ? !id.equals(hashTag.id) : hashTag.id != null) return false;
144+
if (hashTagText != null ? !hashTagText.equals(hashTag.hashTagText) : hashTag.hashTagText != null) return false;
145+
if (numberOfTweets != null ? !numberOfTweets.equals(hashTag.numberOfTweets) : hashTag.numberOfTweets != null)
146+
return false;
147+
return numberOfUsers != null ? numberOfUsers.equals(hashTag.numberOfUsers) : hashTag.numberOfUsers == null;
157148
}
158149

159150
@Override
160151
public int hashCode() {
161-
int result = getId() != null ? getId().hashCode() : 0;
162-
result = 31 * result + (getText() != null ? getText().hashCode() : 0);
152+
int result = id != null ? id.hashCode() : 0;
153+
result = 31 * result + (hashTagText != null ? hashTagText.hashCode() : 0);
154+
result = 31 * result + (numberOfTweets != null ? numberOfTweets.hashCode() : 0);
155+
result = 31 * result + (numberOfUsers != null ? numberOfUsers.hashCode() : 0);
163156
return result;
164157
}
158+
159+
@Override
160+
public String toString() {
161+
return "HashTag{" +
162+
"id=" + id +
163+
", hashTagText=" + hashTagText +
164+
", numberOfTweets=" + numberOfTweets +
165+
", numberOfUsers=" + numberOfUsers +
166+
'}';
167+
}
165168
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
@NamedQueries({
4444
@NamedQuery(
4545
name="Tweet.getTweetsForHashTag",
46-
query="select t from Tweet as t join t.entities.hashTags hashTag WHERE hashTag.text=:hashtagText"
46+
query="select t from Tweet as t join t.entities.hashTags hashTag WHERE hashTag.hashTagText.text=:hashtagText"
4747
),
4848
@NamedQuery(
4949
name="Tweet.countTweetsForHashTag",
50-
query="select count(t) from Tweet as t join t.entities.hashTags hashTag WHERE hashTag.text=:hashtagText"
50+
query="select count(t) from Tweet as t join t.entities.hashTags hashTag WHERE hashTag.hashTagText.text=:hashtagText"
5151
),
5252
@NamedQuery(
5353
name="Tweet.findAllTwitterIds",

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

+24-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.woehlke.twitterwall.oodm.entities;
22

3-
import org.hibernate.validator.constraints.NotEmpty;
43
import org.hibernate.validator.constraints.URL;
54
import org.woehlke.twitterwall.oodm.entities.common.DomainObjectEntity;
65
import org.woehlke.twitterwall.oodm.entities.parts.AbstractDomainObject;
@@ -30,9 +29,13 @@
3029
}
3130
)
3231
@NamedQueries({
32+
@NamedQuery(
33+
name="Url.findByUrl",
34+
query="select t from Url t where t.urlField.url=:url"
35+
),
3336
@NamedQuery(
3437
name="Url.findByUniqueId",
35-
query="select t from Url t where t.url=:url"
38+
query="select t from Url t where t.urlField.url=:url"
3639
)
3740
})
3841
@EntityListeners(UrlListener.class)
@@ -58,23 +61,23 @@ public class Url extends AbstractDomainObject<Url> implements DomainObjectEntity
5861
@Valid
5962
@NotNull
6063
@Embedded
61-
private UrlField url;
64+
private UrlField urlField;
6265

6366
@Transient
6467
public boolean isUrlAndExpandedTheSame(){
65-
if(url == null){
68+
if(urlField == null){
6669
return false;
6770
}
6871
if(expanded == null){
6972
return false;
7073
}
71-
if(this.url.isValid()){
74+
if(this.urlField.isValid()){
7275
return false;
7376
}
7477
if(this.expanded.isEmpty()){
7578
return false;
7679
}
77-
return url.getUrl().compareTo(expanded) == 0;
80+
return urlField.getUrl().compareTo(expanded) == 0;
7881
}
7982

8083
@Transient
@@ -97,7 +100,7 @@ public boolean isRawUrlsFromDescription() {
97100
@Transient
98101
@Override
99102
public boolean isValid() {
100-
if(this.url == null){
103+
if(this.urlField == null){
101104
return false;
102105
}
103106
if(this.expanded == null){
@@ -106,30 +109,29 @@ public boolean isValid() {
106109
if(this.display == null){
107110
return false;
108111
}
109-
if(!this.url.isValid()){
110-
return false;
111-
}
112112
if(this.expanded.isEmpty()){
113113
return false;
114114
}
115115
if(this.display.isEmpty()){
116116
return false;
117117
}
118-
boolean isInvalid = this.isRawUrlsFromDescription()||this.isUrlAndExpandedTheSame();
119-
return !isInvalid;
118+
if(!this.urlField.isValid()){
119+
return false;
120+
}
121+
return true;
120122
}
121123

122124
@Transient
123125
@Override
124126
public String getUniqueId() {
125-
return url.getUrl();
127+
return urlField.getUrl();
126128
}
127129

128130
@Transient
129131
@Override
130132
public Map<String, Object> getParametersForFindByUniqueId() {
131133
Map<String,Object> parameters = new HashMap<>();
132-
parameters.put("url",this.url);
134+
parameters.put("url",this.urlField.getUrl());
133135
return parameters;
134136
}
135137

@@ -139,18 +141,18 @@ public String getQueryNameForFindByUniqueId() {
139141
return "Url.findByUniqueId";
140142
}
141143

142-
public Url(Task createdBy, Task updatedBy,String display, String expanded, UrlField url) {
144+
public Url(Task createdBy, Task updatedBy,String display, String expanded, UrlField urlField) {
143145
super(createdBy,updatedBy);
144146
this.display = display;
145147
this.expanded = expanded;
146-
this.url = url;
148+
this.urlField = urlField;
147149
}
148150

149-
public Url(Task createdBy, Task updatedBy,UrlField url) {
151+
public Url(Task createdBy, Task updatedBy,UrlField urlField) {
150152
super(createdBy,updatedBy);
151153
this.display = Url.UNDEFINED;
152154
this.expanded = Url.UNDEFINED;
153-
this.url = url;
155+
this.urlField = urlField;
154156
}
155157

156158
private Url() {
@@ -186,11 +188,11 @@ public void setExpanded(String expanded) {
186188

187189
@Override
188190
public UrlField getUrl() {
189-
return url;
191+
return urlField;
190192
}
191193

192-
public void setUrl(UrlField url) {
193-
this.url = url;
194+
public void setUrl(UrlField urlField) {
195+
this.urlField = urlField;
194196
}
195197

196198
@Override
@@ -199,7 +201,7 @@ public String toString() {
199201
"id=" + id +
200202
", display='" + display + '\'' +
201203
", expanded='" + expanded + '\'' +
202-
", url='" + url + '\'' +
204+
", urlField='" + urlField + '\'' +
203205
super.toString() +
204206
"}\n";
205207
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464
),
6565
@NamedQuery(
6666
name="User.getUsersForHashTag",
67-
query="select t from User as t join t.entities.hashTags hashTag WHERE hashTag.text=:hashtagText"
67+
query="select t from User as t join t.entities.hashTags hashTag WHERE hashTag.hashTagText.text=:hashtagText"
6868
),
6969
@NamedQuery(
7070
name="User.countUsersForHashTag",
71-
query="select count(t) from User as t join t.entities.hashTags hashTag WHERE hashTag.text=:hashtagText"
71+
query="select count(t) from User as t join t.entities.hashTags hashTag WHERE hashTag.hashTagText.text=:hashtagText"
7272
),
7373
@NamedQuery(
7474
name = "User.findAllDescriptions",

src/main/java/org/woehlke/twitterwall/oodm/entities/common/DomainObjectWithUrl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ public interface DomainObjectWithUrl <T extends DomainObjectWithUrl> extends Dom
99

1010
UrlField getUrl();
1111

12-
void setUrl(UrlField url);
12+
void setUrl(UrlField urlField);
1313
}

src/main/java/org/woehlke/twitterwall/oodm/entities/parts/Entities.java

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import javax.persistence.*;
99
import javax.validation.constraints.NotNull;
10-
import java.io.Serializable;
1110
import java.util.ArrayList;
1211
import java.util.LinkedHashSet;
1312
import java.util.List;

0 commit comments

Comments
 (0)