Skip to content

Commit a17ac5d

Browse files
* 'master' of https://github.com/phasenraum2010/twitterwall2: after release working on #228, working on #225, working on #42, working on #230 working on #228, working on #225, working on #42, working on #230 working on #228, working on #225, working on #42, working on #230 working on #228, working on #225, working on #42, working on #230 Update TaskController.java
2 parents 1c442c1 + 880a7a0 commit a17ac5d

File tree

17 files changed

+137
-11
lines changed

17 files changed

+137
-11
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ buildNumber.properties
1212
!/.mvn/wrapper/maven-wrapper.jar
1313

1414
.idea
15+
todo.txt
16+
tw.txt
1517
twitterwall.log
1618
twitterwall.log*
1719
maven-build.log

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.woehlke.twitterwall</groupId>
66
<artifactId>twitterwall2</artifactId>
7-
<version>1.0.24-SNAPSHOT</version>
7+
<version>1.0.25-SNAPSHOT</version>
88
<name>twitterwall2</name>
99

1010
<description>Twitterwall with spring:boot for heroku</description>

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ public String managementPage(Model model) {
3939
return "application/management";
4040
}
4141

42+
@RequestMapping(path="/domain/delete/all")
43+
public String domainDeleteAll(Model model) {
44+
String msg = "/application/domain/delete/all: ";
45+
String title = "Counted Entities";
46+
String subtitle = twitterProperties.getSearchQuery();
47+
String symbol = Symbols.DATABASE.toString();
48+
model = controllerHelper.setupPage(model,title,subtitle,symbol);
49+
CountedEntities countedEntities =this.countedEntitiesService.deleteAll();
50+
model.addAttribute("countedEntities", countedEntities);
51+
return "application/domain/count";
52+
}
53+
4254
private final CountedEntitiesService countedEntitiesService;
4355

4456
private final ControllerHelper controllerHelper;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public String updateUserProfilesStartTask(Model model) {
173173

174174
private static final Logger log = LoggerFactory.getLogger(TaskController.class);
175175

176-
private final String PATH = "/task";
176+
private final String PATH = "task";
177177

178178
private final UserService userService;
179179

src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/TaskRepositoryCustom.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
public interface TaskRepositoryCustom extends DomainObjectMinimalRepository<Task> {
77

88
Task findByUniqueId(Task domainObject);
9+
10+
void deleteAllDomainData();
11+
912
}

src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/impl/TaskRepositoryImpl.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
package org.woehlke.twitterwall.oodm.repositories.custom.impl;
22

33
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.jdbc.core.JdbcTemplate;
45
import org.springframework.stereotype.Repository;
56
import org.woehlke.twitterwall.oodm.entities.Task;
67
import org.woehlke.twitterwall.oodm.repositories.custom.TaskRepositoryCustom;
78

89
import javax.persistence.EntityManager;
910
import javax.persistence.TypedQuery;
11+
import javax.sql.DataSource;
1012
import java.util.List;
1113

1214
@Repository
1315
public class TaskRepositoryImpl implements TaskRepositoryCustom {
1416

1517
private final EntityManager entityManager;
1618

19+
private JdbcTemplate jdbcTemplate;
20+
1721
@Autowired
18-
public TaskRepositoryImpl(EntityManager entityManager) {
22+
public TaskRepositoryImpl(EntityManager entityManager,DataSource dataSource) {
1923
this.entityManager = entityManager;
24+
this.jdbcTemplate = new JdbcTemplate(dataSource);
2025
}
2126

2227
@Override
@@ -32,4 +37,35 @@ public Task findByUniqueId(Task domainObject) {
3237
return null;
3338
}
3439
}
40+
41+
@Override
42+
public void deleteAllDomainData() {
43+
44+
String SQL_DELETE_ALL_ROWS[] = {
45+
"delete from userprofile_url",
46+
"delete from userprofile_mention",
47+
"delete from userprofile_hashtag",
48+
"delete from userprofile_media",
49+
"delete from userprofile_tickersymbol",
50+
"delete from tweet_tickersymbol",
51+
"delete from tweet_mention",
52+
"delete from tweet_media",
53+
"delete from tweet_hashtag",
54+
"delete from tweet_url",
55+
"delete from url_cache",
56+
"delete from url",
57+
"delete from tickersymbol",
58+
"delete from mention",
59+
"delete from media",
60+
"delete from hashtag",
61+
"delete from tweet",
62+
"delete from userprofile",
63+
"delete from task_history",
64+
"delete from task"
65+
};
66+
67+
for(String SQL : SQL_DELETE_ALL_ROWS){
68+
jdbcTemplate.execute(SQL);
69+
}
70+
}
3571
}

src/main/java/org/woehlke/twitterwall/oodm/service/CountedEntitiesService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ public interface CountedEntitiesService {
1212
long countTweets();
1313

1414
long countUsers();
15+
16+
CountedEntities deleteAll();
17+
1518
}

src/main/java/org/woehlke/twitterwall/oodm/service/impl/CountedEntitiesServiceImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ public long countUsers() {
7272
return userRepository.count();
7373
}
7474

75+
@Override
76+
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
77+
public CountedEntities deleteAll() {
78+
taskRepository.deleteAllDomainData();
79+
return this.countAll();
80+
}
81+
7582
private static final Logger log = LoggerFactory.getLogger(CountedEntitiesServiceImpl.class);
7683

7784
private final TweetRepository tweetRepository;

src/main/resources/application.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ info:
1818
groupId: @project.groupId@
1919
name: @project.name@
2020
version: @project.version@
21-
logging:
22-
file: test/twitterwall.log.txt
2321
management:
2422
address: 127.0.0.1
2523
context-path: "/manage"
@@ -33,14 +31,14 @@ spring:
3331
datasource:
3432
driverClassName: org.postgresql.Driver
3533
#initialSize: 5
36-
max-total: 70
37-
maxActive: 60
34+
max-total: 20
35+
maxActive: 20
3836
#maxIdle: 5
3937
#minIdle: 2
4038
platform: POSTGRESQL
4139
#removeAbandoned: true
4240
tomcat:
43-
max-active: 60
41+
max-active: 20
4442
#max-wait: 100000
4543
#test-on-borrow: true
4644
url: ${DATABASE_URL}

src/main/resources/templates/application/management.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ <h3>Your Options:</h3>
1919
<span>Count Entities</span>
2020
</a>
2121
<hr class="divider" role="separator" />
22+
<a class="list-group-item" href="/application/domain/delete/all" th:href="@{/application/domain/delete/all}">
23+
<i class="fa fa-database" aria-hidden="true"></i>
24+
<span>Delete All Entities</span>
25+
</a>
26+
<hr class="divider" role="separator" />
2227
<a class="list-group-item" href="/user/all" th:href="@{/user/all}">
2328
<i class="fa fa-user" aria-hidden="true"></i>
2429
<span>List All Users</span>

0 commit comments

Comments
 (0)