-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
180 additions
and
103 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
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
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
52 changes: 52 additions & 0 deletions
52
...src/main/java/fr/geonature/occtax/features/record/usecase/EditObservationRecordUseCase.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,52 @@ | ||
package fr.geonature.occtax.features.record.usecase | ||
|
||
import fr.geonature.commons.interactor.BaseResultUseCase | ||
import fr.geonature.occtax.features.record.domain.ObservationRecord | ||
import org.tinylog.kotlin.Logger | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Start editing the given [ObservationRecord]. | ||
* | ||
* @author S. Grimault | ||
* | ||
* @see SetDefaultNomenclatureValuesUseCase | ||
* @see LoadAllMediaRecordUseCase | ||
*/ | ||
class EditObservationRecordUseCase @Inject constructor( | ||
private val setDefaultNomenclatureValuesUseCase: SetDefaultNomenclatureValuesUseCase, | ||
private val loadAllMediaRecordUseCase: LoadAllMediaRecordUseCase | ||
) : | ||
BaseResultUseCase<ObservationRecord, EditObservationRecordUseCase.Params>() { | ||
|
||
override suspend fun run(params: Params): Result<ObservationRecord> { | ||
Logger.info { "loading default nomenclature values from record '${params.observationRecord.internalId}'..." } | ||
|
||
var result = | ||
setDefaultNomenclatureValuesUseCase.run(SetDefaultNomenclatureValuesUseCase.Params(params.observationRecord)) | ||
|
||
if (result.isFailure) { | ||
Logger.error { "failed to load default nomenclature values from record '${params.observationRecord.internalId}" } | ||
return result | ||
} | ||
|
||
val observationRecordUpdated = result.getOrNull() ?: params.observationRecord | ||
|
||
Logger.info { "default nomenclature values successfully loaded for record '${observationRecordUpdated.internalId}'" } | ||
Logger.info { "loading all local medias from record '${observationRecordUpdated.internalId}'..." } | ||
|
||
result = | ||
loadAllMediaRecordUseCase.run(LoadAllMediaRecordUseCase.Params(observationRecordUpdated)) | ||
|
||
if (result.isFailure) { | ||
Logger.warn { "failed to load all local medias from record '${observationRecordUpdated.internalId}'" } | ||
return result | ||
} | ||
|
||
Logger.info { "all medias successfully loaded for record '${observationRecordUpdated.internalId}'" } | ||
|
||
return result | ||
} | ||
|
||
data class Params(val observationRecord: ObservationRecord) | ||
} |
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
Oops, something went wrong.