/// ------------------------------------------------------------------------------------ /// <summary> /// Load the scripture project and enumerator, preparing us to read the data files. /// </summary> /// <param name="settings">Import settings object (filled in by wizard)</param> /// ------------------------------------------------------------------------------------ public void LoadScriptureProject(IScrImportSet settings) { m_settings = settings as ScrImportSet; m_ImportType = settings.ImportTypeEnum; // Load ScriptureText object switch (TypeOfImport) { case TypeOfImport.Paratext6: if (!LoadParatextVernacularProject()) { if (!LoadParatextBackTranslationProject()) { if (!LoadParatextNotesProject()) { throw new InvalidOperationException("There was nothing worth loading."); } } } break; case TypeOfImport.Other: case TypeOfImport.Paratext5: Paratext.ScrVers versification = m_settings.Cache.LangProject.TranslatedScriptureOA.Versification; m_settings.CheckForOverlappingFilesInRange( new ScrReference(m_settings.StartRef, versification), new ScrReference(m_settings.EndRef, versification)); m_scSfmText = new SCScriptureText(settings, ImportDomain.Main); // Now initialize the TextEnum with the range of scripture text we want m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef); break; default: Debug.Assert(false, "bogus TypeOfImport"); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Load the scripture project and enumerator, preparing us to read the data files. /// </summary> /// <param name="settings">Import settings object (filled in by wizard)</param> /// ------------------------------------------------------------------------------------ public void LoadScriptureProject(IScrImportSet settings) { m_settings = settings as ScrImportSet; m_ImportType = settings.ImportTypeEnum; // Load ScriptureText object switch (TypeOfImport) { case TypeOfImport.Paratext6: if (!LoadParatextVernacularProject()) if (!LoadParatextBackTranslationProject()) if (!LoadParatextNotesProject()) throw new InvalidOperationException("There was nothing worth loading."); break; case TypeOfImport.Other: case TypeOfImport.Paratext5: Paratext.ScrVers versification = m_settings.Cache.LangProject.TranslatedScriptureOA.Versification; m_settings.CheckForOverlappingFilesInRange( new ScrReference(m_settings.StartRef, versification), new ScrReference(m_settings.EndRef, versification)); m_scSfmText = new SCScriptureText(settings, ImportDomain.Main); // Now initialize the TextEnum with the range of scripture text we want m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef); break; default: Debug.Assert(false, "bogus TypeOfImport"); break; } }
public void SaveAndReloadProjectFiles_P5() { CheckDisposed(); m_importSettings.ImportTypeEnum = TypeOfImport.Paratext5; TempSFFileMaker fileMaker = new TempSFFileMaker(); string scrFile = fileMaker.CreateFile("GEN", new string[] {@"\p", @"\c 1", @"\v 1", @"\v 2"}); string btFile = fileMaker.CreateFile("GEN", new string[] {@"\p", @"\c 3", @"\v 1"}); string annotationFile = fileMaker.CreateFile("GEN", new string[] {@"\p", @"\c 3", @"\v 1"}); m_importSettings.AddFile(scrFile, ImportDomain.Main, null, 0); m_importSettings.AddFile(btFile, ImportDomain.BackTrans, "es", 0); m_importSettings.AddFile(annotationFile, ImportDomain.Annotations, "de", m_inMemoryCache.m_consultantNoteDefn.Hvo); // Save the settings and reload m_importSettings.SaveSettings(); m_importSettings = new ScrImportSet(Cache, Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.HvoArray[0]); // Test to see that the files were saved and loaded correctly Assert.AreEqual(TypeOfImport.Paratext5, m_importSettings.ImportTypeEnum); ImportFileSource source = m_importSettings.GetImportFiles(ImportDomain.Main); Assert.AreEqual(1, source.Count); foreach (ScrImportFileInfo info in source) Assert.AreEqual(scrFile.ToUpper(), info.FileName.ToUpper()); source = m_importSettings.GetImportFiles(ImportDomain.BackTrans); Assert.AreEqual(1, source.Count); foreach (ScrImportFileInfo info in source) { Assert.AreEqual(btFile.ToUpper(), info.FileName.ToUpper()); Assert.AreEqual("es", info.IcuLocale); } source = m_importSettings.GetImportFiles(ImportDomain.Annotations); Assert.AreEqual(1, source.Count); foreach (ScrImportFileInfo info in source) { Assert.AreEqual(annotationFile.ToUpper(), info.FileName.ToUpper()); Assert.AreEqual("de", info.IcuLocale); Assert.AreEqual(m_inMemoryCache.m_consultantNoteDefn.Hvo, info.NoteTypeHvo); } // While we're at it, let's test CheckForOverlappingFilesInRange. This should // do nothing since there are no overlaps -- it will throw an exception if an // overlap is detected. m_importSettings.CheckForOverlappingFilesInRange( new ScrReference(1, 1, 1, Paratext.ScrVers.English), new ScrReference(66, 21, 8, Paratext.ScrVers.English)); }