Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Assigns a rendering for this check reference.
        /// </summary>
        /// <param name="wordForm">The word form.</param>
        /// ------------------------------------------------------------------------------------
        internal void AssignRendering(IWfiWordform wordForm)
        {
            RenderingStatus = KeyTermRenderingStatus.Assigned;
            RenderingRA     = wordForm;

            ChkTerm owningChkTerm = new ChkTerm(Cache, OwnerHVO);
            bool    fChkTermRenderingAlreadySet = false;

            foreach (IChkRendering rendering in owningChkTerm.RenderingsOC)
            {
                if (rendering.SurfaceFormRAHvo == wordForm.Hvo)
                {
                    fChkTermRenderingAlreadySet = true;
                    break;
                }
            }
            if (!fChkTermRenderingAlreadySet)
            {
                ChkRendering newRendering = new ChkRendering();
                owningChkTerm.RenderingsOC.Add(newRendering);
                newRendering.SurfaceFormRAHvo = wordForm.Hvo;
            }
        }
Esempio n. 2
0
		public void UpgradeWhenExistingListHasRenderings()
		{
			CheckDisposed();

			ILangProject lp = m_fdoCache.LangProject;

			IWfiWordform abc = lp.WordformInventoryOA.AddRealWordform("abc", lp.DefaultVernacularWritingSystem);
			IWfiWordform def = lp.WordformInventoryOA.AddRealWordform("def", lp.DefaultVernacularWritingSystem);
			IWfiWordform ghi = lp.WordformInventoryOA.AddRealWordform("ghi", lp.DefaultVernacularWritingSystem);

			ICmPossibilityList oldKeyTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(oldKeyTermsList);
			ChkTerm term = new ChkTerm();
			oldKeyTermsList.PossibilitiesOS.Append(term);
			term.Name.SetAlternative("Abba", m_wsEn);
			term.Description.SetAlternative("Daddy", m_wsEn);
			AddOccurrenceToOldStyleSense(term, 41014036, abc, "abba", KeyTermRenderingStatus.Assigned);
			AddOccurrenceToOldStyleSense(term, 45008015, abc, "abba", KeyTermRenderingStatus.AutoAssigned);
			AddOccurrenceToOldStyleSense(term, 48004006, null, "abba"); // Not rendered
			AddOccurrenceToOldStyleSense(term, 48004007, abc, "abba"); // This one is not in new list

			term = new ChkTerm();
			oldKeyTermsList.PossibilitiesOS.Append(term);
			term.Name.SetAlternative("Angel", m_wsEn);
			ChkTerm subsense = new ChkTerm();
			term.SubPossibilitiesOS.Append(subsense);
			subsense.Name.SetAlternative("Heavenly being", m_wsEn);
			subsense.Description.SetAlternative("Supernatural being sent as a messenger from God", m_wsEn);
			AddOccurrenceToOldStyleSense(subsense, 040001020, def, "aggelos");
			AddOccurrenceToOldStyleSense(subsense, 040001024, ghi, "aggelos");
			AddOccurrenceToOldStyleSense(subsense, 040002013, null, "aggelos", KeyTermRenderingStatus.Ignored);

			subsense = new ChkTerm();
			term.SubPossibilitiesOS.Append(subsense);
			subsense.Name.SetAlternative("Demon", m_wsEn);
			subsense.Description.SetAlternative("A fallen angel", m_wsEn);
			AddOccurrenceToOldStyleSense(subsense, 040007022, null, "daimonion");

			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = Guid.NewGuid();
			terms.KeyTerms = new List<Term>();
			terms.KeyTerms.Add(new Term(3, "KT", "\u03b1\u03b2\u03b2\u03b1", "Greek",
				"abba; father", null, null, 4101403603, 4500801516, 4800400618));
			terms.KeyTerms.Add(new Term(21, "KT", "\u1F04\u03B3\u03B3\u03B5\u03BB\u03BF\u03C2", "Greek",
				"angel", null, null, 04000102006, 04000102413, 04000201305));
			terms.KeyTerms.Add(new Term(363, "KT", "\u03B4\u03B1\u03B9\u03BC\u1F79\u03BD\u03B9\u03BF\u03BD-1",
				"Greek", "demon", "\u03B4\u03B1\u03B9\u03BC\u1F79\u03BD\u03B9\u03BF\u03BD",
				"\u03B4\u03B1\u03B9\u03BC\u03BF\u03BD\u1F77\u03B6\u03BF\u03BC\u03B1\u03B9, \u03B4\u03B1\u03B9\u03BC\u03BF\u03BD\u03B9\u1F7D\u03B4\u03B7\u03C2, \u03B4\u03B1\u1F77\u03BC\u03C9\u03BD",
				04000702219));

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(1);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(1);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("KT", "Key terms"));
			loc.Terms.Add(new TermLocalization(3, "abba; father", "title for God, literally dad"));
			localizations.Add(loc);

			// Load the terms
			ICmPossibilityList newChkTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(newChkTermsList);
			DummyTeKeyTermsInit.CallLoadKeyTerms(oldKeyTermsList, newChkTermsList, terms,
				localizations);

			int wsGreek = m_wsf.GetWsFromStr("grc");

			// Make sure the old list has been blown away
			// We can't do this now because we delete the list asynchronously
			// Assert.IsFalse(oldKeyTermsList.IsValidObject());
			oldKeyTermsList = null;

			// Make sure there is one category (possibility) in the new list
			ICmPossibility ktCategory = newChkTermsList.PossibilitiesOS[0];
			Assert.AreEqual("KT", ktCategory.Abbreviation.GetAlternative(m_wsEn));

			// Make sure there are three keyterms in that category
			Assert.AreEqual(3, ktCategory.SubPossibilitiesOS.Count);

			// Check the ChkTerm and ChkRefs for "abba"
			IChkTerm keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(3, keyterm.TermId);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", keyterm.Name.GetAlternative(wsGreek));
			Assert.AreEqual("abba", keyterm.Name.GetAlternative(m_wsEn));
			Assert.AreEqual("title for God, literally dad",
				keyterm.Description.GetAlternative(m_wsEn).Text);
			Assert.AreEqual("father", keyterm.SeeAlso.GetAlternative(m_wsEn));
			Assert.AreEqual(1, keyterm.RenderingsOC.Count);
			ChkRendering abbaRendering = new ChkRendering(m_fdoCache, keyterm.RenderingsOC.HvoArray[0]);
			Assert.AreEqual(abc, abbaRendering.SurfaceFormRA);
			Assert.AreEqual(3, keyterm.OccurrencesOS.Count, "There should be 3 references for abba");
			Assert.AreEqual(KeyTermRenderingStatus.Assigned, keyterm.OccurrencesOS[0].Status);
			Assert.AreEqual(abc, keyterm.OccurrencesOS[0].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.AutoAssigned, keyterm.OccurrencesOS[1].Status);
			Assert.AreEqual(abc, keyterm.OccurrencesOS[1].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[2].Status);
			Assert.AreEqual(0, keyterm.OccurrencesOS[2].RenderingRAHvo);

			// Check the ChkRefs for "angel"
			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[1];
			Assert.AreEqual(21, keyterm.TermId);
			Assert.AreEqual(2, keyterm.RenderingsOC.Count);
			bool fFoundDEF = false;
			bool fFoundGHI = false;
			foreach (IChkRendering rendering in keyterm.RenderingsOC)
			{
				fFoundDEF |= (rendering.SurfaceFormRAHvo == def.Hvo);
				fFoundGHI |= (rendering.SurfaceFormRAHvo == ghi.Hvo);
			}
			Assert.IsTrue(fFoundDEF);
			Assert.IsTrue(fFoundGHI);
			Assert.AreEqual(3, keyterm.OccurrencesOS.Count);
			Assert.AreEqual(KeyTermRenderingStatus.Assigned, keyterm.OccurrencesOS[0].Status);
			Assert.AreEqual(def, keyterm.OccurrencesOS[0].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Assigned, keyterm.OccurrencesOS[1].Status);
			Assert.AreEqual(ghi, keyterm.OccurrencesOS[1].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Ignored, keyterm.OccurrencesOS[2].Status);
			Assert.IsNull(keyterm.OccurrencesOS[2].RenderingRA);

			// Check the ChkRefs for "demon"
			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[2];
			Assert.AreEqual(363, keyterm.TermId);
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);
			Assert.AreEqual(1, keyterm.OccurrencesOS.Count);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[0].Status);
			Assert.AreEqual(0, keyterm.OccurrencesOS[0].RenderingRAHvo);
		}
Esempio n. 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Assigns a rendering for this check reference.
		/// </summary>
		/// <param name="wordForm">The word form.</param>
		/// ------------------------------------------------------------------------------------
		internal void AssignRendering(IWfiWordform wordForm)
		{
			RenderingStatus = KeyTermRenderingStatus.Assigned;
			RenderingRA = wordForm;

			ChkTerm owningChkTerm = new ChkTerm(Cache, OwnerHVO);
			bool fChkTermRenderingAlreadySet = false;
			foreach (IChkRendering rendering in owningChkTerm.RenderingsOC)
			{
				if (rendering.SurfaceFormRAHvo == wordForm.Hvo)
				{
					fChkTermRenderingAlreadySet = true;
					break;
				}
			}
			if (!fChkTermRenderingAlreadySet)
			{
				ChkRendering newRendering = new ChkRendering();
				owningChkTerm.RenderingsOC.Add(newRendering);
				newRendering.SurfaceFormRAHvo = wordForm.Hvo;
			}
		}