Skip to content

Commit 97455b1

Browse files
committed
Add acknowledgment
1 parent 098efbc commit 97455b1

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotification.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ data class PriorNotification(
146146
)
147147
}
148148

149-
fun markAsDeleted() {
150-
logbookMessageAndValue = LogbookMessageAndValue(
151-
logbookMessageAndValue.logbookMessage.copy(isDeleted = true),
152-
PNO::class.java,
153-
)
154-
}
155-
156149
companion object {
157150
private val logger = LoggerFactory.getLogger(PriorNotification::class.java)
158151

@@ -187,11 +180,11 @@ data class PriorNotification(
187180
* Used within the prior notification form to display the next state of the prior notification in real-time.
188181
*/
189182
fun getNextState(
190-
isInverificationScope: Boolean,
183+
isInVerificationScope: Boolean,
191184
isPartOfControlUnitSubscriptions: Boolean,
192185
): PriorNotificationState {
193186
return when {
194-
isInverificationScope -> PriorNotificationState.PENDING_VERIFICATION
187+
isInVerificationScope -> PriorNotificationState.PENDING_VERIFICATION
195188
isPartOfControlUnitSubscriptions -> PriorNotificationState.AUTO_SEND_REQUESTED
196189
else -> PriorNotificationState.OUT_OF_VERIFICATION_SCOPE
197190
}

backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaLogbookReportRepository.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ class JpaLogbookReportRepository(
6161
}
6262
}.filter { it.operationType != LogbookOperationType.DEL }
6363
.map {
64-
PriorNotification.fromLogbookMessage(it.toLogbookMessage(objectMapper))
64+
val pno = PriorNotification.fromLogbookMessage(it.toLogbookMessage(objectMapper))
65+
// All messages returned from the SQL query are acknowledged
66+
pno.markAsAcknowledged()
67+
68+
return@map pno
6569
}
6670
}
6771

@@ -343,7 +347,10 @@ class JpaLogbookReportRepository(
343347
isVerified: Boolean,
344348
) {
345349
val logbookReport = dbLogbookReportRepository
346-
.findAcknowledgedNonDeletedPnoDatAndCorsByReportId(reportId, operationDate.withZoneSameInstant(UTC).toString()).firstOrNull()
350+
.findAcknowledgedNonDeletedPnoDatAndCorsByReportId(
351+
reportId,
352+
operationDate.withZoneSameInstant(UTC).toString(),
353+
).firstOrNull()
347354
?: throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND)
348355

349356
val pnoValue = objectMapper.readValue(logbookReport.message, PNO::class.java)
@@ -367,7 +374,10 @@ class JpaLogbookReportRepository(
367374
note: String?,
368375
) {
369376
val logbookReport = dbLogbookReportRepository
370-
.findAcknowledgedNonDeletedPnoDatAndCorsByReportId(reportId, operationDate.withZoneSameInstant(UTC).toString()).firstOrNull()
377+
.findAcknowledgedNonDeletedPnoDatAndCorsByReportId(
378+
reportId,
379+
operationDate.withZoneSameInstant(UTC).toString(),
380+
).firstOrNull()
371381
?: throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND)
372382

373383
val pnoValue = objectMapper.readValue(logbookReport.message, PNO::class.java)
@@ -399,7 +409,10 @@ class JpaLogbookReportRepository(
399409
@CacheEvict(value = ["pno_to_verify"], allEntries = true)
400410
override fun invalidate(reportId: String, operationDate: ZonedDateTime) {
401411
val logbookReport = dbLogbookReportRepository
402-
.findAcknowledgedNonDeletedPnoDatAndCorsByReportId(reportId, operationDate.withZoneSameInstant(UTC).toString()).firstOrNull()
412+
.findAcknowledgedNonDeletedPnoDatAndCorsByReportId(
413+
reportId,
414+
operationDate.withZoneSameInstant(UTC).toString(),
415+
).firstOrNull()
403416
?: throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND)
404417

405418
val pnoValue = objectMapper.readValue(logbookReport.message, PNO::class.java)

0 commit comments

Comments
 (0)