Flight Operation service having flight instance and schedules#7
Conversation
…nfiguration, Maven wrapper, and essential files
… request/response models
…flight scheduling
…tegrate Flight entity and enhance schedule creation
Reviewer's GuideIntroduces a new flight-ops-service Spring Boot microservice that models flights, recurring flight schedules, and concrete flight instances, exposes CRUD/search REST APIs around them, and wires the module into the existing multi-module build alongside shared request/response DTOs and a FlightStatus enum in common-lib. Sequence diagram for creating a flight schedule and generating flight instancessequenceDiagram
actor AirlineAdmin
participant FlightScheduleController
participant FlightScheduleServiceImpl as FlightScheduleService
participant FlightRepository
participant FlightScheduleRepository
participant FlightInstanceServiceImpl as FlightInstanceService
participant FlightInstanceRepository
AirlineAdmin->>FlightScheduleController: POST /api/v1/flight-schedules
FlightScheduleController->>FlightScheduleService: createFlightSchedule(request, userId)
FlightScheduleService->>FlightRepository: findById(request.flightId)
FlightRepository-->>FlightScheduleService: Flight
FlightScheduleService->>FlightScheduleService: validate dates and business rules
FlightScheduleService->>FlightScheduleRepository: save(FlightScheduleMapper.toEntity(request, flight))
FlightScheduleRepository-->>FlightScheduleService: saved FlightSchedule (fs)
FlightScheduleService->>FlightScheduleService: build FlightInstanceRequest template
loop for each date between startDate and endDate
FlightScheduleService->>FlightScheduleService: check operatingDays contains current date dayOfWeek
alt operating day
FlightScheduleService->>FlightScheduleService: set departureTime and arrivalTime on FlightInstanceRequest
FlightScheduleService->>FlightInstanceService: createFlightInstance(airlineId, flightInstanceRequest)
FlightInstanceService->>FlightRepository: findById(flightInstanceRequest.flightId)
FlightRepository-->>FlightInstanceService: Flight
FlightInstanceService->>FlightInstanceRepository: save(FlightInstanceMapper.toEntity(request, flight))
FlightInstanceRepository-->>FlightInstanceService: FlightInstance
end
end
FlightScheduleService-->>FlightScheduleController: FlightScheduleResponse
FlightScheduleController-->>AirlineAdmin: 201 Created with schedule details
ER diagram for flights, schedules, and instanceserDiagram
FLIGHT {
Long id PK
String flight_number
Long airline_id
Long aircraft_id
Long departure_airport_id
Long arrival_airport_id
String status
Instant created_at
Instant updated_at
}
FLIGHT_SCHEDULE {
Long id PK
Long flight_id FK
Long airline_id
Long departure_airport_id
Long arrival_airport_id
Instant departure_time
Instant arrival_time
LocalDate start_date
LocalDate end_date
String operating_days
Boolean is_active
Instant created_at
Instant updated_at
}
FLIGHT_INSTANCE {
Long id PK
Long flight_id FK
Long airline_id
Long departure_airport_id
Long arrival_airport_id
Long schedule_id
Instant departure_time
Instant arrival_time
Integer total_seats
Integer available_seats
String status
Integer min_advance_booking_days
Integer max_advance_booking_days
Boolean is_active
Instant created_at
Instant updated_at
}
FLIGHT ||--o{ FLIGHT_SCHEDULE : has
FLIGHT ||--o{ FLIGHT_INSTANCE : materializes
FLIGHT_SCHEDULE ||--o{ FLIGHT_INSTANCE : generates
Class diagram for core flight operations domain and persistenceclassDiagram
direction LR
class Flight {
+Long id
+String flightNumber
+Long airlineId
+Long aircraftId
+Long departureAirportId
+Long arrivalAirportId
+FlightStatus status
+Instant createdAt
+Instant updatedAt
+boolean isActive()
+boolean isInProgress()
}
class FlightInstance {
+Long id
+Flight flight
+Long airlineId
+Long departureAirportId
+Long arrivalAirportId
+Long scheduleId
+Instant departureTime
+Instant arrivalTime
+Integer totalSeats
+Integer availableSeats
+FlightStatus status
+Integer minAdvanceBookingDays
+Integer maxAdvanceBookingDays
+Boolean isActive
+Instant createdAt
+Instant updatedAt
+String getFormatedDuration()
+void normalizeAndValidate()
}
class FlightSchedule {
+Long id
+Flight flight
+Long airlineId
+Long departureAirportId
+Long arrivalAirportId
+Instant departureTime
+Instant arrivalTime
+LocalDate startDate
+LocalDate endDate
+List~DayOfWeek~ operatingDays
+Boolean isActive
+Instant createdAt
+Instant updatedAt
+boolean isCurrentlyValid()
+boolean operatesOn(DayOfWeek dow)
+String getFormattedOperatingDays()
+void validateAndNormalize()
}
class FlightStatus {
<<enum>>
SCHEDULED
DELAYED
CANCELLED
IN_AIR
LANDED
BOARDING
DEPARTED
ARRIVED
DIVERTED
COMPLETED
}
class FlightRepository {
<<interface>>
+Page~Flight~ findByAirlineId(Long airlineId, Pageable pageable)
+boolean existByFlightNumber(String flightNumber)
+Optional~Flight~ findById(Long id)
+Flight save(Flight flight)
+List~Flight~ findAll()
+boolean existsById(Long id)
+void deleteById(Long id)
}
class FlightInstanceRepository {
<<interface>>
+Page~FlightInstance~ findByAirlineId(Long airlineId, Long departureAirportId, Long arrivalAirportId, Long flightId, LocalDateTime dayStart, LocalDateTime dayEnd, Pageable pageable)
+Optional~FlightInstance~ findById(Long id)
+FlightInstance save(FlightInstance instance)
+boolean existsById(Long id)
+void deleteById(Long id)
}
class FlightScheduleRepository {
<<interface>>
+List~FlightSchedule~ findByFlightAirlineId(Long airlineId)
+List~FlightSchedule~ findByAirlineIdAndIsActiveTrue(Long airlineId)
+List~FlightSchedule~ findByFlightIdOrderByStartDate(Long flightId)
+List~FlightSchedule~ findOverlappingSchedules(Long flightId, LocalDate startDate, LocalDate endDate)
+boolean existsByFlightIdAndStartDateAndEndDate(Long flightId, LocalDate startDate, LocalDate endDate)
+Optional~FlightSchedule~ findById(Long id)
+FlightSchedule save(FlightSchedule schedule)
+boolean existsById(Long id)
+void deleteById(Long id)
}
Flight "1" --> "*" FlightInstance : has_instances
Flight "1" --> "*" FlightSchedule : has_schedules
FlightStatus <.. Flight : uses
FlightStatus <.. FlightInstance : uses
FlightRepository ..|> JpaRepository
FlightInstanceRepository ..|> JpaRepository
FlightScheduleRepository ..|> JpaRepository
class JpaRepository {
<<interface>>
}
Class diagram for flight operations API, services, mappers, and DTOsclassDiagram
direction LR
class FlightController {
+ResponseEntity~ApiResponse~ createFlight(FlightRequest request)
+ResponseEntity~ApiResponse~ updateFlight(Long id, FlightRequest request)
+ResponseEntity~Void~ deleteFlight(Long id)
+ResponseEntity~ApiResponse~ changeStatus(Long id, FlightStatus newStatus)
+ResponseEntity~ApiResponse~ getFlightById(Long id)
+ResponseEntity~ApiResponse~ getAllFlights()
+ResponseEntity~ApiResponse~ getFlightByAirline(Long airlineId, Long departureAirportId, Long arrivalAirportId, Pageable pageable)
}
class FlightInstanceController {
+ResponseEntity~ApiResponse~ createFlightInstance(FlightInstanceRequest request)
+ResponseEntity~ApiResponse~ updateFlightInstance(Long id, FlightInstanceRequest request)
+ResponseEntity~ApiResponse~ getFlightInstanceById(Long id)
+ResponseEntity~ApiResponse~ getFlightInstancesByAirline(Long airlineId, Long departureAirportId, Long arrivalAirportId, LocalDate onDate, Long flightId, Pageable pageable)
+ResponseEntity~Void~ deleteFlightInstance(Long id)
}
class FlightScheduleController {
+ResponseEntity~FlightScheduleResponse~ createFlightSchedule(FlightScheduleRequest request, Long userId)
+ResponseEntity~FlightScheduleResponse~ getFlightScheduleById(Long id)
+ResponseEntity~List~ getAllFlightSchedulesByAirline(Long userId)
+ResponseEntity~FlightScheduleResponse~ updateFlightSchedule(Long id, FlightScheduleRequest request)
+ResponseEntity~Void~ deleteFlightSchedule(Long id)
}
class FlightService {
<<interface>>
+FlightResponse createFlight(Long airlineId, FlightRequest flightRequest)
+FlightResponse updateFlight(Long id, FlightRequest flightRequest)
+List~FlightResponse~ getAllFlights()
+List~FlightResponse~ getFlightByAirline(Long airlineId, Long departureAirportId, Long arrivalAirportId, Pageable pageable)
+FlightResponse getFlightById(Long id)
+void deleteFlight(Long id)
+FlightResponse changeStatus(Long id, FlightStatus newStatus)
}
class FlightServiceImpl {
+FlightResponse createFlight(Long airlineId, FlightRequest flightRequest)
+FlightResponse updateFlight(Long id, FlightRequest flightRequest)
+List~FlightResponse~ getAllFlights()
+List~FlightResponse~ getFlightByAirline(Long airlineId, Long departureAirportId, Long arrivalAirportId, Pageable pageable)
+FlightResponse getFlightById(Long id)
+void deleteFlight(Long id)
+FlightResponse changeStatus(Long id, FlightStatus newStatus)
-FlightRepository flightRepository
}
class FlightInstanceService {
<<interface>>
+FlightInstanceResponse getFlightInstanceById(Long id)
+FlightInstanceResponse createFlightInstance(Long userId, FlightInstanceRequest flightInstanceRequest)
+FlightInstanceResponse updateFlightInstance(Long id, FlightInstanceRequest flightInstanceRequest)
+void deleteFlightInstance(Long id)
+Page~FlightInstanceResponse~ getFlightInstancesByAirlineId(Long airlineId, Long departureAirportId, Long arrivalAirportId, LocalDate onDate, Long flightId, Pageable pageable)
}
class FlightInstanceServiceImpl {
+FlightInstanceResponse getFlightInstanceById(Long id)
+FlightInstanceResponse createFlightInstance(Long userId, FlightInstanceRequest flightInstanceRequest)
+FlightInstanceResponse updateFlightInstance(Long id, FlightInstanceRequest flightInstanceRequest)
+void deleteFlightInstance(Long id)
+Page~FlightInstanceResponse~ getFlightInstancesByAirlineId(Long airlineId, Long departureAirportId, Long arrivalAirportId, LocalDate onDate, Long flightId, Pageable pageable)
-FlightInstanceRepository flightInstanceRepository
-FlightRepository flightRepository
}
class FlightScheduleService {
<<interface>>
+FlightScheduleResponse createFlightSchedule(FlightScheduleRequest flightScheduleRequest, Long userId)
+FlightScheduleResponse getFlightScheduleById(Long id)
+List~FlightScheduleResponse~ getAllFlightSchedulesByAirline(Long userId)
+FlightScheduleResponse updateFlightSchedule(Long id, FlightScheduleRequest flightScheduleRequest)
+void deleteFlightSchedule(Long id)
}
class FlightScheduleServiceImpl {
+FlightScheduleResponse createFlightSchedule(FlightScheduleRequest flightScheduleRequest, Long userId)
+FlightScheduleResponse getFlightScheduleById(Long id)
+List~FlightScheduleResponse~ getAllFlightSchedulesByAirline(Long userId)
+FlightScheduleResponse updateFlightSchedule(Long id, FlightScheduleRequest flightScheduleRequest)
+void deleteFlightSchedule(Long id)
-FlightScheduleRepository flightScheduleRepository
-FlightRepository flightRepository
-FlightInstanceService flightInstanceService
}
class FlightMapper {
<<utility>>
+FlightResponse toResponse(Flight flight, AirlineResponse airline, AircraftResponse aircraft, AirportResponse departureAirport, AirportResponse arrivalAirport, Double lowestPrice, Integer totalAvailableSeats)
+FlightResponse toBasicResponse(Flight flight)
+List~FlightResponse~ toResponseList(List~Flight~ flights)
+Flight toEntity(FlightRequest request)
+void updateEntity(Flight flight, FlightRequest request)
+void updateStatus(Flight flight, FlightStatus newStatus)
}
class FlightInstanceMapper {
<<utility>>
+FlightInstance toEntity(FlightInstanceRequest request, Flight flight)
+FlightInstanceResponse toResponse(FlightInstance instance, String flightNumber, AirlineResponse airline, AircraftResponse aircraft, AirportResponse departureAirport, AirportResponse arrivalAirport)
+FlightInstanceResponse toBasicResponse(FlightInstance instance)
+List~FlightInstanceResponse~ toResponseList(List~FlightInstance~ instances)
+void updateEntity(FlightInstance instance, FlightInstanceRequest request)
+void updateStatus(FlightInstance instance, FlightStatus newStatus)
}
class FlightScheduleMapper {
<<utility>>
+FlightSchedule toEntity(FlightScheduleRequest request, Flight flight)
+FlightScheduleResponse toResponse(FlightSchedule schedule, AirportResponse departureAirport, AirportResponse arrivalAirport)
+void updateEntity(FlightSchedule schedule, FlightScheduleRequest request)
}
class FlightRequest {
+String flightNumber
+Long airlineId
+Long aircraftId
+Long departureAirportId
+Long arrivalAirportId
+FlightStatus status
}
class FlightInstanceRequest {
+Long flightId
+Long airlineId
+Long departureAirportId
+Long arrivalAirportId
+Long scheduleId
+LocalDateTime departureTime
+LocalDateTime arrivalTime
+Integer totalSeats
+Integer availableSeats
+FlightStatus status
+Integer minAdvanceBookingDays
+Integer maxAdvanceBookingDays
+Boolean isActive
}
class FlightScheduleRequest {
+Long flightId
+LocalTime departureTime
+LocalTime arrivalTime
+LocalDate startDate
+LocalDate endDate
+List~DayOfWeek~ operatingDays
+Boolean isActive
+boolean isTimesValid()
+boolean isDatesValid()
+boolean isStartDateNotInPast()
+boolean isOperatingDaysUnique()
}
class FlightResponse {
+Long id
+String flightNumber
+AirlineResponse airline
+AircraftResponse aircraft
+AirportResponse departureAirport
+AirportResponse arrivalAirport
+LocalDateTime departureTime
+LocalDateTime arrivalTime
+FlightStatus status
+Double lowestPrice
+Integer totalAvailableSeats
+Instant createdAt
+Instant updatedAt
}
class FlightInstanceResponse {
+Long id
+Long flightId
+String flightNumber
+Long airlineId
+String airlineName
+String airlineLogo
+Long aircraftId
+String aircraftModel
+String aircraftCode
+AirportResponse departureAirport
+AirportResponse arrivalAirport
+Instant departureTime
+Instant arrivalTime
+String formattedDuration
+Integer totalSeats
+Integer availableSeats
+FlightStatus status
+Integer minAdvanceBookingDays
+Integer maxAdvanceBookingDays
+Boolean isActive
+String terminal
+String gate
+Long version
}
class FlightScheduleResponse {
+Long id
+Long flightId
+String flightNumber
+AirportResponse departureAirport
+AirportResponse arrivalAirport
+LocalDate departureTime
+LocalDate arrivalTime
+LocalDate startDate
+LocalDate endDate
+List~DayOfWeek~ operatingDays
+Boolean isActive
}
class ApiResponse~T~ {
+String message
+T data
+static ApiResponse~T~ success(T data)
+static ApiResponse~T~ success(String message, T data)
}
class AirlineResponse
class AircraftResponse
class AirportResponse
FlightController --> FlightService
FlightInstanceController --> FlightInstanceService
FlightScheduleController --> FlightScheduleService
FlightServiceImpl ..|> FlightService
FlightInstanceServiceImpl ..|> FlightInstanceService
FlightScheduleServiceImpl ..|> FlightScheduleService
FlightServiceImpl --> FlightRepository
FlightInstanceServiceImpl --> FlightInstanceRepository
FlightInstanceServiceImpl --> FlightRepository
FlightScheduleServiceImpl --> FlightScheduleRepository
FlightScheduleServiceImpl --> FlightRepository
FlightScheduleServiceImpl --> FlightInstanceService
FlightMapper ..> Flight
FlightMapper ..> FlightRequest
FlightMapper ..> FlightResponse
FlightInstanceMapper ..> FlightInstance
FlightInstanceMapper ..> FlightInstanceRequest
FlightInstanceMapper ..> FlightInstanceResponse
FlightScheduleMapper ..> FlightSchedule
FlightScheduleMapper ..> FlightScheduleRequest
FlightScheduleMapper ..> FlightScheduleResponse
FlightResponse o--> AirlineResponse
FlightResponse o--> AircraftResponse
FlightResponse o--> AirportResponse
FlightInstanceResponse o--> AirportResponse
FlightScheduleResponse o--> AirportResponse
FlightStatus <.. FlightRequest
FlightStatus <.. FlightInstanceRequest
FlightStatus <.. FlightScheduleRequest
FlightStatus <.. FlightResponse
FlightStatus <.. FlightInstanceResponse
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 7 issues, and left some high level feedback:
- FlightSchedule.operatingDays is defined as List but business methods (operatesOn, getFormattedOperatingDays) still treat it as a comma‑separated String, which will not compile/work as written; align these methods to use the List representation (e.g., contains(DayOfWeek) and joining DayOfWeek values) or change the field type back to a String.
- FlightScheduleRepository refers to non‑existent properties (e.g., fs.flightId in JPQL and derived methods like existsByFlightId...) while FlightSchedule only has a flight relation; update these queries/method names to use the mapped relationship (flight) or add a flightId field if that’s intended.
- Several JPA entities use org.antlr.v4.runtime.misc.NotNull instead of Jakarta validation or JPA annotations (e.g., on FlightSchedule.arrivalTime); replace these with jakarta.validation.constraints.NotNull or JPA nullable=false to get proper validation and configuration.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- FlightSchedule.operatingDays is defined as List<DayOfWeek> but business methods (operatesOn, getFormattedOperatingDays) still treat it as a comma‑separated String, which will not compile/work as written; align these methods to use the List<DayOfWeek> representation (e.g., contains(DayOfWeek) and joining DayOfWeek values) or change the field type back to a String.
- FlightScheduleRepository refers to non‑existent properties (e.g., fs.flightId in JPQL and derived methods like existsByFlightId...) while FlightSchedule only has a flight relation; update these queries/method names to use the mapped relationship (flight) or add a flightId field if that’s intended.
- Several JPA entities use org.antlr.v4.runtime.misc.NotNull instead of Jakarta validation or JPA annotations (e.g., on FlightSchedule.arrivalTime); replace these with jakarta.validation.constraints.NotNull or JPA nullable=false to get proper validation and configuration.
## Individual Comments
### Comment 1
<location path="services/flight-ops-service/src/main/java/com/flynest/flight_ops_service/model/FlightSchedule.java" line_range="129-138" />
<code_context>
+ @ElementCollection
</code_context>
<issue_to_address>
**issue (bug_risk):** operatingDays field type and helper methods are inconsistent and will not compile or work correctly.
`operatingDays` is declared as `List<DayOfWeek>`, but `operatesOn` and `getFormattedOperatingDays` treat it as `List<String>` and even call `operatingDays.split(",")`, which will not compile and is conceptually wrong. Instead, keep `List<DayOfWeek>` and implement:
- `operatesOn` as `return operatingDays.contains(dow);`
- `getFormattedOperatingDays` by streaming over `operatingDays` and mapping each `DayOfWeek` to its display name or a custom label.
This keeps types consistent and uses the enum correctly in both persistence and logic.
</issue_to_address>
### Comment 2
<location path="services/flight-ops-service/src/main/java/com/flynest/flight_ops_service/mapper/FlightScheduleMapper.java" line_range="64-65" />
<code_context>
+
+ .departureAirport(departureAirport)
+ .arrivalAirport(arrivalAirport)
+ .departureTime(schedule.getDepartureTime() != null ? LocalDate.from(schedule.getDepartureTime()) : null)
+ .arrivalTime(schedule.getArrivalTime() != null ? LocalDate.from(schedule.getArrivalTime()) : null)
+
+ .startDate(schedule.getStartDate())
</code_context>
<issue_to_address>
**issue (bug_risk):** Converting Instant to LocalDate with LocalDate.from will throw at runtime and also loses time-of-day semantics.
Given that `FlightSchedule` stores UTC time-of-day in an `Instant`, mapping it to `LocalDate` drops the time component, and `LocalDate.from(Instant)` will fail at runtime.
If the API should expose the time-of-day, change the response field type to `LocalTime` (or `LocalDateTime` for a concrete date) and convert via a zone-aware call, e.g.:
```java
instant.atZone(ZoneOffset.UTC).toLocalTime()
```
If you truly intend a date derived from the epoch-based `Instant`, use:
```java
LocalDate.ofInstant(schedule.getDepartureTime(), ZoneOffset.UTC)
```
though that doesn’t match the current “time-of-day only” semantics of the entity.
</issue_to_address>
### Comment 3
<location path="services/flight-ops-service/src/main/java/com/flynest/flight_ops_service/repository/FlightScheduleRepository.java" line_range="28-30" />
<code_context>
+ /**
+ * Find overlapping schedules (same flight, overlapping date ranges)
+ */
+ @Query("SELECT fs FROM FlightSchedule fs " +
+ "WHERE fs.flightId = :flightId " +
+ "AND fs.startDate <= :endDate " +
+ "AND fs.endDate >= :startDate")
+ List<FlightSchedule> findOverlappingSchedules(
</code_context>
<issue_to_address>
**issue (bug_risk):** JPQL uses nonexistent flightId field on FlightSchedule; it should traverse the flight association.
This will throw a runtime error because `flightId` is not a mapped attribute on `FlightSchedule`.
Use the association path in the query instead:
```java
@Query("SELECT fs FROM FlightSchedule fs " +
"WHERE fs.flight.id = :flightId " +
"AND fs.startDate <= :endDate " +
"AND fs.endDate >= :startDate")
```
The repository method signature can stay the same; Spring Data will still bind `flightId` correctly.
</issue_to_address>
### Comment 4
<location path="services/flight-ops-service/src/main/java/com/flynest/flight_ops_service/model/FlightSchedule.java" line_range="104-106" />
<code_context>
+ /**
+ * Scheduled arrival time (UTC) - time of day only
+ */
+ @NotNull
+ @Column(name = "arrival_time", nullable = false)
+ private Instant arrivalTime;
+
+ // =========================================================
</code_context>
<issue_to_address>
**suggestion (bug_risk):** The NotNull annotation used here is not the Jakarta validation one and will not participate in bean validation.
The imported `org.antlr.v4.runtime.misc.NotNull` won’t be picked up by Jakarta Bean Validation, so this field won’t be validated at the API layer. Since `nullable = false` already enforces the DB constraint, either switch to `jakarta.validation.constraints.NotNull` for bean validation or remove the annotation and rely solely on the column constraint.
Suggested implementation:
```java
/**
* Scheduled arrival time (UTC) - time of day only
*/
@NotNull
@Column(name = "arrival_time", nullable = false)
private Instant arrivalTime;
// PRIMARY KEY
```
1. Update the imports at the top of `FlightSchedule.java`:
- Remove `import org.antlr.v4.runtime.misc.NotNull;` if present.
- Add `import jakarta.validation.constraints.NotNull;`.
2. If other fields in this entity are using the old `org.antlr.v4.runtime.misc.NotNull`, update them to use `jakarta.validation.constraints.NotNull` as well so they participate in bean validation consistently.
</issue_to_address>
### Comment 5
<location path="services/flight-ops-service/readme.md" line_range="15" />
<code_context>
+6. arrivalAirportId
+7. FlightStatus - status [SCHEDULED, DELAYED, CANCELLED, IN_AIR, LANDED,BOARDING, DEPARTED, ARRIVED,DIVERTED, COMPLETED]
+8. createdAt
+9. updateAt
+
+### flightInstance
</code_context>
<issue_to_address>
**suggestion (typo):** Potential typo in field name "updateAt".
Consider renaming it to `updatedAt` to better reflect a last-update timestamp and align with common naming conventions.
```suggestion
9. updatedAt
```
</issue_to_address>
### Comment 6
<location path="services/flight-ops-service/readme.md" line_range="37-41" />
<code_context>
+
+isActive
+
+fu string getFormatedDuration() {
+ // gap between departure time and arrivaltime ---hrs ,mins
+}
</code_context>
<issue_to_address>
**suggestion (typo):** Multiple spelling/wording issues in the method signature line.
Since this is an example signature, please fix the typos: change `fu` to the intended keyword (e.g., `fun`) and rename `getFormatedDuration` to `getFormattedDuration`.
```suggestion
isActive
fun string getFormattedDuration() {
// gap between departure time and arrivaltime ---hrs ,mins
}
```
</issue_to_address>
### Comment 7
<location path="services/flight-ops-service/readme.md" line_range="39" />
<code_context>
+isActive
+
+fu string getFormatedDuration() {
+ // gap between departure time and arrivaltime ---hrs ,mins
+}
+
</code_context>
<issue_to_address>
**nitpick (typo):** Minor spelling and spacing issues in the inline comment.
Consider updating the comment to fix the spelling and spacing, e.g.: `// gap between departure time and arrival time — hrs, mins`.
```suggestion
fu string getFormatedDuration() {
// gap between departure time and arrival time — hrs, mins
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| @ElementCollection | ||
| @Enumerated(EnumType.STRING) | ||
| private List<DayOfWeek> operatingDays; | ||
| // ========================================================= | ||
| // STATUS | ||
| // ========================================================= | ||
|
|
||
| /** | ||
| * Whether this schedule is currently active/in-use | ||
| */ |
There was a problem hiding this comment.
issue (bug_risk): operatingDays field type and helper methods are inconsistent and will not compile or work correctly.
operatingDays is declared as List<DayOfWeek>, but operatesOn and getFormattedOperatingDays treat it as List<String> and even call operatingDays.split(","), which will not compile and is conceptually wrong. Instead, keep List<DayOfWeek> and implement:
operatesOnasreturn operatingDays.contains(dow);getFormattedOperatingDaysby streaming overoperatingDaysand mapping eachDayOfWeekto its display name or a custom label.
This keeps types consistent and uses the enum correctly in both persistence and logic.
| .departureTime(schedule.getDepartureTime() != null ? LocalDate.from(schedule.getDepartureTime()) : null) | ||
| .arrivalTime(schedule.getArrivalTime() != null ? LocalDate.from(schedule.getArrivalTime()) : null) |
There was a problem hiding this comment.
issue (bug_risk): Converting Instant to LocalDate with LocalDate.from will throw at runtime and also loses time-of-day semantics.
Given that FlightSchedule stores UTC time-of-day in an Instant, mapping it to LocalDate drops the time component, and LocalDate.from(Instant) will fail at runtime.
If the API should expose the time-of-day, change the response field type to LocalTime (or LocalDateTime for a concrete date) and convert via a zone-aware call, e.g.:
instant.atZone(ZoneOffset.UTC).toLocalTime()If you truly intend a date derived from the epoch-based Instant, use:
LocalDate.ofInstant(schedule.getDepartureTime(), ZoneOffset.UTC)though that doesn’t match the current “time-of-day only” semantics of the entity.
| @Query("SELECT fs FROM FlightSchedule fs " + | ||
| "WHERE fs.flightId = :flightId " + | ||
| "AND fs.startDate <= :endDate " + |
There was a problem hiding this comment.
issue (bug_risk): JPQL uses nonexistent flightId field on FlightSchedule; it should traverse the flight association.
This will throw a runtime error because flightId is not a mapped attribute on FlightSchedule.
Use the association path in the query instead:
@Query("SELECT fs FROM FlightSchedule fs " +
"WHERE fs.flight.id = :flightId " +
"AND fs.startDate <= :endDate " +
"AND fs.endDate >= :startDate")The repository method signature can stay the same; Spring Data will still bind flightId correctly.
| @NotNull | ||
| @Column(name = "arrival_time", nullable = false) | ||
| private Instant arrivalTime; |
There was a problem hiding this comment.
suggestion (bug_risk): The NotNull annotation used here is not the Jakarta validation one and will not participate in bean validation.
The imported org.antlr.v4.runtime.misc.NotNull won’t be picked up by Jakarta Bean Validation, so this field won’t be validated at the API layer. Since nullable = false already enforces the DB constraint, either switch to jakarta.validation.constraints.NotNull for bean validation or remove the annotation and rely solely on the column constraint.
Suggested implementation:
/**
* Scheduled arrival time (UTC) - time of day only
*/
@NotNull
@Column(name = "arrival_time", nullable = false)
private Instant arrivalTime;
// PRIMARY KEY- Update the imports at the top of
FlightSchedule.java:- Remove
import org.antlr.v4.runtime.misc.NotNull;if present. - Add
import jakarta.validation.constraints.NotNull;.
- Remove
- If other fields in this entity are using the old
org.antlr.v4.runtime.misc.NotNull, update them to usejakarta.validation.constraints.NotNullas well so they participate in bean validation consistently.
| 6. arrivalAirportId | ||
| 7. FlightStatus - status [SCHEDULED, DELAYED, CANCELLED, IN_AIR, LANDED,BOARDING, DEPARTED, ARRIVED,DIVERTED, COMPLETED] | ||
| 8. createdAt | ||
| 9. updateAt |
There was a problem hiding this comment.
suggestion (typo): Potential typo in field name "updateAt".
Consider renaming it to updatedAt to better reflect a last-update timestamp and align with common naming conventions.
| 9. updateAt | |
| 9. updatedAt |
| isActive | ||
|
|
||
| fu string getFormatedDuration() { | ||
| // gap between departure time and arrivaltime ---hrs ,mins | ||
| } |
There was a problem hiding this comment.
suggestion (typo): Multiple spelling/wording issues in the method signature line.
Since this is an example signature, please fix the typos: change fu to the intended keyword (e.g., fun) and rename getFormatedDuration to getFormattedDuration.
| isActive | |
| fu string getFormatedDuration() { | |
| // gap between departure time and arrivaltime ---hrs ,mins | |
| } | |
| isActive | |
| fun string getFormattedDuration() { | |
| // gap between departure time and arrivaltime ---hrs ,mins | |
| } |
|
|
||
| isActive | ||
|
|
||
| fu string getFormatedDuration() { |
There was a problem hiding this comment.
nitpick (typo): Minor spelling and spacing issues in the inline comment.
Consider updating the comment to fix the spelling and spacing, e.g.: // gap between departure time and arrival time — hrs, mins.
| fu string getFormatedDuration() { | |
| fu string getFormatedDuration() { | |
| // gap between departure time and arrival time — hrs, mins |
Flight Operation service having flight instance and schedules
This pull request introduces the new
FlightSchedulefeature for flight scheduling, along with supporting entities, requests, and validation logic. It also updates project configuration files to include the newflight-ops-servicemodule and ensures proper IDE and build tool integration.Flight scheduling feature and supporting entities:
FlightScheduleRequestDTO with validation logic for scheduling flights, including checks for time and date consistency, unique operating days, and active status.FlightInstanceRequestandFlightRequestDTOs to support creation and update operations for flight instances and flights, including field-level validation and status handling. [1] [2]FlightStatusenum to standardize flight status values across the application.Project and IDE configuration:
flight-ops-servicemodule in.idea/compiler.xml,.idea/encodings.xml, and.idea/misc.xmlfor proper build, encoding, and Maven integration. [1] [2] [3] [4].idea/workspace.xmlto track new files, tasks, and commit messages related to the flight scheduling feature and the new module. [1] [2] [3] [4] [5] [6]Summary by Sourcery
Add a new flight-ops-service microservice for managing flights, flight schedules, and flight instances, including REST APIs, persistence models, and supporting DTOs and mappers.
New Features:
Enhancements:
Tests: