Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="output"></param>
        /// <param name="labelName"></param>
        /// <param name="fieldName"></param>
        /// <param name="customFieldId"></param>
        /// <param name="className"></param>
        protected void ReplaceParamsInAttributes(XmlNode output, string labelName, string fieldName, int customFieldId, string className)
        {
            SetupWsParams(output, customFieldId);
            ReplaceSubstringInAttr visitorFn = new ReplaceSubstringInAttr("$fieldName", fieldName);

            XmlUtils.VisitAttributes(output, visitorFn);
            AppendClassAttribute(output, fieldName, className);
            ReplaceSubstringInAttr visitorLab = new ReplaceSubstringInAttr("$label", labelName);

            XmlUtils.VisitAttributes(output, visitorLab);
            if (customFieldId != 0 && m_mdc is IFwMetaDataCacheManaged)
            {
                IFwMetaDataCacheManaged mdc = m_mdc as IFwMetaDataCacheManaged;
                if (mdc.IsCustom(customFieldId) && mdc.GetDstClsId(customFieldId) != 0)
                {
                    Guid guidList = (m_mdc as IFwMetaDataCacheManaged).GetFieldListRoot(customFieldId);
                    if (guidList != Guid.Empty)
                    {
                        string             targetList;
                        ICmPossibilityList list = m_cache.ServiceLocator.GetInstance <ICmPossibilityListRepository>().GetObject(guidList);
                        if (list.Owner != null)
                        {
                            targetList = String.Format("{0}.{1}", list.Owner.ClassName, mdc.GetFieldName(list.OwningFlid));
                        }
                        else
                        {
                            targetList = String.Format("unowned.{0}", guidList.ToString());
                        }
                        ReplaceSubstringInAttr visitorTarg = new ReplaceSubstringInAttr("$targetList", targetList);
                        XmlUtils.VisitAttributes(output, visitorTarg);
                    }
                }
            }
        }
        public void DataMigration7000032Test()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000033.xml");

            IFwMetaDataCacheManaged mockMdc = DataMigrationTests7000020.SetupMdc();

            IDomainObjectDTORepository repoDto = new DomainObjectDtoRepository(7000032, dtos, mockMdc,
                                                                               Path.GetTempPath(), TestDirectoryFinder.LcmDirectories);

            var projectFolder = repoDto.ProjectFolder;
            // This is equivalent to DirectoryFinder.GetConfigSettingsDir(projectFolder) at the time of creating
            // the migration, but could conceivably change later.
            var targetDir = Path.Combine(projectFolder, "ConfigurationSettings");

            Directory.CreateDirectory(targetDir);
            var testFilePath = Path.Combine(targetDir, "LexEntry_Layouts.xml");

            using (var writer = new StreamWriter(testFilePath))
            {
                writer.WriteLine(@"<LayoutInventory>" +
                                 "<layout class='LexEntry' type='jtview' name='publishStemPara' css='$fwstyle=Dictionary-Normal' version='9'>" +
                                 " <part ref='Headword' label='Headword' before='' sep=' ' after='  ' ws='vernacular' wsType='vernacular' style='Dictionary-Headword' css='headword' visibility='ifdata' comment='Headword is a smart field. It is the lexeme form unless there is a citation form. Includes Homograph number and affix marking.' />" +
                                 " <part ref='$child' label='testYYY' before='' after=' ' visibility='ifdata' ws='$ws=analysis' wsType='analysis vernacular' sep=' ' showLabels='false'>" +
                                 "   <configureMlString field='custom' class='LexEntry' />" +
                                 " </part>" +
                                 "<part ref='$child' label='TestXXX' before='' after=' ' visibility='ifdata'>" +
                                 " <string field='custom1' class='LexEntry' />" +
                                 "</part>" +
                                 " <part ref='$child' label='messed up' before='' after=' ' visibility='ifdata' ws='$ws=analysis' wsType='analysis vernacular' sep=' ' showLabels='false' originalLabel='testBB'>" +
                                 "   <configureMlString field='custom' class='LexEntry' />" +
                                 " </part>" +
                                 "<part ref='$child' label='modified' before='' after=' ' visibility='ifdata' originalLabel='TestZZZ'>" +
                                 " <string field='custom1' class='LexEntry' />" +
                                 "</part>" +
                                 " <part ref='$child' before='' after=' ' visibility='ifdata' ws='$ws=analysis' wsType='analysis vernacular' sep=' ' showLabels='false' originalLabel='testCC'>" +
                                 "   <configureMlString field='custom' class='LexEntry' />" +
                                 " </part>" +
                                 "<part ref='$child' before='' after=' ' visibility='ifdata' originalLabel='TestD'>" +
                                 " <string field='custom1' class='LexEntry' />" +
                                 "</part>" +
                                 "</layout>" +
                                 "</LayoutInventory>");
                writer.Close();
            }

            // Do the migration.
            m_dataMigrationManager.PerformMigration(repoDto, 7000033, new DummyProgressDlg());

            Assert.AreEqual(7000033, repoDto.CurrentModelVersion, "Wrong updated version.");
            var root     = XElement.Load(testFilePath);         // layout inventory node
            var layout   = root.Elements().ToList()[0];
            var children = layout.Elements().ToList();

            VerifyChild(children[1], "testYYY");
            VerifyChild(children[2], "TestXXX");
            VerifyChild(children[3], "testBB");
            VerifyChild(children[4], "TestZZZ");
            VerifyChild(children[5], "testCC");
            VerifyChild(children[6], "TestD");
        }
