Skip to content

Commit 47d6f06

Browse files
committed
Added option to share timeline
1 parent 44f5e36 commit 47d6f06

34 files changed

Lines changed: 1852 additions & 140 deletions

backend/src/main/java/org/github/tess1o/geopulse/trips/TripNativeConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
import org.github.tess1o.geopulse.trips.model.dto.CreateTripPlanItemDto;
66
import org.github.tess1o.geopulse.trips.model.dto.PlanSuggestionDto;
77
import org.github.tess1o.geopulse.trips.model.dto.TripDto;
8+
import org.github.tess1o.geopulse.trips.model.dto.TripCollaboratorDto;
89
import org.github.tess1o.geopulse.trips.model.dto.TripPlanItemDto;
910
import org.github.tess1o.geopulse.trips.model.dto.TripSummaryDto;
1011
import org.github.tess1o.geopulse.trips.model.dto.TripVisitOverrideRequestDto;
1112
import org.github.tess1o.geopulse.trips.model.dto.TripVisitSuggestionDto;
1213
import org.github.tess1o.geopulse.trips.model.dto.UpdateTripDto;
14+
import org.github.tess1o.geopulse.trips.model.dto.UpdateTripCollaboratorDto;
1315
import org.github.tess1o.geopulse.trips.model.dto.UpdateTripPlanItemDto;
16+
import org.github.tess1o.geopulse.trips.model.entity.TripCollaboratorAccessRole;
17+
import org.github.tess1o.geopulse.trips.model.entity.TripCollaboratorEntity;
1418
import org.github.tess1o.geopulse.trips.model.entity.TripEntity;
1519
import org.github.tess1o.geopulse.trips.model.entity.TripPlaceVisitMatchEntity;
1620
import org.github.tess1o.geopulse.trips.model.entity.TripPlanItemEntity;
@@ -24,16 +28,20 @@
2428
TripEntity.class,
2529
TripPlanItemEntity.class,
2630
TripPlaceVisitMatchEntity.class,
31+
TripCollaboratorEntity.class,
2732

2833
// Entity enums
2934
TripStatus.class,
3035
TripPlanItemPriority.class,
3136
TripPlanItemVisitSource.class,
3237
TripPlanItemOverrideState.class,
38+
TripCollaboratorAccessRole.class,
3339

3440
// DTOs
3541
CreateTripDto.class,
3642
UpdateTripDto.class,
43+
TripCollaboratorDto.class,
44+
UpdateTripCollaboratorDto.class,
3745
TripDto.class,
3846
TripSummaryDto.class,
3947
CreateTripPlanItemDto.class,

backend/src/main/java/org/github/tess1o/geopulse/trips/model/dto/CreateTripDto.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.github.tess1o.geopulse.trips.model.dto;
22

