Skip to content

Commit

Permalink
Generate Valid Scripture Burritos (#1153)
Browse files Browse the repository at this point in the history
* Add metadata to make burrito export valid

Changed Derived to Source: I incorrectly assumed that Source referred to a Source text, however this is meant as the mutable original (not software modified) burrito. Derived requires a list of operations performed which modified it.

Added a name to Language

Added a currentScope to the AudioFlavor

Added values to Identification

Added an object to Primary for auth

* Update ScriptureBurritoUtils.kt

Slug for current scope needs to be uppercase
  • Loading branch information
jsarabia committed Jun 13, 2024
1 parent 3ca0dfe commit 3a7892f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ import org.bibletranslationtools.scriptureburrito.LocalizedNamesSchema
import org.bibletranslationtools.scriptureburrito.LocalizedText
import org.bibletranslationtools.scriptureburrito.MetaVersionSchema
import org.bibletranslationtools.scriptureburrito.MetadataSchema
import org.bibletranslationtools.scriptureburrito.PrimaryIdentification
import org.bibletranslationtools.scriptureburrito.ScopeSchema
import org.bibletranslationtools.scriptureburrito.ShortStatement
import org.bibletranslationtools.scriptureburrito.SoftwareAndUserInfoSchema
import org.bibletranslationtools.scriptureburrito.SourceMetaSchema
import org.bibletranslationtools.scriptureburrito.SourceMetadataSchema
import org.bibletranslationtools.scriptureburrito.TypeSchema
import org.bibletranslationtools.scriptureburrito.flavor.FlavorType
import org.bibletranslationtools.scriptureburrito.flavor.scripture.audio.AudioFlavorSchema
Expand All @@ -31,6 +34,7 @@ import org.bibletranslationtools.scriptureburrito.flavor.scripture.audio.Perform
import org.wycliffeassociates.otter.common.data.IAppInfo
import org.wycliffeassociates.otter.common.data.workbook.Workbook
import org.wycliffeassociates.otter.common.domain.resourcecontainer.RcConstants
import org.wycliffeassociates.otter.common.domain.resourcecontainer.burrito.auth.AuthProvider
import org.wycliffeassociates.otter.common.domain.resourcecontainer.burrito.auth.IdAuthorityProvider
import org.wycliffeassociates.otter.common.persistence.IDirectoryProvider
import org.wycliffeassociates.resourcecontainer.ResourceContainer
Expand All @@ -47,7 +51,7 @@ import javax.inject.Inject
typealias ChapterNumber = Int

class ScriptureBurritoUtils @Inject constructor(
private val idAuthorityProvider: IdAuthorityProvider,
private val idAuthorityProvider: AuthProvider,
private val appInfo: IAppInfo,
directoryProvider: IDirectoryProvider
) {
Expand Down Expand Up @@ -88,9 +92,9 @@ class ScriptureBurritoUtils @Inject constructor(
val language = workbook.target.language
val langCode = language.slug

return DerivedMetadataSchema(
return SourceMetadataSchema(
Format.SCRIPTURE_BURRITO,
DerivedMetaSchema(
SourceMetaSchema(
dateCreated = Date.from(Instant.now()),
version = MetaVersionSchema._1_0_0,
defaultLocale = rc.manifest.dublinCore.language.identifier,
Expand All @@ -100,7 +104,7 @@ class ScriptureBurritoUtils @Inject constructor(
}
),
idAuthorityProvider.createIdAuthority(),
IdentificationSchema(),
idAuthorityProvider.createIdentification(),
confidential = false,
copyright = CopyrightSchema().apply {
this.shortStatements = mutableListOf(ShortStatement(rc.manifest.dublinCore.rights, langCode))
Expand All @@ -115,11 +119,22 @@ class ScriptureBurritoUtils @Inject constructor(
formats
).apply {
name = "audioTranslation"
currentScope = ScopeSchema().apply {
this[workbook.target.slug.uppercase(Locale.US)] = takes.keys.map { "$it" }.toMutableList()
}
}
}
),
languages = Languages().apply {
add(LanguageSchema(tag = language.slug))
add(
LanguageSchema(
tag = language.slug,
name = hashMapOf(
language.slug to language.name,
"en" to language.anglicizedName
)
)
)
},
localizedNames = buildLocalizedNames(rc),
ingredients = buildIngredients(rc, workbook, takes)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package org.wycliffeassociates.otter.common.domain.resourcecontainer.burrito.auth

import org.bibletranslationtools.scriptureburrito.IdAuthoritiesSchema
import org.bibletranslationtools.scriptureburrito.IdentificationSchema

interface IdAuthorityProvider {
fun createIdAuthority(): IdAuthoritiesSchema
}

}

interface IdentificationProvider {
fun createIdentification(): IdentificationSchema
}

interface AuthProvider: IdAuthorityProvider, IdentificationProvider
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package org.wycliffeassociates.otter.jvm.workbookapp.di.modules

import dagger.Module
import dagger.Provides
import org.wycliffeassociates.otter.common.domain.resourcecontainer.burrito.auth.IdAuthorityProvider
import org.wycliffeassociates.otter.common.domain.resourcecontainer.burrito.auth.AuthProvider
import org.wycliffeassociates.otter.jvm.workbookapp.domain.resourcecontainer.burrito.auth.WacsIdAuthority

@Module
class AuthModule {
@Provides
fun providesWacsAuth(): IdAuthorityProvider = WacsIdAuthority()
fun providesWacsAuth(): AuthProvider = WacsIdAuthority()
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
package org.wycliffeassociates.otter.jvm.workbookapp.domain.resourcecontainer.burrito.auth

import com.fasterxml.jackson.databind.node.JsonNodeFactory
import com.fasterxml.jackson.databind.node.ObjectNode
import org.bibletranslationtools.scriptureburrito.IdAuthoritiesSchema
import org.bibletranslationtools.scriptureburrito.IdAuthority
import org.wycliffeassociates.otter.common.domain.resourcecontainer.burrito.auth.IdAuthorityProvider
import org.bibletranslationtools.scriptureburrito.IdentificationSchema
import org.bibletranslationtools.scriptureburrito.PrimaryIdentification
import org.wycliffeassociates.otter.common.domain.resourcecontainer.burrito.auth.AuthProvider
import javax.inject.Inject

class WacsIdAuthority @Inject constructor(): IdAuthorityProvider {
class WacsIdAuthority @Inject constructor():
AuthProvider
{
override fun createIdAuthority(): IdAuthoritiesSchema {
val authority = IdAuthoritiesSchema()
val wacs = IdAuthority()
wacs.name = hashMapOf("en" to "Wycliffe Associates Content Service ")
wacs.name = hashMapOf("en" to "Wycliffe Associates Content Service")
wacs.id = "https://content.bibletranslationtools.org/"
authority["wacs"] = wacs
return authority
}

override fun createIdentification(): IdentificationSchema {
return IdentificationSchema().apply {
primary = PrimaryIdentification().apply {
this["id"] = ObjectNode(JsonNodeFactory.instance)
}
name = hashMapOf("en" to "Wycliffe Associates Content Service")
}
}
}

0 comments on commit 3a7892f

Please sign in to comment.