Esempio n. 3
0
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Gives the CSharp interface type for the factory that creates objects of the specified class.
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        internal static Type GetFactoryTypeFromFWClassID(IFwMetaDataCacheManaged mdc, int classId)
        {
            // Abstract classes have no factory.
            if (mdc.GetAbstract(classId))
            {
                throw new ArgumentException("No factory for abstract classes", "classId");
            }

            // if the class ID is cached then return the type now.
            Type result;

            if (s_classIdToFactType.TryGetValue(classId, out result))
            {
                return(result);
            }

            // Find the class name of this object
            var sClassName = mdc.GetClassName(classId);
            // find the Type for the factory for this class.
            var fullTypeName = string.Format("SIL.FieldWorks.FDO.I{0}Factory", sClassName);

            result = Assembly.GetExecutingAssembly().GetType(fullTypeName, true);
            s_classIdToFactType.Add(classId, result);             // Store for next time.
            return(result);
        }
 public ConvertMongoToFdoCustomField(FdoCache cache, ILogger logger)
 {
     this.cache = cache;
     servLoc = cache.ServiceLocator;
     fdoMetaData = (IFwMetaDataCacheManaged)cache.MetaDataCacheAccessor;
     this.logger = logger;
 }
 public ConvertMongoToLcmCustomField(LcmCache cache, FwServiceLocatorCache serviceLocator, ILogger logger, int wsEn)
 {
     this.cache       = cache;
     this.servLoc     = serviceLocator;
     this.lcmMetaData = (IFwMetaDataCacheManaged)cache.MetaDataCacheAccessor;
     this.logger      = logger;
     this.wsEn        = wsEn;
 }
Esempio n. 6
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="CopyObject&lt;TTopLevel&gt;"/> class.
 /// </summary>
 /// <param name="cache">The cache.</param>
 /// <param name="topLevelOwnerFunct">The delegate used for adding the created object to
 /// an owner.</param>
 /// ------------------------------------------------------------------------------------
 private CopyObject(FdoCache cache, CopiedOwner <TTopLevel> topLevelOwnerFunct)
 {
     m_cache              = cache;
     m_servLoc            = m_cache.ServiceLocator;
     m_sda                = m_cache.DomainDataByFlid;
     m_mdc                = m_cache.ServiceLocator.GetInstance <IFwMetaDataCacheManaged>();
     m_topLevelOwnerFunct = topLevelOwnerFunct;
 }
Esempio n. 7
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="metaDataCache">The FDO FdoMetaDataCache implementation,
        /// which is used to get the basic FDO data.</param>
        /// <remarks>
        /// The hvo values are true 'handles' in that they are valid for one session,
        /// but may not be the same integer for another session for the 'same' object.
        /// Therefore, one should not use them for multi-session identity.
        /// CmObject identity can only be guaranteed by using their Guids (or using '==' in code).
        /// </remarks>
        protected FdoMetaDataCacheDecoratorBase(IFwMetaDataCacheManaged metaDataCache)
        {
            if (metaDataCache == null)
            {
                throw new ArgumentNullException("metaDataCache");
            }

            m_metaDataCache = metaDataCache;
        }
		public void FixtureSetup()
		{
			var mockMDC = new MockMDCForDataMigration();
			// Set it up for CmObject, LangProject, LexDb, and LexEntry.
			var clsid = 0;
			mockMDC.AddClass(++clsid, "CmObject", null, new List<string> { "LangProject", "LexDb", "LexEntry" });
			mockMDC.AddClass(++clsid, "LangProject", "CmObject", new List<string>());
			mockMDC.AddClass(++clsid, "LexDb", "CmObject", new List<string>());
			mockMDC.AddClass(++clsid, "LexEntry", "CmObject", new List<string>());

			m_mdc = mockMDC;
		}
Esempio n. 9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:FdoInspectorList"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public FdoInspectorList(FdoCache cache)
		{
			m_cache = cache;
			m_mdc = m_cache.ServiceLocator.GetInstance<IFwMetaDataCacheManaged>();
			m_fldSuffix = new Dictionary<CellarPropertyType, string>();
			m_fldSuffix[CellarPropertyType.OwningCollection] = "OC";
			m_fldSuffix[CellarPropertyType.OwningSequence] = "OS";
			m_fldSuffix[CellarPropertyType.ReferenceCollection] = "RC";
			m_fldSuffix[CellarPropertyType.ReferenceSequence] = "RS";
			m_fldSuffix[CellarPropertyType.OwningAtomic] = "OA";
			m_fldSuffix[CellarPropertyType.ReferenceAtomic] = "RA";
		}
Esempio n. 10
0
 /// <summary>
 /// Constructor
 /// </summary>
 internal LoadingServices(IDataSetup dataSetup, ICmObjectIdFactory objIdFactory,
                          IFwMetaDataCacheManaged mdcManaged, ILgWritingSystemFactory wsf, IUnitOfWorkService uowService,
                          ICmObjectSurrogateRepository surrRepository, ICmObjectRepository cmObjRepository)
 {
     m_dataSetup       = dataSetup;
     m_objIdFactory    = objIdFactory;
     m_mdcManaged      = mdcManaged;
     m_wsf             = wsf;
     m_uowService      = uowService;
     m_surrRepository  = surrRepository;
     m_cmObjRepository = cmObjRepository;
 }
Esempio n. 11
0
        /// <summary>
        /// Constructor
        /// </summary>
        internal IdentityMap(IFwMetaDataCacheManaged mdc)
        {
            if (mdc == null)
            {
                throw new ArgumentNullException("mdc");
            }

            m_mdc = mdc;
            foreach (var clsid in mdc.GetClassIds())
            {
                m_clsid2Surrogates.Add(clsid, new HashSet <ICmObjectOrSurrogate>(new ObjectSurrogateEquater()));
            }
        }