33
import jakarta.validation.constraints.NotBlank;
4-
import jakarta.validation.constraints.NotNull;
54
import jakarta.validation.constraints.Pattern;
65
import jakarta.validation.constraints.Size;
76
import lombok.AllArgsConstructor;
@@ -19,10 +18,8 @@ public class CreateTripDto {
1918
@Size(max = 150, message = "Trip name cannot exceed 150 characters")
2019
private String name;
2120

22-
@NotNull(message = "Start time is required")
2321
private Instant startTime;
2422

25-
@NotNull(message = "End time is required")
2623
private Instant endTime;
2724

2825
@Pattern(regexp = "^#[0-9A-Fa-f]{6}$", message = "Color must be a valid hex color code (e.g., #FF6B6B)")
@@ -31,4 +28,3 @@ public class CreateTripDto {
3128
@Size(max = 4000, message = "Notes cannot exceed 4000 characters")
3229
private String notes;
3330
}
34-
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.github.tess1o.geopulse.trips.model.dto;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
import org.github.tess1o.geopulse.trips.model.entity.TripCollaboratorAccessRole;
8+
9+
import java.time.Instant;
10+
import java.util.UUID;
11+
12+
@Data
13+
@NoArgsConstructor
14+
@AllArgsConstructor
15+
@Builder
16+
public class TripCollaboratorDto {
17+
private UUID userId;
18+
private String fullName;
19+
private String email;
20+
private String avatar;
21+
private TripCollaboratorAccessRole accessRole;
22+
private Instant createdAt;
23+
private Instant updatedAt;
24+
}

backend/src/main/java/org/github/tess1o/geopulse/trips/model/dto/TripDto.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
public class TripDto {
1717
private Long id;
1818
private UUID userId;
19+
private String ownerFullName;
1920
private Long periodTagId;
2021
private String name;
2122
private Instant startTime;
2223
private Instant endTime;
2324
private TripStatus status;
2425
private String color;
2526
private String notes;
27+
private Boolean isOwner;
28+
private String accessRole;
2629
private Instant createdAt;
2730
private Instant updatedAt;
2831
}
29-
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.github.tess1o.geopulse.trips.model.dto;
2+
3+
import jakarta.validation.constraints.NotNull;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
import org.github.tess1o.geopulse.trips.model.entity.TripCollaboratorAccessRole;
9+
10+
@Data
11+
@NoArgsConstructor
12+
@AllArgsConstructor
13+
@Builder
14+
public class UpdateTripCollaboratorDto {
15+
16+
@NotNull(message = "accessRole is required")
17+
private TripCollaboratorAccessRole accessRole;
18+
}

backend/src/main/java/org/github/tess1o/geopulse/trips/model/dto/UpdateTripDto.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.github.tess1o.geopulse.trips.model.dto;
22

33
import jakarta.validation.constraints.NotBlank;
4-
import jakarta.validation.constraints.NotNull;
54
import jakarta.validation.constraints.Pattern;
65
import jakarta.validation.constraints.Size;
76
import lombok.AllArgsConstructor;
@@ -20,10 +19,8 @@ public class UpdateTripDto {
2019
@Size(max = 150, message = "Trip name cannot exceed 150 characters")
2120
private String name;
2221

23-
@NotNull(message = "Start time is required")
2422
private Instant startTime;
2523

26-
@NotNull(message = "End time is required")
2724
private Instant endTime;
2825

2926
@Pattern(regexp = "^#[0-9A-Fa-f]{6}$", message = "Color must be a valid hex color code (e.g., #FF6B6B)")
@@ -34,4 +31,3 @@ public class UpdateTripDto {
3431

3532
private TripStatus status;
3633
}
37-
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.github.tess1o.geopulse.trips.model.entity;
2+
3+
public enum TripCollaboratorAccessRole {
4+
VIEW,
5+
EDIT
6+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package org.github.tess1o.geopulse.trips.model.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.*;
5+
import org.github.tess1o.geopulse.user.model.UserEntity;
6+
7+
import java.time.Instant;
8+
9+
@Entity
10+
@Table(
11+
name = "trip_collaborators",
12+
uniqueConstraints = {
13+
@UniqueConstraint(name = "uk_trip_collaborators_trip_user", columnNames = {"trip_id", "collaborator_user_id"})
14+
}
15+
)
16+
@Getter
17+
@Setter
18+
@ToString
19+
@AllArgsConstructor
20+
@NoArgsConstructor
21+
@Builder
22+
public class TripCollaboratorEntity {
23+
24+
@Id
25+
@GeneratedValue(strategy = GenerationType.IDENTITY)
26+
private Long id;
27+
28+
@ManyToOne(fetch = FetchType.LAZY, optional = false)
29+
@JoinColumn(name = "trip_id", nullable = false)
30+
@ToString.Exclude
31+
private TripEntity trip;
32+
33+
@ManyToOne(fetch = FetchType.LAZY, optional = false)
34+
@JoinColumn(name = "collaborator_user_id", nullable = false)
35+
@ToString.Exclude
36+
private UserEntity collaborator;
37+
38+
@Enumerated(EnumType.STRING)
39+
@Column(name = "access_role", nullable = false, length = 16)
40+
private TripCollaboratorAccessRole accessRole;
41+
42+
@Column(name = "created_at", nullable = false)
43+
private Instant createdAt;
44+
45+
@Column(name = "updated_at", nullable = false)
46+
private Instant updatedAt;
47+
48+
@PrePersist
49+
protected void onCreate() {
50+
Instant now = Instant.now();
51+
this.createdAt = now;
52+
this.updatedAt = now;
53+
if (this.accessRole == null) {
54+
this.accessRole = TripCollaboratorAccessRole.VIEW;
55+
}
56+
}
57+
58+
@PreUpdate
59+
protected void onUpdate() {
60+
this.updatedAt = Instant.now();
61+
}
62+
}

backend/src/main/java/org/github/tess1o/geopulse/trips/model/entity/TripEntity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public class TripEntity {
3434
@Column(name = "name", nullable = false, length = 150)
3535
private String name;
3636

37-
@Column(name = "start_time", nullable = false)
37+
@Column(name = "start_time")
3838
private Instant startTime;
3939

40-
@Column(name = "end_time", nullable = false)
40+
@Column(name = "end_time")
4141
private Instant endTime;
4242

4343
@Enumerated(EnumType.STRING)
@@ -71,4 +71,3 @@ protected void onUpdate() {
7171
this.updatedAt = Instant.now();
7272
}
7373
}
74-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.github.tess1o.geopulse.trips.model.entity;
22

33
public enum TripStatus {
4+
UNPLANNED,
45
UPCOMING,
56
ACTIVE,
67
COMPLETED,
78
CANCELLED
89
}
9-

0 commit comments

Comments
 (0)