Skip to content

Commit

Permalink
workin on #161
Browse files Browse the repository at this point in the history
  • Loading branch information
phasenraum2010 committed Jul 31, 2017
1 parent ac5493c commit 5a7b4e7
Show file tree
Hide file tree
Showing 25 changed files with 41 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
import java.util.HashMap;
import java.util.Map;

import static javax.persistence.CascadeType.DETACH;
import static javax.persistence.CascadeType.REFRESH;
import static javax.persistence.CascadeType.REMOVE;
import static javax.persistence.CascadeType.*;
import static javax.persistence.FetchType.EAGER;

/**
Expand Down Expand Up @@ -137,7 +135,7 @@ public class Tweet extends AbstractDomainObject<Tweet> implements DomainObjectWi
private Boolean retweeted;

@JoinColumn(name="fk_tweet_retweeted")
@ManyToOne(cascade = {DETACH, REFRESH, REMOVE}, fetch = EAGER, optional = true)
@ManyToOne(cascade = {ALL}, fetch = EAGER, optional = true)
private Tweet retweetedStatus;

@Column(name="favorited")
Expand Down Expand Up @@ -186,7 +184,7 @@ public class Tweet extends AbstractDomainObject<Tweet> implements DomainObjectWi
@Valid
@NotNull
@JoinColumn(name="fk_user")
@ManyToOne(cascade = {DETACH, REFRESH, REMOVE}, fetch = EAGER, optional = false)
@ManyToOne(cascade = { ALL }, fetch = EAGER, optional = false)
private User user;

@AssertTrue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import java.util.List;
import java.util.Set;

import static javax.persistence.CascadeType.DETACH;
import static javax.persistence.CascadeType.REFRESH;
import static javax.persistence.CascadeType.REMOVE;
import static javax.persistence.CascadeType.*;
import static javax.persistence.FetchType.EAGER;

/**
Expand All @@ -25,23 +23,24 @@
public class Entities extends EntitiesFilter implements DomainObjectEmbededField {

@NotNull
@ManyToMany(cascade = { DETACH, REFRESH, REMOVE }, fetch = EAGER)
//@ManyToMany(cascade = { DETACH, REFRESH, REMOVE }, fetch = EAGER)
@ManyToMany(cascade = { ALL }, fetch = EAGER)
private Set<Url> urls = new LinkedHashSet<Url>();

@NotNull
@ManyToMany(cascade = { DETACH, REFRESH, REMOVE }, fetch = EAGER)
@ManyToMany(cascade = { ALL }, fetch = EAGER)
private Set<HashTag> hashTags = new LinkedHashSet<HashTag>();

@NotNull
@ManyToMany(cascade = { DETACH, REFRESH, REMOVE }, fetch = EAGER)
@ManyToMany(cascade = { ALL }, fetch = EAGER)
private Set<Mention> mentions = new LinkedHashSet<Mention>();

@NotNull
@ManyToMany(cascade = { DETACH, REFRESH, REMOVE }, fetch = EAGER)
@ManyToMany(cascade = { ALL }, fetch = EAGER)
private Set<Media> media = new LinkedHashSet<Media>();

@NotNull
@ManyToMany(cascade = { DETACH, REFRESH, REMOVE }, fetch = EAGER)
@ManyToMany(cascade = { ALL }, fetch = EAGER)
private Set<TickerSymbol> tickerSymbols = new LinkedHashSet<TickerSymbol>();

public Entities(Set<Url> urls, Set<HashTag> hashTags, Set<Mention> mentions, Set<Media> media, Set<TickerSymbol> tickerSymbols) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.woehlke.twitterwall.oodm.entities.Task;
import org.woehlke.twitterwall.oodm.entities.common.DomainObjectWithTask;
import org.woehlke.twitterwall.oodm.repositories.TaskRepository;
import org.woehlke.twitterwall.oodm.repositories.common.DomainRepository;
import org.woehlke.twitterwall.oodm.service.common.DomainService;


@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
public abstract class DomainServiceWithTaskImpl<T extends DomainObjectWithTask> implements DomainService<T> {

private static final Logger log = LoggerFactory.getLogger(DomainServiceWithTaskImpl.class);
Expand Down Expand Up @@ -43,7 +40,6 @@ public long count() {
}

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public T store(T domainObject, Task task) {
String msg = "store "+domainObject.getUniqueId()+" in Task "+task.getUniqueId()+" ";
T domainObjectResult = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Created by tw on 12.06.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public class HashTagServiceImpl extends DomainServiceWithTaskImpl<HashTag> implements HashTagService {

private static final Logger log = LoggerFactory.getLogger(HashTagServiceImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Created by tw on 12.06.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public class MediaServiceImpl extends DomainServiceWithTaskImpl<Media> implements MediaService {

private static final Logger log = LoggerFactory.getLogger(MediaServiceImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Created by tw on 12.06.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public class MentionServiceImpl extends DomainServiceWithTaskImpl<Mention> implements MentionService {

private static final Logger log = LoggerFactory.getLogger(MentionServiceImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Created by tw on 11.07.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public class TaskHistoryServiceImpl implements TaskHistoryService {

private static final Logger log = LoggerFactory.getLogger(TaskHistoryServiceImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Created by tw on 09.07.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public class TaskServiceImpl implements TaskService {

private static final Logger log = LoggerFactory.getLogger(TaskServiceImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Created by tw on 12.06.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public class TickerSymbolServiceImpl extends DomainServiceWithTaskImpl<TickerSymbol> implements TickerSymbolService {

private static final Logger log = LoggerFactory.getLogger(TickerSymbolServiceImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Created by tw on 10.06.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public class TweetServiceImpl extends DomainServiceWithTaskImpl<Tweet> implements TweetService {

private static final Logger log = LoggerFactory.getLogger(TweetServiceImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Created by tw on 23.06.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public class UrlCacheServiceImpl extends DomainServiceWithTaskImpl<UrlCache> implements UrlCacheService {

private static final Logger log = LoggerFactory.getLogger(TickerSymbolServiceImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Created by tw on 12.06.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public class UrlServiceImpl extends DomainServiceWithTaskImpl<Url> implements UrlService {

private static final Logger log = LoggerFactory.getLogger(UrlServiceImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Created by tw on 11.06.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public class UserServiceImpl extends DomainServiceWithTaskImpl<User> implements UserService {

private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Created by tw on 09.07.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
public class CountedEntitiesServiceImpl implements CountedEntitiesService {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Component;
import org.woehlke.twitterwall.oodm.entities.User;
import org.woehlke.twitterwall.oodm.entities.Task;
import org.woehlke.twitterwall.oodm.entities.Mention;
Expand All @@ -16,8 +14,8 @@
/**
* Created by tw on 14.07.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)

@Component
public class CreatePersistentMentionImpl implements CreatePersistentMention {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import org.springframework.stereotype.Component;
import org.woehlke.twitterwall.oodm.entities.Task;
import org.woehlke.twitterwall.oodm.entities.parts.UrlField;
import org.woehlke.twitterwall.oodm.repositories.UrlCacheRepository;
import org.woehlke.twitterwall.oodm.repositories.UrlRepository;
import org.woehlke.twitterwall.oodm.service.UrlCacheService;
import org.woehlke.twitterwall.oodm.service.UrlService;
import org.woehlke.twitterwall.scheduled.service.backend.TwitterUrlService;
Expand Down Expand Up @@ -120,22 +118,16 @@ public Url createPersistentUrlFor(String url, Task task) {

private static final Logger log = LoggerFactory.getLogger(CreatePersistentUrlImpl.class);

//private final UrlRepository urlRepository;

//private final UrlCacheRepository urlCacheRepository;

private final UrlService urlService;

private final UrlCacheService urlCacheService;

private final TwitterUrlService twitterUrlService;

@Autowired
public CreatePersistentUrlImpl(UrlRepository urlRepository, UrlCacheRepository urlCacheRepository, UrlService urlService, UrlCacheService urlCacheService, TwitterUrlService twitterUrlService) {
public CreatePersistentUrlImpl(UrlService urlService, UrlCacheService urlCacheService, TwitterUrlService twitterUrlService) {
this.urlService = urlService;
this.urlCacheService = urlCacheService;
//this.urlRepository = urlRepository;
//this.urlCacheRepository = urlCacheRepository;
this.twitterUrlService = twitterUrlService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.woehlke.twitterwall.oodm.entities.*;
import org.woehlke.twitterwall.oodm.entities.parts.Entities;
import org.woehlke.twitterwall.oodm.service.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Component;
import org.woehlke.twitterwall.oodm.entities.Tweet;
import org.woehlke.twitterwall.oodm.entities.Task;
import org.woehlke.twitterwall.scheduled.service.persist.StoreOneTweet;
Expand All @@ -15,8 +13,7 @@
/**
* Created by tw on 09.07.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
@Component
public class StoreOneTweetImpl implements StoreOneTweet {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Component;
import org.woehlke.twitterwall.oodm.entities.parts.Entities;
import org.woehlke.twitterwall.oodm.entities.Tweet;
import org.woehlke.twitterwall.oodm.entities.User;
Expand All @@ -16,8 +14,7 @@
/**
* Created by tw on 09.07.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
@Component
public class StoreOneTweetPerformImpl implements StoreOneTweetPerform {

/** Method because of recursive Method Call in this Method **/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.social.ApiException;
import org.springframework.social.twitter.api.TwitterProfile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Component;
import org.woehlke.twitterwall.oodm.entities.*;
import org.woehlke.twitterwall.oodm.entities.parts.CountedEntities;
import org.woehlke.twitterwall.oodm.entities.parts.Entities;
Expand All @@ -24,9 +22,7 @@
/**
* Created by tw on 14.07.17.
*/