Esempio n. 12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ModelWnd"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ModelWnd()
        {
            InitializeComponent();

            m_tvModel.Font = SystemFonts.MenuFont;
            m_lvModel.Font = SystemFonts.MenuFont;

            // Add model browsing cache (no data, just model browsing).
            m_cache = LcmCache.CreateCacheWithNoLangProj(new BrowserProjectId(BackendProviderType.kMemoryOnly, null), "en",
                                                         new SilentLcmUI(this), FwDirectoryFinder.LcmDirectories, new LcmSettings());
            m_mdc = (IFwMetaDataCacheManaged)m_cache.MainCacheAccessor.MetaDataCache;
            PopulateModelTree();

            if (Properties.Settings.Default.ModelWndSplitterLocation > 0)
            {
                m_splitter.SplitterDistance = Properties.Settings.Default.ModelWndSplitterLocation;
            }

            if (Properties.Settings.Default.ModelWndCol0Width > 0)
            {
                m_hdrImplementor.Width = Properties.Settings.Default.ModelWndCol0Width;
            }

            if (Properties.Settings.Default.ModelWndCol1Width > 0)
            {
                m_hdrId.Width = Properties.Settings.Default.ModelWndCol1Width;
            }

            if (Properties.Settings.Default.ModelWndCol2Width > 0)
            {
                m_hdrName.Width = Properties.Settings.Default.ModelWndCol2Width;
            }

            if (Properties.Settings.Default.ModelWndCol3Width > 0)
            {
                m_hdrType.Width = Properties.Settings.Default.ModelWndCol3Width;
            }

            if (Properties.Settings.Default.ModelWndCol4Width > 0)
            {
                m_hdrSig.Width = Properties.Settings.Default.ModelWndCol4Width;
            }

            m_hdrImplementor.Tag = true;
            m_hdrId.Tag          = true;
            m_hdrName.Tag        = true;
            m_hdrSig.Tag         = true;
            m_hdrType.Tag        = true;
        }
        public void FixtureSetup()
        {
            var mockMDC = new MockMDCForDataMigration();
            // Set it up for CmObject, LangProject, LexDb, and LexEntry.
            var clsid = 0;

            mockMDC.AddClass(++clsid, "CmObject", null, new List <string> {
                "LangProject", "LexDb", "LexEntry"
            });
            mockMDC.AddClass(++clsid, "LangProject", "CmObject", new List <string>());
            mockMDC.AddClass(++clsid, "LexDb", "CmObject", new List <string>());
            mockMDC.AddClass(++clsid, "LexEntry", "CmObject", new List <string>());

            m_mdc = mockMDC;
        }
Esempio n. 14
0
		/// ----------------------------------------------------------------------------------------
		/// <summary>
		/// Gives the CSharp interface type for the repository that creates objects of the specified class.
		/// </summary>
		/// ----------------------------------------------------------------------------------------
		internal static Type GetRepositoryTypeFromFWClassID(IFwMetaDataCacheManaged mdc, int classId)
		{
			// if the class ID is cached then return the type now.
			Type result;
			if (s_classIdToRepoType.TryGetValue(classId, out result))
				return result;

			// Find the class name of this object
			var sClassName = mdc.GetClassName(classId);
			// find the Type for the repository for this class.
			var fullTypeName = string.Format("SIL.FieldWorks.FDO.I{0}Repository", sClassName);
			result = Assembly.GetExecutingAssembly().GetType(fullTypeName, true);
			s_classIdToRepoType.Add(classId, result); // Store for next time.
			return result;
		}
Esempio n. 15
0
		public LiftExporter(FdoCache cache)
		{
			m_cache = cache;
			m_mdc = cache.MetaDataCacheAccessor as IFwMetaDataCacheManaged;
			Debug.Assert(m_mdc != null);
			m_sda = m_cache.DomainDataByFlid as ISilDataAccessManaged;
			Debug.Assert(m_sda != null);
			m_repoCmPossibilityLists = m_cache.ServiceLocator.GetInstance<ICmPossibilityListRepository>();

			m_wsEn = cache.WritingSystemFactory.GetWsFromStr("en");
			if (m_wsEn == 0)
				m_wsEn = cache.DefaultUserWs;
			m_wsManager = cache.ServiceLocator.WritingSystemManager;
			m_wsBestAnalVern = (int)SpecialWritingSystemCodes.BestAnalysisOrVernacular;
		}
Esempio n. 16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Import a file (encapsulated by a TextReader) containing translations for one or more lists.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool ImportTranslatedLists(TextReader reader, FdoCache cache, IProgress progress)
		{
			m_cache = cache;
			m_mdc = cache.ServiceLocator.GetInstance<IFwMetaDataCacheManaged>();
			m_rgItemClasses = m_mdc.GetAllSubclasses(CmPossibilityTags.kClassId);
			m_wsf = cache.WritingSystemFactory;
			m_wsEn = GetWsFromStr("en");
			Debug.Assert(m_wsEn != 0);
			m_progress = progress;

			using (var xreader = XmlReader.Create(reader))
				Import(xreader);

			return true;
		}
Esempio n. 17
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Import a file (encapsulated by a TextReader) containing translations for one or more lists.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool ImportTranslatedLists(TextReader reader, FdoCache cache, IProgress progress)
        {
            m_cache         = cache;
            m_mdc           = cache.ServiceLocator.GetInstance <IFwMetaDataCacheManaged>();
            m_rgItemClasses = m_mdc.GetAllSubclasses(CmPossibilityTags.kClassId);
            m_wsf           = cache.WritingSystemFactory;
            m_wsEn          = GetWsFromStr("en");
            Debug.Assert(m_wsEn != 0);
            m_progress = progress;

            using (var xreader = XmlReader.Create(reader))
                Import(xreader);

            return(true);
        }
Esempio n. 18
0
		/// <summary>
		/// Constructor. Called by service locator factory (by reflection).
		/// </summary>
		/// <remarks>
		/// The hvo values are true 'handles' in that they are valid for one session,
		/// but may not be the same integer for another session for the 'same' object.
		/// Therefore, one should not use them for multi-session identity.
		/// CmObject identity can only be guaranteed by using their Guids (or using '==' in code).
		/// </remarks>
		internal DomainDataByFlid(ICmObjectRepository cmObjectRepository, IStTextRepository stTxtRepository,
			IFwMetaDataCacheManaged mdc, ISilDataAccessHelperInternal uowService,
			ITsStrFactory tsf, ILgWritingSystemFactory wsf)
		{
			if (cmObjectRepository == null) throw new ArgumentNullException("cmObjectRepository");
			if (stTxtRepository == null) throw new ArgumentNullException("stTxtRepository");
			if (mdc == null) throw new ArgumentNullException("mdc");
			if (uowService == null) throw new ArgumentNullException("uowService");
			if (tsf == null) throw new ArgumentNullException("tsf");
			if (wsf == null) throw new ArgumentNullException("wsf");

			m_cmObjectRepository = cmObjectRepository;
			m_stTxtRepository = stTxtRepository;
			m_mdc = mdc;
			m_uowService = uowService;
			m_tsf = tsf;
			m_wsf = wsf;
		}
