コード例 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the category hierarchy from this class.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <returns>an ORC-delimited string providing the full hierarchy path of this category
        /// </returns>
        /// ------------------------------------------------------------------------------------
        private string GetCategoryHierarchyFromXml(XmlNoteCategory category)
        {
            StringBuilder strBldr = new StringBuilder();

            strBldr.Append(category.CategoryName);
            if (category.SubCategory != null)
            {
                strBldr.Append(StringUtils.kChObject + GetCategoryHierarchyFromXml(category.SubCategory));
            }

            return(strBldr.ToString());
        }
コード例 #2
0
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();

			m_xmlNote = new XmlNoteCategory();

			m_scrInMemoryCache.InitializeWritingSystemEncodings();
			m_scrInMemoryCache.InitializeScripture();
			m_scrInMemoryCache.SetupScriptureAnnotationCategories();

			// Initialize the annotation category possibility list.
			m_wsSpanish = InMemoryFdoCache.s_wsHvos.Es;
			m_possList = CreateCategories(m_scrInMemoryCache.Cache, m_possList, m_wsSpanish);
		}
コード例 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes categories in the hierarchy.
        /// </summary>
        /// <param name="categoryList">The list of categories for a Scripture note.</param>
        /// <param name="lgwsf">The language writing system factory.</param>
        /// <exception cref="ArgumentOutOfRangeException">thrown when the category list is empty.
        /// </exception>
        /// ------------------------------------------------------------------------------------
        private void InitializeCategory(List <CategoryNode> categoryList, ILgWritingSystemFactory lgwsf)
        {
            XmlNoteCategory curCategory = this;
            CategoryNode    node        = null;

            for (int i = 0; i < categoryList.Count; i++)
            {
                node = categoryList[i];
                curCategory.CategoryName = node.CategoryName;
                curCategory.IcuLocale    = lgwsf.GetStrFromWs(node.Ws);
                if (categoryList.Count > i + 1)
                {
                    curCategory.SubCategory = new XmlNoteCategory();
                    curCategory             = curCategory.SubCategory;
                }
                else
                {
                    curCategory.SubCategory = null;
                }
            }
        }
コード例 #4
0
ファイル: XmlScrNote.cs プロジェクト: vkarthim/FieldWorks
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="XmlScrNote"/> class based on
        /// the given Scripture note.
        /// </summary>
        /// <param name="ann">The Scripture annotation.</param>
        /// <param name="wsDefault">The default (analysis) writing system.</param>
        /// <param name="lgwsf">The writing system factory.</param>
        /// ------------------------------------------------------------------------------------
        public XmlScrNote(IScrScriptureNote ann, int wsDefault, ILgWritingSystemFactory lgwsf)
            : this()
        {
            m_wsDefault      = wsDefault;
            m_lgwsf          = lgwsf;
            ResolutionStatus = ann.ResolutionStatus;
            m_typeName       = ann.AnnotationTypeRA.Name.get_String(WritingSystemServices.FallbackUserWs(ann.Cache)).Text;
            m_guidType       = ann.AnnotationTypeRA.Guid;
            SetNoteType(ann);

            m_startRef = ann.BeginRef;
            if (ann.BeginRef != ann.EndRef)
            {
                m_endRef = ann.EndRef;
            }

            if (ann.BeginObjectRA != null)
            {
                m_guidBegObj = ann.BeginObjectRA.Guid;
            }

            if (ann.BeginObjectRA != ann.EndObjectRA && ann.EndObjectRA != null)
            {
                m_guidEndObj = ann.EndObjectRA.Guid;
            }

            BeginOffset = ann.BeginOffset;
            EndOffset   = ann.EndOffset;

            m_createdDate  = ann.DateCreated;
            m_modifiedDate = ann.DateModified;
            m_resolvedDate = ann.DateResolved;

            Quote      = XmlNotePara.GetParagraphList(ann.QuoteOA, m_wsDefault, m_lgwsf);
            Discussion = XmlNotePara.GetParagraphList(ann.DiscussionOA, m_wsDefault, m_lgwsf);
            Suggestion = XmlNotePara.GetParagraphList(ann.RecommendationOA, m_wsDefault, m_lgwsf);
            Resolution = XmlNotePara.GetParagraphList(ann.ResolutionOA, m_wsDefault, m_lgwsf);
            Categories = XmlNoteCategory.GetCategoryList(ann, m_lgwsf);
            Responses  = XmlNoteResponse.GetResponsesList(ann, m_wsDefault, m_lgwsf);
        }
コード例 #5
0
		public void GetCategoryHierarchyFromXml()
		{
			ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
			XmlNoteCategory noteCategory = new XmlNoteCategory(
				m_possList.PossibilitiesOS[1].SubPossibilitiesOS[1].SubPossibilitiesOS[0], wsf);

			string xmlCategoryPath = (string)ReflectionHelper.GetResult(noteCategory,
				"GetCategoryHierarchyFromXml", noteCategory);

			Assert.AreEqual("Level 1b" + StringUtils.kchObject + "Level 2b, parent is 1b" +
				StringUtils.kchObject + "Level 3, parent is 2b", xmlCategoryPath);
		}
コード例 #6
0
		public void CategoryPath_Level3()
		{
			ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
			XmlNoteCategory noteCategory = new XmlNoteCategory(
				m_possList.PossibilitiesOS[1].SubPossibilitiesOS[1].SubPossibilitiesOS[0], wsf);
			Assert.AreEqual("Level 1b" + StringUtils.kchObject + "Level 2b, parent is 1b" +
				StringUtils.kchObject + "Level 3, parent is 2b", noteCategory.CategoryPath);
		}
