Revert "Add architecture module with Hexagonal example"

This reverts commit 50efbf3dfb3a951d276c13ab3b8f1a0cadb114d4.
This commit is contained in:
andrebrowne 2020-04-25 13:41:47 -04:00
parent a2efde1d87
commit 6008e44467
14 changed files with 0 additions and 313 deletions

View File

@ -1,3 +0,0 @@
### Relevant articles
- [A Quick and Practical Example of Hexagonal Architecture in Java](https://www.baeldung.com/a-quick-and-practical-example-of-hexagonal-architecture-in-java-3/)

View File

@ -1,33 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung.architecture</groupId>
<artifactId>architecture</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>architecture</name>
<packaging>jar</packaging>
<description>A Quick and Practical Example of Hexagonal Architecture in Java</description>
<parent>
<artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,12 +0,0 @@
package com.baeldung.architecture;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class HexagonalArchitectureTaskApplication {
public static void main(String[] args) {
SpringApplication.run(HexagonalArchitectureTaskApplication.class, args);
}
}

View File

@ -1,29 +0,0 @@
package com.baeldung.architecture.application.task;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import com.baeldung.architecture.commands.task.CreateTask;
import com.baeldung.architecture.domain.task.Task;
import org.springframework.stereotype.Component;
@Component
public class AddNewDailyTask implements CreateTask {
private AddNewTask addNewTask;
public AddNewDailyTask(AddNewTask addNewTask) {
this.addNewTask = addNewTask;
}
@Override
public void create(Task newTask) {
Instant initialDueDate = newTask.getDueDate();
String description = newTask.getDescription();
for (int i = 1; i <= 5; i++) {
Task task = new Task(initialDueDate.plus(i, ChronoUnit.DAYS), description);
addNewTask.create(task);
}
}
};

View File

@ -1,22 +0,0 @@
package com.baeldung.architecture.application.task;
import com.baeldung.architecture.domain.task.Task;
import com.baeldung.architecture.domain.task.TaskService;
import com.baeldung.architecture.commands.task.*;
import org.springframework.stereotype.Component;
@Component
public class AddNewTask implements CreateTask {
private TaskService taskService;
public AddNewTask(TaskService taskService) {
this.taskService = taskService;
}
@Override
public void create(Task newTask) {
taskService.createTask(newTask);
}
};

View File

@ -1,22 +0,0 @@
package com.baeldung.architecture.application.task;
import com.baeldung.architecture.domain.task.Task;
import com.baeldung.architecture.domain.task.TaskService;
import com.baeldung.architecture.commands.task.*;
import org.springframework.stereotype.Component;
@Component
public class GetTasks implements GetAllTasks {
private TaskService taskService;
public GetTasks(TaskService taskService) {
this.taskService = taskService;
}
@Override
public Iterable<Task> getAll() {
return taskService.getAllTasks();
}
};

View File

@ -1,7 +0,0 @@
package com.baeldung.architecture.commands.task;
import com.baeldung.architecture.domain.task.Task;
public interface CreateTask {
public void create(Task newTask);
};

View File

@ -1,7 +0,0 @@
package com.baeldung.architecture.commands.task;
import com.baeldung.architecture.domain.task.Task;
public interface GetAllTasks {
public Iterable<Task> getAll();
};

View File

@ -1,53 +0,0 @@
package com.baeldung.architecture.domain.task;
import java.time.Instant;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Task {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private Instant dueDate = Instant.now();
private String description;
public Task() {}
public Task(Instant dueDate, String description) {
this.dueDate = dueDate;
this.description = description;
}
public Task(Long id, Instant dueDate, String description) {
this(dueDate, description);
this.id = id;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Instant getDueDate() {
return dueDate;
}
public void setDueDate(Instant dueDate) {
this.dueDate = dueDate;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -1,7 +0,0 @@
package com.baeldung.architecture.domain.task;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface TaskRepository extends CrudRepository<Task, Long> {};

View File

@ -1,22 +0,0 @@
package com.baeldung.architecture.domain.task;
import org.springframework.stereotype.Service;
@Service
public class TaskService {
private TaskRepository taskRepository;
public TaskService(TaskRepository taskRepository) {
this.taskRepository = taskRepository;
}
public void createTask(Task task) {
taskRepository.save(task);
}
public Iterable<Task> getAllTasks() {
return taskRepository.findAll();
}
};

View File

@ -1,25 +0,0 @@
package com.baeldung.architecture.framework.cli;
import com.baeldung.architecture.application.task.AddNewDailyTask;
import com.baeldung.architecture.domain.task.Task;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
@Component
public class StartupRunner implements ApplicationRunner {
AddNewDailyTask addNewDailyTask;
public StartupRunner(AddNewDailyTask addNewDailyTask) {
this.addNewDailyTask = addNewDailyTask;
}
@Override
public void run(ApplicationArguments args) throws Exception {
System.out.println("Adding daily tasks");
Task task = new Task();
task.setDescription("Startup Task");
addNewDailyTask.create(task);
}
}

View File

@ -1,42 +0,0 @@
package com.baeldung.architecture.framework.http.task;
import java.time.Instant;
import com.baeldung.architecture.application.task.AddNewTask;
import com.baeldung.architecture.application.task.GetTasks;
import com.baeldung.architecture.domain.task.Task;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("task")
public class TaskApiController {
private AddNewTask addNewTask;
private GetTasks getTasks;
public TaskApiController(
AddNewTask addNewTask,
GetTasks getTasks
) {
this.addNewTask = addNewTask;
this.getTasks = getTasks;
}
@GetMapping
Iterable<Task> listTasks() {
return getTasks.getAll();
}
@PostMapping(consumes = "application/json", produces = "application/json")
void createTask(@RequestBody TaskRequest taskRequest) {
Task task = new Task();
task.setDescription(taskRequest.getDescription());
task.setDueDate(Instant.parse(taskRequest.getDueDate()));
addNewTask.create(task);
}
}

View File

@ -1,29 +0,0 @@
package com.baeldung.architecture.framework.http.task;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
public class TaskRequest {
@JsonInclude(Include.NON_NULL)
private String description;
@JsonInclude(Include.NON_NULL)
private String dueDate;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDueDate() {
return dueDate;
}
public void setDueDate(String dueDate) {
this.dueDate = dueDate;
}
}