Esempio n. 19
0
		/// ----------------------------------------------------------------------------------------
		/// <summary>
		/// Gives the CSharp interface type for the factory that creates objects of the specified class.
		/// </summary>
		/// ----------------------------------------------------------------------------------------
		internal static Type GetFactoryTypeFromFWClassID(IFwMetaDataCacheManaged mdc, int classId)
		{
			// Abstract classes have no factory.
			if (mdc.GetAbstract(classId))
				throw new ArgumentException("No factory for abstract classes", "classId");

			// if the class ID is cached then return the type now.
			Type result;
			if (s_classIdToFactType.TryGetValue(classId, out result))
				return result;

			// Find the class name of this object
			var sClassName = mdc.GetClassName(classId);
			// find the Type for the factory for this class.
			var fullTypeName = string.Format("SIL.FieldWorks.FDO.I{0}Factory", sClassName);
			result = Assembly.GetExecutingAssembly().GetType(fullTypeName, true);
			s_classIdToFactType.Add(classId, result); // Store for next time.
			return result;
		}
Esempio n. 20
0
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Gives the CSharp interface type for the repository that creates objects of the specified class.
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        internal static Type GetRepositoryTypeFromFWClassID(IFwMetaDataCacheManaged mdc, int classId)
        {
            // if the class ID is cached then return the type now.
            Type result;

            if (s_classIdToRepoType.TryGetValue(classId, out result))
            {
                return(result);
            }

            // Find the class name of this object
            var sClassName = mdc.GetClassName(classId);
            // find the Type for the repository for this class.
            var fullTypeName = string.Format("SIL.FieldWorks.FDO.I{0}Repository", sClassName);

            result = Assembly.GetExecutingAssembly().GetType(fullTypeName, true);
            s_classIdToRepoType.Add(classId, result);             // Store for next time.
            return(result);
        }
Esempio n. 21
0
        public void Initialize(FdoCache cache, IHelpTopicProvider helpTopicProvider, IApp app,
                               NotebookImportWiz.RnSfMarker rsf, Sfm2Xml.SfmFile sfmFile,
                               Dictionary <int, string> mapFlidName, IVwStylesheet stylesheet,
                               Mediator mediator)
        {
            m_cache             = cache;
            m_helpTopicProvider = helpTopicProvider;
            m_app         = app;
            m_rsfm        = rsf;
            m_sfmFile     = sfmFile;
            m_stylesheet  = stylesheet;
            m_mdc         = cache.ServiceLocator.GetInstance <IFwMetaDataCacheManaged>();
            m_mediator    = mediator;
            m_mapFlidName = mapFlidName;

            FillInFieldList();
            FillInContentsPane(rsf, sfmFile);
            SetSubControl();
        }
        public void DataMigration7000020Test()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000020.xml");

            IFwMetaDataCacheManaged mockMdc = SetupMdc();

            IDomainObjectDTORepository repoDto = new DomainObjectDtoRepository(7000019, dtos, mockMdc,
                                                                               Path.GetTempPath());

            // Initial check that data was read properly.
            var cObjects = repoDto.AllInstances().Count();

            Assert.AreEqual(378, cObjects, "Before migrating, should be 378 objects");
            var cLangProject = repoDto.AllInstancesSansSubclasses("LangProject").Count();

            Assert.AreEqual(1, cLangProject, "Before migrating, should be 1 LangProject object");
            var cUserView = repoDto.AllInstancesSansSubclasses("UserView").Count();

            Assert.AreEqual(17, cUserView, "Before migrating, should be 17 UserView objects");
            var cUserViewRec = repoDto.AllInstancesSansSubclasses("UserViewRec").Count();

            Assert.AreEqual(31, cUserViewRec, "Before migrating, should be 31 UserViewRec objects");
            var cUserViewField = repoDto.AllInstancesSansSubclasses("UserViewField").Count();

            Assert.AreEqual(329, cUserViewField, "Before migrating, should be 329 UserViewField objects");

            // Do the migration.
            m_dataMigrationManager.PerformMigration(repoDto, 7000020, new DummyProgressDlg());

            // Verification Phase
            Assert.AreEqual(7000020, repoDto.CurrentModelVersion, "Wrong updated version.");
            cObjects = repoDto.AllInstances().Count();
            Assert.AreEqual(31, cObjects, "After migrating, should be 31 objects");
            cLangProject = repoDto.AllInstancesSansSubclasses("LangProject").Count();
            Assert.AreEqual(1, cLangProject, "After migrating, should be 1 LangProject object");
            cUserView = repoDto.AllInstancesSansSubclasses("UserView").Count();
            Assert.AreEqual(12, cUserView, "After migrating, should be 12 UserView objects");
            cUserViewRec = repoDto.AllInstancesSansSubclasses("UserViewRec").Count();
            Assert.AreEqual(3, cUserViewRec, "After migrating, should be 3 UserViewRec objects");
            cUserViewField = repoDto.AllInstancesSansSubclasses("UserViewField").Count();
            Assert.AreEqual(15, cUserViewField, "After migrating, should be 15 UserViewField objects");
        }
