Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <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;
            }
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Advance the scripture text object enumerator to the next segment.
        /// </summary>
        /// <remarks>Virtual to support testing</remarks>
        /// <param name="sText">Set to the text of the current segment</param>
        /// <param name="sMarker">Set to the marker of the current segment tag</param>
        /// <param name="domain">Set to the domain of the stream being processed</param>
        /// <returns>True if successful. False if there are no more segments.</returns>
        /// ------------------------------------------------------------------------------------
        public virtual bool GetNextSegment(out string sText, out string sMarker,
                                           out ImportDomain domain)
        {
            domain = m_currentDomain;

            if (TypeOfImport == TypeOfImport.Paratext6)
            {
                GetNextParatextSegment(out sText, out sMarker);
                if (sMarker != null)
                {
                    return(true);
                }

                // We didn't get any segment so assume that we hit the end of the data for the book
                // ENHANCE: When we support partial book imports, this needs to change.
                m_ptCurrBook.BookNum++;
                if (m_ptCurrBook.BookNum <= m_settings.EndRef.Book)
                {
                    ResetParatextState();
                    return(GetNextSegment(out sText, out sMarker, out domain));
                }

                // We hit the end of our import range so try the next import domain
                m_ptCurrBook.BookNum = m_settings.StartRef.Book;
                switch (m_currentDomain)
                {
                case ImportDomain.Main:
                {
                    if (LoadParatextBackTranslationProject())
                    {
                        return(GetNextSegment(out sText, out sMarker, out domain));
                    }
                    goto case ImportDomain.BackTrans;
                }

                case ImportDomain.BackTrans:
                {
                    if (LoadParatextNotesProject())
                    {
                        return(GetNextSegment(out sText, out sMarker, out domain));
                    }
                    break;
                }
                }
            }
            else if (TypeOfImport == TypeOfImport.Other || TypeOfImport == TypeOfImport.Paratext5)
            {
                m_scTextSegment = m_scTextEnum.Next();
                if (m_scTextSegment != null)
                {
                    sText   = m_scTextSegment.Text;
                    sMarker = m_scTextSegment.Marker;
                    return(true);
                }
                switch (m_currentDomain)
                {
                case ImportDomain.Main:
                {
                    m_currentDomain = ImportDomain.BackTrans;
                    m_scSfmText     = new SCScriptureText(m_settings, ImportDomain.BackTrans);
                    // Now initialize the TextEnum with the range of scripture text we want
                    m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
                    return(GetNextSegment(out sText, out sMarker, out domain));
                }

                case ImportDomain.BackTrans:
                {
                    m_currentDomain = ImportDomain.Annotations;
                    m_scSfmText     = new SCScriptureText(m_settings, ImportDomain.Annotations);
                    // Now initialize the TextEnum with the range of scripture text we want
                    m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
                    return(GetNextSegment(out sText, out sMarker, out domain));
                }
                }
            }
            else
            {
                throw new Exception("GetNextSegment has an invalid import type");
            }

            sText   = null;
            sMarker = null;
            return(false);
        }
Ejemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <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;
			m_ImportType = settings.ImportTypeEnum;

			// Load ScriptureText object
			switch (TypeOfImport)
			{
				case TypeOfImport.Paratext6:
					if ((!settings.ImportTranslation && !settings.ImportAnnotations) || !LoadParatextVernacularProject())
						if (!LoadParatextBackTranslationProject())
							if (!LoadParatextNotesProject())
								throw new InvalidOperationException("There was nothing worth loading.");
					break;
				case TypeOfImport.Other:
				case TypeOfImport.Paratext5:
					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;
			}
		}
