/// <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"); }
/// ---------------------------------------------------------------------------------------- /// <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; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="CopyObject<TTopLevel>"/> 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; }
/// <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; }
/// ------------------------------------------------------------------------------------ /// <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"; }
/// <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; }
/// <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())); } }
/// ------------------------------------------------------------------------------------ /// <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; }
/// ---------------------------------------------------------------------------------------- /// <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; }
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; }
/// ------------------------------------------------------------------------------------ /// <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; }
/// ------------------------------------------------------------------------------------ /// <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); }
/// <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; }
/// ---------------------------------------------------------------------------------------- /// <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; }
/// ---------------------------------------------------------------------------------------- /// <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); }
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"); }
/// ------------------------------------------------------------------------------------ /// <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)); } }
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>(); }
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>"); }
/// ------------------------------------------------------------------------------------ /// <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)); } }
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; }
/// <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); }
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; }
/// ----------------------------------------------------------------------------------- /// <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; }
public ComplexConcordancePatternMdc(IFwMetaDataCacheManaged metaDataCache) : base(metaDataCache) { }
public PhonologicalFeatureMdc(IFwMetaDataCacheManaged mdc) : base(mdc) { }
public ObjectListPublisherMdc(IFwMetaDataCacheManaged metaDataCache, ObjectListPublisher publisher) : base(metaDataCache) { m_publisher = publisher; }
public GhostMdc(IFwMetaDataCacheManaged mdc) : base(mdc) { }
/// <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); }
internal Virtuals(IFwMetaDataCacheManaged mdc) { m_mdc = mdc; }
public FakeMdc(IFwMetaDataCacheManaged metaDataCache) : base(metaDataCache) { }
/// <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); }
/// ------------------------------------------------------------------------------------ /// <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; }
public XmlViewsMdc(IFwMetaDataCacheManaged metaDataCache) : base(metaDataCache) { }
/// <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(); }
public FeatureConstraintMdc(IFwMetaDataCacheManaged mdc) : base(mdc) { }
public RespellingMdc(IFwMetaDataCacheManaged metaDataCache) : base(metaDataCache) { }
/// <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); }
public override void FixtureSetup() { base.FixtureSetup(); m_mdc = (IFwMetaDataCacheManaged)Cache.MetaDataCache; }
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 override void FixtureTeardown() { base.FixtureTeardown(); m_mdc = null; }
public InterestingTextsMdc(IFwMetaDataCacheManaged metaDataCache) : base(metaDataCache) { }
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 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; }
/// ------------------------------------------------------------------------------------ /// <summary> /// If a test overrides this, it should call this base implementation. /// </summary> /// ------------------------------------------------------------------------------------ public override void FixtureTeardown() { m_mdc = null; base.FixtureTeardown(); }