Esempio n. 23
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Loads the list of all FDO class names from the meta data cache.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private static void LoadFDOClassNames()
        {
            if (s_allFDOClassNames != null)
            {
                return;
            }

            using (FdoCache cache = FdoCache.CreateCacheWithNoLangProj(new BrowserProjectId(FDOBackendProviderType.kMemoryOnly, null), "en", null))
            {
                IFwMetaDataCacheManaged mdc = (IFwMetaDataCacheManaged)cache.MainCacheAccessor.MetaDataCache;
                s_allFDOClassNames = new List <string>();

                foreach (int clsid in mdc.GetClassIds())
                {
                    s_allFDOClassNames.Add(mdc.GetClassName(clsid));
                }

                s_allFDOClassNames.Sort((x, y) => x.CompareTo(y));
            }
        }
Esempio n. 24
0
        public ConvertLcmToMongoCustomField(LcmCache cache, FwServiceLocatorCache serviceLocator, ILogger logger)
        {
            this.cache       = cache;
            this.servLoc     = serviceLocator;
            this.LcmMetaData = (IFwMetaDataCacheManaged)cache.MetaDataCacheAccessor;
            this.logger      = logger;
            _wsEn            = servLoc.WritingSystemFactory.GetWsFromStr("en");

            GuidToListCode = new Dictionary <Guid, string>
            {
                { servLoc.LanguageProject.LexDbOA.DomainTypesOA.Guid, MagicStrings.LfOptionListCodeForAcademicDomainTypes },
                { servLoc.LanguageProject.AnthroListOA.Guid, MagicStrings.LfOptionListCodeForAnthropologyCodes },
                { servLoc.LanguageProject.PartsOfSpeechOA.Guid, MagicStrings.LfOptionListCodeForGrammaticalInfo },
                { servLoc.LanguageProject.LocationsOA.Guid, MagicStrings.LfOptionListCodeForLocations },
                { servLoc.LanguageProject.SemanticDomainListOA.Guid, MagicStrings.LfOptionListCodeForSemanticDomains },
                { servLoc.LanguageProject.LexDbOA.SenseTypesOA.Guid, MagicStrings.LfOptionListCodeForSenseTypes },
                { servLoc.LanguageProject.StatusOA.Guid, MagicStrings.LfOptionListCodeForStatus },
                { servLoc.LanguageProject.LexDbOA.UsageTypesOA.Guid, MagicStrings.LfOptionListCodeForUsageTypes }
            };
        }
        public ConvertFdoToMongoCustomField(FdoCache cache, ILogger logger)
        {
            this.cache = cache;
            fdoMetaData = (IFwMetaDataCacheManaged)cache.MetaDataCacheAccessor;
            this.logger = logger;
            _wsEn = cache.WritingSystemFactory.GetWsFromStr("en");

            GuidToListCode = new Dictionary<Guid, string>
            {
                {cache.LanguageProject.LexDbOA.DomainTypesOA.Guid, MagicStrings.LfOptionListCodeForAcademicDomainTypes},
                {cache.LanguageProject.AnthroListOA.Guid, MagicStrings.LfOptionListCodeForAnthropologyCodes},
                {cache.LanguageProject.LexDbOA.PublicationTypesOA.Guid, MagicStrings.LfOptionListCodeForDoNotPublishIn},
                {cache.LanguageProject.PartsOfSpeechOA.Guid, MagicStrings.LfOptionListCodeForGrammaticalInfo},
                {cache.LanguageProject.LocationsOA.Guid, MagicStrings.LfOptionListCodeForLocations},
                {cache.LanguageProject.SemanticDomainListOA.Guid, MagicStrings.LfOptionListCodeForSemanticDomains},
                {cache.LanguageProject.LexDbOA.SenseTypesOA.Guid, MagicStrings.LfOptionListCodeForSenseTypes},
                {cache.LanguageProject.StatusOA.Guid, MagicStrings.LfOptionListCodeForStatus},
                {cache.LanguageProject.LexDbOA.UsageTypesOA.Guid, MagicStrings.LfOptionListCodeForUsageTypes}
            };
            _fieldNameToFieldType = new Dictionary<string, string>();
        }
Esempio n. 26
0
        private void ExportRecords(TextWriter writer, IProgress progress)
        {
            m_mdc = m_cache.ServiceLocator.GetInstance <IFwMetaDataCacheManaged>();
            foreach (int flid in m_mdc.GetFields(RnGenericRecTags.kClassId, true,
                                                 (int)CellarPropertyTypeFilter.All))
            {
                if (m_mdc.IsCustom(flid))
                {
                    m_customFlids.Add(flid);
                }
            }


            writer.WriteLine("<Entries docRightToLeft=\"{0}\">",
                             m_fRightToLeft ? "true" : "false");
            foreach (var record in m_cache.LangProject.ResearchNotebookOA.RecordsOC)
            {
                ExportRecord(writer, record, 0);
                progress.Step(1);
            }
            writer.WriteLine("</Entries>");
        }
Esempio n. 27
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Loads the list of all FDO class names from the meta data cache.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private static void LoadFDOClassNames()
        {
            if (s_allLCMClassNames != null)
            {
                return;
            }

            using (var threadHelper = new ThreadHelper())
                using (LcmCache cache = LcmCache.CreateCacheWithNoLangProj(new BrowserProjectId(BackendProviderType.kMemoryOnly, null), "en",
                                                                           new SilentLcmUI(threadHelper), FwDirectoryFinder.LcmDirectories, new LcmSettings()))
                {
                    IFwMetaDataCacheManaged mdc = (IFwMetaDataCacheManaged)cache.MainCacheAccessor.MetaDataCache;
                    s_allLCMClassNames = new List <string>();

                    foreach (int clsid in mdc.GetClassIds())
                    {
                        s_allLCMClassNames.Add(mdc.GetClassName(clsid));
                    }

                    s_allLCMClassNames.Sort((x, y) => x.CompareTo(y));
                }
        }