Ejemplo n.º 4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Advance the scripture text object enumerator to the next segment.
		/// </summary>
		/// <remarks>Virtual to support testing</remarks>
		/// <param name="sText">Set to the text of the current segment</param>
		/// <param name="sMarker">Set to the marker of the current segment tag</param>
		/// <param name="domain">Set to the domain of the stream being processed</param>
		/// <returns>True if successful. False if there are no more segments.</returns>
		/// ------------------------------------------------------------------------------------
		public virtual bool GetNextSegment(out string sText, out string sMarker,
			out ImportDomain domain)
		{
			domain = m_currentDomain;

			if (TypeOfImport == TypeOfImport.Paratext6)
			{
				GetNextParatextSegment(out sText, out sMarker);
				if (sMarker != null)
					return true;

				// We didn't get any segment so assume that we hit the end of the data for the book
				// ENHANCE: When we support partial book imports, this needs to change.
				m_ptCurrBook.BookNum++;
				if (m_ptCurrBook.BookNum <= m_settings.EndRef.Book)
				{
					ResetParatextState();
					return GetNextSegment(out sText, out sMarker, out domain);
				}

				// We hit the end of our import range so try the next import domain
				m_ptCurrBook.BookNum = m_settings.StartRef.Book;
				switch (m_currentDomain)
				{
					case ImportDomain.Main:
					{
						if (LoadParatextBackTranslationProject())
							return GetNextSegment(out sText, out sMarker, out domain);
						goto case ImportDomain.BackTrans;
					}
					case ImportDomain.BackTrans:
					{
						if (LoadParatextNotesProject())
							return GetNextSegment(out sText, out sMarker, out domain);
						break;
					}
				}
			}
			else if (TypeOfImport == TypeOfImport.Other || TypeOfImport == TypeOfImport.Paratext5)
			{
				m_scTextSegment = m_scTextEnum.Next();
				if (m_scTextSegment != null)
				{
					sText = m_scTextSegment.Text;
					sMarker = m_scTextSegment.Marker;
					return true;
				}
				switch (m_currentDomain)
				{
					case ImportDomain.Main:
					{
						m_currentDomain = ImportDomain.BackTrans;
						m_scSfmText = new SCScriptureText(m_settings, ImportDomain.BackTrans);
						// Now initialize the TextEnum with the range of scripture text we want
						m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
						return GetNextSegment(out sText, out sMarker, out domain);
					}
					case ImportDomain.BackTrans:
					{
						m_currentDomain = ImportDomain.Annotations;
						m_scSfmText = new SCScriptureText(m_settings, ImportDomain.Annotations);
						// Now initialize the TextEnum with the range of scripture text we want
						m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
						return GetNextSegment(out sText, out sMarker, out domain);
					}
				}
			}
			else
				throw new Exception("GetNextSegment has an invalid import type");

			sText = null;
			sMarker = null;
			return false;
		}
Ejemplo n.º 5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Advance the scripture text object enumerator to the next segment.
        /// </summary>
        /// <remarks>Virtual to support testing</remarks>
        /// <param name="sText">Set to the text of the current segment</param>
        /// <param name="sMarker">Set to the marker of the current segment tag</param>
        /// <param name="domain">Set to the domain of the stream being processed</param>
        /// <returns>True if successful. False if there are no more segments.</returns>
        /// ------------------------------------------------------------------------------------
        public virtual bool GetNextSegment(out string sText, out string sMarker,
                                           out ImportDomain domain)
        {
            int result = 0;

            domain = m_currentDomain;

            if (TypeOfImport == TypeOfImport.Paratext6)
            {
                result = m_scParatextTextEnum.Next(m_scParatextTextSegment);
                if (result != 0)
                {
                    sText   = m_scParatextTextSegment.Text;
                    sMarker = @"\" + m_scParatextTextSegment.Tag.Marker;

                    if (!ScrImportFileInfo.IsValidMarker(sMarker))
                    {
                        throw new ScriptureUtilsException(SUE_ErrorCode.InvalidCharacterInMarker, null, 0,
                                                          sMarker + sText, m_scParatextTextSegment.FirstReference.BBCCCVVV);
                    }
                    return(true);
                }
                else
                {
                    switch (m_currentDomain)
                    {
                    case ImportDomain.Main:
                    {
                        if (LoadParatextBackTranslationProject())
                        {
                            return(GetNextSegment(out sText, out sMarker, out domain));
                        }
                        goto case ImportDomain.BackTrans;
                    }

                    case ImportDomain.BackTrans:
                    {
                        if (LoadParatextNotesProject())
                        {
                            return(GetNextSegment(out sText, out sMarker, out domain));
                        }
                        break;
                    }
                    }
                }
            }
            else if (TypeOfImport == TypeOfImport.Other || TypeOfImport == TypeOfImport.Paratext5)
            {
                m_scTextSegment = m_scTextEnum.Next();
                if (m_scTextSegment != null)
                {
                    sText   = m_scTextSegment.Text;
                    sMarker = m_scTextSegment.Marker;
                    return(true);
                }
                else
                {
                    switch (m_currentDomain)
                    {
                    case ImportDomain.Main:
                    {
                        m_currentDomain = ImportDomain.BackTrans;
                        m_scSfmText     = new SCScriptureText(m_settings, ImportDomain.BackTrans);
                        // Now initialize the TextEnum with the range of scripture text we want
                        m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
                        return(GetNextSegment(out sText, out sMarker, out domain));
                    }

                    case ImportDomain.BackTrans:
                    {
                        m_currentDomain = ImportDomain.Annotations;
                        m_scSfmText     = new SCScriptureText(m_settings, ImportDomain.Annotations);
                        // Now initialize the TextEnum with the range of scripture text we want
                        m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
                        return(GetNextSegment(out sText, out sMarker, out domain));
                    }
                    }
                }
            }
            else
            {
                throw new Exception("GetNextSegment has an invalid import type");
            }

            sText   = null;
            sMarker = null;
            return(false);
        }
