-
Notifications
You must be signed in to change notification settings - Fork 0
Task/add location object #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
e82b14e
Add db changelog for location
SelahattinSert 554658f
Add location entity class
SelahattinSert b1ba4d0
Add dto for location object
SelahattinSert 3fac938
Add custom exception for location
SelahattinSert 7e47269
Add location not added handling method
SelahattinSert b801398
Include changelog-v2
SelahattinSert 7a9a8bb
Add location relation
SelahattinSert 9ab51ef
Add location rest endpoint
SelahattinSert 66177b0
Add location handling method
SelahattinSert e505c39
Add location handling method
SelahattinSert cb10faa
Add location dto converter
SelahattinSert 7534e15
Add location response
SelahattinSert 8b412f9
Refactor addLocation method
SelahattinSert 95db1de
Add Jakarta validation annotations
SelahattinSert 0c26d2d
Refactor handle add location method
SelahattinSert 5d30ef1
Import necessary component
SelahattinSert 9ee1078
Add necessary component
SelahattinSert bc8c0c7
Import necessary component
SelahattinSert 0133d18
Merge remote-tracking branch 'origin/task/add-location-object' into t…
SelahattinSert 261740c
Import necessary component
SelahattinSert 14bb462
Merge remote-tracking branch 'origin/task/add-location-object' into t…
SelahattinSert 650ad92
Enhance validation with jakarta
SelahattinSert 289d258
Fix lombok @ToString bug
SelahattinSert 2e269ad
Add location dto converter unit test
SelahattinSert 373ddb0
Add handle add location unit test
SelahattinSert f4b0f58
Add add location REST endpoint unit test
SelahattinSert 237a220
Improve assertion approach
SelahattinSert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/onboarding/camera/cameraonboarding/converter/LocationDtoConverter.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.onboarding.camera.cameraonboarding.converter; | ||
|
|
||
| import com.onboarding.camera.cameraonboarding.dto.LocationResponse; | ||
| import com.onboarding.camera.cameraonboarding.entity.Location; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class LocationDtoConverter { | ||
|
|
||
| public LocationResponse toLocationResponse(Location location) { | ||
| LocationResponse response = new LocationResponse(); | ||
| response.setLatitude(location.getLatitude()); | ||
| response.setLongitude(location.getLongitude()); | ||
| response.setAddress(location.getAddress()); | ||
| return response; | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/onboarding/camera/cameraonboarding/dto/LocationDto.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.onboarding.camera.cameraonboarding.dto; | ||
|
|
||
| import jakarta.validation.constraints.DecimalMax; | ||
| import jakarta.validation.constraints.DecimalMin; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Size; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Data | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class LocationDto { | ||
|
|
||
| @NotNull(message = "Latitude cannot be null") | ||
| @DecimalMin(value = "-90.0", message = "Latitude must be >= -90") | ||
| @DecimalMax(value = "90.0", message = "Latitude must be <= 90") | ||
| private double latitude; | ||
|
|
||
| @NotNull(message = "Longitude cannot be null") | ||
| @DecimalMin(value = "-180.0", message = "Longitude must be >= -180") | ||
| @DecimalMax(value = "180.0", message = "Longitude must be <= 180") | ||
| private double longitude; | ||
|
|
||
| @NotBlank(message = "Address cannot be blank") | ||
| @Size(min = 10, max = 100, message = "Address should be up to 100 characters") | ||
| private String address; | ||
| } | ||
10 changes: 10 additions & 0 deletions
10
src/main/java/com/onboarding/camera/cameraonboarding/dto/LocationResponse.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.onboarding.camera.cameraonboarding.dto; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class LocationResponse { | ||
| private double latitude; | ||
| private double longitude; | ||
| private String address; | ||
| } |
This file contains hidden or 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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/onboarding/camera/cameraonboarding/entity/Location.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.onboarding.camera.cameraonboarding.entity; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonBackReference; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.OneToOne; | ||
| import jakarta.persistence.Table; | ||
| import lombok.Data; | ||
| import lombok.ToString; | ||
| import org.hibernate.annotations.UuidGenerator; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @Data | ||
| @ToString(exclude = "camera") | ||
| @Entity | ||
| @Table(name = "location") | ||
| public class Location { | ||
|
|
||
| @Id | ||
| @GeneratedValue | ||
| @UuidGenerator | ||
| @Column(name = "location_id") | ||
| private UUID locationId; | ||
|
|
||
| @Column(name = "latitude", nullable = false) | ||
| private Double latitude; | ||
|
|
||
| @Column(name = "longitude", nullable = false) | ||
| private Double longitude; | ||
|
|
||
| @Column(name = "address", nullable = false) | ||
| private String address; | ||
|
|
||
| @OneToOne | ||
| @JoinColumn(name = "camera_id", referencedColumnName = "cam_id") | ||
| @JsonBackReference | ||
| private Camera camera; | ||
| } |
7 changes: 7 additions & 0 deletions
7
...main/java/com/onboarding/camera/cameraonboarding/exception/LocationNotAddedException.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.onboarding.camera.cameraonboarding.exception; | ||
|
|
||
| public class LocationNotAddedException extends RuntimeException { | ||
| public LocationNotAddedException(String message) { | ||
| super(message); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <databaseChangeLog | ||
| xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
| https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
|
|
||
| <changeSet id="2" author="selahattin" runOnChange="true"> | ||
| <preConditions onFail="MARK_RAN"> | ||
| <not> | ||
| <tableExists tableName="location"/> | ||
| </not> | ||
| </preConditions> | ||
| <createTable tableName="location"> | ||
| <column name="location_id" type="UUID"> | ||
| <constraints primaryKey="true" nullable="false"/> | ||
| </column> | ||
| <column name="latitude" type="DOUBLE"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| <column name="longitude" type="DOUBLE"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| <column name="address" type="VARCHAR(255)"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| <column name="camera_id" type="UUID"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| </createTable> | ||
|
|
||
| <addForeignKeyConstraint | ||
| baseTableName="location" | ||
| baseColumnNames="camera_id" | ||
| referencedTableName="camera_metadata" | ||
| referencedColumnNames="cam_id" | ||
| constraintName="fk_location_camera_id"/> | ||
|
|
||
| </changeSet> | ||
|
|
||
| </databaseChangeLog> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.