This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
micronaut: | |
application: | |
name: todo-list-micronaut-server | |
server: | |
port: 3000 | |
coherence: | |
cluster: task-cluster | |
ttl: 0 | |
serializer: java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Put(value = "{id}", consumes = MediaType.APPLICATION_JSON) | |
public Task updateTask(@PathVariable("id") String id, Task task) | |
{ | |
String description = task.getDescription(); | |
Boolean completed = task.getCompleted(); | |
if (description != null) | |
{ | |
return tasks.update(id, Task::setDescription, description); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Delete | |
public void deleteCompletedTasks() | |
{ | |
tasks.deleteByCompletedTrue(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@CoherenceRepository("tasks") | |
public abstract class TaskRepository | |
extends AbstractCoherenceRepository<Task, String> | |
{ | |
/** | |
* Delete all {@link Task}s that have been completed. | |
*/ | |
public abstract void deleteByCompletedTrue(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Delete | |
public void deleteCompletedTasks() | |
{ | |
tasks.removeAll(Filters.equal(Task::getCompleted, true)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Delete("{id}") | |
public void deleteTask(@PathVariable("id") String id) | |
{ | |
tasks.removeById(id); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Post(consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON) | |
public Task createTask(Task task) | |
{ | |
return tasks.save(new Task(task.getDescription())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Get | |
@Produces(MediaType.APPLICATION_JSON) | |
public Collection<Task> getTasks(@Nullable @QueryValue(value = "completed") Boolean completed) | |
{ | |
Filter<Task> filter = completed == null | |
? Filters.always() | |
: Filters.equal(Task::getCompleted, completed); | |
return tasks.getAllOrderedBy(filter, Task::getCreatedAt); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.oracle.coherence.examples.todo.server; | |
// ... | |
import io.micronaut.data.annotation.Id; | |
import io.micronaut.data.annotation.MappedEntity; | |
// ... | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.oracle.coherence.examples.todo.server; | |
import com.oracle.coherence.repository.Indexed; | |
import java.io.Serializable; | |
import java.time.Instant; | |
import java.time.LocalDateTime; | |
import java.time.ZoneId; |
NewerOlder