Ejemplo n.º 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Advance the scripture text object enumerator to the next segment.
		/// </summary>
		/// <remarks>Virtual to support testing</remarks>
		/// <param name="sText">Set to the text of the current segment</param>
		/// <param name="sMarker">Set to the marker of the current segment tag</param>
		/// <param name="domain">Set to the domain of the stream being processed</param>
		/// <returns>True if successful. False if there are no more segments.</returns>
		/// ------------------------------------------------------------------------------------
		public virtual bool GetNextSegment(out string sText, out string sMarker,
			out ImportDomain domain)
		{
			int result = 0;
			domain = m_currentDomain;

			if (TypeOfImport == TypeOfImport.Paratext6)
			{
				result = m_scParatextTextEnum.Next(m_scParatextTextSegment);
				if (result != 0)
				{
					sText = m_scParatextTextSegment.Text;
					sMarker = @"\" + m_scParatextTextSegment.Tag.Marker;

					if (!ScrImportFileInfo.IsValidMarker(sMarker))
					{
						throw new ScriptureUtilsException(SUE_ErrorCode.InvalidCharacterInMarker, null, 0,
							sMarker + sText, m_scParatextTextSegment.FirstReference.BBCCCVVV);
					}
					return true;
				}
				else
				{
					switch (m_currentDomain)
					{
						case ImportDomain.Main:
						{
							if (LoadParatextBackTranslationProject())
								return GetNextSegment(out sText, out sMarker, out domain);
							goto case ImportDomain.BackTrans;
						}
						case ImportDomain.BackTrans:
						{
							if (LoadParatextNotesProject())
								return GetNextSegment(out sText, out sMarker, out domain);
							break;
						}
					}
				}
			}
			else if (TypeOfImport == TypeOfImport.Other || TypeOfImport == TypeOfImport.Paratext5)
			{
				m_scTextSegment = m_scTextEnum.Next();
				if (m_scTextSegment != null)
				{
					sText = m_scTextSegment.Text;
					sMarker = m_scTextSegment.Marker;
					return true;
				}
				else
				{
					switch (m_currentDomain)
					{
						case ImportDomain.Main:
						{
							m_currentDomain = ImportDomain.BackTrans;
							m_scSfmText = new SCScriptureText(m_settings, ImportDomain.BackTrans);
							// Now initialize the TextEnum with the range of scripture text we want
							m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
							return GetNextSegment(out sText, out sMarker, out domain);
						}
						case ImportDomain.BackTrans:
						{
							m_currentDomain = ImportDomain.Annotations;
							m_scSfmText = new SCScriptureText(m_settings, ImportDomain.Annotations);
							// Now initialize the TextEnum with the range of scripture text we want
							m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
							return GetNextSegment(out sText, out sMarker, out domain);
						}
					}
				}
			}
			else
				throw new Exception("GetNextSegment has an invalid import type");

			sText = null;
			sMarker = null;
			return false;
		}