Skip to main content
The GetTasksByStationUseCase queries all preparation tasks assigned to a specific kitchen station (BAR, HOT_KITCHEN, or COLD_KITCHEN).

Input Port

The use case implements the GetTasksByStationPort interface:
public interface GetTasksByStationPort {
    List<Task> execute(Station station);
}

Implementation

GetTasksByStationUseCase.java
package com.foodtech.kitchen.application.usecases;

import com.foodtech.kitchen.application.ports.in.GetTasksByStationPort;
import com.foodtech.kitchen.application.ports.out.TaskRepository;
import com.foodtech.kitchen.domain.model.Station;
import com.foodtech.kitchen.domain.model.Task;

import java.util.List;

public class GetTasksByStationUseCase implements GetTasksByStationPort {

    private final TaskRepository taskRepository;

    public GetTasksByStationUseCase(TaskRepository taskRepository) {
        this.taskRepository = taskRepository;
    }

    @Override
    public List<Task> execute(Station station) {
        return taskRepository.findByStation(station);
    }
}

Use Case Flow

1

Query Repository

Invoke taskRepository.findByStation(station) to retrieve all tasks for the specified station.
2

Return Task List

Return the list of tasks, which may be empty if no tasks are assigned to that station.

Station Types

The kitchen has three stations:
public enum Station {
    BAR,          // Beverages and drinks
    HOT_KITCHEN,  // Hot dishes (meats, soups)
    COLD_KITCHEN  // Cold dishes (salads, desserts)
}

Example Usage

GetTasksByStationPort getTasksByStation = new GetTasksByStationUseCase(
    taskRepository
);

// Get all tasks for the hot kitchen
List<Task> hotKitchenTasks = getTasksByStation.execute(Station.HOT_KITCHEN);

hotKitchenTasks.forEach(task -> {
    System.out.println("Task ID: " + task.getId());
    System.out.println("Order ID: " + task.getOrderId());
    System.out.println("Table: " + task.getTableNumber());
    System.out.println("Status: " + task.getStatus());
    System.out.println("Products: " + task.getProducts());
});

Use Cases

Station Dashboard

Display pending and in-progress tasks for a specific station’s UI

Load Balancing

Monitor workload distribution across different stations

Priority Management

Identify which tasks should be started next at each station

Performance Tracking

Analyze task completion rates by station

Filtering by Status

This use case returns all tasks for a station regardless of status. If you need to filter by status (e.g., only PENDING tasks), you can filter the returned list:
List<Task> pendingTasks = getTasksByStation.execute(Station.BAR)
    .stream()
    .filter(task -> task.getStatus() == TaskStatus.PENDING)
    .toList();

Dependencies

TaskRepository

Persistence port that provides findByStation(Station) query method

Build docs developers (and LLMs) love