Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
kolya-t committed Aug 14, 2017
2 parents 41ad329 + 622c342 commit 7401c7b
Show file tree
Hide file tree
Showing 102 changed files with 4,303 additions and 3,122 deletions.
94 changes: 17 additions & 77 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,33 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.teapot</groupId>
<artifactId>teapot-backend</artifactId>
<version>2.2.0</version>
<version>3.0.0</version>
<packaging>jar</packaging>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.7.RELEASE</version>
<version>1.5.6.RELEASE</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>

<!-- JPA -->
<javax.persistence.version>2.1.1</javax.persistence.version>

<!-- Spring -->
<spring.version>4.3.8.RELEASE</spring.version>

<!-- JUnit -->
<junit.version>4.12</junit.version>

<!-- H2 Database -->
<h2.version>1.4.195</h2.version>

<!-- Hibernate -->
<hibernate.version>5.2.10.Final</hibernate.version>

<!--Google Guava-->
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<guava.version>22.0</guava.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
Expand All @@ -81,55 +45,26 @@
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.eclipse.persistence/javax.persistence -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>${javax.persistence.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-data</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
<artifactId>hibernate-java8</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.security.oauth/spring-security-oauth2 -->
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310 -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
Expand All @@ -148,6 +83,11 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -160,4 +100,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
126 changes: 82 additions & 44 deletions src/main/java/org/teapot/backend/config/DevelopmentProfileConfig.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.teapot.backend.config;

import lombok.RequiredArgsConstructor;
import org.h2.server.web.WebServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.teapot.backend.model.Board;
import org.teapot.backend.model.kanban.*;
import org.teapot.backend.model.meta.TeapotAction;
import org.teapot.backend.model.meta.TeapotProperty;
import org.teapot.backend.model.meta.TeapotResource;
Expand All @@ -16,7 +17,9 @@
import org.teapot.backend.model.organization.Organization;
import org.teapot.backend.model.user.User;
import org.teapot.backend.model.user.UserAuthority;
import org.teapot.backend.repository.BoardRepository;
import org.teapot.backend.repository.kanban.KanbanRepository;
import org.teapot.backend.repository.kanban.ProjectRepository;
import org.teapot.backend.repository.kanban.TicketListRepository;
import org.teapot.backend.repository.meta.TeapotActionRepository;
import org.teapot.backend.repository.meta.TeapotPropertyRepository;
import org.teapot.backend.repository.meta.TeapotResourceRepository;
Expand All @@ -25,34 +28,22 @@
import org.teapot.backend.repository.user.UserRepository;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;


@Configuration
@Profile("development")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class DevelopmentProfileConfig {

@Autowired
private UserRepository userRepository;

@Autowired
private TeapotPropertyRepository propertyRepository;

@Autowired
private TeapotActionRepository actionRepository;

@Autowired
private TeapotResourceRepository resourceRepository;

@Autowired
private OrganizationRepository organizationRepository;

@Autowired
private MemberRepository memberRepository;

@Autowired
private BoardRepository boardRepository;
private final UserRepository userRepository;
private final TeapotPropertyRepository propertyRepository;
private final TeapotActionRepository actionRepository;
private final TeapotResourceRepository resourceRepository;
private final OrganizationRepository organizationRepository;
private final MemberRepository memberRepository;
private final ProjectRepository projectRepository;
private final KanbanRepository kanbanRepository;
private final TicketListRepository ticketListRepository;

@Bean
ServletRegistrationBean h2ServletRegistrationBean() {
Expand All @@ -78,7 +69,10 @@ public CommandLineRunner loadData() {
addActions();
addOrganizations();
addMembers();
addBoards();
addProjects();
addKanbans();
addTicketLists();
addTickets();
};
}

Expand All @@ -91,7 +85,6 @@ private void registerAdmin() {
admin.setActivated(true);
admin.setFirstName("Cake");
admin.setLastName("Lover");
admin.setRegistrationDateTime(LocalDateTime.now());
admin.setBirthday(LocalDate.now());
admin.setDescription("i manage everything");
admin.setAuthority(UserAuthority.ADMIN);
Expand All @@ -108,7 +101,6 @@ private void registerDaleCooper() {
user.setActivated(true);
user.setFirstName("Dale");
user.setLastName("Cooper");
user.setRegistrationDateTime(LocalDateTime.now());
user.setBirthday(LocalDate.now());
user.setDescription("a special FBI agent");
user.setAuthority(UserAuthority.USER);
Expand All @@ -125,7 +117,6 @@ private void registerLoraPalmer() {
user.setActivated(true);
user.setFirstName("Lora");
user.setLastName("Palmer");
user.setRegistrationDateTime(LocalDateTime.now());
user.setBirthday(LocalDate.now());
user.setDescription("a dead girl");
user.setAuthority(UserAuthority.USER);
Expand All @@ -142,7 +133,6 @@ private void registerSherlockHolmes() {
user.setActivated(true);
user.setFirstName("Sherlock");
user.setLastName("Holmes");
user.setRegistrationDateTime(LocalDateTime.now());
user.setBirthday(LocalDate.now());
user.setDescription("private detective");
user.setAuthority(UserAuthority.USER);
Expand All @@ -159,7 +149,6 @@ private void registerDoctorWatson() {
user.setActivated(true);
user.setFirstName("John");
user.setLastName("Watson");
user.setRegistrationDateTime(LocalDateTime.now());
user.setBirthday(LocalDate.now());
user.setDescription("Sherlock Holmes' mate");
user.setAuthority(UserAuthority.USER);
Expand Down Expand Up @@ -209,52 +198,101 @@ private void addActions() {
private void addOrganizations() {
Organization teapot = new Organization();
teapot.setName("teapot");
teapot.setRegistrationDateTime(LocalDateTime.now());
organizationRepository.save(teapot);

Organization someOrganization = new Organization();
someOrganization.setName("someOrganization");
someOrganization.setRegistrationDateTime(LocalDateTime.now());
organizationRepository.save(someOrganization);
}

private void addMembers() {
Member member1 = new Member();
member1.setAdmissionDate(LocalDate.now());
member1.setOrganization(organizationRepository.findByName("teapot"));
member1.setUser(userRepository.findByName("dr_watson"));
member1.setStatus(MemberStatus.CREATOR);
memberRepository.save(member1);

Member member2 = new Member();
member2.setAdmissionDate(LocalDate.now());
member2.setOrganization(organizationRepository.findByName("teapot"));
member2.setUser(userRepository.findByName("lora_palmer"));
member2.setStatus(MemberStatus.WORKER);
memberRepository.save(member2);

Member member3 = new Member();
member3.setAdmissionDate(LocalDate.now());
member3.setOrganization(organizationRepository.findByName("someOrganization"));
member3.setUser(userRepository.findByName("dale_cooper"));
member3.setStatus(MemberStatus.CREATOR);
memberRepository.save(member3);

Member member4 = new Member();
member4.setAdmissionDate(LocalDate.now());
member4.setOrganization(organizationRepository.findByName("someOrganization"));
member4.setUser(userRepository.findByName("sherlock_holmes"));
member4.setStatus(MemberStatus.OWNER);
memberRepository.save(member4);
}

private void addBoards() {
boardRepository.save(new Board("board", userRepository.findByName("dr_watson")));
boardRepository.save(new Board("board", userRepository.findByName("admin")));
boardRepository.save(new Board("board", userRepository.findByName("admin")));
boardRepository.save(new Board("board1", organizationRepository.findByName("teapot")));
boardRepository.save(new Board("board2", organizationRepository.findByName("teapot")));
boardRepository.save(new Board("board3", organizationRepository.findByName("teapot")));
boardRepository.save(new Board("board2", organizationRepository.findByName("teapot")));
private void addProjects() {
projectRepository.save(new Project());
projectRepository.save(new Project());
}

private void addKanbans() {
Kanban kanban = new Kanban("kanban123");
kanban.setOwner(userRepository.findByName("admin"));
kanban.setProject(projectRepository.findOne(1L));
kanban.getContributors().add(userRepository.findByName("dr_watson"));
kanbanRepository.save(kanban);

kanbanRepository.save(new Kanban("kanban", userRepository.findByName("admin")));
kanbanRepository.save(new Kanban("kanban1", organizationRepository.findByName("teapot")));
kanbanRepository.save(new Kanban("kanban2", organizationRepository.findByName("teapot"), KanbanAccess.PRIVATE));
kanbanRepository.save(new Kanban("kanban3", organizationRepository.findByName("teapot")));
kanbanRepository.save(new Kanban("kanban2", organizationRepository.findByName("teapot")));
}

private void addTicketLists() {
Kanban kanban1 = kanbanRepository.findOne(3L);
kanban1.addTicketList(new TicketList("ticketList1"));
kanbanRepository.save(kanban1);

Kanban kanban2 = kanbanRepository.findOne(4L);
kanban2.addTicketList(new TicketList("ticketList2"));
kanbanRepository.save(kanban2);

Kanban kanban3 = kanbanRepository.findOne(3L);
kanban3.addTicketList(new TicketList("ticketList3"));
kanbanRepository.save(kanban3);

Kanban kanban4 = kanbanRepository.findOne(3L);
kanban4.addTicketList(new TicketList("ticketList4"));
kanbanRepository.save(kanban4);

Kanban kanban5 = kanbanRepository.findOne(4L);
kanban5.addTicketList(new TicketList("ticketList4"));
kanbanRepository.save(kanban5);

Kanban kanban6 = kanbanRepository.findOne(5L);
kanban6.addTicketList(new TicketList("ticketList4"));
kanbanRepository.save(kanban6);

Kanban kanban7 = kanbanRepository.findOne(5L);
kanban7.addTicketList(new TicketList("ticketList2"));
kanbanRepository.save(kanban7);

Kanban kanban8 = kanbanRepository.findOne(6L);
kanban8.addTicketList(new TicketList("ticketList5"));
kanbanRepository.save(kanban8);

Kanban kanban9 = kanbanRepository.findOne(7L);
kanban9.addTicketList(new TicketList("ticketList6"));
kanbanRepository.save(kanban9);
}

private void addTickets() {
TicketList ticketList = ticketListRepository.findOne(1L);
Ticket ticket = new Ticket("ticket1", "lalalalal");
ticket.getSubscribers().add(userRepository.findByName("lora_palmer"));
ticketList.addTicket(ticket);
ticketListRepository.save(ticketList);
}
}
Loading

0 comments on commit 7401c7b

Please sign in to comment.