/// <summary> /// Returns a dictionary of custom fields at the LexEntry, LexSense, and LexExampleSentence levels /// From Lcm to LF. If the dictionary doesn't exist, create one. /// </summary> /// <returns>Dictionary of custom fields where the keys are the parent listCode</returns> public Dictionary <string, ICmPossibilityList> GetCustomFieldParentLists() { // Generate the dictionary of custom fields var lfCustomFieldLists = new Dictionary <string, ICmPossibilityList>(); // The three classes that are allowed to have custom fields in them are LexEntry, LexSense, and LexExampleSentence List <int> customFieldIds = new List <int>( LcmMetaData.GetFields(LexEntryTags.kClassId, false, (int)CellarPropertyTypeFilter.AllReference) .Where(flid => cache.GetIsCustomField(flid) && LcmMetaData.GetFieldListRoot(flid) != Guid.Empty)); customFieldIds.AddRange( LcmMetaData.GetFields(LexSenseTags.kClassId, false, (int)CellarPropertyTypeFilter.AllReference) .Where(flid => cache.GetIsCustomField(flid) && LcmMetaData.GetFieldListRoot(flid) != Guid.Empty)); customFieldIds.AddRange( LcmMetaData.GetFields(LexExampleSentenceTags.kClassId, false, (int)CellarPropertyTypeFilter.AllReference) .Where(flid => cache.GetIsCustomField(flid) && LcmMetaData.GetFieldListRoot(flid) != Guid.Empty)); var listRepo = servLoc.GetInstance <ICmPossibilityListRepository>(); foreach (int flid in customFieldIds) { Guid parentListGuid = LcmMetaData.GetFieldListRoot(flid); string listCode = GetParentListCode(flid); lfCustomFieldLists[listCode] = listRepo.GetObject(parentListGuid); } return(lfCustomFieldLists); }
public ICmPossibilityList GetParentListForField(int flid) { Guid parentListGuid = lcmMetaData.GetFieldListRoot(flid); if (parentListGuid == Guid.Empty) { string fieldName = lcmMetaData.GetFieldNameOrNull(flid); logger.Warning("No possibility list found for custom field {0} (field ID {1}); it will not be present in LCM", fieldName ?? "(name not found)", flid); return(null); // TODO: If this happens, we're probably importing a newly-created possibility list, so we should // probably create it in LCM using ConvertMongoToLcmOptionList. Implementation needed. } return(servLoc.GetInstance <ICmPossibilityListRepository>().GetObject(parentListGuid)); }
/// <summary> Gets the listRoot of the field. </summary> /// <param name='luFlid'>Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table. </param> /// <returns>Points to the output field ListRoot. In the database, this /// corresponds to the "ListRootId" column in the Field$ table.</returns> public virtual Guid GetFieldListRoot(int luFlid) { return(m_metaDataCache.GetFieldListRoot(luFlid)); }