@Service
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
@Component
public class StoreTwitterProfileForProxyMentionForUserImpl implements StoreTwitterProfileForProxyMentionForUser {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Component;
import org.woehlke.twitterwall.oodm.entities.User;
import org.woehlke.twitterwall.oodm.entities.Task;
import org.woehlke.twitterwall.oodm.entities.Mention;
Expand All @@ -15,8 +13,7 @@
/**
* Created by tw on 11.07.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
@Component
public class StoreUserFromMentionImpl implements StoreUserFromMention {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,20 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.social.RateLimitExceededException;
import org.springframework.social.twitter.api.TwitterProfile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Component;
import org.woehlke.twitterwall.oodm.entities.User;
import org.woehlke.twitterwall.oodm.entities.Task;
import org.woehlke.twitterwall.oodm.service.UserService;
import org.woehlke.twitterwall.oodm.service.TaskService;
import org.woehlke.twitterwall.scheduled.service.backend.TwitterApiService;
import org.woehlke.twitterwall.scheduled.service.persist.StoreUserProfile;
import org.woehlke.twitterwall.scheduled.service.persist.StoreUserProfileForScreenName;

/**
* Created by tw on 11.07.17.
*/
@Service
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
@Component
public class StoreUserProfileForScreenNameImpl implements StoreUserProfileForScreenName {

@Override
Expand Down Expand Up @@ -59,14 +54,11 @@ public User storeUserProfileForScreenName(String screenName, Task task){

private final StoreUserProfile storeUserProfile;

private final TaskService taskService;

@Autowired
public StoreUserProfileForScreenNameImpl(UserService userService, TwitterApiService twitterApiService, StoreUserProfile storeUserProfile, TaskService taskService) {
public StoreUserProfileForScreenNameImpl(UserService userService, TwitterApiService twitterApiService, StoreUserProfile storeUserProfile) {
this.userService = userService;
this.twitterApiService = twitterApiService;
this.storeUserProfile = storeUserProfile;
this.taskService = taskService;
}

}
Loading

0 comments on commit 5a7b4e7

Please sign in to comment.