diff --git a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/HomePageViewModel2.kt b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/HomePageViewModel2.kt index 9ed007f9db..632fecb1e1 100644 --- a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/HomePageViewModel2.kt +++ b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/HomePageViewModel2.kt @@ -169,14 +169,16 @@ class HomePageViewModel2 : ViewModel() { } fun selectBook(workbookDescriptor: WorkbookDescriptor) { - val projectGroup = selectedProjectGroupProperty.value - workbookDS.currentModeProperty.set(projectGroup.mode) - - val workbook = workbookRepo.get( - workbookDescriptor.sourceCollection, - workbookDescriptor.targetCollection - ) - openWorkbook(workbook, projectGroup.mode) +// val projectGroup = selectedProjectGroupProperty.value +// workbookDS.currentModeProperty.set(projectGroup.mode) +// +// val workbook = workbookRepo.get( +// workbookDescriptor.sourceCollection, +// workbookDescriptor.targetCollection +// ) +// openWorkbook(workbook, projectGroup.mode) + + find().generateBook(workbookDescriptor) } /** diff --git a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ImportAudioViewModel.kt b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ImportAudioViewModel.kt index 427d6a5188..c708e10597 100644 --- a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ImportAudioViewModel.kt +++ b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ImportAudioViewModel.kt @@ -21,16 +21,42 @@ package org.wycliffeassociates.otter.jvm.workbookapp.ui.viewmodel import io.reactivex.subjects.PublishSubject import org.slf4j.LoggerFactory import org.wycliffeassociates.otter.common.audio.AudioFileFormat +import org.wycliffeassociates.otter.common.data.workbook.Chapter +import org.wycliffeassociates.otter.common.data.workbook.Workbook +import org.wycliffeassociates.otter.common.data.workbook.WorkbookDescriptor +import org.wycliffeassociates.otter.common.domain.audio.AudioGenerator +import org.wycliffeassociates.otter.common.persistence.repositories.ICollectionRepository +import org.wycliffeassociates.otter.common.persistence.repositories.IContentRepository +import org.wycliffeassociates.otter.common.persistence.repositories.IWorkbookDescriptorRepository +import org.wycliffeassociates.otter.common.persistence.repositories.IWorkbookRepository import org.wycliffeassociates.otter.jvm.workbookapp.di.IDependencyGraphProvider import tornadofx.* import java.io.File +import javax.inject.Inject class ImportAudioViewModel : ViewModel() { + @Inject + lateinit var audioGenerator: AudioGenerator + + @Inject + lateinit var workbookRepository: IWorkbookRepository + + @Inject + lateinit var workbookDescriptorRepository: IWorkbookDescriptorRepository + + @Inject + lateinit var collectionRepository: ICollectionRepository + + @Inject + lateinit var contentRepository: IContentRepository + private val logger = LoggerFactory.getLogger(ImportAudioViewModel::class.java) - + val snackBarObservable: PublishSubject = PublishSubject.create() + val workbookDS: WorkbookDataStore by inject() + init { (app as IDependencyGraphProvider).dependencyGraph.inject(this) } @@ -65,4 +91,32 @@ class ImportAudioViewModel : ViewModel() { else -> true } } + + fun generateBook(workbookDescriptor: WorkbookDescriptor) { + + val workbook = workbookRepository.get( + workbookDescriptor.sourceCollection, + workbookDescriptor.targetCollection + ) + val chapters = collectionRepository.getChildren(workbookDescriptor.sourceCollection) + .blockingGet() + + val chapter = chapters.first() + val chapterVerseContents = contentRepository.getByCollection(chapter).blockingGet() + val verseText = chapterVerseContents.filter { it.labelKey == "verse" }.map{ it.text } + println(verseText.size) + } + + fun generateForChapter(chapter: Chapter) { + val chunksText = chapter.chunks.blockingGet() + .map { it.textItem.text } + + val audio = audioGenerator.convertTextToAudio(chunksText) + + // delete/restart chapter + + + // import to chapter content + + } }