Skip to content

Commit 4476944

Browse files
authored
Development: Implement InterviewSlot entity/repository (#1242)
1 parent 8ebe5f7 commit 4476944

File tree

4 files changed

+141
-0
lines changed

4 files changed

+141
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package de.tum.cit.aet.interview.domain;
2+
3+
import de.tum.cit.aet.core.domain.AbstractAuditingEntity;
4+
import jakarta.persistence.*;
5+
import jakarta.validation.constraints.NotNull;
6+
import java.time.Instant;
7+
import java.util.UUID;
8+
import lombok.Getter;
9+
import lombok.Setter;
10+
11+
/**
12+
* Entity representing a time slot for an interview.
13+
* Each slot can be booked by exactly one application.
14+
*/
15+
@Entity
16+
@Table(name = "interview_slots")
17+
@Getter
18+
@Setter
19+
public class InterviewSlot extends AbstractAuditingEntity {
20+
21+
@Id
22+
@GeneratedValue
23+
private UUID id;
24+
25+
@NotNull
26+
@ManyToOne(fetch = FetchType.LAZY, optional = false)
27+
@JoinColumn(name = "interview_process_id", nullable = false)
28+
private InterviewProcess interviewProcess;
29+
30+
@NotNull
31+
@Column(name = "start_date_time", nullable = false)
32+
private Instant startDateTime;
33+
34+
@NotNull
35+
@Column(name = "end_date_time", nullable = false)
36+
private Instant endDateTime;
37+
38+
@NotNull
39+
@Column(name = "location", nullable = false)
40+
private String location;
41+
42+
@Column(name = "stream_link")
43+
private String streamLink;
44+
45+
@Column(name = "is_booked", nullable = false)
46+
private Boolean isBooked = false;
47+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package de.tum.cit.aet.interview.repository;
2+
3+
import de.tum.cit.aet.interview.domain.InterviewSlot;
4+
import java.util.List;
5+
import java.util.UUID;
6+
import org.springframework.data.jpa.repository.JpaRepository;
7+
import org.springframework.data.jpa.repository.Query;
8+
import org.springframework.data.repository.query.Param;
9+
import org.springframework.stereotype.Repository;
10+
11+
/**
12+
* Repository for managing interview slots.
13+
*/
14+
@Repository
15+
public interface InterviewSlotRepository extends JpaRepository<InterviewSlot, UUID> {
16+
/**
17+
* Finds all interview slots for a given interview process, ordered by start time.
18+
*
19+
* @param processId the ID of the interview process
20+
* @return a list of {@link InterviewSlot} entities associated with the given process,
21+
* ordered by start date and time
22+
*/
23+
@Query("SELECT s FROM InterviewSlot s WHERE s.interviewProcess.id = :processId ORDER BY s.startDateTime")
24+
List<InterviewSlot> findByInterviewProcessIdOrderByStartDateTime(@Param("processId") UUID processId);
25+
26+
/**
27+
* Counts all interview slots associated with a specific interview process.
28+
*
29+
* @param processId the ID of the interview process
30+
* @return the number of slots linked to the given process
31+
*/
32+
long countByInterviewProcessId(UUID processId);
33+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
6+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
7+
8+
<changeSet id="create-interview-slots-table" author="abinayasivaguru">
9+
<createTable tableName="interview_slots">
10+
<column name="id" type="uuid">
11+
<constraints primaryKey="true" nullable="false"/>
12+
</column>
13+
14+
<column name="interview_process_id" type="uuid">
15+
<constraints nullable="false"/>
16+
</column>
17+
18+
<column name="start_date_time" type="timestamp">
19+
<constraints nullable="false"/>
20+
</column>
21+
22+
<column name="end_date_time" type="timestamp">
23+
<constraints nullable="false"/>
24+
</column>
25+
26+
<column name="location" type="varchar(255)">
27+
<constraints nullable="false"/>
28+
</column>
29+
30+
<column name="stream_link" type="varchar(500)"/>
31+
32+
<column name="is_booked" type="boolean" defaultValueBoolean="false">
33+
<constraints nullable="false"/>
34+
</column>
35+
36+
<!-- Audit fields from AbstractAuditingEntity -->
37+
<column name="created_by" type="varchar(50)"/>
38+
<column name="created_at" type="timestamp"/>
39+
<column name="last_modified_by" type="varchar(50)"/>
40+
<column name="last_modified_at" type="timestamp"/>
41+
</createTable>
42+
43+
<addForeignKeyConstraint
44+
baseTableName="interview_slots"
45+
baseColumnNames="interview_process_id"
46+
referencedTableName="interview_processes"
47+
referencedColumnNames="id"
48+
constraintName="fk_interview_slots_process"
49+
onDelete="CASCADE"/>
50+
51+
<createIndex tableName="interview_slots" indexName="idx_slots_process_start_time">
52+
<column name="interview_process_id"/>
53+
<column name="start_date_time"/>
54+
</createIndex>
55+
56+
<createIndex tableName="interview_slots" indexName="idx_slots_is_booked">
57+
<column name="is_booked"/>
58+
</createIndex>
59+
</changeSet>
60+
</databaseChangeLog>

src/main/resources/config/liquibase/master.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<include file="changelog/00000000000011_alter_application_add_applied_date.xml"
2323
relativeToChangelogFile="true" />
2424
<include file="changelog/00000000000012_create_interview_processes.xml" relativeToChangelogFile="true"/>
25+
<include file="changelog/00000000000013_create_interview_slot_table.xml" relativeToChangelogFile="true"/>
2526

2627
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
2728
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints

0 commit comments

Comments
 (0)