-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Préavis - Ajouter dans le formulaire -12 m la possibilité de joindre …
- Loading branch information
Showing
30 changed files
with
912 additions
and
44 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
.../fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationDocument.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,44 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification | ||
|
||
import fr.gouv.cnsp.monitorfish.utils.CustomZonedDateTime | ||
|
||
data class PriorNotificationDocument( | ||
val id: String?, | ||
val content: ByteArray, | ||
val createdAt: CustomZonedDateTime, | ||
val fileName: String, | ||
val isManualPriorNotification: Boolean, | ||
val mimeType: String, | ||
val reportId: String, | ||
val updatedAt: CustomZonedDateTime, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as PriorNotificationDocument | ||
|
||
if (id != other.id) return false | ||
if (!content.contentEquals(other.content)) return false | ||
if (createdAt != other.createdAt) return false | ||
if (fileName != other.fileName) return false | ||
if (isManualPriorNotification != other.isManualPriorNotification) return false | ||
if (mimeType != other.mimeType) return false | ||
if (reportId != other.reportId) return false | ||
if (updatedAt != other.updatedAt) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = id?.hashCode() ?: 0 | ||
result = 31 * result + content.contentHashCode() | ||
result = 31 * result + createdAt.hashCode() | ||
result = 31 * result + fileName.hashCode() | ||
result = 31 * result + isManualPriorNotification.hashCode() | ||
result = 31 * result + mimeType.hashCode() | ||
result = 31 * result + reportId.hashCode() | ||
result = 31 * result + updatedAt.hashCode() | ||
return result | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...r/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationIdentifier.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 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification | ||
|
||
import java.time.ZonedDateTime | ||
|
||
data class PriorNotificationIdentifier( | ||
val reportId: String, | ||
val operationDate: ZonedDateTime, | ||
val isManualPriorNotification: Boolean, | ||
) |
13 changes: 13 additions & 0 deletions
13
.../kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PriorNotificationUploadRepository.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 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.repositories | ||
|
||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationDocument | ||
|
||
interface PriorNotificationUploadRepository { | ||
fun findAllByReportId(reportId: String): List<PriorNotificationDocument> | ||
|
||
fun findById(id: String): PriorNotificationDocument | ||
|
||
fun save(newPriorNotificationDocument: PriorNotificationDocument): PriorNotificationDocument | ||
|
||
fun deleteById(id: String) | ||
} |
50 changes: 50 additions & 0 deletions
50
...ouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreatePriorNotificationUpload.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,50 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification | ||
|
||
import fr.gouv.cnsp.monitorfish.config.UseCase | ||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationDocument | ||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationIdentifier | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.LogbookReportRepository | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.ManualPriorNotificationRepository | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.PriorNotificationUploadRepository | ||
import fr.gouv.cnsp.monitorfish.utils.CustomZonedDateTime | ||
|
||
@UseCase | ||
class CreatePriorNotificationUpload( | ||
private val logbookReportRepository: LogbookReportRepository, | ||
private val manualPriorNotificationRepository: ManualPriorNotificationRepository, | ||
private val priorNotificationUploadRepository: PriorNotificationUploadRepository, | ||
) { | ||
fun execute(identifier: PriorNotificationIdentifier, content: ByteArray, fileName: String, mimeType: String) { | ||
val createdAt = CustomZonedDateTime.now() | ||
|
||
val newPriorNotificationDocument = PriorNotificationDocument( | ||
id = null, | ||
content = content, | ||
createdAt = createdAt, | ||
fileName = fileName, | ||
isManualPriorNotification = identifier.isManualPriorNotification, | ||
mimeType = mimeType, | ||
reportId = identifier.reportId, | ||
updatedAt = createdAt, | ||
) | ||
|
||
priorNotificationUploadRepository.save(newPriorNotificationDocument) | ||
|
||
if (identifier.isManualPriorNotification) { | ||
manualPriorNotificationRepository.updateState( | ||
reportId = identifier.reportId, | ||
isBeingSent = false, | ||
isSent = false, | ||
isVerified = false, | ||
) | ||
} else { | ||
logbookReportRepository.updatePriorNotificationState( | ||
reportId = identifier.reportId, | ||
operationDate = identifier.operationDate, | ||
isBeingSent = false, | ||
isSent = false, | ||
isVerified = false, | ||
) | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ouv/cnsp/monitorfish/domain/use_cases/prior_notification/DeletePriorNotificationUpload.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,35 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification | ||
|
||
import fr.gouv.cnsp.monitorfish.config.UseCase | ||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationIdentifier | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.LogbookReportRepository | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.ManualPriorNotificationRepository | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.PriorNotificationUploadRepository | ||
|
||
@UseCase | ||
class DeletePriorNotificationUpload( | ||
private val logbookReportRepository: LogbookReportRepository, | ||
private val manualPriorNotificationRepository: ManualPriorNotificationRepository, | ||
private val priorNotificationUploadRepository: PriorNotificationUploadRepository, | ||
) { | ||
fun execute(identifier: PriorNotificationIdentifier, priorNotificationUploadId: String) { | ||
priorNotificationUploadRepository.deleteById(priorNotificationUploadId) | ||
|
||
if (identifier.isManualPriorNotification) { | ||
manualPriorNotificationRepository.updateState( | ||
reportId = identifier.reportId, | ||
isBeingSent = false, | ||
isSent = false, | ||
isVerified = false, | ||
) | ||
} else { | ||
logbookReportRepository.updatePriorNotificationState( | ||
reportId = identifier.reportId, | ||
operationDate = identifier.operationDate, | ||
isBeingSent = false, | ||
isSent = false, | ||
isVerified = false, | ||
) | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...r/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUpload.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,14 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification | ||
|
||
import fr.gouv.cnsp.monitorfish.config.UseCase | ||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationDocument | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.PriorNotificationUploadRepository | ||
|
||
@UseCase | ||
class GetPriorNotificationUpload( | ||
private val priorNotificationUploadRepository: PriorNotificationUploadRepository, | ||
) { | ||
fun execute(priorNotificationUploadId: String): PriorNotificationDocument { | ||
return priorNotificationUploadRepository.findById(priorNotificationUploadId) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationUploads.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,14 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification | ||
|
||
import fr.gouv.cnsp.monitorfish.config.UseCase | ||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationDocument | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.PriorNotificationUploadRepository | ||
|
||
@UseCase | ||
class GetPriorNotificationUploads( | ||
private val priorNotificationUploadRepository: PriorNotificationUploadRepository, | ||
) { | ||
fun execute(reportId: String): List<PriorNotificationDocument> { | ||
return priorNotificationUploadRepository.findAllByReportId(reportId) | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
.../fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationUploadDataOutput.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,32 @@ | ||
package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs | ||
|
||
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationDocument | ||
import fr.gouv.cnsp.monitorfish.utils.CustomZonedDateTime | ||
|
||
class PriorNotificationUploadDataOutput( | ||
val id: String, | ||
val createdAt: CustomZonedDateTime, | ||
val fileName: String, | ||
val isManualPriorNotification: Boolean, | ||
val mimeType: String, | ||
val reportId: String, | ||
val updatedAt: CustomZonedDateTime, | ||
) { | ||
companion object { | ||
fun fromPriorNotificationDocument(priorNotificationDocument: PriorNotificationDocument): PriorNotificationUploadDataOutput { | ||
val id = requireNotNull(priorNotificationDocument.id) { | ||
"`id` is null." | ||
} | ||
|
||
return PriorNotificationUploadDataOutput( | ||
id = id, | ||
createdAt = priorNotificationDocument.createdAt, | ||
fileName = priorNotificationDocument.fileName, | ||
isManualPriorNotification = priorNotificationDocument.isManualPriorNotification, | ||
mimeType = priorNotificationDocument.mimeType, | ||
reportId = priorNotificationDocument.reportId, | ||
updatedAt = priorNotificationDocument.updatedAt, | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.