Esempio n. 28
0
		public ModelWnd()
		{
			InitializeComponent();

			m_tvModel.Font = SystemFonts.MenuFont;
			m_lvModel.Font = SystemFonts.MenuFont;

			// Add model browsing cache (no data, just model browsing).
			m_cache = FdoCache.CreateCacheWithNoLangProj(new BrowserProjectId(FDOBackendProviderType.kMemoryOnly, null), "en", new SilentFdoUI(this), FwDirectoryFinder.FdoDirectories, new FdoSettings());
			m_mdc = (IFwMetaDataCacheManaged)m_cache.MainCacheAccessor.MetaDataCache;
			PopulateModelTree();

			if (Properties.Settings.Default.ModelWndSplitterLocation > 0)
				m_splitter.SplitterDistance = Properties.Settings.Default.ModelWndSplitterLocation;

			if (Properties.Settings.Default.ModelWndCol0Width > 0)
				m_hdrImplementor.Width = Properties.Settings.Default.ModelWndCol0Width;

			if (Properties.Settings.Default.ModelWndCol1Width > 0)
				m_hdrId.Width = Properties.Settings.Default.ModelWndCol1Width;

			if (Properties.Settings.Default.ModelWndCol2Width > 0)
				m_hdrName.Width = Properties.Settings.Default.ModelWndCol2Width;

			if (Properties.Settings.Default.ModelWndCol3Width > 0)
				m_hdrType.Width = Properties.Settings.Default.ModelWndCol3Width;

			if (Properties.Settings.Default.ModelWndCol4Width > 0)
				m_hdrSig.Width = Properties.Settings.Default.ModelWndCol4Width;

			m_hdrImplementor.Tag = true;
			m_hdrId.Tag = true;
			m_hdrName.Tag = true;
			m_hdrSig.Tag = true;
			m_hdrType.Tag = true;
		}
Esempio n. 29
0
        /// <summary>
        /// Get the field values as a dict, keyed by field ID, for any CmObject.
        /// </summary>
        /// <returns>A dictionary with integer field ID mapped to values.</returns>
        /// <param name="cache">LCM cache the object lives in.</param>
        /// <param name="obj">Object whose fields we're getting.</param>
        protected IDictionary <int, object> GetFieldValues(LcmCache cache, ICmObject obj)
        {
            IFwMetaDataCacheManaged mdc  = cache.ServiceLocator.MetaDataCache;
            ISilDataAccess          data = cache.DomainDataByFlid;

            int[] fieldIds    = mdc.GetFields(obj.ClassID, false, (int)CellarPropertyTypeFilter.All);
            var   fieldValues = new Dictionary <int, object>();

            foreach (int flid in fieldIds)
            {
                if (mdc.IsCustom(flid))
                {
                    continue;                     // Custom fields get processed differently
                }
                string fieldName = mdc.GetFieldNameOrNull(flid);
                if (String.IsNullOrEmpty(fieldName))
                {
                    continue;
                }
                object value = data.get_Prop(obj.Hvo, flid);
                fieldValues[flid] = value;
            }
            return(fieldValues);
        }
Esempio n. 30
0
		private static Dictionary<string, List<PropertyInfo>> CacheBasicProperties(IFwMetaDataCacheManaged mdc)
		{
			var cachedBasicProperties = new Dictionary<string, List<PropertyInfo>>();
			foreach (var classId in mdc.GetClassIds())
			{
				var className = mdc.GetClassName(classId);
				List<PropertyInfo> basicProps;
				if (!cachedBasicProperties.TryGetValue(className, out basicProps))
				{
					basicProps = new List<PropertyInfo>();
					cachedBasicProperties.Add(className, basicProps);
				}
				basicProps.AddRange(mdc.GetFields(classId, className != "CmObject", (int)CellarPropertyTypeFilter.AllBasic).Select(propId => new PropertyInfo
					{
						m_propertyName = mdc.GetFieldName(propId),
						m_propertyType = (CellarPropertyType)mdc.GetFieldType(propId),
						m_isCustom = mdc.IsCustom(propId),
						m_isVirtual = mdc.get_IsVirtual(propId)
					}));
				if (basicProps.Count == 0)
					cachedBasicProperties.Remove(className);
			}
			return cachedBasicProperties;
		}
Esempio n. 31
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="XDumper"/> class.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		public XDumper(FdoCache cache)
		{
			m_cache = cache;
			m_mdc = m_cache.ServiceLocator.GetInstance<IFwMetaDataCacheManaged>();
			m_cmObjectRepository = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>();
			m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
			m_wsContainer = m_cache.ServiceLocator.WritingSystems;
		}
Esempio n. 32
0
 public ComplexConcordancePatternMdc(IFwMetaDataCacheManaged metaDataCache)
     : base(metaDataCache)
 {
 }
Esempio n. 33
0
 public PhonologicalFeatureMdc(IFwMetaDataCacheManaged mdc)
     : base(mdc)
 {
 }
Esempio n. 34
0
 public ObjectListPublisherMdc(IFwMetaDataCacheManaged metaDataCache, ObjectListPublisher publisher)
     : base(metaDataCache)
 {
     m_publisher = publisher;
 }
Esempio n. 35
0
 public GhostMdc(IFwMetaDataCacheManaged mdc)
     : base(mdc)
 {
 }
Esempio n. 36
0
			public ComplexConcordancePatternMdc(IFwMetaDataCacheManaged metaDataCache)
				: base(metaDataCache)
			{
			}
Esempio n. 37
0
			public GhostMdc(IFwMetaDataCacheManaged mdc)
				: base(mdc)
			{
			}
Esempio n. 38
0
		/// <summary>
		/// Return the LIFT range name for a given cmPossibilityList. Get the fieldName
		/// of the owning field and use that to get the range name.
		/// </summary>
		/// <returns></returns>
		public static string GetRangeNameForLiftExport(IFwMetaDataCacheManaged mdc, ICmPossibilityList list)
		{
			string rangeName = null;
			if (list.OwningFlid == 0)
			{
				rangeName = list.Name.BestAnalysisVernacularAlternative.Text;
			}
			else
			{
				var fieldName = mdc.GetFieldName(list.OwningFlid);
				rangeName = GetRangeName(fieldName);
			}
			return rangeName;
		}
 public FakeDecorator(ISilDataAccessManaged domainDataByFlid)
     : base(domainDataByFlid)
 {
     m_mdc = new FakeMdc((IFwMetaDataCacheManaged)domainDataByFlid.MetaDataCache);
 }
