forked from OSGP/sng-crest-device-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OSGP#49 from OSGP/feature/FDP-2551-firmware
FDP-2551: Firmware entities
- Loading branch information
Showing
14 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
22 changes: 22 additions & 0 deletions
22
application/src/main/resources/db/migration/V8__firmware.sql
This file contains 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,22 @@ | ||
CREATE TABLE firmware | ||
( | ||
id uuid not null, | ||
name varchar(255) not null, | ||
hash varchar(255) not null, | ||
previous_firmware_id uuid null, | ||
PRIMARY KEY (id), | ||
CONSTRAINT fk_previous_firmware | ||
FOREIGN KEY (previous_firmware_id) | ||
REFERENCES firmware (id) | ||
); | ||
|
||
CREATE TABLE firmware_packet | ||
( | ||
firmware_id uuid not null, | ||
packet_number int not null, | ||
packet varchar(1024), | ||
PRIMARY KEY (firmware_id, packet_number), | ||
CONSTRAINT fk_firmware | ||
FOREIGN KEY (firmware_id) | ||
REFERENCES firmware (id) | ||
) |
This file contains 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,11 @@ | ||
dependencies { | ||
implementation("org.springframework.boot:spring-boot-starter-data-jpa") | ||
implementation("org.springframework.security:spring-security-core") | ||
|
||
implementation(libs.logging) | ||
|
||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testImplementation(libs.mockitoKotlin) | ||
|
||
testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
} |
21 changes: 21 additions & 0 deletions
21
components/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/entity/Firmware.kt
This file contains 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,21 @@ | ||
// SPDX-FileCopyrightText: Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.gxf.crestdeviceservice.firmware.entity | ||
|
||
import jakarta.annotation.Generated | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.OneToMany | ||
import java.util.UUID | ||
import org.hibernate.annotations.Cascade | ||
import org.hibernate.annotations.CascadeType | ||
|
||
@Entity | ||
class Firmware( | ||
@Id @Generated val id: UUID, | ||
val name: String, | ||
val hash: String, | ||
val previousFirmwareId: UUID?, | ||
@OneToMany @Cascade(CascadeType.ALL) val packets: List<FirmwarePacket> | ||
) |
17 changes: 17 additions & 0 deletions
17
...nts/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/entity/FirmwarePacket.kt
This file contains 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 @@ | ||
// SPDX-FileCopyrightText: Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.gxf.crestdeviceservice.firmware.entity | ||
|
||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.IdClass | ||
import jakarta.persistence.ManyToOne | ||
|
||
@Entity | ||
@IdClass(FirmwarePacketCompositeKey::class) | ||
class FirmwarePacket( | ||
@ManyToOne @Id val firmware: Firmware, | ||
@Id val packetNumber: Int, | ||
val packet: String | ||
) |
8 changes: 8 additions & 0 deletions
8
.../src/main/kotlin/org/gxf/crestdeviceservice/firmware/entity/FirmwarePacketCompositeKey.kt
This file contains 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,8 @@ | ||
// SPDX-FileCopyrightText: Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.gxf.crestdeviceservice.firmware.entity | ||
|
||
import java.io.Serializable | ||
|
||
data class FirmwarePacketCompositeKey(val firmware: Firmware, val packetNumber: Int) : Serializable |
12 changes: 12 additions & 0 deletions
12
...rc/main/kotlin/org/gxf/crestdeviceservice/firmware/repository/FirmwarePacketRepository.kt
This file contains 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,12 @@ | ||
// SPDX-FileCopyrightText: Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.gxf.crestdeviceservice.firmware.repository | ||
|
||
import org.gxf.crestdeviceservice.firmware.entity.FirmwarePacket | ||
import org.gxf.crestdeviceservice.firmware.entity.FirmwarePacketCompositeKey | ||
import org.springframework.data.repository.CrudRepository | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
interface FirmwarePacketRepository : CrudRepository<FirmwarePacket, FirmwarePacketCompositeKey> |
13 changes: 13 additions & 0 deletions
13
...ware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/repository/FirmwareRepository.kt
This file contains 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,13 @@ | ||
// SPDX-FileCopyrightText: Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.gxf.crestdeviceservice.firmware.repository | ||
|
||
import org.gxf.crestdeviceservice.firmware.entity.Firmware | ||
import org.springframework.data.repository.CrudRepository | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
interface FirmwareRepository : CrudRepository<Firmware, Int> { | ||
fun findByName(name: String): Firmware | ||
} |
9 changes: 9 additions & 0 deletions
9
...s/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/service/FirmwareService.kt
This file contains 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,9 @@ | ||
// SPDX-FileCopyrightText: Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.gxf.crestdeviceservice.firmware.service | ||
|
||
import org.gxf.crestdeviceservice.firmware.repository.FirmwareRepository | ||
import org.springframework.stereotype.Service | ||
|
||
@Service class FirmwareService(private val firmwareRepository: FirmwareRepository) |
This file contains 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
Binary file not shown.
This file contains 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 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 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