From 122ff5b0141e9b5c92296cdb65931979b1e4ab46 Mon Sep 17 00:00:00 2001 From: phasenraum2010 Date: Mon, 7 Aug 2017 01:01:08 +0200 Subject: [PATCH 1/4] working on #228, working on #225, working on #42, working on #230 --- src/main/resources/application.yml | 2 -- src/test/resources/application-test.yml | 2 ++ twitterwall2.iml | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 95e75e3a..c9e3eb74 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -18,8 +18,6 @@ info: groupId: @project.groupId@ name: @project.name@ version: @project.version@ -logging: - file: test/twitterwall.log.txt management: address: 127.0.0.1 context-path: "/manage" diff --git a/src/test/resources/application-test.yml b/src/test/resources/application-test.yml index 24fd0c01..d74cdde3 100644 --- a/src/test/resources/application-test.yml +++ b/src/test/resources/application-test.yml @@ -4,6 +4,8 @@ endpoints: endpoints: shutdown: enabled: true +logging: + file: test/twitterwall.log.txt #hibernate: #dialect: org.hibernate.dialect.H2Dialect management: diff --git a/twitterwall2.iml b/twitterwall2.iml index 83394c77..89bcd3a6 100644 --- a/twitterwall2.iml +++ b/twitterwall2.iml @@ -12,6 +12,13 @@ + + + + + + + @@ -25,6 +32,13 @@ + + + + + + + From 1736dc8ab983bacb56515c79a429f788ad36023a Mon Sep 17 00:00:00 2001 From: phasenraum2010 Date: Mon, 7 Aug 2017 01:38:49 +0200 Subject: [PATCH 2/4] working on #228, working on #225, working on #42, working on #230 --- src/main/resources/application.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c9e3eb74..7d3f360b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -31,14 +31,14 @@ spring: datasource: driverClassName: org.postgresql.Driver #initialSize: 5 - max-total: 70 - maxActive: 60 + max-total: 20 + maxActive: 20 #maxIdle: 5 #minIdle: 2 platform: POSTGRESQL #removeAbandoned: true tomcat: - max-active: 60 + max-active: 20 #max-wait: 100000 #test-on-borrow: true url: ${DATABASE_URL} From f64278bd1fb47cc128374ce0cb47ecca21c72719 Mon Sep 17 00:00:00 2001 From: phasenraum2010 Date: Mon, 7 Aug 2017 04:58:45 +0200 Subject: [PATCH 3/4] working on #228, working on #225, working on #42, working on #230 --- .gitignore | 2 ++ twitterwall2.iml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0cf64417..e051b386 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,8 @@ buildNumber.properties !/.mvn/wrapper/maven-wrapper.jar .idea +todo.txt +tw.txt twitterwall.log twitterwall.log* maven-build.log diff --git a/twitterwall2.iml b/twitterwall2.iml index 89bcd3a6..c3e72524 100644 --- a/twitterwall2.iml +++ b/twitterwall2.iml @@ -16,7 +16,9 @@ - + + + From 8ccb62d20f2b8a92f9547662383709aa404041ee Mon Sep 17 00:00:00 2001 From: phasenraum2010 Date: Mon, 7 Aug 2017 07:16:41 +0200 Subject: [PATCH 4/4] working on #228, working on #225, working on #42, working on #230 --- .../controller/ApplicationController.java | 12 ++++++ .../custom/TaskRepositoryCustom.java | 3 ++ .../custom/impl/TaskRepositoryImpl.java | 38 ++++++++++++++++++- .../oodm/service/CountedEntitiesService.java | 3 ++ .../impl/CountedEntitiesServiceImpl.java | 7 ++++ .../templates/application/management.html | 5 +++ src/main/resources/templates/hashtag/id.html | 5 +++ .../resources/templates/hashtag/overview.html | 12 ++++-- src/main/resources/templates/layoutMain.html | 7 ++++ src/main/resources/templates/task/id.html | 12 ++++++ .../resources/templates/taskhistory/all.html | 12 ++++++ 11 files changed, 112 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/woehlke/twitterwall/frontend/controller/ApplicationController.java b/src/main/java/org/woehlke/twitterwall/frontend/controller/ApplicationController.java index 6a2c2844..16f2998f 100644 --- a/src/main/java/org/woehlke/twitterwall/frontend/controller/ApplicationController.java +++ b/src/main/java/org/woehlke/twitterwall/frontend/controller/ApplicationController.java @@ -39,6 +39,18 @@ public String managementPage(Model model) { return "application/management"; } + @RequestMapping(path="/domain/delete/all") + public String domainDeleteAll(Model model) { + String msg = "/application/domain/delete/all: "; + String title = "Counted Entities"; + String subtitle = twitterProperties.getSearchQuery(); + String symbol = Symbols.DATABASE.toString(); + model = controllerHelper.setupPage(model,title,subtitle,symbol); + CountedEntities countedEntities =this.countedEntitiesService.deleteAll(); + model.addAttribute("countedEntities", countedEntities); + return "application/domain/count"; + } + private final CountedEntitiesService countedEntitiesService; private final ControllerHelper controllerHelper; diff --git a/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/TaskRepositoryCustom.java b/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/TaskRepositoryCustom.java index b88b05be..180b2b6d 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/TaskRepositoryCustom.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/TaskRepositoryCustom.java @@ -6,4 +6,7 @@ public interface TaskRepositoryCustom extends DomainObjectMinimalRepository { Task findByUniqueId(Task domainObject); + + void deleteAllDomainData(); + } diff --git a/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/impl/TaskRepositoryImpl.java b/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/impl/TaskRepositoryImpl.java index c03eb25c..9e5f5a1d 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/impl/TaskRepositoryImpl.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/impl/TaskRepositoryImpl.java @@ -1,12 +1,14 @@ package org.woehlke.twitterwall.oodm.repositories.custom.impl; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository; import org.woehlke.twitterwall.oodm.entities.Task; import org.woehlke.twitterwall.oodm.repositories.custom.TaskRepositoryCustom; import javax.persistence.EntityManager; import javax.persistence.TypedQuery; +import javax.sql.DataSource; import java.util.List; @Repository @@ -14,9 +16,12 @@ public class TaskRepositoryImpl implements TaskRepositoryCustom { private final EntityManager entityManager; + private JdbcTemplate jdbcTemplate; + @Autowired - public TaskRepositoryImpl(EntityManager entityManager) { + public TaskRepositoryImpl(EntityManager entityManager,DataSource dataSource) { this.entityManager = entityManager; + this.jdbcTemplate = new JdbcTemplate(dataSource); } @Override @@ -32,4 +37,35 @@ public Task findByUniqueId(Task domainObject) { return null; } } + + @Override + public void deleteAllDomainData() { + + String SQL_DELETE_ALL_ROWS[] = { + "delete from userprofile_url", + "delete from userprofile_mention", + "delete from userprofile_hashtag", + "delete from userprofile_media", + "delete from userprofile_tickersymbol", + "delete from tweet_tickersymbol", + "delete from tweet_mention", + "delete from tweet_media", + "delete from tweet_hashtag", + "delete from tweet_url", + "delete from url_cache", + "delete from url", + "delete from tickersymbol", + "delete from mention", + "delete from media", + "delete from hashtag", + "delete from tweet", + "delete from userprofile", + "delete from task_history", + "delete from task" + }; + + for(String SQL : SQL_DELETE_ALL_ROWS){ + jdbcTemplate.execute(SQL); + } + } } diff --git a/src/main/java/org/woehlke/twitterwall/oodm/service/CountedEntitiesService.java b/src/main/java/org/woehlke/twitterwall/oodm/service/CountedEntitiesService.java index 99b92cf9..861d5179 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/service/CountedEntitiesService.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/service/CountedEntitiesService.java @@ -12,4 +12,7 @@ public interface CountedEntitiesService { long countTweets(); long countUsers(); + + CountedEntities deleteAll(); + } diff --git a/src/main/java/org/woehlke/twitterwall/oodm/service/impl/CountedEntitiesServiceImpl.java b/src/main/java/org/woehlke/twitterwall/oodm/service/impl/CountedEntitiesServiceImpl.java index 86c1a6b6..95a847e1 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/service/impl/CountedEntitiesServiceImpl.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/service/impl/CountedEntitiesServiceImpl.java @@ -72,6 +72,13 @@ public long countUsers() { return userRepository.count(); } + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false) + public CountedEntities deleteAll() { + taskRepository.deleteAllDomainData(); + return this.countAll(); + } + private static final Logger log = LoggerFactory.getLogger(CountedEntitiesServiceImpl.class); private final TweetRepository tweetRepository; diff --git a/src/main/resources/templates/application/management.html b/src/main/resources/templates/application/management.html index 9a20454f..2ecbed91 100644 --- a/src/main/resources/templates/application/management.html +++ b/src/main/resources/templates/application/management.html @@ -19,6 +19,11 @@

Your Options:

Count Entities + + + Delete All Entities + + List All Users diff --git a/src/main/resources/templates/hashtag/id.html b/src/main/resources/templates/hashtag/id.html index da40036e..7bcc4d6a 100644 --- a/src/main/resources/templates/hashtag/id.html +++ b/src/main/resources/templates/hashtag/id.html @@ -66,6 +66,11 @@

Users with the Hashtag #Hashtag

+
+
+
+
+
diff --git a/src/main/resources/templates/hashtag/overview.html b/src/main/resources/templates/hashtag/overview.html index a1ff8458..9ea36388 100644 --- a/src/main/resources/templates/hashtag/overview.html +++ b/src/main/resources/templates/hashtag/overview.html @@ -10,7 +10,7 @@