Skip to content
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
package com.simprints.infra.enrolment.records.repository.remote.models.face

import androidx.annotation.Keep
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.simprints.core.ExcludedFromGeneratedTestCoverageReports
import com.simprints.core.domain.face.FaceSample
import com.simprints.core.tools.utils.EncodingUtils
import com.simprints.infra.enrolment.records.repository.remote.models.ApiBiometricReference

@Keep
@ExcludedFromGeneratedTestCoverageReports("API model")
internal data class ApiFaceReference(
val id: String,
val templates: List<ApiFaceTemplate>,
val format: String,
// [MS-1076] The parent 'ApiBiometricReference' class should have its JsonSubTypes annotation updated to
// @JsonSubTypes.Type([...], looseHandling = true) once we update to SDK => 25 and Jackson => 2.16.0.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once we update to SDK => 25

if :D

// Then, this annotation should be removed
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
val metadata: HashMap<String, String>? = null,
) : ApiBiometricReference(ApiBiometricReferenceType.FaceReference)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
package com.simprints.infra.enrolment.records.repository.remote.models.fingerprint

import androidx.annotation.Keep
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.simprints.core.ExcludedFromGeneratedTestCoverageReports
import com.simprints.core.domain.fingerprint.FingerprintSample
import com.simprints.core.tools.utils.EncodingUtils
import com.simprints.infra.enrolment.records.repository.remote.models.ApiBiometricReference

@Keep
@ExcludedFromGeneratedTestCoverageReports("API model")
internal data class ApiFingerprintReference(
val id: String,
val templates: List<ApiFingerprintTemplate>,
val format: String,
// [MS-1076] The parent 'ApiBiometricReference' class should have its JsonSubTypes annotation updated to
// @JsonSubTypes.Type([...], looseHandling = true) once we update to SDK => 25 and Jackson => 2.16.0.
// Then, this annotation should be removed
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
val metadata: HashMap<String, String>? = null,
) : ApiBiometricReference(ApiBiometricReferenceType.FingerprintReference)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.simprints.infra.eventsync.event.remote.models.subject.biometricref
import androidx.annotation.Keep
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.simprints.core.ExcludedFromGeneratedTestCoverageReports
import com.simprints.core.domain.fingerprint.IFingerIdentifier
import com.simprints.infra.events.event.domain.models.subject.FaceTemplate
import com.simprints.infra.events.event.domain.models.subject.FingerprintTemplate
Expand All @@ -16,8 +17,12 @@ import com.simprints.infra.events.event.domain.models.subject.FingerprintReferen
private const val FACE_REFERENCE_KEY = "FaceReference"
private const val FINGERPRINT_REFERENCE_KEY = "FingerprintReference"

@ExcludedFromGeneratedTestCoverageReports("API model")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true)
@JsonSubTypes(
// [MS-1076] Annotations should have 'looseHandling' parameter passed to it to allow loose type handling of the nested fields (metadata)
// @JsonSubTypes.Type([...], looseHandling = true) once we update to SDK => 25 and Jackson => 2.16.0.
// Ref: https://github.com/FasterXML/jackson-databind/issues/3877#issuecomment-1508508854
JsonSubTypes.Type(value = ApiFaceReference::class, name = FACE_REFERENCE_KEY),
JsonSubTypes.Type(value = ApiFingerprintReference::class, name = FINGERPRINT_REFERENCE_KEY),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package com.simprints.infra.eventsync.event.remote.models.subject.biometricref.face

import androidx.annotation.Keep
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.simprints.core.ExcludedFromGeneratedTestCoverageReports
import com.simprints.infra.eventsync.event.remote.models.subject.biometricref.ApiBiometricReference
import com.simprints.infra.eventsync.event.remote.models.subject.biometricref.ApiBiometricReferenceType
import com.simprints.infra.eventsync.event.remote.models.subject.biometricref.ApiBiometricReferenceType.FaceReference
import java.util.UUID

@Keep
@ExcludedFromGeneratedTestCoverageReports("API model")
internal data class ApiFaceReference(
override val id: String = UUID.randomUUID().toString(),
val templates: List<ApiFaceTemplate>,
val format: String,
val metadata: HashMap<String, String>? = null,
// [MS-1076] The parent 'ApiBiometricReference' class should have its JsonSubTypes annotation updated to
// @JsonSubTypes.Type([...], looseHandling = true) once we update to SDK => 25 and Jackson => 2.16.0.
// Then, this annotation should be removed
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
val metadata: Map<String, String>? = null,
) : ApiBiometricReference {
override val type: ApiBiometricReferenceType = FaceReference
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package com.simprints.infra.eventsync.event.remote.models.subject.biometricref.fingerprint

import androidx.annotation.Keep
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.simprints.core.ExcludedFromGeneratedTestCoverageReports
import com.simprints.infra.eventsync.event.remote.models.subject.biometricref.ApiBiometricReference
import com.simprints.infra.eventsync.event.remote.models.subject.biometricref.ApiBiometricReferenceType
import com.simprints.infra.eventsync.event.remote.models.subject.biometricref.ApiBiometricReferenceType.FingerprintReference
import java.util.UUID

@Keep
@ExcludedFromGeneratedTestCoverageReports("API model")
internal data class ApiFingerprintReference(
override val id: String = UUID.randomUUID().toString(),
val templates: List<ApiFingerprintTemplate>,
val format: String,
val metadata: HashMap<String, String>? = null,
// [MS-1076] The parent 'ApiBiometricReference' class should have its JsonSubTypes annotation updated to
// @JsonSubTypes.Type([...], looseHandling = true) once we update to SDK => 25 and Jackson => 2.16.0.
// Then, this annotation should be removed
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
val metadata: Map<String, String>? = null,
) : ApiBiometricReference {
override val type: ApiBiometricReferenceType = FingerprintReference
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package com.simprints.infra.events.event.domain.models.subject
import androidx.annotation.Keep
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.simprints.core.ExcludedFromGeneratedTestCoverageReports
import com.simprints.infra.events.event.domain.models.subject.BiometricReferenceType.Companion.FACE_REFERENCE_KEY
import com.simprints.infra.events.event.domain.models.subject.BiometricReferenceType.Companion.FINGERPRINT_REFERENCE_KEY

@ExcludedFromGeneratedTestCoverageReports("Domain model")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type")
@JsonSubTypes(
JsonSubTypes.Type(value = FaceReference::class, name = FACE_REFERENCE_KEY),
Expand All @@ -17,18 +19,20 @@ sealed class BiometricReference(
val type: BiometricReferenceType,
)

@ExcludedFromGeneratedTestCoverageReports("Domain model")
data class FaceReference(
override val id: String,
val templates: List<FaceTemplate>,
val format: String,
val metadata: HashMap<String, String>? = null,
val metadata: Map<String, String>? = null,
) : BiometricReference(id, BiometricReferenceType.FACE_REFERENCE)

@ExcludedFromGeneratedTestCoverageReports("Domain model")
data class FingerprintReference(
override val id: String,
val templates: List<FingerprintTemplate>,
val format: String,
val metadata: HashMap<String, String>? = null,
val metadata: Map<String, String>? = null,
) : BiometricReference(id, BiometricReferenceType.FINGERPRINT_REFERENCE)

enum class BiometricReferenceType {
Expand Down