Esempio n. 40
0
 internal Virtuals(IFwMetaDataCacheManaged mdc)
 {
     m_mdc = mdc;
 }
		public FakeMdc(IFwMetaDataCacheManaged metaDataCache) : base(metaDataCache)
		{
		}
Esempio n. 42
0
		internal Virtuals(IFwMetaDataCacheManaged mdc)
		{
			m_mdc = mdc;
		}
		/// <summary>
		/// Setup a (typically decorator) override MDC.
		/// This will affect additional layers of decorator, but not the main SDA.
		/// </summary>
		/// <param name="mdc"></param>
		public void SetOverrideMdc(IFwMetaDataCacheManaged mdc)
		{
			m_mdc = mdc;
			if (m_domainDataByFlid is DomainDataByFlidDecoratorBase)
				(m_domainDataByFlid as DomainDataByFlidDecoratorBase).SetOverrideMdc(mdc);
		}
Esempio n. 44
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// If a test overrides this, it should call this base implementation.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            m_mdc = (IFwMetaDataCacheManaged)Cache.DomainDataByFlid.MetaDataCache;
        }
Esempio n. 45
0
 public XmlViewsMdc(IFwMetaDataCacheManaged metaDataCache) : base(metaDataCache)
 {
 }
Esempio n. 46
0
		/// <summary>
		/// Initialize the data values for this dialog.
		/// </summary>
		public void Init(FdoCache cache, Mediator mediator)
		{
			m_cache = cache;
			m_mediator = mediator;
			m_mdc = cache.MetaDataCacheAccessor as IFwMetaDataCacheManaged;
			m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
			lblMappingLanguagesInstructions.Text = String.Format(m_sFmtEncCnvLabel, cache.ProjectId.Name);

			m_tbDatabaseFileName.Text = m_mediator.PropertyTable.GetStringProperty("DataNotebookImportDb", String.Empty);
			m_tbProjectFileName.Text = m_mediator.PropertyTable.GetStringProperty("DataNotebookImportPrj", String.Empty);
			m_tbSettingsFileName.Text = m_mediator.PropertyTable.GetStringProperty("DataNotebookImportMap", String.Empty);
			if (String.IsNullOrEmpty(m_tbSettingsFileName.Text) || m_tbSettingsFileName.Text == m_sStdImportMap)
			{
				m_tbSettingsFileName.Text = m_sStdImportMap;
				if (!String.IsNullOrEmpty(m_tbDatabaseFileName.Text))

				{
					m_tbSaveAsFileName.Text = Path.Combine(Path.GetDirectoryName(m_tbDatabaseFileName.Text),
						Path.GetFileNameWithoutExtension(m_tbDatabaseFileName.Text) + "-import-settings.map");
				}
			}
			else
			{
				m_tbSaveAsFileName.Text = m_tbSettingsFileName.Text;
				m_fDirtySettings = false;
			}
			m_stylesheet = AnthroStyleSheetFromMediator(mediator);
			if (m_stylesheet == null)
			{
				FwStyleSheet styles = new FwStyleSheet();
				styles.Init(m_cache, m_cache.LangProject.Hvo, LangProjectTags.kflidStyles);
				m_stylesheet = styles;
			}
			ShowSaveButtonOrNot();
		}
Esempio n. 47
0
			public ObjectListPublisherMdc(IFwMetaDataCacheManaged metaDataCache, ObjectListPublisher publisher)
				: base(metaDataCache)
			{
				m_publisher = publisher;
			}
 public FeatureConstraintMdc(IFwMetaDataCacheManaged mdc)
     : base(mdc)
 {
 }
Esempio n. 49
0
		public RespellingMdc(IFwMetaDataCacheManaged metaDataCache)
			: base(metaDataCache)
		{
		}
Esempio n. 50
0
		/// <summary>
		/// This seems a bit clumsy, but the metadata cache now throws an exception if the class
		/// id/field name pair isn't valid for GetFieldId2(). So we check first in cases where
		/// we want a zero if not found.
		/// </summary>
		private int GetFlidIfPossible(int clid, string fieldName, IFwMetaDataCacheManaged mdc)
		{
			if (!mdc.FieldExists(clid, fieldName, true))
				return 0;
			return mdc.GetFieldId2(clid, fieldName, true);
		}
Esempio n. 51
0
		public override void FixtureSetup()
		{
			base.FixtureSetup();

			m_mdc = (IFwMetaDataCacheManaged)Cache.MetaDataCache;
		}
Esempio n. 52
0
		public void Initialize(FdoCache cache, IHelpTopicProvider helpTopicProvider, IApp app,
			NotebookImportWiz.RnSfMarker rsf, Sfm2Xml.SfmFile sfmFile,
			Dictionary<int, string> mapFlidName, IVwStylesheet stylesheet,
			Mediator mediator)
		{
			m_cache = cache;
			m_helpTopicProvider = helpTopicProvider;
			m_app = app;
			m_rsfm = rsf;
			m_sfmFile = sfmFile;
			m_stylesheet = stylesheet;
			m_mdc = cache.ServiceLocator.GetInstance<IFwMetaDataCacheManaged>();
			m_mediator = mediator;
			m_mapFlidName = mapFlidName;

			FillInFieldList();
			FillInContentsPane(rsf, sfmFile);
			SetSubControl();
		}
Esempio n. 53
0
		public override void FixtureTeardown()
		{
			base.FixtureTeardown();
			m_mdc = null;
		}
Esempio n. 54
0
 public InterestingTextsMdc(IFwMetaDataCacheManaged metaDataCache)
     : base(metaDataCache)
 {
 }