コード例 #7
0
		public void CategoryPath_Level1()
		{
			ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
			XmlNoteCategory noteCategory = new XmlNoteCategory(m_possList.PossibilitiesOS[0], wsf);
			Assert.AreEqual("Level 1a", noteCategory.CategoryPath);
		}
コード例 #8
0
		public void XmlNoteCategory_ThirdLevel()
		{
			ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
			XmlNoteCategory noteCategory = new XmlNoteCategory(
				m_possList.PossibilitiesOS[1].SubPossibilitiesOS[1].SubPossibilitiesOS[0], wsf);

			Assert.AreEqual("Level 1b", noteCategory.CategoryName);
			Assert.AreEqual("es", noteCategory.IcuLocale);
			Assert.IsNotNull(noteCategory.SubCategory);

			Assert.AreEqual("Level 2b, parent is 1b", noteCategory.SubCategory.CategoryName);
			Assert.AreEqual("es", noteCategory.SubCategory.IcuLocale);
			Assert.IsNotNull(noteCategory.SubCategory.SubCategory);

			Assert.AreEqual("Level 3, parent is 2b", noteCategory.SubCategory.SubCategory.CategoryName);
			Assert.AreEqual("es", noteCategory.SubCategory.SubCategory.IcuLocale);
		}
コード例 #9
0
		public void XmlNoteCategory_TopLevel()
		{
			ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
			XmlNoteCategory noteCategory = new XmlNoteCategory(m_possList.PossibilitiesOS[0], wsf);

			Assert.AreEqual("Level 1a", noteCategory.CategoryName);
			Assert.AreEqual("es", noteCategory.IcuLocale);
			Assert.IsNull(noteCategory.SubCategory);
		}
コード例 #10
0
		public void SavingDeserializedAnnotationsToCache_WithCategories()
		{
			DateTime now = DateTime.Now;
			DateTime utcNow = now.ToUniversalTime();

			XmlScrNote ann = CreateNote();
			ann.BeginScrRef = "LEV 2:8";
			ann.ResolutionStatus = NoteStatus.Open;
			ann.AnnotationTypeGuid = LangProject.kguidAnnTranslatorNote.ToString();
			ann.DateTimeCreated = utcNow.ToString();
			ann.DateTimeModified = utcNow.AddDays(1).ToString();
			AddParasTo(ann.Discussion, "This is my discussion");
			AddParasTo(ann.Resolution, "This is my resolution for the note");
			AddParasTo(ann.Quote, "This is the quoted text");
			AddParasTo(ann.Suggestion, "This is my suggestion");
			XmlNoteCategory category1 = new XmlNoteCategory();
			category1.CategoryName = "Monkey";
			category1.IcuLocale = "en";
			ann.Categories.Add(category1);
			XmlNoteCategory category2 = new XmlNoteCategory();
			category2.CategoryName = "Discourse";
			category2.IcuLocale = "en";
			ann.Categories.Add(category2);

			DummyXmlScrAnnotationsList list = new DummyXmlScrAnnotationsList();
			list.Annotations.Add(ann);

			// Make sure 'Monkey' is not in the DB yet
			foreach (ICmPossibility poss in m_scr.NoteCategoriesOA.PossibilitiesOS)
				Assert.AreNotEqual("Monkey", poss.Name.GetAlternative(InMemoryFdoCache.s_wsHvos.En));

			list.CallWriteToCache(Cache, m_stylesheet);

			IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[2];
			Assert.AreEqual(1, annotations.NotesOS.Count);

			IScrScriptureNote note = annotations.NotesOS[0];
			Assert.AreEqual(NoteType.Translator, note.AnnotationType);
			Assert.IsTrue(AreDateTimesClose(now, note.DateCreated));
			Assert.IsTrue(AreDateTimesClose(now.AddDays(1), note.DateModified));
			Assert.AreEqual(DateTime.MinValue, note.DateResolved);

			TestAnnotationField(note.QuoteOA, "This is the quoted text");
			TestAnnotationField(note.DiscussionOA, "This is my discussion");
			TestAnnotationField(note.ResolutionOA, "This is my resolution for the note");
			TestAnnotationField(note.RecommendationOA, "This is my suggestion");

			Assert.AreEqual(0, note.ResponsesOS.Count);

			bool foundMonkey = false;
			foreach (ICmPossibility poss in m_scr.NoteCategoriesOA.PossibilitiesOS)
				foundMonkey |= (poss.Name.GetAlternative(InMemoryFdoCache.s_wsHvos.En) == "Monkey");
			Assert.IsTrue(foundMonkey, "Monkey should have been added to the DB");

			Assert.AreEqual(2, note.CategoriesRS.Count);
			Assert.AreEqual("Monkey",
				note.CategoriesRS[0].Name.GetAlternative(InMemoryFdoCache.s_wsHvos.En));
			Assert.AreEqual("Discourse",
				note.CategoriesRS[1].Name.GetAlternative(InMemoryFdoCache.s_wsHvos.En));
		}
コード例 #11
0
ファイル: XmlNoteCategory.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the category hierarchy from this class.
		/// </summary>
		/// <param name="category">The category.</param>
		/// <returns>an ORC-delimited string providing the full hierarchy path of this category
		/// </returns>
		/// ------------------------------------------------------------------------------------
		private string GetCategoryHierarchyFromXml(XmlNoteCategory category)
		{
			StringBuilder strBldr = new StringBuilder();

			strBldr.Append(category.CategoryName);
			if (category.SubCategory != null)
				strBldr.Append(StringUtils.kChObject + GetCategoryHierarchyFromXml(category.SubCategory));

			return strBldr.ToString();
		}