Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ buildNumber.properties
!/.mvn/wrapper/maven-wrapper.jar

.idea
todo.txt
tw.txt
twitterwall.log
twitterwall.log*
maven-build.log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
public interface TaskRepositoryCustom extends DomainObjectMinimalRepository<Task> {

Task findByUniqueId(Task domainObject);

void deleteAllDomainData();

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
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
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
Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ public interface CountedEntitiesService {
long countTweets();

long countUsers();

CountedEntities deleteAll();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 3 additions & 5 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -33,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}
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/templates/application/management.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ <h3>Your Options:</h3>
<span>Count Entities</span>
</a>
<hr class="divider" role="separator" />
<a class="list-group-item" href="/application/domain/delete/all" th:href="@{/application/domain/delete/all}">
<i class="fa fa-database" aria-hidden="true"></i>
<span>Delete All Entities</span>
</a>
<hr class="divider" role="separator" />
<a class="list-group-item" href="/user/all" th:href="@{/user/all}">
<i class="fa fa-user" aria-hidden="true"></i>
<span>List All Users</span>
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/templates/hashtag/id.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ <h3>Users with the Hashtag #<span th:text="${hashTag.text}">Hashtag</span></h3>
</span>
</div>
</div>
<div class="row">
<div class="col-md-12">
<hr />
</div>
</div>
</div>
</main>

Expand Down
12 changes: 9 additions & 3 deletions src/main/resources/templates/hashtag/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="row">
<div class="col-md-12">
<h3>Tweets HashTags</h3>
<div>
<div class="well">
<span th:each="hashTag : ${hashTagsTweets}">
<a href="" th:href="@{|/hashtag/${hashTag.id}|}">
<span class="tw-vector tw-vector-hashtag-overview">
Expand All @@ -22,11 +22,12 @@ <h3>Tweets HashTags</h3>
</a>
</span>
</div>
<hr/>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>User HashTags</h3>
<div>
<div class="well">
<span th:each="hashTag : ${hashTagsUsers}">
<a href="" th:href="@{|/hashtag/${hashTag.id}|}">
<span class="tw-vector tw-vector-hashtag-overview">
Expand All @@ -41,6 +42,11 @@ <h3>User HashTags</h3>
<hr/>
</div>
</div>
<div class="row">
<div class="col-md-12">
<hr />
</div>
</div>
</div>
</main>

Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/templates/layoutMain.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@
</a>
</li>
<li role="separator" class="divider"></li>
<li>
<a href="/application/domain/delete/all" th:href="@{/application/domain/delete/all}">
<i class="fa fa-database" aria-hidden="true"></i>
Delete All Entities
</a>
</li>
<li role="separator" class="divider"></li>
<li>
<a href="/application/domain/count" th:href="@{/application/domain/count}">
<i class="fa fa-database" aria-hidden="true"></i>
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/templates/task/id.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
</div>
<div class="row">
<div class="col-md-12">
<div class="well">
<a href="/task/all" th:href="@{/task/all}">
<i class="fa fa-check-square" aria-hidden="true"></i>
<span>Tasks</span>
</a>
</div>
<table class="table table-striped">
<tr>
<th>
Expand Down Expand Up @@ -64,6 +70,12 @@
</td>
</tr>
</table>
<div class="well">
<a href="/task/all" th:href="@{/task/all}">
<i class="fa fa-check-square" aria-hidden="true"></i>
<span>Tasks</span>
</a>
</div>
</div>
</div>
<div class="row">
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/templates/taskhistory/all.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
</div>
<div class="row">
<div class="col-md-12">
<div class="well">
<a href="/task/all" th:href="@{/task/all}">
<i class="fa fa-check-square" aria-hidden="true"></i>
<span>Tasks</span>
</a>
</div>
<table class="table table-striped">
<thead th:include="layoutDataview :: tw-data-view-thead">
</thead>
Expand Down Expand Up @@ -55,6 +61,12 @@
<tfoot th:include="layoutDataview :: tw-data-view-tfoot">
</tfoot>
</table>
<div class="well">
<a href="/task/all" th:href="@{/task/all}">
<i class="fa fa-check-square" aria-hidden="true"></i>
<span>Tasks</span>
</a>
</div>
</div>
</div>
<div class="row">
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ endpoints:
endpoints:
shutdown:
enabled: true
logging:
file: test/twitterwall.log.txt
#hibernate:
#dialect: org.hibernate.dialect.H2Dialect
management:
Expand Down
16 changes: 16 additions & 0 deletions twitterwall2.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
</fileset>
</configuration>
</facet>
<facet type="jpa" name="JPA">
<configuration>
<setting name="validation-enabled" value="true" />
<setting name="provider-name" value="Hibernate" />
<datasource-mapping>
<factory-entry name="entityManagerFactory" />
</datasource-mapping>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
Expand All @@ -25,6 +34,13 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="org.thymeleaf:thymeleaf:Release" level="project" />
<orderEntry type="library" name="org.thymeleaf.extras:thymeleaf-extras-conditionalcomments:Release" level="project" />
<orderEntry type="library" name="org.thymeleaf.extras:thymeleaf-extras-tiles2:Release" level="project" />
<orderEntry type="library" name="org.thymeleaf.extras:thymeleaf-extras-java8time:Release" level="project" />
<orderEntry type="library" name="org.thymeleaf:thymeleaf-testing:Release" level="project" />
<orderEntry type="library" name="org.thymeleaf.extras:thymeleaf-extras-springsecurity4:Release" level="project" />
<orderEntry type="library" name="org.thymeleaf:thymeleaf-spring4:Release" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.6.RELEASE" level="project" />
Expand Down