Esempio n. 55
0
        public void DataMigration7000019Test()
        {
            string storePath = Path.Combine(Path.GetTempPath(), FdoFileHelper.ksWritingSystemsDir);

            PrepareStore(storePath);
            string globalStorePath = DirectoryFinder.GlobalWritingSystemStoreDirectory;

            PrepareStore(globalStorePath);

            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000019Tests.xml");

            IFwMetaDataCacheManaged mockMdc = SetupMdc();

            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000018, dtos, mockMdc, Path.GetTempPath(), FwDirectoryFinder.FdoDirectories);

            // Do the migration.
            m_dataMigrationManager.PerformMigration(dtoRepos, 7000019, new DummyProgressDlg());

            // Verification Phase
            Assert.AreEqual(7000019, dtoRepos.CurrentModelVersion, "Wrong updated version.");

            Assert.AreEqual(0, dtoRepos.AllInstancesSansSubclasses("LgWritingSystem").Count());
            Assert.AreEqual(0, dtoRepos.AllInstancesSansSubclasses("LgCollation").Count());
            Assert.AreEqual(0, dtoRepos.AllInstancesSansSubclasses("CmSortSpec").Count());

            DomainObjectDTO lpDto  = dtoRepos.AllInstancesSansSubclasses("LangProject").First();
            XElement        lpElem = XElement.Parse(lpDto.Xml);

            var kalabaPath = Path.Combine(storePath, "x-kal.ldml");             // Note this migration does NOT yet convert to qaa-x-kal
            var kalabaNode = XDocument.Parse(Encoding.UTF8.GetString(File.ReadAllBytes(kalabaPath))).Root;

            Assert.That(kalabaNode.Name.LocalName, Is.EqualTo("ldml"));
            var identityNode = kalabaNode.Element("identity");

            Assert.That(identityNode.Element("language").Attribute("type").Value, Is.EqualTo("x-kal"));
            var        specialNode = kalabaNode.Element("special");
            XNamespace xmlns       = "http://www.w3.org/2000/xmlns/";

            Assert.That(specialNode.Attribute(xmlns + "palaso").Value, Is.EqualTo("urn://palaso.org/ldmlExtensions/v1"));
            XNamespace palaso = "urn://palaso.org/ldmlExtensions/v1";

            Assert.That(specialNode.Element(palaso + "languageName").Attribute("value").Value, Is.EqualTo("Kalaba"));
            Assert.That(specialNode.Element(palaso + "abbreviation").Attribute("value").Value, Is.EqualTo("Kal"));
            // Todo: check a lot more things.
            //Assert.AreEqual(1033, kalaba.LCID);

            //IWritingSystem frIpa = wsManager.Get("fr-fonipa-x-etic");
            //Assert.AreEqual("FrnI", frIpa.Abbreviation);
            //Assert.AreEqual("IPA Unicode 1.0", frIpa.Keyboard);

            var analysisWss = (string)lpElem.Element("AnalysisWss");
            //foreach (string id in analysisWss.Split(' '))
            //    Assert.IsTrue(wsManager.Exists(id));
            //var vernWss = (string)lpElem.Element("VernWss");
            //foreach (string id in vernWss.Split(' '))
            //    Assert.IsTrue(wsManager.Exists(id));

            //CheckWsProperty(dtoRepos.AllInstancesWithSubclasses("CmPossibilityList"), wsManager);

            //foreach (DomainObjectDTO dto in dtoRepos.AllInstancesWithValidClasses())
            //    CheckStringWsIds(wsManager, dto);

            DomainObjectDTO importSourceDto  = dtoRepos.AllInstancesWithSubclasses("ScrImportSource").First();
            XElement        importSourceElem = XElement.Parse(importSourceDto.Xml);

            Assert.AreEqual("x-kal", (string)importSourceElem.Element("WritingSystem").Element("Uni"));
            Assert.IsNull(importSourceElem.Element("ICULocale"));

            DomainObjectDTO mappingDto  = dtoRepos.AllInstancesWithSubclasses("ScrMarkerMapping").First();
            XElement        mappingElem = XElement.Parse(mappingDto.Xml);

            Assert.AreEqual("fr-fonipa-x-etic", (string)mappingElem.Element("WritingSystem").Element("Uni"));
            Assert.IsNull(mappingElem.Element("ICULocale"));

            DomainObjectDTO styleDto  = dtoRepos.AllInstancesWithSubclasses("StStyle").First();
            XElement        styleElem = XElement.Parse(styleDto.Xml);

            Assert.AreEqual("<default font>", (string)styleElem.Element("Rules").Element("Prop").Attribute("fontFamily"));
        }
		public InterestingTextsMdc(IFwMetaDataCacheManaged metaDataCache)
			: base(metaDataCache)
		{
		}
Esempio n. 57
0
		public ConcMdc(IFwMetaDataCacheManaged metaDataCache)
			: base(metaDataCache)
		{
		}
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="metaDataCache">The FDO FdoMetaDataCache implementation,
		/// which is used to get the basic FDO data.</param>
		/// <remarks>
		/// The hvo values are true 'handles' in that they are valid for one session,
		/// but may not be the same integer for another session for the 'same' object.
		/// Therefore, one should not use them for multi-session identity.
		/// CmObject identity can only be guaranteed by using their Guids (or using '==' in code).
		/// </remarks>
		protected FdoMetaDataCacheDecoratorBase(IFwMetaDataCacheManaged metaDataCache)
		{
			if (metaDataCache == null) throw new ArgumentNullException("metaDataCache");

			m_metaDataCache = metaDataCache;
		}
Esempio n. 59
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// If a test overrides this, it should call this base implementation.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void FixtureTeardown()
        {
            m_mdc = null;

            base.FixtureTeardown();
        }
Esempio n. 60
0
		public XmlViewsMdc(IFwMetaDataCacheManaged metaDataCache) : base(metaDataCache)
		{
		}