diff --git a/src/SIL.LCModel/DomainImpl/CmObject.cs b/src/SIL.LCModel/DomainImpl/CmObject.cs index b71c6623..fa0e5a3c 100644 --- a/src/SIL.LCModel/DomainImpl/CmObject.cs +++ b/src/SIL.LCModel/DomainImpl/CmObject.cs @@ -3447,7 +3447,7 @@ int ICmObjectOrIdInternal.GetHvo(IdentityMap identityMap) // These methods allow a real CmObject to be used where we would sometimes use a surrogate. #region ICmObjectOrSurrogate Members - string ICmObjectOrSurrogate.XML + string GetStringRepresentation { get { return ((ICmObjectInternal)this).ToXmlString(); } } @@ -3462,7 +3462,7 @@ string ICmObjectOrSurrogate.Classname get { return ClassName; } } - byte[] ICmObjectOrSurrogate.XMLBytes + byte[] GetByteRepresentation { get { return ((ICmObjectInternal)this).ToXmlBytes(); } } @@ -3484,6 +3484,17 @@ bool ICmObjectOrSurrogate.HasObject get { return true; } } + /// + /// The DTO for this class (which came from storage? which can go to storage?) + /// + ICmObjectDTO ICmObjectOrSurrogate.DTO + { + get + { + return ((BackendProvider)Cache.ServiceLocator.GetInstance()) + .MakeDTO(this); + } + } #endregion #region IReferenceSource Members diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000002.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000002.cs index 25dfaeb7..02254ab0 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000002.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000002.cs @@ -48,7 +48,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor { DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000001); - var parasToChangeClasses = new List(); + var parasToChangeClasses = new List(); foreach (var stTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("StTxtPara")) { var paraOwner = domainObjectDtoRepository.GetOwningDTO(stTxtPara); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000003.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000003.cs index adff0cc7..249355f6 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000003.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000003.cs @@ -49,7 +49,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor { DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000002); - var footnotesToChangeClasses = new List(); + var footnotesToChangeClasses = new List(); foreach (var footnote in domainObjectDtoRepository.AllInstancesSansSubclasses("StFootnote")) { XElement footnoteEl = XElement.Parse(footnote.Xml); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000005.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000005.cs index a8244396..715bef39 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000005.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000005.cs @@ -102,7 +102,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor new XElement("AUni", new XAttribute("ws", "en"), "Analysis")), new XElement("UnderColor", new XAttribute("val", "255")), new XElement("UnderStyle", new XAttribute("val", "1")))); - domainObjectDtoRepository.Add(new DomainObjectDTO("82290763-1633-4998-8317-0EC3F5027FBD", + domainObjectDtoRepository.Add(new DomainObjectXMLDTO("82290763-1633-4998-8317-0EC3F5027FBD", "CmPossibility", typeElement.ToString())); // 3. Move the attributes that are in RnEvent and RnAnalysis into RnGenericRec. diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000008.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000008.cs index dd9c0835..eb6d9d16 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000008.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000008.cs @@ -72,7 +72,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor }; //Collect up the ones to be removed. - var goners = new List(); + var goners = new List(); foreach (var annDTO in domainObjectDtoRepository.AllInstancesSansSubclasses("CmBaseAnnotation")) { var annElement = XElement.Parse(annDTO.Xml); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000010.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000010.cs index 933f6322..12e700a7 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000010.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000010.cs @@ -76,8 +76,8 @@ public void PerformMigration(IDomainObjectDTORepository dtoRepos) // The old objects to be removed go into 'goners'. // In this case, it is the annotation defn type objects. - var goners = new List((int) (dtoRepos.Count*0.80)); - DomainObjectDTO dtoGoner; + var goners = new List((int) (dtoRepos.Count*0.80)); + DomainObjectXMLDTO dtoGoner; if (dtoRepos.TryGetValue(DataMigrationServices.kSegmentAnnDefnGuid, out dtoGoner)) goners.Add(dtoGoner); if (dtoRepos.TryGetValue(DataMigrationServices.kTwficAnnDefnGuid, out dtoGoner)) @@ -245,7 +245,7 @@ public void PerformMigration(IDomainObjectDTORepository dtoRepos) private static void DeleteCcwgWithGuidIndex(IDomainObjectDTORepository dtoRepos) { - var goners = new List(); + var goners = new List(); var ccwgs = dtoRepos.AllInstancesSansSubclasses("ConstChartWordGroup"); foreach (var dto in ccwgs) { @@ -277,7 +277,7 @@ private static void DeleteCcwgWithGuidIndex(IDomainObjectDTORepository dtoRepos) } private static void DeleteUnneededGoners(IDomainObjectDTORepository dtoRepos, - IEnumerable goners, ICollection neededGoners) + IEnumerable goners, ICollection neededGoners) { // We have run out of memory during this data migration on large projects. (See // FWR-3849.) One possible reason is that we can make 15000+ copies of LangProject @@ -291,10 +291,10 @@ private static void DeleteUnneededGoners(IDomainObjectDTORepository dtoRepos, Where(t => (t.Attribute("t") != null && t.Attribute("t").Value == "o")).Count(); if (cAnn > 0) { - var gonersInLangProject = new List(cAnn); + var gonersInLangProject = new List(cAnn); foreach (var goner in goners) { - DomainObjectDTO gonerActual; + DomainObjectXMLDTO gonerActual; if (!dtoRepos.TryGetValue(goner.Guid, out gonerActual)) continue; // Not in repos. if (neededGoners.Contains(goner.Guid)) @@ -329,7 +329,7 @@ private static void SortOutMultipleXficBackrefs(IDomainObjectDTORepository dtoRe Dictionary oldCcas, Dictionary ccaGuidMap, IEnumerable oldCcrs, - List goners) + List goners) { // Look for any xfics that have multiple CCA backrefs. // If we find any, look through backrefs of CCAs and backrefs of xfic.BeginObj @@ -674,7 +674,7 @@ private static List> ProcessDiscourseData(IDomain halfBakedCcwgItems, refsFromAppliesTo, oldCCAs, ccaGuidMap, newGuid.ToString().ToLowerInvariant()))); // Add DTO to repos. - dtoRepos.Add(new DomainObjectDTO(newGuid.ToString().ToLowerInvariant(), className, newCCRElement.ToString())); + dtoRepos.Add(new DomainObjectXMLDTO(newGuid.ToString().ToLowerInvariant(), className, newCCRElement.ToString())); } return halfBakedCcwgItems; @@ -942,7 +942,7 @@ private static IEnumerable ConvertCCAsAndAddCCRObjSurElements( retval.Add(DataMigrationServices.CreateOwningObjSurElement(newGuid)); // Add newly converted CCA to repos. - dtoRepos.Add(new DomainObjectDTO(newGuid, newClassName, newCCAElement.ToString())); + dtoRepos.Add(new DomainObjectXMLDTO(newGuid, newClassName, newCCAElement.ToString())); } return retval; @@ -1022,7 +1022,7 @@ private static List GetAStrElements(byte[] xmlBytes, int ichMin, int i } private static void DeleteImmediatelyAllUnlovedCCRs( - IDomainObjectDTORepository dtoRepos, ICollection goners, + IDomainObjectDTORepository dtoRepos, ICollection goners, IDictionary xficHasTextOrDiscourseBackReference, ICollection oldCCRs, IDictionary oldCCAs, @@ -1060,7 +1060,7 @@ from objsurElement in allChartElements.Descendants("Rows").Elements("objsur") private static void DeleteImmediatelyBadCca(IDomainObjectDTORepository dtoRepos, string gonerCcaGuid, - ICollection goners, + ICollection goners, IDictionary ccaGuidMap, IDictionary oldCcas, IDictionary xficHasTextOrDiscourseBackReference) @@ -1353,7 +1353,7 @@ private static void ProcessParagraphs( newSegmentElement = DeleteTemporaryAnalyses(newSegmentElement); // Create a new Segment instance DTO from the 'newSegmentElement', // and add it to repos. - var newSegDto = new DomainObjectDTO(newSegGuid, "Segment", newSegmentElement.ToString()); + var newSegDto = new DomainObjectXMLDTO(newSegGuid, "Segment", newSegmentElement.ToString()); dtoRepos.Add(newSegDto); } @@ -1485,7 +1485,7 @@ private static void CreateTemporaryXfic(bool fWfic, int beginOffset, int endOffs } private static void CollectIndirectAnnotations( - IDomainObjectDTORepository dtoRepos, ICollection goners, + IDomainObjectDTORepository dtoRepos, ICollection goners, IDictionary oldCCAs, IDictionary ccaGuidMap, IDictionary xficHasTextOrDiscourseBackReference, @@ -1632,7 +1632,7 @@ private static void RemoveMismatchedAppliesToRefs(byte[] xmlBytes, ICollection goners, + IDomainObjectDTORepository dtoRepos, ICollection goners, IDictionary oldCCAs, IDictionary ccaGuidMap, IDictionary xficHasTextOrDiscourseBackReference, @@ -1641,7 +1641,7 @@ private static void CollectBaseAnnotations( IDictionary>> paraToDuplicateOldXfics, IDictionary> paraToOldXfics) { - var newPunctForms = new Dictionary(); + var newPunctForms = new Dictionary(); foreach (var baseAnnDto in dtoRepos.AllInstancesSansSubclasses("CmBaseAnnotation")) { var surrGuid = GetAnnotationTypeGuid(baseAnnDto.XmlBytes); @@ -1712,8 +1712,8 @@ private static string GetAnnotationTypeGuid(byte[] xmlBytes) private static bool EnsurePficHasInstanceOf( IDomainObjectDTORepository dtoRepos, - DomainObjectDTO dtoPfic, - IDictionary newPunctForms) + DomainObjectXMLDTO dtoPfic, + IDictionary newPunctForms) { var pficElement = dtoPfic.XmlBytes; /* @@ -1795,7 +1795,7 @@ private static bool EnsurePficHasInstanceOf( // then make the new PF object, and return true. // Find/Create PunctuationForm object that has a Form in the matching IcuLocale & matching string. var key = icuLocale + "-" + newForm; - DomainObjectDTO dtoMatchingPf; + DomainObjectXMLDTO dtoMatchingPf; if (!newPunctForms.TryGetValue(key, out dtoMatchingPf)) { // Create new PunctuationForm dto. @@ -1809,7 +1809,7 @@ private static bool EnsurePficHasInstanceOf( new XElement("Form", new XElement("Str", new XElement("Run", new XAttribute("ws", icuLocale), newForm))))); - dtoMatchingPf = new DomainObjectDTO(newPunctFormGuid, className, newPfElement.ToString()); + dtoMatchingPf = new DomainObjectXMLDTO(newPunctFormGuid, className, newPfElement.ToString()); // Add new PunctuationForm to dtoRepos. dtoRepos.Add(dtoMatchingPf); // Add new PunctuationForm to newPunctForms. @@ -1830,7 +1830,7 @@ private static bool EnsurePficHasInstanceOf( } private static void MarkParaAsNeedingTokenization(IDomainObjectDTORepository dtoRepos, - DomainObjectDTO paraDto) + DomainObjectXMLDTO paraDto) { var stTxtParaBounds = new ElementBounds(paraDto.XmlBytes, s_tagsStTxtPara); if (!stTxtParaBounds.IsValid) @@ -1917,19 +1917,19 @@ private static XElement CreateATranslation(string oldSegGuid, Dictionary goners, + private static void PreprocessTextTagAnnotation(ICollection goners, ICollection annElements, - DomainObjectDTO annDto, + DomainObjectXMLDTO annDto, byte[] annElement) { goners.Add(annDto); annElements.Add(annElement); } - private static void PreprocessDiscourseAnnotation(ICollection goners, + private static void PreprocessDiscourseAnnotation(ICollection goners, IDictionary annElements, IDictionary ccaGuidMap, - DomainObjectDTO annDto, byte[] annElement) + DomainObjectXMLDTO annDto, byte[] annElement) { goners.Add(annDto); var oldGuid = GetGuid(annElement); @@ -1939,8 +1939,8 @@ private static void PreprocessDiscourseAnnotation(ICollection g ccaGuidMap.Add(new Guid(oldGuid), Guid.NewGuid()); } - private static void PreprocessDiscourseAnnotation(ICollection goners, - ICollection annElements, DomainObjectDTO annDto, byte[] annElement) + private static void PreprocessDiscourseAnnotation(ICollection goners, + ICollection annElements, DomainObjectXMLDTO annDto, byte[] annElement) { goners.Add(annDto); var annoBounds = new ElementBounds(annElement, s_tagsCmAnnotation); @@ -1952,8 +1952,8 @@ private static void PreprocessDiscourseAnnotation(ICollection g annElements.Add(annElement); } - private static void PreprocessTranslationOrNoteAnnotation(ICollection goners, - Dictionary> annElements, DomainObjectDTO annDto, byte[] annElement) + private static void PreprocessTranslationOrNoteAnnotation(ICollection goners, + Dictionary> annElements, DomainObjectXMLDTO annDto, byte[] annElement) { goners.Add(annDto); var annoBounds = new ElementBounds(annElement, s_tagsCmAnnotation); @@ -1980,10 +1980,10 @@ private static void PreprocessTranslationOrNoteAnnotation(ICollection goners, + ICollection goners, IDictionary>> paraToDuplicates, IDictionary> paraToAnnotation, - DomainObjectDTO baseAnnDto, byte[] annElement, bool checkOnInstanceOf) + DomainObjectXMLDTO baseAnnDto, byte[] annElement, bool checkOnInstanceOf) { goners.Add(baseAnnDto); @@ -2106,7 +2106,7 @@ private static XElement AddNotes(IDomainObjectDTORepository dtoRepos, string new new XElement("CmObject"), new XElement("Note", GetOptionalComment(oldNotePair, "Content"))); // Create new dto and add to repos. - var newNoteDto = new DomainObjectDTO(newNoteGuid, "Note", newNoteElement.ToString()); + var newNoteDto = new DomainObjectXMLDTO(newNoteGuid, "Note", newNoteElement.ToString()); dtoRepos.Add(newNoteDto); } } @@ -2121,7 +2121,7 @@ private static XElement AddSegmentAnalyses( ICollection oldTextTags, string newSegmentGuid, bool isLastOldSegment, - DomainObjectDTO paraDto) + DomainObjectXMLDTO paraDto) { XElement retval = null; @@ -2288,7 +2288,7 @@ where GetAnnotationTypeGuid(xficKvp.Value) == DataMigrationServices.kTwficAnnDef new XElement("Tag", DataMigrationServices.CreateReferenceObjSurElement(GetInstanceOfGuid(oldTextTagAnnElement))))); // Add new DTO to repos. - var newTextTagDto = new DomainObjectDTO(newTextTagGuid, "TextTag", newTextTagElement.ToString()); + var newTextTagDto = new DomainObjectXMLDTO(newTextTagGuid, "TextTag", newTextTagElement.ToString()); dtoRepos.Add(newTextTagDto); // Add new TextTag to owning prop on owner as objsur element. var owningStTextElement = XElement.Parse(owningStText.Xml); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000011.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000011.cs index e5cb1d92..d0582fd9 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000011.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000011.cs @@ -22,16 +22,16 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor { DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000010); - DomainObjectDTO nbkDto = domainObjectDtoRepository.AllInstancesSansSubclasses("RnResearchNbk").First(); + DomainObjectXMLDTO nbkDto = domainObjectDtoRepository.AllInstancesSansSubclasses("RnResearchNbk").First(); XElement nbkElem = XElement.Parse(nbkDto.Xml); var recTypesGuid = (string) nbkElem.XPathSelectElement("RnResearchNbk/RecTypes/objsur").Attribute("guid"); - var stack = new Stack(domainObjectDtoRepository.GetDirectlyOwnedDTOs(recTypesGuid)); - IEnumerable recDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("RnGenericRec"); - IEnumerable overlayDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("CmOverlay"); + var stack = new Stack(domainObjectDtoRepository.GetDirectlyOwnedDTOs(recTypesGuid)); + IEnumerable recDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("RnGenericRec"); + IEnumerable overlayDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("CmOverlay"); while (stack.Count > 0) { - DomainObjectDTO dto = stack.Pop(); - foreach (DomainObjectDTO childDto in domainObjectDtoRepository.GetDirectlyOwnedDTOs(dto.Guid)) + DomainObjectXMLDTO dto = stack.Pop(); + foreach (DomainObjectXMLDTO childDto in domainObjectDtoRepository.GetDirectlyOwnedDTOs(dto.Guid)) stack.Push(childDto); XElement posElem = XElement.Parse(dto.Xml); XElement uniElem = posElem.XPathSelectElement("CmPossibility/Abbreviation/AUni[@ws='en']"); @@ -70,7 +70,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor } } - DomainObjectDTO recTypesDto = domainObjectDtoRepository.GetDTO(recTypesGuid); + DomainObjectXMLDTO recTypesDto = domainObjectDtoRepository.GetDTO(recTypesGuid); DataMigrationServices.ChangeGuid(domainObjectDtoRepository, recTypesDto, "D9D55B12-EA5E-11DE-95EF-0013722F8DEC", overlayDtos); DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository); } diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000012.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000012.cs index c4da94d9..902c0eb0 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000012.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000012.cs @@ -48,7 +48,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor /// Name of the object containing fieldToDelete. /// The name of the field to delete. /// ------------------------------------------------------------------------------------ - private void RemoveField(DomainObjectDTO dto, XElement objElement, string fieldToDelete) + private void RemoveField(DomainObjectXMLDTO dto, XElement objElement, string fieldToDelete) { XElement rmElement = objElement.Element(fieldToDelete); if (rmElement != null) diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000013.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000013.cs index b6296091..7f5a537f 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000013.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000013.cs @@ -28,7 +28,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor // 1) Select the ConstChartWordGroup class objects. // 2) Convert any with null BeginSegment reference to ConstChartTag objects with null Tag reference. - var objsToChangeClasses = new List(); + var objsToChangeClasses = new List(); foreach (var cellPartDto in domainObjectDtoRepository.AllInstancesSansSubclasses("ConstChartWordGroup")) { var rtElement = XElement.Parse(cellPartDto.Xml); @@ -72,7 +72,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor /// Name of the object containing fieldToDelete. /// The name of the field to delete. /// ------------------------------------------------------------------------------------ - private void RemoveField(DomainObjectDTO dto, XElement objElement, string fieldToDelete) + private void RemoveField(DomainObjectXMLDTO dto, XElement objElement, string fieldToDelete) { XElement rmElement = objElement.Element(fieldToDelete); if (rmElement != null) diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000014.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000014.cs index 16a40c12..b3827d07 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000014.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000014.cs @@ -119,7 +119,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository); } - private static DomainObjectDTO MakeEvaluation(string ownerGuid, IDomainObjectDTORepository domainObjectDtoRepository, XElement agentElement, string owningAttr) + private static DomainObjectXMLDTO MakeEvaluation(string ownerGuid, IDomainObjectDTORepository domainObjectDtoRepository, XElement agentElement, string owningAttr) { var newGuid = Guid.NewGuid().ToString().ToLower(); var newEvalElt = new XElement("rt", @@ -129,7 +129,7 @@ private static DomainObjectDTO MakeEvaluation(string ownerGuid, IDomainObjectDTO new XElement("CmObject"), new XElement("CmAgentEvaluation")); // Create new dto and add to repos. - var newEval = new DomainObjectDTO(newGuid, "CmAgentEvaluation", newEvalElt.ToString()); + var newEval = new DomainObjectXMLDTO(newGuid, "CmAgentEvaluation", newEvalElt.ToString()); domainObjectDtoRepository.Add(newEval); agentElement.Add(new XElement(owningAttr, new XElement("objsur", new XAttribute("t", "o"), new XAttribute("guid", newGuid)))); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000016.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000016.cs index a375904d..eab5779b 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000016.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000016.cs @@ -64,7 +64,7 @@ public void PerformMigration(IDomainObjectDTORepository repoDTO) { DataMigrationServices.CheckVersionNumber(repoDTO, 7000015); - DomainObjectDTO dtoList = repoDTO.GetDTO(ksguidRecTypesList); + DomainObjectXMLDTO dtoList = repoDTO.GetDTO(ksguidRecTypesList); XElement xeList = XElement.Parse(dtoList.Xml); XElement xeListPossibilities = xeList.XPathSelectElement("Possibilities"); if (xeListPossibilities == null) @@ -73,10 +73,10 @@ public void PerformMigration(IDomainObjectDTORepository repoDTO) xeList.Add(xeListPossibilities); } // The user can edit the list, so these might possibly have been deleted (or moved). :-( - DomainObjectDTO dtoObservation = GetDTOIfItExists(repoDTO, ksguidObservation); - DomainObjectDTO dtoConversation = GetDTOIfItExists(repoDTO, ksguidConversation); - DomainObjectDTO dtoInterview = GetDTOIfItExists(repoDTO, ksguidInterview); - DomainObjectDTO dtoPerformance = GetDTOIfItExists(repoDTO, ksguidPerformance); + DomainObjectXMLDTO dtoObservation = GetDTOIfItExists(repoDTO, ksguidObservation); + DomainObjectXMLDTO dtoConversation = GetDTOIfItExists(repoDTO, ksguidConversation); + DomainObjectXMLDTO dtoInterview = GetDTOIfItExists(repoDTO, ksguidInterview); + DomainObjectXMLDTO dtoPerformance = GetDTOIfItExists(repoDTO, ksguidPerformance); // Create the new Event, Methodology, and Weather record types. var nowStr = DateTime.Now.ToLCMTimeFormatWithMillisString(); @@ -90,7 +90,7 @@ public void PerformMigration(IDomainObjectDTORepository repoDTO) sb.AppendFormat("", nowStr); sb.Append(""); XElement xeEvent = XElement.Parse(sb.ToString()); - var dtoEvent = new DomainObjectDTO(ksguidEvent, "CmPossibility", xeEvent.ToString()); + var dtoEvent = new DomainObjectXMLDTO(ksguidEvent, "CmPossibility", xeEvent.ToString()); repoDTO.Add(dtoEvent); xeListPossibilities.AddFirst(DataMigrationServices.CreateOwningObjSurElement(ksguidEvent)); @@ -102,7 +102,7 @@ public void PerformMigration(IDomainObjectDTORepository repoDTO) sb.AppendFormat("", nowStr); sb.AppendFormat("", nowStr); sb.Append(""); - var dtoMethod = new DomainObjectDTO(ksguidMethodology, "CmPossibility", sb.ToString()); + var dtoMethod = new DomainObjectXMLDTO(ksguidMethodology, "CmPossibility", sb.ToString()); repoDTO.Add(dtoMethod); xeListPossibilities.LastNode.AddAfterSelf(DataMigrationServices.CreateOwningObjSurElement(ksguidMethodology)); @@ -114,7 +114,7 @@ public void PerformMigration(IDomainObjectDTORepository repoDTO) sb.AppendFormat("", nowStr); sb.AppendFormat("", nowStr); sb.Append(""); - var dtoWeather = new DomainObjectDTO(ksguidWeather, "CmPossibility", sb.ToString()); + var dtoWeather = new DomainObjectXMLDTO(ksguidWeather, "CmPossibility", sb.ToString()); repoDTO.Add(dtoWeather); xeListPossibilities.LastNode.AddAfterSelf(DataMigrationServices.CreateOwningObjSurElement(ksguidWeather)); @@ -133,7 +133,7 @@ public void PerformMigration(IDomainObjectDTORepository repoDTO) DataMigrationServices.IncrementVersionNumber(repoDTO); } - private void ChangeOwner(IDomainObjectDTORepository repoDTO, DomainObjectDTO dto, string sGuidNew, + private void ChangeOwner(IDomainObjectDTORepository repoDTO, DomainObjectXMLDTO dto, string sGuidNew, string xpathNew) { XElement xe = XElement.Parse(dto.Xml); @@ -151,7 +151,7 @@ private void ChangeOwner(IDomainObjectDTORepository repoDTO, DomainObjectDTO dto DataMigrationServices.UpdateDTO(repoDTO, dto, xe.ToString()); if (sGuidOld != null) { - DomainObjectDTO dtoOldOwner = repoDTO.GetDTO(sGuidOld); + DomainObjectXMLDTO dtoOldOwner = repoDTO.GetDTO(sGuidOld); XElement xeOldOwner = XElement.Parse(dtoOldOwner.Xml); string xpathOld = string.Format(".//objsur[@t='o' and @guid='{0}']", dto.Guid); XElement xeOldRef = xeOldOwner.XPathSelectElement(xpathOld); @@ -183,7 +183,7 @@ private void ChangeOwner(IDomainObjectDTORepository repoDTO, DomainObjectDTO dto DataMigrationServices.UpdateDTO(repoDTO, dtoOldOwner, xeOldOwner.ToString()); } } - DomainObjectDTO dtoNewOwner = repoDTO.GetDTO(sGuidNew); + DomainObjectXMLDTO dtoNewOwner = repoDTO.GetDTO(sGuidNew); XElement xeNewOwner = XElement.Parse(dtoNewOwner.Xml); XElement xeNewField = xeNewOwner.XPathSelectElement(xpathNew); if (xeNewField == null) @@ -243,7 +243,7 @@ private static XElement CreateXPathElementsAsNeeded(string xpathNew, XElement xe return null; } - private static DomainObjectDTO GetDTOIfItExists(IDomainObjectDTORepository dtoRepository, string sGuid) + private static DomainObjectXMLDTO GetDTOIfItExists(IDomainObjectDTORepository dtoRepository, string sGuid) { try { diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000017.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000017.cs index 22326b7e..cc10b3b6 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000017.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000017.cs @@ -32,7 +32,7 @@ internal class DataMigration7000017 : IDataMigration /// public void PerformMigration(IDomainObjectDTORepository repoDTO) { - var collectOverlaysToRemove = new List(); + var collectOverlaysToRemove = new List(); bool fWeatherUsed = IsWeatherUsed(repoDTO, collectOverlaysToRemove); if (fWeatherUsed) ConvertWeatherToCustomListAndField(repoDTO); @@ -45,9 +45,9 @@ public void PerformMigration(IDomainObjectDTORepository repoDTO) DataMigrationServices.IncrementVersionNumber(repoDTO); } - private void RemoveUnwantedOverlays(IDomainObjectDTORepository repoDTO, List collectOverlaysToRemove) + private void RemoveUnwantedOverlays(IDomainObjectDTORepository repoDTO, List collectOverlaysToRemove) { - DomainObjectDTO dtoLP = GetDtoLangProj(repoDTO); + DomainObjectXMLDTO dtoLP = GetDtoLangProj(repoDTO); foreach (var dto in collectOverlaysToRemove) { RemoveOverlayElement(dtoLP, dto.Guid); @@ -62,10 +62,10 @@ private void RemoveUnwantedOverlays(IDomainObjectDTORepository repoDTO, List rgdtoDead = new List(); + List rgdtoDead = new List(); GatherDeadObjects(repoDTO, dtoDeadList, rgdtoDead); foreach (var dto in rgdtoDead) repoDTO.Remove(dto); @@ -92,9 +92,9 @@ private void DeleteWeatherListAndField(IDomainObjectDTORepository repoDTO) } } - private DomainObjectDTO GetDtoLangProj(IDomainObjectDTORepository repoDTO) + private DomainObjectXMLDTO GetDtoLangProj(IDomainObjectDTORepository repoDTO) { - DomainObjectDTO dtoLP = null; + DomainObjectXMLDTO dtoLP = null; foreach (var dto in repoDTO.AllInstancesWithSubclasses("LangProject")) { dtoLP = dto; @@ -116,15 +116,15 @@ private string RemoveEmptyWeather(string sXml, int idx) return sXml; } - private void GatherDeadObjects(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoDead, - List rgdtoDead) + private void GatherDeadObjects(IDomainObjectDTORepository repoDTO, DomainObjectXMLDTO dtoDead, + List rgdtoDead) { rgdtoDead.Add(dtoDead); foreach (var dto in repoDTO.GetDirectlyOwnedDTOs(dtoDead.Guid)) GatherDeadObjects(repoDTO, dto, rgdtoDead); } - private string RemoveWeatherConditionsElement(DomainObjectDTO dtoLP) + private string RemoveWeatherConditionsElement(DomainObjectXMLDTO dtoLP) { string sLpXml = dtoLP.Xml; int idx = sLpXml.IndexOf(""); @@ -135,7 +135,7 @@ private string RemoveWeatherConditionsElement(DomainObjectDTO dtoLP) return ExtractFirstGuid(sWeatherConditions, 0, " guid=\""); } - private void RemoveOverlayElement(DomainObjectDTO dtoLP, string overlayGuid) + private void RemoveOverlayElement(DomainObjectXMLDTO dtoLP, string overlayGuid) { string sLpXml = dtoLP.Xml; int idx = sLpXml.IndexOf(""); @@ -197,7 +197,7 @@ private string ExtractFirstGuid(string sElement, int startIndex, string sAttrTag private void ConvertWeatherToCustomListAndField(IDomainObjectDTORepository repoDTO) { // Change the Weather list to being unowned. - DomainObjectDTO dtoLP = null; + DomainObjectXMLDTO dtoLP = null; foreach (var dto in repoDTO.AllInstancesWithSubclasses("LangProject")) { dtoLP = dto; @@ -205,7 +205,7 @@ private void ConvertWeatherToCustomListAndField(IDomainObjectDTORepository repoD } string sWeatherListGuid = RemoveWeatherConditionsElement(dtoLP).ToLowerInvariant(); repoDTO.Update(dtoLP); - DomainObjectDTO dtoWeatherList = null; + DomainObjectXMLDTO dtoWeatherList = null; foreach (var dto in repoDTO.AllInstancesWithSubclasses("CmPossibilityList")) { if (dto.Guid.ToLowerInvariant() == sWeatherListGuid) @@ -254,13 +254,13 @@ private string RemoveOwnerGuid(string sXml) return sXml.Remove(idx, idxLim - idx); } - private bool IsWeatherUsed(IDomainObjectDTORepository repoDTO, List collectOverlaysToRemove) + private bool IsWeatherUsed(IDomainObjectDTORepository repoDTO, List collectOverlaysToRemove) { - DomainObjectDTO dtoLP = GetDtoLangProj(repoDTO); + DomainObjectXMLDTO dtoLP = GetDtoLangProj(repoDTO); string sLpXml = dtoLP.Xml; int idxW = sLpXml.IndexOf(""); var sguidWeather = ExtractFirstGuid(sLpXml, idxW, " guid=\""); - DomainObjectDTO dtoWeather = repoDTO.GetDTO(sguidWeather); + DomainObjectXMLDTO dtoWeather = repoDTO.GetDTO(sguidWeather); var weatherItems = new HashSet(); CollectItems(repoDTO, dtoWeather, weatherItems); foreach (var dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec")) @@ -337,7 +337,7 @@ private bool StringContainsRefToItemInList(string elementName, HashSet w /// Add to weatherItems the guids of all the things owned directly or indirectly by dtoRoot. /// Does not include the root itself. /// - private void CollectItems(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoRoot, HashSet guidCollector) + private void CollectItems(IDomainObjectDTORepository repoDTO, DomainObjectXMLDTO dtoRoot, HashSet guidCollector) { foreach (var dto in repoDTO.GetDirectlyOwnedDTOs(dtoRoot.Guid)) { diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000018.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000018.cs index 7599fc82..77f8f017 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000018.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000018.cs @@ -27,15 +27,15 @@ internal class DataMigration7000018 : IDataMigration { IDomainObjectDTORepository m_repoDTO; /// list of objects affected by TE's stylesheet - HashSet m_scrDtos = new HashSet(); + HashSet m_scrDtos = new HashSet(); /// the LangProject object - DomainObjectDTO m_dtoLangProj; + DomainObjectXMLDTO m_dtoLangProj; /// XML string representation of the <Styles> field in the LangProject object string m_sLangProjStyles; /// the LangProject StStyle objects - List m_langProjStyles = new List(); + List m_langProjStyles = new List(); /// - Dictionary m_mapPropsToStyle = new Dictionary(); + Dictionary m_mapPropsToStyle = new Dictionary(); Dictionary m_mapStyleNameToGuid = new Dictionary(); int m_cNewCharStyles = 0; int m_cNewParaStyles = 0; @@ -59,12 +59,12 @@ public void PerformMigration(IDomainObjectDTORepository repoDTO) // Get the list of StStyle DTOs from the LexDb.Styles field, and delete the // LexDb.Styles field. string sClass = "LexDb"; - DomainObjectDTO dtoLexDb = GetFirstInstance(sClass); + DomainObjectXMLDTO dtoLexDb = GetFirstInstance(sClass); string sXmlLexDb = dtoLexDb.Xml; int idxStyles = sXmlLexDb.IndexOf(""); int idxStylesLim = sXmlLexDb.IndexOf("") + 9; string sLexDbStyles = sXmlLexDb.Substring(idxStyles, idxStylesLim - idxStyles); - List stylesLexDb = new List(); + List stylesLexDb = new List(); foreach (string sGuid in GetGuidList(sLexDbStyles)) { var dto = m_repoDTO.GetDTO(sGuid); @@ -84,12 +84,12 @@ public void PerformMigration(IDomainObjectDTORepository repoDTO) List styleNames = new List(); m_langProjStyles.Clear(); m_mapStyleNameToGuid.Clear(); - DomainObjectDTO dtoHyperlink = null; - DomainObjectDTO dtoExternalLink = null; - DomainObjectDTO dtoInternalLink = null; - DomainObjectDTO dtoLanguageCode = null; - DomainObjectDTO dtoWrtSysAbbr = null; - DomainObjectDTO dtoStrong = null; + DomainObjectXMLDTO dtoHyperlink = null; + DomainObjectXMLDTO dtoExternalLink = null; + DomainObjectXMLDTO dtoInternalLink = null; + DomainObjectXMLDTO dtoLanguageCode = null; + DomainObjectXMLDTO dtoWrtSysAbbr = null; + DomainObjectXMLDTO dtoStrong = null; foreach (string sGuid in GetGuidList(m_sLangProjStyles)) { var dto = m_repoDTO.GetDTO(sGuid); @@ -303,9 +303,9 @@ private void UpdateStyleCrossReference(Dictionary mapLexDbStyleG } } - private DomainObjectDTO CreateCharStyle(string sName, string sProp, ContextValues context) + private DomainObjectXMLDTO CreateCharStyle(string sName, string sProp, ContextValues context) { - DomainObjectDTO dtoStyle; + DomainObjectXMLDTO dtoStyle; Guid guid = Guid.NewGuid(); string sGuid = guid.ToString().ToLowerInvariant(); StringBuilder sb = new StringBuilder(); @@ -322,7 +322,7 @@ private DomainObjectDTO CreateCharStyle(string sName, string sProp, ContextValue if (context != ContextValues.General) sb.AppendLine(String.Format("", (int)context)); sb.AppendLine(""); - dtoStyle = new DomainObjectDTO(sGuid, "StStyle", sb.ToString()); + dtoStyle = new DomainObjectXMLDTO(sGuid, "StStyle", sb.ToString()); m_repoDTO.Add(dtoStyle); int idxEnd = m_sLangProjStyles.IndexOf(""); m_sLangProjStyles = m_sLangProjStyles.Insert(idxEnd, String.Format("{1}", sGuid, Environment.NewLine)); @@ -331,7 +331,7 @@ private DomainObjectDTO CreateCharStyle(string sName, string sProp, ContextValue private void UpdateStyleLinks(Dictionary mapStyleGuids) { - foreach (DomainObjectDTO dto in m_repoDTO.AllInstancesSansSubclasses("StStyle")) + foreach (DomainObjectXMLDTO dto in m_repoDTO.AllInstancesSansSubclasses("StStyle")) { string sXml = dto.Xml; if (sXml.Contains("") || sXml.Contains("")) @@ -348,7 +348,7 @@ private void UpdateStyleLinks(Dictionary mapStyleGuids) } // Also change any references in Data Notebook UserViewField objects, even though // these probably don't matter. - foreach (DomainObjectDTO dto in m_repoDTO.AllInstancesSansSubclasses("UserViewField")) + foreach (DomainObjectXMLDTO dto in m_repoDTO.AllInstancesSansSubclasses("UserViewField")) { string sXml = dto.Xml; if (!sXml.Contains(" mapStyleGuids, return false; } - private string DeleteStyle(string sLangProjStyles, DomainObjectDTO dto) + private string DeleteStyle(string sLangProjStyles, DomainObjectXMLDTO dto) { string sGuid = dto.Guid.ToLowerInvariant(); m_repoDTO.Remove(dto); @@ -415,7 +415,7 @@ where os.Attribute("guid").Value.ToLowerInvariant() == sGuid && os.Attribute("t" return sLangProjStyles; } - private void SetOwnerGuid(DomainObjectDTO dto, string sGuidNewOwner) + private void SetOwnerGuid(DomainObjectXMLDTO dto, string sGuidNewOwner) { string sXml = dto.Xml; int idx = sXml.IndexOf(" ownerguid=") + 11; @@ -437,7 +437,7 @@ private string GetStyleName(string sXmlStyle) return sXmlName.Substring(idx, idxLim - idx); } - private DomainObjectDTO GetFirstInstance(string sClass) + private DomainObjectXMLDTO GetFirstInstance(string sClass) { foreach (var dto in m_repoDTO.AllInstancesSansSubclasses(sClass)) { @@ -475,7 +475,7 @@ private void ChangeStyleReferences() byte[] rgbExternalLink2 = Encoding.UTF8.GetBytes(" namedStyle='External Link'"); byte[] rgbInternalLink2 = Encoding.UTF8.GetBytes(" namedStyle='Internal Link'"); byte[] rgbLanguageCode2 = Encoding.UTF8.GetBytes(" namedStyle='Language Code'"); - foreach (DomainObjectDTO dto in m_repoDTO.AllInstancesWithValidClasses()) + foreach (DomainObjectXMLDTO dto in m_repoDTO.AllInstancesWithValidClasses()) { if (m_scrDtos.Contains(dto)) continue; @@ -518,7 +518,7 @@ private void EnsureScrObjListFull() { if (m_scrDtos.Count == 0) { - foreach (DomainObjectDTO dto in m_repoDTO.AllInstancesSansSubclasses("Scripture")) + foreach (DomainObjectXMLDTO dto in m_repoDTO.AllInstancesSansSubclasses("Scripture")) { m_scrDtos.Add(dto); AddOwnedObjects(dto, m_scrDtos); @@ -530,7 +530,7 @@ private void ReplaceDirectFormattingWithStyles() { EnsureScrObjListFull(); byte[] rgbRun = Encoding.UTF8.GetBytes(""); + DomainObjectXMLDTO dtoStyle = GetMatchingStyle(sNormDirectFmt, ""); ReplaceRunDirectFmts(xe, GetStyleName(dtoStyle.Xml)); fUpdate = true; } @@ -556,7 +556,7 @@ private void ReplaceDirectFormattingWithStyles() } } byte[] rgbProp = Encoding.UTF8.GetBytes(""); - dtoStyle = new DomainObjectDTO(guidNew.ToString().ToLowerInvariant(), "StStyle", sb.ToString()); + dtoStyle = new DomainObjectXMLDTO(guidNew.ToString().ToLowerInvariant(), "StStyle", sb.ToString()); m_repoDTO.Add(dtoStyle); int idxEnd = m_sLangProjStyles.IndexOf(""); m_sLangProjStyles = m_sLangProjStyles.Insert(idxEnd, String.Format("{1}", @@ -637,14 +637,14 @@ private DomainObjectDTO GetMatchingStyle(string sNormProps, string sTypeVal) private void LoadPropsToStyleMap() { - foreach (DomainObjectDTO dto in m_langProjStyles) + foreach (DomainObjectXMLDTO dto in m_langProjStyles) { string sNormProps = GetNormalizedStyleProps(dto); if (String.IsNullOrEmpty(sNormProps)) continue; // empty definition is possible... // More than one style can have the same properties -- we'll use the first, or // the first without a element (ie, the general context). - DomainObjectDTO dtoPrior; + DomainObjectXMLDTO dtoPrior; if (m_mapPropsToStyle.TryGetValue(sNormProps, out dtoPrior)) { if (dtoPrior.Xml.Contains(" 0; } - private void AddOwnedObjects(DomainObjectDTO dto, HashSet scrObjs) + private void AddOwnedObjects(DomainObjectXMLDTO dto, HashSet scrObjs) { - foreach (DomainObjectDTO dtoOwned in m_repoDTO.GetDirectlyOwnedDTOs(dto.Guid)) + foreach (DomainObjectXMLDTO dtoOwned in m_repoDTO.GetDirectlyOwnedDTOs(dto.Guid)) { scrObjs.Add(dtoOwned); AddOwnedObjects(dtoOwned, scrObjs); @@ -1031,7 +1031,7 @@ private void ReplacePropDirectFmts(XElement xeProp, string sStyleName) private void EnsureBuiltinStylesAreMarkedBuiltin() { - foreach (DomainObjectDTO dto in m_langProjStyles) + foreach (DomainObjectXMLDTO dto in m_langProjStyles) { string sXml = dto.Xml; if (IsStyleBuiltIn(sXml)) diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000019.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000019.cs index e77ba652..59cf8647 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000019.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000019.cs @@ -60,8 +60,8 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000018); // collect all writing system info - var guidToWsInfo = new Dictionary>(); - foreach (DomainObjectDTO wsDto in domainObjectDtoRepository.AllInstancesSansSubclasses("LgWritingSystem").ToArray()) + var guidToWsInfo = new Dictionary>(); + foreach (DomainObjectXMLDTO wsDto in domainObjectDtoRepository.AllInstancesSansSubclasses("LgWritingSystem").ToArray()) { XElement wsElem = XElement.Parse(wsDto.Xml); XElement icuLocaleElem = wsElem.Element("ICULocale"); @@ -71,11 +71,11 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor } // remove all CmSortSpec objects - foreach (DomainObjectDTO sortSpecDto in domainObjectDtoRepository.AllInstancesSansSubclasses("CmSortSpec").ToArray()) + foreach (DomainObjectXMLDTO sortSpecDto in domainObjectDtoRepository.AllInstancesSansSubclasses("CmSortSpec").ToArray()) domainObjectDtoRepository.Remove(sortSpecDto); // remove SortSpecs property from LangProject - DomainObjectDTO lpDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject").First(); + DomainObjectXMLDTO lpDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject").First(); XElement lpElem = XElement.Parse(lpDto.Xml); XElement sortSpecsElem = lpElem.Element("SortSpecs"); bool lpModified = false; @@ -126,7 +126,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor ConvertAllIcuLocalesToLangTags(domainObjectDtoRepository, "ScrImportSource", referencedWsIds); // convert all ICU locales to Language Tags and remove legacy magic font names - foreach (DomainObjectDTO dto in domainObjectDtoRepository.AllInstances()) + foreach (DomainObjectXMLDTO dto in domainObjectDtoRepository.AllInstances()) UpdateStringsAndProps(domainObjectDtoRepository, dto, referencedWsIds); var localStoreFolder = Path.Combine(domainObjectDtoRepository.ProjectFolder, LcmFileHelper.ksWritingSystemsDir); @@ -136,7 +136,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor // extracting data from the obsolete writing system object's XML. if (!string.IsNullOrEmpty(domainObjectDtoRepository.ProjectFolder)) { - foreach (Tuple wsInfo in guidToWsInfo.Values) + foreach (Tuple wsInfo in guidToWsInfo.Values) { if (referencedWsIds.Contains(wsInfo.Item1)) { @@ -168,7 +168,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor } } } - foreach (Tuple wsInfo in guidToWsInfo.Values) + foreach (Tuple wsInfo in guidToWsInfo.Values) { // this should also remove all LgCollations as well DataMigrationServices.RemoveIncludingOwnedObjects(domainObjectDtoRepository, wsInfo.Item2, false); @@ -180,7 +180,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor private static void ConvertAllIcuLocalesToLangTags(IDomainObjectDTORepository domainObjectDtoRepository, string className, HashSet referencedWsIds) { - foreach (DomainObjectDTO dto in domainObjectDtoRepository.AllInstancesWithSubclasses(className)) + foreach (DomainObjectXMLDTO dto in domainObjectDtoRepository.AllInstancesWithSubclasses(className)) { XElement elem = XElement.Parse(dto.Xml); XElement icuLocaleElem = elem.Element("ICULocale"); @@ -196,7 +196,7 @@ private static void ConvertAllIcuLocalesToLangTags(IDomainObjectDTORepository do } } - private static void UpdateStringsAndProps(IDomainObjectDTORepository domainObjectDtoRepository, DomainObjectDTO dto, + private static void UpdateStringsAndProps(IDomainObjectDTORepository domainObjectDtoRepository, DomainObjectXMLDTO dto, HashSet referencedWsIds) { XElement objElem = XElement.Parse(dto.Xml); @@ -286,9 +286,9 @@ private static bool UpdateFontAttribute(XElement elem) } private static void ConvertAllRefsToStrings(IDomainObjectDTORepository domainObjectDtoRepository, string className, - Dictionary> guidToWsInfo, HashSet referencedWsIds) + Dictionary> guidToWsInfo, HashSet referencedWsIds) { - foreach (DomainObjectDTO dto in domainObjectDtoRepository.AllInstancesWithSubclasses(className)) + foreach (DomainObjectXMLDTO dto in domainObjectDtoRepository.AllInstancesWithSubclasses(className)) { XElement elem = XElement.Parse(dto.Xml); if (ConvertRefToString(elem.Element("WritingSystem"), guidToWsInfo, referencedWsIds)) @@ -296,7 +296,7 @@ private static void ConvertAllRefsToStrings(IDomainObjectDTORepository domainObj } } - private static bool ConvertRefToString(XElement refElem, Dictionary> guidToWsInfo, + private static bool ConvertRefToString(XElement refElem, Dictionary> guidToWsInfo, HashSet referencedWsIds) { if (refElem == null) @@ -474,7 +474,7 @@ private static void FillWritingSystemFromLcm(IDomainObjectDTORepository domainOb if (surElem != null) { var guid = (string) surElem.Attribute("guid"); - DomainObjectDTO collDto = domainObjectDtoRepository.GetDTO(guid); + DomainObjectXMLDTO collDto = domainObjectDtoRepository.GetDTO(guid); XElement collElem = XElement.Parse(collDto.Xml); string sortRules = GetUnicode(collElem, "ICURules"); if (!string.IsNullOrEmpty(sortRules)) diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000020.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000020.cs index 9f1c688b..c901effa 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000020.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000020.cs @@ -30,7 +30,7 @@ public void PerformMigration(IDomainObjectDTORepository repoDto) { DataMigrationServices.CheckVersionNumber(repoDto, 7000019); - var viewsToDelete = new List(); + var viewsToDelete = new List(); foreach (var dtoView in repoDto.AllInstancesSansSubclasses("UserView")) { var xeView = XElement.Parse(dtoView.Xml); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000022.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000022.cs index 4aa7d65f..4521f66f 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000022.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000022.cs @@ -198,7 +198,7 @@ private static XElement MakeEmptyNameElementInList(XElement listElement) return nameElem; } - private static DomainObjectDTO GetListDto(IDomainObjectDTORepository dtoRepos, + private static DomainObjectXMLDTO GetListDto(IDomainObjectDTORepository dtoRepos, XElement owningElem, string flidName) { var xPath = flidName + "/objsur"; @@ -206,7 +206,7 @@ private static DomainObjectDTO GetListDto(IDomainObjectDTORepository dtoRepos, if (objsurElem == null) return null; var guid = objsurElem.Attribute("guid").Value; - DomainObjectDTO dto; + DomainObjectXMLDTO dto; if(dtoRepos.TryGetValue(guid, out dto)) return dto; return null; diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000024.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000024.cs index c1d13535..5c98b6dd 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000024.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000024.cs @@ -196,7 +196,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor /// Given that the element has been changed to represent the desired new state of the DTO, /// save the change. /// - private void UpdateDto(IDomainObjectDTORepository domainObjectDtoRepository, DomainObjectDTO dto, XElement element) + private void UpdateDto(IDomainObjectDTORepository domainObjectDtoRepository, DomainObjectXMLDTO dto, XElement element) { dto.Xml = element.ToString(); domainObjectDtoRepository.Update(dto); @@ -207,7 +207,7 @@ private void UpdateDto(IDomainObjectDTORepository domainObjectDtoRepository, Dom /// private void UpdateDto(IDomainObjectDTORepository domainObjectDtoRepository, XElement element) { - DomainObjectDTO dto = domainObjectDtoRepository.GetDTO(element.Attribute("guid").Value); + DomainObjectXMLDTO dto = domainObjectDtoRepository.GetDTO(element.Attribute("guid").Value); dto.Xml = element.ToString(); domainObjectDtoRepository.Update(dto); } @@ -232,7 +232,7 @@ private string MakeStatus(IDomainObjectDTORepository domainObjectDtoRepository, new XAttribute("ownerguid", langPossListGuid), MakeMultiUnicode("Name", name), MakeMultiUnicode("Abbreviation", abbr)); - var dtoConfirmed = new DomainObjectDTO(statusConfirmedGuid, "CmPossibility", confirmed.ToString()); + var dtoConfirmed = new DomainObjectXMLDTO(statusConfirmedGuid, "CmPossibility", confirmed.ToString()); domainObjectDtoRepository.Add(dtoConfirmed); langPossListElement.Element("Possibilities").Add(MakeOwningSurrogate(statusConfirmedGuid)); return statusConfirmedGuid; diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000025.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000025.cs index af5537a8..1adef1f4 100644 Binary files a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000025.cs and b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000025.cs differ diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000026.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000026.cs index ab3c48dc..ef5b7723 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000026.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000026.cs @@ -74,7 +74,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor /// Given that the element has been changed to represent the desired new state of the DTO, /// save the change. /// - private void UpdateDto(IDomainObjectDTORepository domainObjectDtoRepository, DomainObjectDTO dto, XElement element) + private void UpdateDto(IDomainObjectDTORepository domainObjectDtoRepository, DomainObjectXMLDTO dto, XElement element) { dto.Xml = element.ToString(); domainObjectDtoRepository.Update(dto); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000027.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000027.cs index 7a72a73f..c10a41a4 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000027.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000027.cs @@ -61,7 +61,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor XAttribute linkAttr = run.Attribute("ownlink"); if (linkAttr == null) continue; // Run doesn't contain a link - DomainObjectDTO linkObj; + DomainObjectXMLDTO linkObj; // skip links to missing footnotes - user will have to clean these up later. if (!domainObjectDtoRepository.TryGetValue(linkAttr.Value, out linkObj)) continue; diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000029.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000029.cs index 6fda2160..6f106e1c 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000029.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000029.cs @@ -100,7 +100,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor /// Given that the element has been changed to represent the desired new state of the DTO, /// save the change. /// - private void UpdateDto(IDomainObjectDTORepository domainObjectDtoRepository, DomainObjectDTO dto, XElement element) + private void UpdateDto(IDomainObjectDTORepository domainObjectDtoRepository, DomainObjectXMLDTO dto, XElement element) { dto.Xml = element.ToString(); domainObjectDtoRepository.Update(dto); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000030.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000030.cs index e471e7b7..aa03d6f2 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000030.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000030.cs @@ -83,7 +83,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor //------------------------------------------------- var langProjectGuid = langProjElement.Attribute("guid").Value; var filePathsInTsStringsElement = AddFilePathsInTsStringsElement(langProjElement); - DomainObjectDTO cmFolderDto; + DomainObjectXMLDTO cmFolderDto; var cmFolderXElement = MakeCmFolder(domainObjectDtoRepository, langProjectGuid, filePathsInTsStringsElement, CmFolderTags.LocalFilePathsInTsStrings, out cmFolderDto); UpdateDto(domainObjectDtoRepository, langProjDto, langProjElement); @@ -128,7 +128,7 @@ private XElement AddFilePathsInTsStringsElement(XElement langProject) // // private XElement MakeCmFolder(IDomainObjectDTORepository domainObjectDtoRepository, string langProjectGuid, - XElement filePathsInTsStringsCmFolder, string name, out DomainObjectDTO folderDto) + XElement filePathsInTsStringsCmFolder, string name, out DomainObjectXMLDTO folderDto) { string cmFolderGuid; cmFolderGuid = Guid.NewGuid().ToString(); @@ -138,7 +138,7 @@ private XElement MakeCmFolder(IDomainObjectDTORepository domainObjectDtoReposito new XAttribute("ownerguid", langProjectGuid), MakeMultiUnicode("Name", name), new XElement("Files")); - folderDto = new DomainObjectDTO(cmFolderGuid, "CmFolder", cmFolderXML.ToString()); + folderDto = new DomainObjectXMLDTO(cmFolderGuid, "CmFolder", cmFolderXML.ToString()); domainObjectDtoRepository.Add(folderDto); filePathsInTsStringsCmFolder.Add(MakeOwningSurrogate(cmFolderGuid)); return cmFolderXML; @@ -162,7 +162,7 @@ private void MakeCmFile(IDomainObjectDTORepository domainObjectDtoRepository, st new XAttribute("class", "CmFile"), new XAttribute("ownerguid", langCmFolderGuid), MakeUnicode("InternalPath", path)); - var dtoConfirmed = new DomainObjectDTO(cmFileGuid, "CmFile", cmFileXElement.ToString()); + var dtoConfirmed = new DomainObjectXMLDTO(cmFileGuid, "CmFile", cmFileXElement.ToString()); domainObjectDtoRepository.Add(dtoConfirmed); langCmFolder.Element("Files").Add(MakeOwningSurrogate(cmFileGuid)); } @@ -249,7 +249,7 @@ private List ProcessExternalLinksRelativePaths(IDomainObjectDTORepositor /// Given that the element has been changed to represent the desired new state of the DTO, /// save the change. /// - private void UpdateDto(IDomainObjectDTORepository domainObjectDtoRepository, DomainObjectDTO dto, XElement element) + private void UpdateDto(IDomainObjectDTORepository domainObjectDtoRepository, DomainObjectXMLDTO dto, XElement element) { dto.Xml = element.ToString(); domainObjectDtoRepository.Update(dto); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000031.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000031.cs index 8b3a06c5..03d6f261 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000031.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000031.cs @@ -55,8 +55,8 @@ public void PerformMigration(IDomainObjectDTORepository repoDto) { DataMigrationServices.CheckVersionNumber(repoDto, 7000030); - List viewsToDelete = new List(); - foreach (DomainObjectDTO dtoView in repoDto.AllInstancesSansSubclasses("UserView")) + List viewsToDelete = new List(); + foreach (DomainObjectXMLDTO dtoView in repoDto.AllInstancesSansSubclasses("UserView")) { XElement xeView = XElement.Parse(dtoView.Xml); XElement xeApp = xeView.Element("App"); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000034.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000034.cs index b49a1903..324c8a4f 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000034.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000034.cs @@ -57,7 +57,7 @@ public void PerformMigration(IDomainObjectDTORepository repoDto) if (pictures != null && pictures.Elements().Count() > 1) { - DomainObjectDTO folder = null; + DomainObjectXMLDTO folder = null; bool foundFiles = false; foreach (var x in pictures.Elements()) { @@ -84,8 +84,8 @@ public void PerformMigration(IDomainObjectDTORepository repoDto) DataMigrationServices.IncrementVersionNumber(repoDto); } - private void MoveFileReferences(IDomainObjectDTORepository repoDto, DomainObjectDTO langProj, - DomainObjectDTO srcFolder, DomainObjectDTO destFolder) + private void MoveFileReferences(IDomainObjectDTORepository repoDto, DomainObjectXMLDTO langProj, + DomainObjectXMLDTO srcFolder, DomainObjectXMLDTO destFolder) { var srcFolderElement = XElement.Parse(srcFolder.Xml); var destFolderElement = XElement.Parse(destFolder.Xml); @@ -105,7 +105,7 @@ private void MoveFileReferences(IDomainObjectDTORepository repoDto, DomainObject DataMigrationServices.UpdateDTO(repoDto, destFolder, destFolderElement.ToString()); } - private void RemoveReferenceFromPictures(IDomainObjectDTORepository repoDto, DomainObjectDTO langProj, + private void RemoveReferenceFromPictures(IDomainObjectDTORepository repoDto, DomainObjectXMLDTO langProj, string guid) { var langProjElement = XElement.Parse(langProj.Xml); @@ -121,7 +121,7 @@ private void RemoveReferenceFromPictures(IDomainObjectDTORepository repoDto, Dom } private void RemoveInvalidFiles(IDomainObjectDTORepository repoDto, - DomainObjectDTO langProj, DomainObjectDTO folder) + DomainObjectXMLDTO langProj, DomainObjectXMLDTO folder) { var langProjElement = XElement.Parse(langProj.Xml); var pictures = langProjElement.Element("Pictures"); @@ -151,7 +151,7 @@ private void RemoveInvalidFiles(IDomainObjectDTORepository repoDto, } } - private void MoveFileToFolder(IDomainObjectDTORepository repoDto, DomainObjectDTO folder, DomainObjectDTO fileToMove) + private void MoveFileToFolder(IDomainObjectDTORepository repoDto, DomainObjectXMLDTO folder, DomainObjectXMLDTO fileToMove) { // Create surogate for file and add it to the folder var surrogate = DataMigrationServices.CreateOwningObjSurElement(fileToMove.Guid); @@ -166,11 +166,11 @@ private void MoveFileToFolder(IDomainObjectDTORepository repoDto, DomainObjectDT DataMigrationServices.UpdateDTO(repoDto, fileToMove, fileElement.ToString()); } - private void UpdatePictureReferences(IDomainObjectDTORepository repoDto, DomainObjectDTO file, + private void UpdatePictureReferences(IDomainObjectDTORepository repoDto, DomainObjectXMLDTO file, string replacementFileGuid, - Dictionary> pictureMap) + Dictionary> pictureMap) { - List pictures; + List pictures; if(pictureMap.TryGetValue(file.Guid, out pictures)) { foreach (var picture in pictures) @@ -183,9 +183,9 @@ private void UpdatePictureReferences(IDomainObjectDTORepository repoDto, DomainO } } - private Dictionary> CreateFileGuidToPictureMap(IDomainObjectDTORepository repoDto) + private Dictionary> CreateFileGuidToPictureMap(IDomainObjectDTORepository repoDto) { - var map = new Dictionary>(); + var map = new Dictionary>(); foreach (var picture in repoDto.AllInstancesSansSubclasses("CmPicture")) { // all TE pictures are unowned, so no need to look at those with owners @@ -200,10 +200,10 @@ private Dictionary> CreateFileGuidToPictureMap(IDo var objSurrogateElement = pictureFileElement.Element("objsur"); var fileGuid = objSurrogateElement.Attribute("guid").Value; - List list; + List list; if (!map.TryGetValue(fileGuid, out list)) { - list = new List(); + list = new List(); map[fileGuid] = list; } list.Add(picture); @@ -212,7 +212,7 @@ private Dictionary> CreateFileGuidToPictureMap(IDo return map; } - private Dictionary CreateFilePathToGuidMap(IDomainObjectDTORepository repoDto, DomainObjectDTO folder) + private Dictionary CreateFilePathToGuidMap(IDomainObjectDTORepository repoDto, DomainObjectXMLDTO folder) { var folderElement = XElement.Parse(folder.Xml); var map = new Dictionary(); @@ -226,7 +226,7 @@ private Dictionary CreateFilePathToGuidMap(IDomainObjectDTORepos return map; } - private string GetFilePath(DomainObjectDTO file) + private string GetFilePath(DomainObjectXMLDTO file) { var fileElement = XElement.Parse(file.Xml); var pathElement = fileElement.Element("InternalPath"); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000041.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000041.cs index 2d3d7ccc..9e9c798f 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000041.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000041.cs @@ -58,17 +58,17 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor if (dtoPubList == null || dtoPubList.Count() == 0) // add the Publications list to the project { // This list is owned by LexDb var ieDtoLexDb = domainObjectDtoRepository.AllInstancesSansSubclasses("LexDb"); - Debug.Assert(ieDtoLexDb != null && ieDtoLexDb.Count() == 1, "Project has no LexDb Dto or more than one"); - var dtoLexDb = ieDtoLexDb.First(); + Debug.Assert(ieDtoLexDb != null && ieDtoLexDb.Count() == 1, "Project has no LexDb Dto or more than one"); + var dtoLexDb = ieDtoLexDb.First(); var xNode = XElement.Parse(dtoLexDb.Xml); var ksguidLexDb = xNode.Attribute("guid").Value; var nowStr = DateTime.Now.ToLCMTimeFormatWithMillisString(); string xmlStrPub = "Publications"; - var dtoPub = new DomainObjectDTO(ksguidPubList, "CmPossibilityList", xmlStrPub); + var dtoPub = new DomainObjectXMLDTO(ksguidPubList, "CmPossibilityList", xmlStrPub); string xmlStrMD = "Main DictionaryMain"; - var dtoMD = new DomainObjectDTO(ksguidMainDictionary, "CmPossibility", xmlStrMD); + var dtoMD = new DomainObjectXMLDTO(ksguidMainDictionary, "CmPossibility", xmlStrMD); domainObjectDtoRepository.Add(dtoMD); domainObjectDtoRepository.Add(dtoPub); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000042.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000042.cs index 799ce8e8..f93ae95c 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000042.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000042.cs @@ -116,7 +116,7 @@ private void FixOwnershipOfSubtypes(IDomainObjectDTORepository repoDto) var cFixed = 0; foreach (var dtoSub in repoDto.GetDirectlyOwnedDTOs(dto.Guid)) { - DomainObjectDTO dtoOwner; + DomainObjectXMLDTO dtoOwner; if (!repoDto.TryGetOwner(dtoSub.Guid, out dtoOwner) || dtoOwner != dto) { // we have a broken ownership link -- fix it! @@ -183,14 +183,14 @@ private void FixOrAddMissingTypes(IDomainObjectDTORepository repoDto, IEnumerabl if (m_mapNameGuid.Count > 0) { BuildNewTypeMaps(); - var newTypes = new HashSet(); + var newTypes = new HashSet(); foreach (var guid in m_mapGuidName.Keys) { // We need to create this LexEntryType! var rgNewDtos = m_mapGuidNewDtos[guid]; foreach (var info in rgNewDtos) { - var dto = new DomainObjectDTO(info.Guid, info.ClassName, info.Xml); + var dto = new DomainObjectXMLDTO(info.Guid, info.ClassName, info.Xml); repoDto.Add(dto); if (info.ClassName == "LexEntryType") newTypes.Add(dto); @@ -257,7 +257,7 @@ private void ChangeInvalidGuid(IDomainObjectDTORepository repoDto, LexTypeInfo i m_mapBadGoodGuids.Add(guidBad, guidStd); var className = info.DTO.Classname; repoDto.Remove(info.DTO); - info.DTO = new DomainObjectDTO(guidStd, className, info.XmlElement.ToString()); + info.DTO = new DomainObjectXMLDTO(guidStd, className, info.XmlElement.ToString()); repoDto.Add(info.DTO); // Fix the owning reference (but only if it's one of the two lists, because otherwise // it might be contained in a LexTypeInfo that hasn't yet been processed). @@ -265,7 +265,7 @@ private void ChangeInvalidGuid(IDomainObjectDTORepository repoDto, LexTypeInfo i var good = String.Format("guid=\"{0}\"", guidStd); var bad2 = String.Format("guid='{0}'", guidBad); // probably pure paranoia... var good2 = String.Format("guid='{0}'", guidStd); - DomainObjectDTO dtoOwner; + DomainObjectXMLDTO dtoOwner; if (repoDto.TryGetOwner(info.DTO.Guid, out dtoOwner) && dtoOwner.Classname == "CmPossibilityList") { dtoOwner.Xml = dtoOwner.Xml.Replace(bad, good).Replace(bad2, good2); @@ -1847,10 +1847,10 @@ private static string GetGuidValue(XNode xe, string xpath) /// internal class LexTypeInfo { - public DomainObjectDTO DTO { get; set; } + public DomainObjectXMLDTO DTO { get; set; } public XElement XmlElement { get; private set; } - internal LexTypeInfo(DomainObjectDTO dto, XElement xe) + internal LexTypeInfo(DomainObjectXMLDTO dto, XElement xe) { DTO = dto; XmlElement = xe; diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000047.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000047.cs index 0712d4fb..7bee6062 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000047.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000047.cs @@ -49,10 +49,10 @@ public void PerformMigration(IDomainObjectDTORepository repoDto) { DataMigrationServices.CheckVersionNumber(repoDto, 7000046); - Dictionary mapOfRenderingsToChk = new Dictionary(); - HashSet renderingsToDelete = new HashSet(); + Dictionary mapOfRenderingsToChk = new Dictionary(); + HashSet renderingsToDelete = new HashSet(); - foreach (DomainObjectDTO dto in repoDto.AllInstances()) + foreach (DomainObjectXMLDTO dto in repoDto.AllInstances()) { XElement data = XElement.Parse(dto.Xml); XAttribute classAttr = data.Attribute("class"); @@ -71,9 +71,9 @@ public void PerformMigration(IDomainObjectDTORepository repoDto) } } - foreach (DomainObjectDTO rendering in renderingsToDelete) + foreach (DomainObjectXMLDTO rendering in renderingsToDelete) { - DomainObjectDTO chkTerm = mapOfRenderingsToChk[new Guid(rendering.Guid)]; + DomainObjectXMLDTO chkTerm = mapOfRenderingsToChk[new Guid(rendering.Guid)]; XElement termData = XElement.Parse(chkTerm.Xml); XElement renderings = termData.Element("Renderings"); XElement bogusRendering = renderings.Elements().First(e => e.Attribute("guid").Value.Equals(rendering.Guid, StringComparison.OrdinalIgnoreCase)); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000051.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000051.cs index d053e7dc..c351891c 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000051.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000051.cs @@ -36,7 +36,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor var lpElement = XElement.Parse(data); lpElement.Attribute("guid").Value = newGuidValue; - var newLpDto = new DomainObjectDTO(newGuidValue, className, lpElement.ToString()); + var newLpDto = new DomainObjectXMLDTO(newGuidValue, className, lpElement.ToString()); domainObjectDtoRepository.Add(newLpDto); // Change ownerguid attr for each owned item to new guid. diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000056.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000056.cs index 39648477..32e2e0d0 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000056.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000056.cs @@ -46,7 +46,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor var newPhPhonDataElt = new XElement("PhPhonData", new XAttribute("guid", sPhPhonDataGuid), new XAttribute("ownerguid", wmbLangProj.Guid)); - wmbPhonData = new DomainObjectDTO(sPhPhonDataGuid, "PhPhonData", newPhPhonDataElt.ToString()); + wmbPhonData = new DomainObjectXMLDTO(sPhPhonDataGuid, "PhPhonData", newPhPhonDataElt.ToString()); domainObjectDtoRepository.Add(wmbPhonData); } XElement wmbPhonDataElt = XElement.Parse(wmbPhonData.Xml); @@ -83,7 +83,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor sb.Append(""); sb.Append(""); var newCmPossibilityListElt = XElement.Parse(sb.ToString()); - var dtoCmPossibilityList = new DomainObjectDTO(sPossibilityListGuid, "CmPossibilityList", newCmPossibilityListElt.ToString()); + var dtoCmPossibilityList = new DomainObjectXMLDTO(sPossibilityListGuid, "CmPossibilityList", newCmPossibilityListElt.ToString()); domainObjectDtoRepository.Add(dtoCmPossibilityList); DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000057.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000057.cs index a7ecfdbe..96e7e263 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000057.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000057.cs @@ -33,7 +33,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor // first change the class of all the known systemGuids foreach (var systemGuid in irregularlyInflectedFormVariantTypeSystemGuids) { - DomainObjectDTO dtoVariantType; + DomainObjectXMLDTO dtoVariantType; // LT-13312 Note some projects may not have these guids. if (domainObjectDtoRepository.TryGetValue(systemGuid, out dtoVariantType)) { @@ -44,7 +44,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository); } - void ChangeClassOfOwnerAndChildren(IDomainObjectDTORepository dtoRepo, DomainObjectDTO dtoToChange, string oldClassname, string newClassname) + void ChangeClassOfOwnerAndChildren(IDomainObjectDTORepository dtoRepo, DomainObjectXMLDTO dtoToChange, string oldClassname, string newClassname) { // bail out if we've already changed the class name (assume we've already changed its children too). if (!TryChangeOwnerClass(dtoRepo, dtoToChange, oldClassname, newClassname)) @@ -55,7 +55,7 @@ void ChangeClassOfOwnerAndChildren(IDomainObjectDTORepository dtoRepo, DomainObj } } - bool TryChangeOwnerClass(IDomainObjectDTORepository dtoRepo, DomainObjectDTO dtoToChange, string oldClassname, string newClassname) + bool TryChangeOwnerClass(IDomainObjectDTORepository dtoRepo, DomainObjectXMLDTO dtoToChange, string oldClassname, string newClassname) { XElement dtoToChangeElt = XElement.Parse(dtoToChange.Xml); if (dtoToChangeElt.Attribute("class").Value != oldClassname) diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000058.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000058.cs index 34d96006..332bd912 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000058.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000058.cs @@ -26,7 +26,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000057); { // LT-13312 Note some projects may not have these guids. - DomainObjectDTO dtoVariantType; + DomainObjectXMLDTO dtoVariantType; if (domainObjectDtoRepository.TryGetValue(LexEntryTypeTags.kguidLexTypPluralVar.ToString(), out dtoVariantType)) AddGlossAppendIfEmpty(domainObjectDtoRepository, dtoVariantType, ".pl"); if (domainObjectDtoRepository.TryGetValue(LexEntryTypeTags.kguidLexTypPastVar.ToString(), out dtoVariantType)) @@ -35,7 +35,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository); } - static private void AddGlossAppendIfEmpty(IDomainObjectDTORepository dtoRepo, DomainObjectDTO dtoToChange, string glossAppend) + static private void AddGlossAppendIfEmpty(IDomainObjectDTORepository dtoRepo, DomainObjectXMLDTO dtoToChange, string glossAppend) { XElement dtoToChangeElt = XElement.Parse(dtoToChange.Xml); XElement glossAppendElt = dtoToChangeElt.XPathSelectElement("GlossAppend"); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000065.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000065.cs index 0fbdc211..7c130f94 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000065.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000065.cs @@ -117,7 +117,7 @@ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepositor DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository); } - private static void GetWsNamesFromReversalIndex(DomainObjectDTO revIndexDto, Dictionary wsCodeNameDict ) + private static void GetWsNamesFromReversalIndex(DomainObjectXMLDTO revIndexDto, Dictionary wsCodeNameDict ) { var wsElt = XElement.Parse(revIndexDto.Xml).Element(Name); var existingNameAUniElts = wsElt.Elements(Auni); @@ -129,7 +129,7 @@ private static void GetWsNamesFromReversalIndex(DomainObjectDTO revIndexDto, Dic } } - private static bool GetGuidForPosListSafely(DomainObjectDTO revIndexDto, out string possListGuid) + private static bool GetGuidForPosListSafely(DomainObjectXMLDTO revIndexDto, out string possListGuid) { possListGuid = string.Empty; var posElt = XElement.Parse(revIndexDto.Xml).Element("PartsOfSpeech"); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000069.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000069.cs index df1947e8..61fe3638 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000069.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000069.cs @@ -188,7 +188,7 @@ private static void UpdateRestrictions(IDomainObjectDTORepository repoDto) } } - private static void ChangeMultiUnicodeElementToMultiString(IDomainObjectDTORepository repoDto, DomainObjectDTO dto, + private static void ChangeMultiUnicodeElementToMultiString(IDomainObjectDTORepository repoDto, DomainObjectXMLDTO dto, string xpathToMultiUnicodeElement) { const string auniXpath = "/AUni"; @@ -328,7 +328,7 @@ private static void CreateLexEntryType(IDomainObjectDTORepository repoDto, strin repoDto.Update(entryTypeDto); } - internal static void AddRefType(XElement data, IDomainObjectDTORepository repoDto, DomainObjectDTO dto, string tagName, string guid, bool owned) + internal static void AddRefType(XElement data, IDomainObjectDTORepository repoDto, DomainObjectXMLDTO dto, string tagName, string guid, bool owned) { var varElementTag = data.Element(tagName); if (varElementTag == null) diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000070.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000070.cs index 1a5ba35d..8ba28377 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000070.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigration7000070.cs @@ -31,8 +31,8 @@ public void PerformMigration(IDomainObjectDTORepository repoDto) private void RenameDuplicateCustomListsAndFixBadLists(IDomainObjectDTORepository repoDto) { var allLists = repoDto.AllInstancesWithSubclasses("CmPossibilityList"); - var namesAndLists = new Dictionary, DomainObjectDTO>(); - var duplicates = new List>(); + var namesAndLists = new Dictionary, DomainObjectXMLDTO>(); + var duplicates = new List>(); foreach (var list in allLists) { var listElement = XElement.Parse(list.Xml); @@ -70,7 +70,7 @@ private void RenameDuplicateCustomListsAndFixBadLists(IDomainObjectDTORepository continue; if (namesAndLists.ContainsKey(key)) { - duplicates.Add(new Tuple(namesAndLists[key], list)); + duplicates.Add(new Tuple(namesAndLists[key], list)); } else { @@ -94,7 +94,7 @@ private void RenameDuplicateCustomListsAndFixBadLists(IDomainObjectDTORepository } } - private void AppendCustomToNamesAndUpdate(IDomainObjectDTORepository repoDto, DomainObjectDTO dto, XElement dtoXml) + private void AppendCustomToNamesAndUpdate(IDomainObjectDTORepository repoDto, DomainObjectXMLDTO dto, XElement dtoXml) { var names = dtoXml.Elements("Name"); foreach (var titleElement in names.Select(name => name.Element("AUni")).Where(titleElement => titleElement != null)) diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DataMigrationServices.cs b/src/SIL.LCModel/DomainServices/DataMigration/DataMigrationServices.cs index 69cac31f..bfd62dfc 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DataMigrationServices.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DataMigrationServices.cs @@ -59,7 +59,7 @@ internal static void IncrementVersionNumber(IDomainObjectDTORepository dtoRepos) /// or an emty string. /// internal static void UpdateDTO(IDomainObjectDTORepository dtoRepos, - DomainObjectDTO dirtball, string newXmlValue) + DomainObjectXMLDTO dirtball, string newXmlValue) { if (dtoRepos == null) throw new ArgumentNullException("dtoRepos"); if (dirtball == null) throw new ArgumentNullException("dirtball"); @@ -78,7 +78,7 @@ internal static void UpdateDTO(IDomainObjectDTORepository dtoRepos, /// or an emty string. /// internal static void UpdateDTO(IDomainObjectDTORepository dtoRepos, - DomainObjectDTO dirtball, byte[] newXmlBytes) + DomainObjectXMLDTO dirtball, byte[] newXmlBytes) { if (dtoRepos == null) throw new ArgumentNullException("dtoRepos"); if (dirtball == null) throw new ArgumentNullException("dirtball"); @@ -97,7 +97,7 @@ internal static void UpdateDTO(IDomainObjectDTORepository dtoRepos, /// or an emty string. /// internal static void UpdateDTO(IDomainObjectDTORepository dtoRepos, - DomainObjectDTO dirtball, string newXmlValue, string oldClassName) + DomainObjectXMLDTO dirtball, string newXmlValue, string oldClassName) { dtoRepos.ChangeClass(dirtball, oldClassName); UpdateDTO(dtoRepos, dirtball, newXmlValue); @@ -107,9 +107,9 @@ internal static void UpdateDTO(IDomainObjectDTORepository dtoRepos, /// Remove and everything it owns. /// Be sure to include removing goner from its optional owning property. /// - internal static void RemoveIncludingOwnedObjects(IDomainObjectDTORepository dtoRepos, DomainObjectDTO goner, bool removeFromOwner) + internal static void RemoveIncludingOwnedObjects(IDomainObjectDTORepository dtoRepos, DomainObjectXMLDTO goner, bool removeFromOwner) { - DomainObjectDTO gonerActual; + DomainObjectXMLDTO gonerActual; if (!dtoRepos.TryGetValue(goner.Guid, out gonerActual)) return; // Not in repos. @@ -143,7 +143,7 @@ where objSurNode.Attribute("t").Value == "o" && objSurNode.Attribute("guid").Val /// Remove a number of objects with a common owner, and everything they own. /// internal static void RemoveMultipleIncludingOwnedObjects(IDomainObjectDTORepository dtoRepos, - List goners, DomainObjectDTO ownerDto) + List goners, DomainObjectXMLDTO ownerDto) { if (ownerDto != null) { @@ -198,7 +198,7 @@ internal static void Delint(IDomainObjectDTORepository dtoRepos) private static void RemoveZombies( IDomainObjectDTORepository dtoRepos, - IList allDtos) + IList allDtos) { var count = allDtos.Count; var legalOwnerlessClasses = new HashSet @@ -226,15 +226,15 @@ private static void RemoveZombies( legalOwnerlessClasses.Add("Text"); - var goners = new List(count); + var goners = new List(count); // Key is guid of owner. Value is set of guids it owns. // In one very large project that ran out of memory, it had 1281871 dtos, and // 115694 of them owned more than one other dto. So we'll guess that 1/10th // of the total count is a reasonable estimate for the capacity of ownerMap. - var ownerMap = new Dictionary>(count/10); + var ownerMap = new Dictionary>(count/10); foreach (var currentDto in allDtos) { - DomainObjectDTO owningDto; + DomainObjectXMLDTO owningDto; if (dtoRepos.TryGetOwner(currentDto.Guid, out owningDto)) { if (owningDto == null) @@ -295,7 +295,7 @@ private static HashSet GetOwnees(byte[] xmlBytes) private static void RemoveDanglingReferences( IDomainObjectDTORepository dtoRepos, - IEnumerable allDtos) + IEnumerable allDtos) { foreach (var currentDto in allDtos) { @@ -305,7 +305,7 @@ private static void RemoveDanglingReferences( // See if it is a dangling ref, where target object has been deleted. foreach (var targetGuid in referredToGuids) { - DomainObjectDTO referencedDto; + DomainObjectXMLDTO referencedDto; if (dtoRepos.TryGetValue(targetGuid, out referencedDto)) continue; @@ -336,7 +336,7 @@ private static void RemoveDanglingReferences( private static void RemoveEmptyPropertyElements( IDomainObjectDTORepository dtoRepos, - IEnumerable allInstancesWithValidClasses) + IEnumerable allInstancesWithValidClasses) { foreach (var currentDto in allInstancesWithValidClasses) { @@ -344,7 +344,7 @@ private static void RemoveEmptyPropertyElements( } } - private static bool RemoveEmptyPropertyElements(IDomainObjectDTORepository dtoRepos, DomainObjectDTO currentDto, XContainer rtElement) + private static bool RemoveEmptyPropertyElements(IDomainObjectDTORepository dtoRepos, DomainObjectXMLDTO currentDto, XContainer rtElement) { var propertyElements = (rtElement.Element("CmObject") != null) ? rtElement.Elements().Elements() // Two levels for old stuff before DM15 @@ -374,7 +374,7 @@ private static bool RemoveEmptyPropertyElements(IDomainObjectDTORepository dtoRe /// /// /// - private static void ChangeClass(DomainObjectDTO target, string oldClass, string newClass) + private static void ChangeClass(DomainObjectXMLDTO target, string oldClass, string newClass) { // If there's no unexpected white space we can do this efficiently. // This depends (like various other code) on NOT having unexpected white space around the '='. @@ -391,7 +391,7 @@ private static void ChangeClass(DomainObjectDTO target, string oldClass, string /// Change class of object to a new subclass of the original class. /// Caller still needs to move it from one collection to another in the repository. /// - internal static void ChangeToSubClass(DomainObjectDTO target, string oldClass, string newClass) + internal static void ChangeToSubClass(DomainObjectXMLDTO target, string oldClass, string newClass) { ChangeClass(target, oldClass, newClass); // Need to fill in the new empty element. It will be right before the closing <\rt>. @@ -406,7 +406,7 @@ internal static void ChangeToSubClass(DomainObjectDTO target, string oldClass, s target.XmlBytes = input.ReplaceSubArray(index, 0, insertBytes); } - private static string[] ExtractReferencedObjects(DomainObjectDTO dto) + private static string[] ExtractReferencedObjects(DomainObjectXMLDTO dto) { var rootElement = XElement.Parse(dto.Xml); @@ -487,8 +487,8 @@ private enum ObjSurType /// The dto. /// The new GUID. /// The possible referrers. - internal static void ChangeGuid(IDomainObjectDTORepository dtoRepos, DomainObjectDTO dto, string newGuid, - IEnumerable possibleReferrers) + internal static void ChangeGuid(IDomainObjectDTORepository dtoRepos, DomainObjectXMLDTO dto, string newGuid, + IEnumerable possibleReferrers) { // if the DTO already has the new GUID, don't do anything if (dto.Guid.ToLowerInvariant() == newGuid.ToLowerInvariant()) @@ -496,8 +496,8 @@ internal static void ChangeGuid(IDomainObjectDTORepository dtoRepos, DomainObjec XElement rtElem = XElement.Parse(dto.Xml); rtElem.Attribute("guid").Value = newGuid; - dtoRepos.Add(new DomainObjectDTO(newGuid, dto.Classname, rtElem.ToString())); - foreach (DomainObjectDTO ownedDto in dtoRepos.GetDirectlyOwnedDTOs(dto.Guid)) + dtoRepos.Add(new DomainObjectXMLDTO(newGuid, dto.Classname, rtElem.ToString())); + foreach (DomainObjectXMLDTO ownedDto in dtoRepos.GetDirectlyOwnedDTOs(dto.Guid)) { XElement ownedElem = XElement.Parse(ownedDto.Xml); ownedElem.Attribute("ownerguid").Value = newGuid; @@ -510,13 +510,13 @@ internal static void ChangeGuid(IDomainObjectDTORepository dtoRepos, DomainObjec if (possibleReferrers != null) { - foreach (DomainObjectDTO referrer in possibleReferrers) + foreach (DomainObjectXMLDTO referrer in possibleReferrers) UpdateObjSurElement(dtoRepos, referrer, dto.Guid, newGuid); } dtoRepos.Remove(dto); } - private static void UpdateObjSurElement(IDomainObjectDTORepository dtoRepos, DomainObjectDTO dto, string oldGuid, string newGuid) + private static void UpdateObjSurElement(IDomainObjectDTORepository dtoRepos, DomainObjectXMLDTO dto, string oldGuid, string newGuid) { var rtElem = XElement.Parse(dto.Xml); var ownObjSurGuidAttr = (from objSurNode in rtElem.Descendants("objsur") @@ -593,11 +593,11 @@ public static void CreatePossibilityList(IDomainObjectDTORepository dtoRepo, str sb.Append($""); sb.Append(""); - var newList = new DomainObjectDTO(listGuid, "CmPossibilityList", sb.ToString()); + var newList = new DomainObjectXMLDTO(listGuid, "CmPossibilityList", sb.ToString()); dtoRepo.Add(newList); } - private static DomainObjectDTO FindMatchingCustomList(IEnumerable allCmPossibilityLists, + private static DomainObjectXMLDTO FindMatchingCustomList(IEnumerable allCmPossibilityLists, Tuple[] languageAbbrAndNames) { var englishTitle = languageAbbrAndNames.First(t => t.Item1 == "en").Item3; @@ -620,7 +620,7 @@ private static DomainObjectDTO FindMatchingCustomList(IEnumerable /// Creates a CmPossibility with all the basic properties filled in for the xml (necessary for S/R) and adds it to the dto /// - public static DomainObjectDTO CreatePossibility(IDomainObjectDTORepository repoDto, string listGuid, string possibilityGuid, string name, + public static DomainObjectXMLDTO CreatePossibility(IDomainObjectDTORepository repoDto, string listGuid, string possibilityGuid, string name, string abbr, DateTime createTime, string className = "CmPossibility") { var sb = new StringBuilder(); @@ -641,7 +641,7 @@ public static DomainObjectDTO CreatePossibility(IDomainObjectDTORepository repoD sb.Append(""); sb.Append(""); sb.Append(""); - var dtoCmPossibility = new DomainObjectDTO(possibilityGuid, className, sb.ToString()); + var dtoCmPossibility = new DomainObjectXMLDTO(possibilityGuid, className, sb.ToString()); repoDto.Add(dtoCmPossibility); return dtoCmPossibility; } diff --git a/src/SIL.LCModel/DomainServices/DataMigration/DomainObjectDTO.cs b/src/SIL.LCModel/DomainServices/DataMigration/DomainObjectXMLDTO.cs similarity index 93% rename from src/SIL.LCModel/DomainServices/DataMigration/DomainObjectDTO.cs rename to src/SIL.LCModel/DomainServices/DataMigration/DomainObjectXMLDTO.cs index 8a2ab948..b45d9630 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/DomainObjectDTO.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/DomainObjectXMLDTO.cs @@ -20,7 +20,7 @@ namespace SIL.LCModel.DomainServices.DataMigration /// Instances of this object will be available to DM-land via a special Repository. /// /// ---------------------------------------------------------------------------------------- - internal class DomainObjectDTO + internal class DomainObjectXMLDTO { private readonly string m_guid; private string m_classname; @@ -34,7 +34,7 @@ internal class DomainObjectDTO /// The CmObject's class name. /// The CmObject's xml representation. /// ------------------------------------------------------------------------------------ - internal DomainObjectDTO(string guid, string classname, byte[] xml) + internal DomainObjectXMLDTO(string guid, string classname, byte[] xml) { if (string.IsNullOrEmpty(guid)) throw new ArgumentNullException("guid"); if (string.IsNullOrEmpty(classname)) throw new ArgumentNullException("classname"); @@ -45,7 +45,7 @@ internal DomainObjectDTO(string guid, string classname, byte[] xml) m_xml = xml; } - internal DomainObjectDTO(string guid, string classname, string xml) + internal DomainObjectXMLDTO(string guid, string classname, string xml) : this(guid, classname, Encoding.UTF8.GetBytes(xml)) { @@ -113,10 +113,10 @@ public override bool Equals(object obj) { if (obj == null) return false; - if (!(obj is DomainObjectDTO)) + if (!(obj is DomainObjectXMLDTO)) return false; - return m_guid.ToLower() == ((DomainObjectDTO)obj).m_guid.ToLower(); + return m_guid.ToLower() == ((DomainObjectXMLDTO)obj).m_guid.ToLower(); } /// @@ -140,7 +140,7 @@ public override string ToString() /// ---------------------------------------------------------------------------------------- /// - /// Provide information on class and superclass of a . + /// Provide information on class and superclass of a . /// /// ---------------------------------------------------------------------------------------- internal class ClassStructureInfo diff --git a/src/SIL.LCModel/DomainServices/DataMigration/IDomainObjectDTORepository.cs b/src/SIL.LCModel/DomainServices/DataMigration/IDomainObjectDTORepository.cs index b6580dcf..a72bdca3 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/IDomainObjectDTORepository.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/IDomainObjectDTORepository.cs @@ -38,52 +38,52 @@ internal interface IDomainObjectDTORepository /// ------------------------------------------------------------------------------------ /// - /// Get the with the specified Guid (as string). + /// Get the with the specified Guid (as string). /// - /// The guid of the as a string. + /// The guid of the as a string. /// - /// The with the given . + /// The with the given . /// /// /// Thrown if the requested object is not in the repository. /// /// ------------------------------------------------------------------------------------ - DomainObjectDTO GetDTO(string guid); + DomainObjectXMLDTO GetDTO(string guid); /// - /// Try to get the with the given + /// Try to get the with the given /// . /// - /// The guid for the sought after . - /// The sought after , + /// The guid for the sought after . + /// The sought after , /// or null, if not found. /// 'true' if the object exists, otherwise 'false'. - bool TryGetValue(string guid, out DomainObjectDTO dtoWithGuid); + bool TryGetValue(string guid, out DomainObjectXMLDTO dtoWithGuid); /// - /// Try to get the owning DTO of the given + /// Try to get the owning DTO of the given /// . /// - /// The guid for the sought after owning . - /// The sought after , + /// The guid for the sought after owning . + /// The sought after , /// or null, if no onwer at all. /// 'true' if the owner exists, otherwise 'false'. - bool TryGetOwner(string guid, out DomainObjectDTO owningDto); + bool TryGetOwner(string guid, out DomainObjectXMLDTO owningDto); /// ------------------------------------------------------------------------------------ /// - /// Get the owner for the specified object. + /// Get the owner for the specified object. /// - /// The owned . + /// The owned . /// - /// The owner for the given , + /// The owner for the given , /// or null, if there is no owner. /// /// /// Thrown if the owned object is not in the repository. /// /// ------------------------------------------------------------------------------------ - DomainObjectDTO GetOwningDTO(DomainObjectDTO ownedObj); + DomainObjectXMLDTO GetOwningDTO(DomainObjectXMLDTO ownedObj); /// ------------------------------------------------------------------------------------ /// @@ -91,13 +91,13 @@ internal interface IDomainObjectDTORepository /// /// The owning guid. /// - /// An enumeration of zero, or more owned objects. + /// An enumeration of zero, or more owned objects. /// /// /// Thrown if the Guid is not in the repository. /// /// ------------------------------------------------------------------------------------ - IEnumerable GetDirectlyOwnedDTOs(string guid); + IEnumerable GetDirectlyOwnedDTOs(string guid); /// ------------------------------------------------------------------------------------ /// @@ -106,11 +106,11 @@ internal interface IDomainObjectDTORepository /// /// The class of instances to get. /// - /// An enumeration of zero, or more instances + /// An enumeration of zero, or more instances /// of the given class. /// /// ------------------------------------------------------------------------------------ - IEnumerable AllInstancesSansSubclasses(string classname); + IEnumerable AllInstancesSansSubclasses(string classname); /// ------------------------------------------------------------------------------------ /// @@ -119,7 +119,7 @@ internal interface IDomainObjectDTORepository /// /// The class of instances to get, including subclasses. /// - /// An enumeration of zero, or more instances + /// An enumeration of zero, or more instances /// of the given class. /// /// @@ -127,35 +127,35 @@ internal interface IDomainObjectDTORepository /// which may not match that of the data bieng migrated. /// /// ------------------------------------------------------------------------------------ - IEnumerable AllInstancesWithSubclasses(string classname); + IEnumerable AllInstancesWithSubclasses(string classname); /// /// Equivalent to AllInstancesWithSubclasses("CmObject") but more efficient and less /// likely to cause out-of-memory through large object heap fragmentation. /// /// - IEnumerable AllInstancesWithValidClasses(); + IEnumerable AllInstancesWithValidClasses(); /// /// Get all instances, including ones that are no longer in the model. /// This will not return DTOs that have been deleted, however. /// - IEnumerable AllInstances(); + IEnumerable AllInstances(); /// - /// Add a new to the repository. + /// Add a new to the repository. /// /// The new object to add. - void Add(DomainObjectDTO newby); + void Add(DomainObjectXMLDTO newby); /// - /// Remove a 'deleted' from the repository. + /// Remove a 'deleted' from the repository. /// /// The deletion of the underlying CmObject object won't happen, /// until the entire current migration is finished. /// /// The object being deleted. - void Remove(DomainObjectDTO goner); + void Remove(DomainObjectXMLDTO goner); /// /// Let the Repository know that has been modified. @@ -165,7 +165,7 @@ internal interface IDomainObjectDTORepository /// The underlying CmObject won't be changed, until the end of the current /// migration is finished. /// - void Update(DomainObjectDTO dirtball); + void Update(DomainObjectXMLDTO dirtball); /// /// Let the Repository know that has been modified, @@ -178,9 +178,9 @@ internal interface IDomainObjectDTORepository /// The underlying CmObject won't be changed, until the end of the current /// migration is finished. /// - void Update(DomainObjectDTO dirtball, ClassStructureInfo oldClassStructure, ClassStructureInfo newClassStructure); + void Update(DomainObjectXMLDTO dirtball, ClassStructureInfo oldClassStructure, ClassStructureInfo newClassStructure); - void ChangeClass(DomainObjectDTO dirtball, string oldClassName); + void ChangeClass(DomainObjectXMLDTO dirtball, string oldClassName); /// /// Get the count of dtos in the repository. @@ -222,8 +222,8 @@ void CreateCustomField(string className, string fieldName, CellarPropertyType cp internal sealed class DomainObjectDtoRepository : IDomainObjectDTORepository { - private readonly HashSet m_dtos; - private readonly Dictionary m_dtoByGuid; + private readonly HashSet m_dtos; + private readonly Dictionary m_dtoByGuid; private readonly Dictionary> m_classesAndTheirDirectSubclasses = new Dictionary>(); /// Class name is the key, superclass is the value of that. private readonly Dictionary m_classAndSuperClass = new Dictionary(); @@ -231,12 +231,12 @@ internal sealed class DomainObjectDtoRepository : IDomainObjectDTORepository /// For each class name that occurs on an element in the DTO collection, store a hash set of the instances /// which have exactly that class. (Unlike an earlier version, does NOT include instances of subclasses.) /// - private readonly Dictionary> m_dtosByClass = new Dictionary>(); - private readonly HashSet m_newbies = new HashSet(); - private readonly HashSet m_dirtballs = new HashSet(); - private readonly HashSet m_goners = new HashSet(); + private readonly Dictionary> m_dtosByClass = new Dictionary>(); + private readonly HashSet m_newbies = new HashSet(); + private readonly HashSet m_dirtballs = new HashSet(); + private readonly HashSet m_goners = new HashSet(); private int m_currentModelVersionNumber; - private readonly HashSet m_oldTimers = new HashSet(); + private readonly HashSet m_oldTimers = new HashSet(); private readonly string m_projectFolder; private readonly ILcmDirectories m_dirs; @@ -255,7 +255,7 @@ internal sealed class DomainObjectDtoRepository : IDomainObjectDTORepository /// your thoughts!). /// /// ------------------------------------------------------------------------------------ - internal DomainObjectDtoRepository(int startingModelVersionNumber, HashSet dtos, + internal DomainObjectDtoRepository(int startingModelVersionNumber, HashSet dtos, IFwMetaDataCacheManaged mdc, string projectFolder, ILcmDirectories dirs) { if (dtos == null) throw new ArgumentNullException("dtos"); @@ -272,7 +272,7 @@ internal DomainObjectDtoRepository(int startingModelVersionNumber, HashSet()); + m_dtosByClass.Add(className, new HashSet()); if (className == "CmObject") m_classAndSuperClass.Add(className, null); var subclasses = new HashSet(); @@ -311,7 +311,7 @@ internal DomainObjectDtoRepository(int startingModelVersionNumber, HashSet(m_dtos.Count); + m_dtoByGuid = new Dictionary(m_dtos.Count); foreach (var dto in m_dtos) { m_dtoByGuid.Add(dto.Guid.ToLower(), dto); @@ -335,7 +335,7 @@ private void AddClassnamesRecursively(ICollection classnames, string cla /// /// Only to be called by BEP. /// - internal HashSet Newbies + internal HashSet Newbies { get { return m_newbies; } } @@ -343,7 +343,7 @@ internal HashSet Newbies /// /// Only to be called by BEP. /// - internal HashSet Dirtballs + internal HashSet Dirtballs { get { return m_dirtballs; } } @@ -351,7 +351,7 @@ internal HashSet Dirtballs /// /// Only to be called by BEP. /// - internal HashSet Goners + internal HashSet Goners { get { return m_goners; } } @@ -377,48 +377,48 @@ public IFwMetaDataCacheManaged MDC /// ------------------------------------------------------------------------------------ /// - /// Get the with the specified Guid (as string). + /// Get the with the specified Guid (as string). /// - /// The guid of the as a string. + /// The guid of the as a string. /// - /// The with the given . + /// The with the given . /// /// /// Thrown if the requested object is not in the repository. /// /// ------------------------------------------------------------------------------------ - DomainObjectDTO IDomainObjectDTORepository.GetDTO(string guid) + DomainObjectXMLDTO IDomainObjectDTORepository.GetDTO(string guid) { - DomainObjectDTO retval; + DomainObjectXMLDTO retval; if (!m_dtoByGuid.TryGetValue(guid.ToLower(), out retval)) throw new ArgumentException("No object with the given guid", "guid"); return retval; } /// - /// Try to get the with the given + /// Try to get the with the given /// . /// - /// The guid for the sought after . - /// The sought after , + /// The guid for the sought after . + /// The sought after , /// or null, if not found. /// 'true' if the object exists, otherwise 'false'. - bool IDomainObjectDTORepository.TryGetValue(string guid, out DomainObjectDTO dtoWithGuid) + bool IDomainObjectDTORepository.TryGetValue(string guid, out DomainObjectXMLDTO dtoWithGuid) { return m_dtoByGuid.TryGetValue(guid.ToLower(), out dtoWithGuid); } /// - /// Try to get the owning DTO of the given + /// Try to get the owning DTO of the given /// . /// - /// The guid for the sought after owning . - /// The sought after , + /// The guid for the sought after owning . + /// The sought after , /// or null, if no onwer at all. /// 'true' if the owner exists, otherwise 'false'. - bool IDomainObjectDTORepository.TryGetOwner(string guid, out DomainObjectDTO owningDto) + bool IDomainObjectDTORepository.TryGetOwner(string guid, out DomainObjectXMLDTO owningDto) { - DomainObjectDTO ownedDto; + DomainObjectXMLDTO ownedDto; if (!m_dtoByGuid.TryGetValue(guid.ToLower(), out ownedDto)) { // DTO of 'guid' not found. @@ -441,18 +441,18 @@ bool IDomainObjectDTORepository.TryGetOwner(string guid, out DomainObjectDTO own private static readonly byte[] OwnerGuid = Encoding.UTF8.GetBytes("ownerguid="); /// ------------------------------------------------------------------------------------ /// - /// Get the owner for the specified object. + /// Get the owner for the specified object. /// - /// The owned . + /// The owned . /// - /// The owner for the given , + /// The owner for the given , /// or null, if there is no owner. /// /// /// Thrown if the owned object is not in the repository. /// /// ------------------------------------------------------------------------------------ - DomainObjectDTO IDomainObjectDTORepository.GetOwningDTO(DomainObjectDTO ownedObj) + DomainObjectXMLDTO IDomainObjectDTORepository.GetOwningDTO(DomainObjectXMLDTO ownedObj) { if (ownedObj == null) throw new ArgumentNullException("ownedObj"); @@ -468,13 +468,13 @@ DomainObjectDTO IDomainObjectDTORepository.GetOwningDTO(DomainObjectDTO ownedObj /// /// The owning guid. /// - /// An enumeration of zero, or more owned objects. + /// An enumeration of zero, or more owned objects. /// /// /// Thrown if the Guid is not in the repository. /// /// ------------------------------------------------------------------------------------ - IEnumerable IDomainObjectDTORepository.GetDirectlyOwnedDTOs(string guid) + IEnumerable IDomainObjectDTORepository.GetDirectlyOwnedDTOs(string guid) { var dto = AsInterface.GetDTO(guid); var rootElement = XElement.Parse(dto.Xml); @@ -490,14 +490,14 @@ where ownedSurrogates.Attribute("t").Value == "o" /// /// The class of instances to get. /// - /// An enumeration of zero, or more instances + /// An enumeration of zero, or more instances /// of the given class. /// /// ------------------------------------------------------------------------------------ - IEnumerable IDomainObjectDTORepository.AllInstancesSansSubclasses(string classname) + IEnumerable IDomainObjectDTORepository.AllInstancesSansSubclasses(string classname) { - HashSet dtos; - return m_dtosByClass.TryGetValue(classname, out dtos) ? dtos : Enumerable.Empty(); + HashSet dtos; + return m_dtosByClass.TryGetValue(classname, out dtos) ? dtos : Enumerable.Empty(); } /// ------------------------------------------------------------------------------------ @@ -507,7 +507,7 @@ IEnumerable IDomainObjectDTORepository.AllInstancesSansSubclass /// /// The class of instances to get, including subclasses. /// - /// An enumeration of zero, or more instances + /// An enumeration of zero, or more instances /// of the given class. /// /// @@ -515,27 +515,27 @@ IEnumerable IDomainObjectDTORepository.AllInstancesSansSubclass /// which may not match that of the data being migrated. /// /// ------------------------------------------------------------------------------------ - IEnumerable IDomainObjectDTORepository.AllInstancesWithSubclasses(string classname) + IEnumerable IDomainObjectDTORepository.AllInstancesWithSubclasses(string classname) { int cobj = 0; var classList = new HashSet(); AddClassnamesRecursively(classList, classname); foreach (var name in classList) cobj += m_dtosByClass[name].Count; - List retval = new List(cobj); + List retval = new List(cobj); foreach (var name in classList) retval.AddRange(m_dtosByClass[name]); return retval; } - List m_dtosCopy = new List(); + List m_dtosCopy = new List(); /// /// Equivalent to AllInstancesWithSubclasses("CmObject") but slightly more efficient and /// less likely to cause out-of-memory through large object heap fragmentation. /// /// - IEnumerable IDomainObjectDTORepository.AllInstancesWithValidClasses() + IEnumerable IDomainObjectDTORepository.AllInstancesWithValidClasses() { m_dtosCopy.Clear(); int needed = m_dtos.Count - m_oldTimers.Count; @@ -554,16 +554,16 @@ IEnumerable IDomainObjectDTORepository.AllInstancesWithValidCla /// Get all instances, including ones that are no longer in the model. /// This will not return DTOs that have been deleted, however. /// - IEnumerable IDomainObjectDTORepository.AllInstances() + IEnumerable IDomainObjectDTORepository.AllInstances() { return m_dtos; } /// - /// Add a new to the repository. + /// Add a new to the repository. /// /// The new object to add. - void IDomainObjectDTORepository.Add(DomainObjectDTO newby) + void IDomainObjectDTORepository.Add(DomainObjectXMLDTO newby) { if (newby == null) throw new ArgumentNullException("newby"); @@ -575,7 +575,7 @@ void IDomainObjectDTORepository.Add(DomainObjectDTO newby) m_newbies.Add(newby); } - private void AddToClassList(DomainObjectDTO dto) + private void AddToClassList(DomainObjectXMLDTO dto) { var className = dto.Classname; string superclassName; @@ -589,23 +589,23 @@ private void AddToClassList(DomainObjectDTO dto) if (superclassName == null) // Unknown class, so must be obsolete. m_oldTimers.Add(dto); - HashSet instances; + HashSet instances; if (!m_dtosByClass.TryGetValue(className, out instances)) { - instances = new HashSet(); + instances = new HashSet(); m_dtosByClass.Add(className, instances); } instances.Add(dto); } /// - /// Remove a 'deleted' from the repository. + /// Remove a 'deleted' from the repository. /// /// The deletion of the underlying CmObject object won't happen, /// until the entire current migration is finished. /// /// The object being deleted. - void IDomainObjectDTORepository.Remove(DomainObjectDTO goner) + void IDomainObjectDTORepository.Remove(DomainObjectXMLDTO goner) { if (goner == null) throw new ArgumentNullException("goner"); @@ -615,13 +615,13 @@ void IDomainObjectDTORepository.Remove(DomainObjectDTO goner) RemoveFromClassList(goner); } - private void RemoveFromClassList(DomainObjectDTO obj) + private void RemoveFromClassList(DomainObjectXMLDTO obj) { RemoveFromClassList(obj, obj.Classname); } - private void RemoveFromClassList(DomainObjectDTO obj, string oldClassName) + private void RemoveFromClassList(DomainObjectXMLDTO obj, string oldClassName) { - HashSet instances; + HashSet instances; if (m_dtosByClass.TryGetValue(oldClassName, out instances)) instances.Remove(obj); } @@ -634,7 +634,7 @@ private void RemoveFromClassList(DomainObjectDTO obj, string oldClassName) /// The underlying CmObject won't be changed, until the end of the current /// migration is finished. /// - void IDomainObjectDTORepository.Update(DomainObjectDTO dirtball) + void IDomainObjectDTORepository.Update(DomainObjectXMLDTO dirtball) { if (dirtball == null) throw new ArgumentNullException("dirtball"); if (!m_dtoByGuid.ContainsKey(dirtball.Guid.ToLower())) throw new InvalidOperationException("Can't update DTO that isn't in the system."); @@ -653,7 +653,7 @@ void IDomainObjectDTORepository.Update(DomainObjectDTO dirtball) /// The underlying CmObject won't be changed, until the end of the current /// migration is finished. /// - public void Update(DomainObjectDTO dirtball, ClassStructureInfo oldClassStructure, ClassStructureInfo newClassStructure) + public void Update(DomainObjectXMLDTO dirtball, ClassStructureInfo oldClassStructure, ClassStructureInfo newClassStructure) { if (oldClassStructure == null) throw new ArgumentNullException("oldClassStructure"); if (newClassStructure == null) throw new ArgumentNullException("newClassStructure"); @@ -664,7 +664,7 @@ public void Update(DomainObjectDTO dirtball, ClassStructureInfo oldClassStructur AddToClassList(dirtball); } - public void ChangeClass(DomainObjectDTO dirtball, string oldClassName) + public void ChangeClass(DomainObjectXMLDTO dirtball, string oldClassName) { RemoveFromClassList(dirtball, oldClassName); AddToClassList(dirtball); diff --git a/src/SIL.LCModel/DomainServices/DataMigration/WritingSystemIdMigrator.cs b/src/SIL.LCModel/DomainServices/DataMigration/WritingSystemIdMigrator.cs index 4faee2f9..2b620d46 100644 --- a/src/SIL.LCModel/DomainServices/DataMigration/WritingSystemIdMigrator.cs +++ b/src/SIL.LCModel/DomainServices/DataMigration/WritingSystemIdMigrator.cs @@ -33,7 +33,7 @@ public WritingSystemIdMigrator(IDomainObjectDTORepository repoDto, TryGetNewLang // it simplifies the code and testing. public void Migrate() { - foreach (DomainObjectDTO dto in m_repoDto.AllInstances()) + foreach (DomainObjectXMLDTO dto in m_repoDto.AllInstances()) { var changed = false; XElement data = XElement.Parse(dto.Xml); @@ -123,7 +123,7 @@ public void Migrate() DataMigrationServices.UpdateDTO(m_repoDto, dto, data.ToString()); } } - DomainObjectDTO langProjDto = m_repoDto.AllInstancesSansSubclasses("LangProject").First(); + DomainObjectXMLDTO langProjDto = m_repoDto.AllInstancesSansSubclasses("LangProject").First(); XElement langProj = XElement.Parse(langProjDto.Xml); bool lpChanged = UpdateAttr(langProj, "AnalysisWss"); lpChanged |= UpdateAttr(langProj, "CurVernWss"); diff --git a/src/SIL.LCModel/IOC/LcmServiceLocatorFactory.cs b/src/SIL.LCModel/IOC/LcmServiceLocatorFactory.cs index 97a61a27..42660c98 100644 --- a/src/SIL.LCModel/IOC/LcmServiceLocatorFactory.cs +++ b/src/SIL.LCModel/IOC/LcmServiceLocatorFactory.cs @@ -108,12 +108,6 @@ public IServiceProvider CreateServiceLocator() .For() .LifecycleIs(new SingletonLifecycle()) .Use(); - // No. This makes a second instance of IdentityMap, - // which is probably not desirable. - //registry - // .For() - // .LifecycleIs(new SingletonLifecycle()) - // .Use(); // Register IdentityMap's other interface. registry .For() @@ -122,12 +116,6 @@ public IServiceProvider CreateServiceLocator() .For() .Use(c => (ICmObjectRepositoryInternal)c.GetInstance()); - // Add surrogate factory (internal); - registry - .For() - .LifecycleIs(new SingletonLifecycle()) - .Use(); - // Add surrogate repository (internal); registry .For() diff --git a/src/SIL.LCModel/Infrastructure/CmObjectXmlDTO.cs b/src/SIL.LCModel/Infrastructure/CmObjectXmlDTO.cs new file mode 100644 index 00000000..ade88252 --- /dev/null +++ b/src/SIL.LCModel/Infrastructure/CmObjectXmlDTO.cs @@ -0,0 +1,69 @@ +// // Copyright (c) $year$ SIL International +// // This software is licensed under the LGPL, version 2.1 or later +// // (http://www.gnu.org/licenses/lgpl-2.1.html) + +using System; +using System.Diagnostics; +using System.Text; +using System.Xml.Linq; + +namespace SIL.LCModel.Infrastructure +{ + internal class CmObjectXmlDTO : ICmObjectDTO + { + + private byte[] m_xml; + public CmObjectXmlDTO(string xml) + { + m_xml = Encoding.UTF8.GetBytes(xml); + } + + public CmObjectXmlDTO(byte[] xml) + { + m_xml = xml; + } + + public byte[] XMLBytes => m_xml; + + public string XML + { + get + { + byte[] xmlBytes = m_xml; // Use local variable to prevent race condition + return xmlBytes == null ? null : Encoding.UTF8.GetString(xmlBytes); + } + } + + public ICmObject Transfer(LcmCache cache, string className) + { + var rtElement = XElement.Parse(XML); + var cmObject = (ICmObject)SurrogateConstructorInfo.ClassToConstructorInfo[className].Invoke(null); + try + { + ((ICmObjectInternal)cmObject).LoadFromDataStore( + cache, + rtElement, + ((IServiceLocatorInternal)cache.ServiceLocator).LoadingServices); + } + catch (InvalidOperationException) + { + // Asserting just so developers know that this is happening + Debug.Assert(false, "See LT-13574: something is corrupt in this database."); + // LT-13574 had a m_classname that was different from the that in rtElement. + // That causes attributes to be leftover or missing - hence the exception. + rtElement = XElement.Parse(XML); // rtElement is consumed in loading, so re-init + var xmlClassName = rtElement.Attribute("class").Value; + if (xmlClassName != className) + { + cmObject = (ICmObject)SurrogateConstructorInfo.ClassToConstructorInfo[xmlClassName].Invoke(null); + ((ICmObjectInternal)cmObject).LoadFromDataStore( + cache, + rtElement, + ((IServiceLocatorInternal)cache.ServiceLocator).LoadingServices); + } + } + + return cmObject; + } + } +} \ No newline at end of file diff --git a/src/SIL.LCModel/Infrastructure/ICmObjectDTO.cs b/src/SIL.LCModel/Infrastructure/ICmObjectDTO.cs new file mode 100644 index 00000000..9244358c --- /dev/null +++ b/src/SIL.LCModel/Infrastructure/ICmObjectDTO.cs @@ -0,0 +1,16 @@ +// Copyright (c) 2023 SIL International +// This software is licensed under the LGPL, version 2.1 or later +// (http://www.gnu.org/licenses/lgpl-2.1.html) + +namespace SIL.LCModel.Infrastructure +{ + /// + /// This DTO should hold any information needed to realize an object from backend storage + /// + public interface ICmObjectDTO + { + /// + /// The fully restored object contents + ICmObject Transfer(LcmCache cache, string className); + } +} \ No newline at end of file diff --git a/src/SIL.LCModel/Infrastructure/ICmObjectSurrogate.cs b/src/SIL.LCModel/Infrastructure/ICmObjectSurrogate.cs index 957cad87..9c27aeee 100644 --- a/src/SIL.LCModel/Infrastructure/ICmObjectSurrogate.cs +++ b/src/SIL.LCModel/Infrastructure/ICmObjectSurrogate.cs @@ -17,15 +17,7 @@ internal interface ICmObjectSurrogate : ICmObjectOrSurrogate /// /// void AttachObject(ICmObject obj); - - /// - /// Get the main XML string converted to a byte array encoded in UTF8. Typically this is how it is - /// actually stored, so it is more efficient to work with this than the XML string unless you - /// really need a string. Note that this (unlike ICmObjectOrSurrogate.XMLBytes) may answer null; - /// it will NOT generate the XML from the object. - /// - byte[] RawXmlBytes { get; } - + /// /// Get the Object's Guid. /// @@ -52,18 +44,6 @@ internal interface ICmObjectSurrogate : ICmObjectOrSurrogate /// internal interface ICmObjectOrSurrogate { - /// - /// Get the main XML string for the internal CmObject. - /// - string XML { get; } - - /// - /// Get the main byte array of the XML string for the internal CmObject. This should never be null; - /// if an XML representation is not stored it will be computed from the CmObject. - /// Enhance JohnT: this method should be renamed or merged with XmlBytes. - /// - byte[] XMLBytes { get; } - ICmObjectId Id { get; } /// @@ -80,6 +60,11 @@ internal interface ICmObjectOrSurrogate /// Find out if the surrogate has the actual object. /// bool HasObject { get; } + + /// + /// Return the DTO for the object + /// + ICmObjectDTO DTO { get; } } /// @@ -87,41 +72,20 @@ internal interface ICmObjectOrSurrogate /// internal interface ICmObjectSurrogateFactory { - /// + /// /// Create a surrogate from the data store. - /// This gets the full XML string of the object from the BEP. - /// - ICmObjectSurrogate Create(string xmlData); + ICmObjectSurrogate Create(ICmObjectDTO dto); /// /// Create a surrogate from the data store. - /// This gets the full XML string of the object from the BEP. /// - ICmObjectSurrogate Create(byte[] xmlData); - - /// - /// Create a surrogate from the data store. - /// This gets the full XML string of the object from the BEP. - /// - ICmObjectSurrogate Create(Guid guid, string classname, string xmlData); - - /// - /// Create a surrogate from the data store. - /// This gets the full XML string of the object from the BEP. - /// - ICmObjectSurrogate Create(Guid guid, string classname, byte[] xmlData); - - /// - /// Create a surrogate from the data store. - /// This gets the full XML string of the object from the BEP. - /// - ICmObjectSurrogate Create(ICmObjectId objId, string classname, string xmlData); - + ICmObjectSurrogate Create(Guid guid, string classname, ICmObjectDTO data); + /// /// Create a surrogate from the data store. /// This gets the full XML string of the object from the BEP. /// - ICmObjectSurrogate Create(ICmObjectId objId, string classname, byte[] xmlData); + ICmObjectSurrogate Create(ICmObjectId objId, string classname, ICmObjectDTO xmlData); /// /// Create a surrogate from the data store. diff --git a/src/SIL.LCModel/Infrastructure/IPersistenceStrategyInterfaces.cs b/src/SIL.LCModel/Infrastructure/IPersistenceStrategyInterfaces.cs index e7566352..a32962c3 100644 --- a/src/SIL.LCModel/Infrastructure/IPersistenceStrategyInterfaces.cs +++ b/src/SIL.LCModel/Infrastructure/IPersistenceStrategyInterfaces.cs @@ -246,7 +246,7 @@ internal interface IDataReader : IDisposable ICmObjectOrId GetObjectOrIdWithHvoFromGuid(Guid guid); /// - /// Get the HVO associatd with the given ID or object. May actually create the + /// Get the HVO associated with the given ID or object. May actually create the /// association, though it is more normal for it to be created in a call to /// GetObjectOrIdWithHvoFromGuid. /// @@ -257,7 +257,7 @@ internal interface IDataReader : IDisposable /// /// Persist the given objects. /// This may be create new ones, modify previously persisted ones, - /// or delete presiously persisted ones. + /// or delete previously persisted ones. /// /// /// Implementors should not assume an object to be in only one of the given sets, diff --git a/src/SIL.LCModel/Infrastructure/Impl/BackendProvider.cs b/src/SIL.LCModel/Infrastructure/Impl/BackendProvider.cs index 94fec081..2ca6334d 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/BackendProvider.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/BackendProvider.cs @@ -11,6 +11,7 @@ using System.Threading; using SIL.LCModel.Core.Cellar; using SIL.LCModel.Core.WritingSystems; +using SIL.LCModel.DomainImpl; using SIL.LCModel.DomainServices; using SIL.LCModel.DomainServices.DataMigration; using SIL.LCModel.Utils; @@ -28,7 +29,7 @@ internal abstract partial class BackendProvider : IDataSetup, IDataReader, IData // and the client can load more domains, as needed. private LoadedDomains m_loadedDomains = new LoadedDomains(false, false, false, false); protected readonly IdentityMap m_identityMap; - protected readonly ICmObjectSurrogateFactory m_surrogateFactory; + protected ICmObjectSurrogateFactory m_surrogateFactory; protected readonly LcmCache m_cache; protected readonly IFwMetaDataCacheManagedInternal m_mdcInternal; private readonly IDataMigrationManager m_dataMigrationManager; @@ -44,13 +45,11 @@ internal abstract partial class BackendProvider : IDataSetup, IDataReader, IData /// /// /// - protected BackendProvider(LcmCache cache, IdentityMap identityMap, - ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc, IDataMigrationManager dataMigrationManager, + protected BackendProvider(LcmCache cache, IdentityMap identityMap, IFwMetaDataCacheManagedInternal mdc, IDataMigrationManager dataMigrationManager, ILcmUI ui, ILcmDirectories dirs, LcmSettings settings) { if (cache == null) throw new ArgumentNullException("cache"); if (identityMap == null) throw new ArgumentNullException("identityMap"); - if (surrogateFactory == null) throw new ArgumentNullException("surrogateFactory"); if (dataMigrationManager == null) throw new ArgumentNullException("dataMigrationManager"); if (ui == null) throw new ArgumentNullException("ui"); if (dirs == null) throw new ArgumentNullException("dirs"); @@ -59,7 +58,6 @@ protected BackendProvider(LcmCache cache, IdentityMap identityMap, m_cache = cache; m_cache.Disposing += OnCacheDisposing; m_identityMap = identityMap; - m_surrogateFactory = surrogateFactory; m_mdcInternal = mdc; m_dataMigrationManager = dataMigrationManager; m_ui = ui; @@ -399,8 +397,8 @@ private HashSet DoMigrationBasics(int currentDataStoreVers // only if passed an actual collection of some sort. Passing just the enumeration is therefore actually LESS // efficient, and may cause the large object heap to become fragmented. Please don't take the ToArray() call out // unless you really know what you're doing, and preferably discuss with JohnT first. - var dtos = new HashSet((from surrogate in m_identityMap.AllObjectsOrSurrogates() - select new DomainObjectDTO(surrogate.Id.Guid.ToString(), surrogate.Classname, surrogate.XMLBytes)).ToArray()); + var dtos = new HashSet((from surrogate in m_identityMap.AllObjectsOrSurrogates() + select new DomainObjectXMLDTO(surrogate.Id.Guid.ToString(), surrogate.Classname, ((CmObjectXmlDTO)surrogate.DTO).XMLBytes)).ToArray()); var dtoRepository = new DomainObjectDtoRepository( currentDataStoreVersion, dtos, @@ -418,7 +416,7 @@ private HashSet DoMigrationBasics(int currentDataStoreVers foreach (var dirtball in dtoRepository.Dirtballs) { // Since we're doing migration, everything in the map should still be a surrogate. - var originalSurr = (CmObjectSurrogate)m_identityMap.GetObjectOrSurrogate(idFact.FromGuid(new Guid(dirtball.Guid))); + var originalSurr = (CmObjectXmlSurrogate)m_identityMap.GetObjectOrSurrogate(idFact.FromGuid(new Guid(dirtball.Guid))); originalSurr.Reset(dirtball.Classname, dirtball.XmlBytes); dirtballs.Add(originalSurr); } @@ -444,7 +442,7 @@ private HashSet DoMigrationBasics(int currentDataStoreVers var newSurr = m_surrogateFactory.Create( new Guid(newbie.Guid), newbie.Classname, - newbie.Xml); + new CmObjectXmlDTO(newbie.Xml)); RegisterInactiveSurrogate(newSurr); newbies.Add(newSurr); } @@ -1223,6 +1221,8 @@ private void EnsureItemsInOnlyOneSet(HashSet newbies, Hash /// Update the version number. /// protected abstract void UpdateVersionNumber(); + + public abstract ICmObjectDTO MakeDTO(ICmObject cmObject); } /// diff --git a/src/SIL.LCModel/Infrastructure/Impl/CmObjectId.cs b/src/SIL.LCModel/Infrastructure/Impl/CmObjectId.cs index a98b5516..7fb7ad7a 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/CmObjectId.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/CmObjectId.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2015 SIL International +// Copyright (c) 2015 SIL International // This software is licensed under the LGPL, version 2.1 or later // (http://www.gnu.org/licenses/lgpl-2.1.html) @@ -128,16 +128,6 @@ public void ToXMLString(bool owning, System.Xml.XmlWriter writer) #region ICmObjectOrSurrogate Members - string ICmObjectOrSurrogate.XML - { - get { throw new NotImplementedException(); } - } - - byte[] ICmObjectOrSurrogate.XMLBytes - { - get { throw new NotImplementedException(); } - } - ICmObjectId ICmObjectOrSurrogate.Id { get { return this; } @@ -158,6 +148,8 @@ bool ICmObjectOrSurrogate.HasObject get { return false; } } + ICmObjectDTO ICmObjectOrSurrogate.DTO => throw new NotImplementedException(); + #endregion } diff --git a/src/SIL.LCModel/Infrastructure/Impl/CmObjectIdentityMap.cs b/src/SIL.LCModel/Infrastructure/Impl/CmObjectIdentityMap.cs index 79b794b3..923092ac 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/CmObjectIdentityMap.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/CmObjectIdentityMap.cs @@ -598,9 +598,9 @@ internal int GetOrAssignHvoFor(ICmObjectId id) lock (SyncRoot) { ICmObjectOrSurrogate canonicalItem = m_IdentityMap[id]; - if (canonicalItem is CmObjectSurrogate) + if (canonicalItem is ICmObjectSurrogate) { - ICmObjectId canonicalId = ((CmObjectSurrogate) canonicalItem).Id; + ICmObjectId canonicalId = ((ICmObjectSurrogate) canonicalItem).Id; if (canonicalId is CmObjectIdWithHvo) return ((CmObjectIdWithHvo) canonicalId).Hvo; } @@ -631,8 +631,8 @@ internal ICmObjectOrId GetObjectOrIdWithHvoFromGuid(Guid guid) } if (canonicalItem is ICmObject) return (ICmObject)canonicalItem; - if (canonicalItem is CmObjectSurrogate) - return ((CmObjectSurrogate) canonicalItem).ObjectOrIdWithHvo; + if (canonicalItem is CmObjectXmlSurrogate) + return ((CmObjectXmlSurrogate) canonicalItem).ObjectOrIdWithHvo; // If it's neither, it doesn't map to a valid object, and we don't want to // assign it an HVO. return null; diff --git a/src/SIL.LCModel/Infrastructure/Impl/CmObjectSurrogate.cs b/src/SIL.LCModel/Infrastructure/Impl/CmObjectXmlSurrogate.cs similarity index 75% rename from src/SIL.LCModel/Infrastructure/Impl/CmObjectSurrogate.cs rename to src/SIL.LCModel/Infrastructure/Impl/CmObjectXmlSurrogate.cs index 69123547..f8ae970f 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/CmObjectSurrogate.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/CmObjectXmlSurrogate.cs @@ -30,9 +30,8 @@ namespace SIL.LCModel.Infrastructure.Impl /// In the case where bulk loading is best, then both the Guid and the object are stored /// at the same time. /// - internal sealed class CmObjectSurrogate : ICmObjectSurrogate //, IEquatable + internal sealed class CmObjectXmlSurrogate : ICmObjectSurrogate //, IEquatable { - private static Dictionary s_classToConstructorInfo; /// /// It's common that hundreds of thousands of surrogates only use a few hundred class names. This is a local interning /// of those names. @@ -60,24 +59,9 @@ internal sealed class CmObjectSurrogate : ICmObjectSurrogate //, IEquatable (CmObjectXmlDTO)DTO; - /// - /// Constructor. - /// - /// - /// This Constructor is used for lazy load cases. - /// The stored XML string (from the data store) is used to instantiate m_object. - /// - internal CmObjectSurrogate(LcmCache cache, string xmlData) - { - if (cache == null) throw new ArgumentNullException("cache"); - if (xmlData == null) throw new ArgumentNullException("xmlData"); - - m_cache = cache; - m_object = null; - Xml = xmlData; - SetBasics(); - } + public ICmObjectDTO DTO { get; set; } /// /// Constructor. @@ -86,14 +70,14 @@ internal CmObjectSurrogate(LcmCache cache, string xmlData) /// This Constructor is used for lazy load cases. /// The stored XML string (from the data store) is used to instantiate m_object. /// - internal CmObjectSurrogate(LcmCache cache, byte[] xmlData) + internal CmObjectXmlSurrogate(LcmCache cache, ICmObjectDTO xmlData) { if (cache == null) throw new ArgumentNullException("cache"); - if (xmlData == null) throw new ArgumentNullException("xmlData"); + if (!(xmlData is CmObjectXmlDTO)) throw new ArgumentNullException("xmlData"); m_cache = cache; m_object = null; - RawXmlBytes = xmlData; + DTO = xmlData; SetBasics(); } @@ -104,19 +88,7 @@ internal CmObjectSurrogate(LcmCache cache, byte[] xmlData) /// This Constructor is used for lazy load cases. /// The stored XML string (from the data store) is used to instantiate m_object. /// - internal CmObjectSurrogate(LcmCache cache, Guid guid, string classname, string xmlData) - : this(cache, ((IServiceLocatorInternal)cache.ServiceLocator).IdentityMap.CreateObjectIdWithHvo(guid), classname, xmlData) - { - } - - /// - /// Constructor. - /// - /// - /// This Constructor is used for lazy load cases. - /// The stored XML string (from the data store) is used to instantiate m_object. - /// - internal CmObjectSurrogate(LcmCache cache, Guid guid, string classname, byte[] xmlData) + internal CmObjectXmlSurrogate(LcmCache cache, Guid guid, string classname, ICmObjectDTO xmlData) : this(cache, ((IServiceLocatorInternal)cache.ServiceLocator).IdentityMap.CreateObjectIdWithHvo(guid), classname, xmlData) { } @@ -128,16 +100,16 @@ internal CmObjectSurrogate(LcmCache cache, Guid guid, string classname, byte[] x /// This Constructor is used for lazy load cases. /// The stored XML string (from the data store) is used to instantiate m_object. /// - internal CmObjectSurrogate(LcmCache cache, ICmObjectId objId, string classname, string xmlData) + internal CmObjectXmlSurrogate(LcmCache cache, ICmObjectId objId, string classname, ICmObjectDTO xmlData) { if (cache == null) throw new ArgumentNullException("cache"); if (objId == null) throw new ArgumentNullException("objId"); if (string.IsNullOrEmpty(classname)) throw new ArgumentNullException("classname"); - if (string.IsNullOrEmpty(xmlData)) throw new ArgumentNullException("xmlData"); + if (!(xmlData is CmObjectXmlDTO)) throw new ArgumentNullException("xmlData"); m_cache = cache; m_object = null; - Xml = xmlData; + DTO = xmlData; m_guid = objId is CmObjectIdWithHvo ? objId : ((IServiceLocatorInternal)cache.ServiceLocator).IdentityMap.CreateObjectIdWithHvo(objId.Guid); SetClassName(classname); @@ -150,7 +122,7 @@ internal CmObjectSurrogate(LcmCache cache, ICmObjectId objId, string classname, /// This Constructor is used for lazy load cases. /// The stored XML string (from the data store) is used to instantiate m_object. /// - internal CmObjectSurrogate(LcmCache cache, ICmObjectId objId, string classname, byte[] xmlData) + internal CmObjectXmlSurrogate(LcmCache cache, ICmObjectId objId, string classname, byte[] xmlData) { if (cache == null) throw new ArgumentNullException("cache"); if (objId == null) throw new ArgumentNullException("objId"); @@ -159,7 +131,7 @@ internal CmObjectSurrogate(LcmCache cache, ICmObjectId objId, string classname, m_cache = cache; m_object = null; - RawXmlBytes = xmlData; + DTO = new CmObjectXmlDTO(xmlData); m_guid = objId is CmObjectIdWithHvo ? objId : ((IServiceLocatorInternal)cache.ServiceLocator).IdentityMap.CreateObjectIdWithHvo(objId.Guid); SetClassName(classname); @@ -172,22 +144,19 @@ internal CmObjectSurrogate(LcmCache cache, ICmObjectId objId, string classname, /// This Constructor is used for porting from one BEP to another. /// It's faster than getting all the stuff from the xml string. /// - internal CmObjectSurrogate(LcmCache cache, ICmObjectSurrogate sourceSurrogate) + internal CmObjectXmlSurrogate(LcmCache cache, ICmObjectSurrogate sourceSurrogate) { if (cache == null) throw new ArgumentNullException("cache"); if (sourceSurrogate == null) throw new ArgumentNullException("sourceSurrogate"); - var surr = (CmObjectSurrogate) sourceSurrogate; + var surr = sourceSurrogate; m_cache = cache; m_object = null; - if (surr.RawXmlBytes != null) - RawXmlBytes = surr.RawXmlBytes; - else - Xml = sourceSurrogate.XML; + DTO = surr.DTO; ICmObjectId objId = surr.Id; m_guid = objId is CmObjectIdWithHvo ? objId : ((IServiceLocatorInternal)cache.ServiceLocator).IdentityMap.CreateObjectIdWithHvo(objId.Guid); - SetClassName(surr.m_classname); + SetClassName(surr.Classname); } /// @@ -196,7 +165,7 @@ internal CmObjectSurrogate(LcmCache cache, ICmObjectSurrogate sourceSurrogate) /// /// This Constructor is used for newly created CmObject cases. /// - internal CmObjectSurrogate(ICmObject obj) + internal CmObjectXmlSurrogate(ICmObject obj) { if (obj == null) throw new ArgumentNullException("obj"); @@ -213,31 +182,15 @@ internal CmObjectSurrogate(ICmObject obj) /// but not linked to it. Currently this is just used in testing, to simulate state obtained from /// another client. /// - internal static CmObjectSurrogate CreateSnapshot(ICmObject obj) + internal static CmObjectXmlSurrogate CreateSnapshot(ICmObject obj) { - var result = new CmObjectSurrogate(obj); + var result = new CmObjectXmlSurrogate(obj); result.m_object = null; - result.Xml = ((ICmObjectInternal)obj).ToXmlString(); + result.DTO = new CmObjectXmlDTO(((ICmObjectInternal)obj).ToXmlBytes()); return result; } - - internal static void InitializeConstructors(List cmObjectTypes) - { - if (s_classToConstructorInfo != null) return; - - s_classToConstructorInfo = new Dictionary(); - // Get default constructor. - // Only do this once, since they are stored in a static data member. - foreach (var lcmType in cmObjectTypes) - { - if (lcmType.IsAbstract) continue; - - s_classToConstructorInfo.Add(lcmType.Name, lcmType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null)); - } - } - /// /// Initialize from the data store (which uses byte arrays). /// @@ -263,42 +216,13 @@ internal void InitializeFromDataStore(LcmCache cache, ICmObjectId objId, string // e.g., in Refreshing a surrogate to align it with another client, // we might be making a new object, yet the CmObject might already exist! m_object = ((ICmObjectRepositoryInternal) m_cache.ServiceLocator.ObjectRepository).GetObjectIfFluffed(objId); - RawXmlBytes = xmlData; + DTO = new CmObjectXmlDTO(xmlData); m_guid = objId is CmObjectIdWithHvo ? objId : ((IServiceLocatorInternal)cache.ServiceLocator).IdentityMap.CreateObjectIdWithHvo(objId.Guid); SetClassName(className); } } - - private string Xml - { - get - { - byte[] xmlBytes = m_xml; // Use local variable to prevent race condition - return xmlBytes == null ? null : Encoding.UTF8.GetString(xmlBytes); - } - set - { - if (value == null) - { - m_xml = null; - return; - } - m_xml = Encoding.UTF8.GetBytes(value); - } - } - - /// - /// Get the main XML string converted to a byte array encoded in UTF8. Typically this is how it is - /// actually stored, so it is more efficient to work with this than the XML string unless you - /// really need a string. Note that this (unlike ICmObjectOrSurrogate.XMLBytes) may answer null; - /// it will NOT generate the XML from the object. - /// - public byte[] RawXmlBytes - { - get { return m_xml;} - set { m_xml = value; } - } + /// /// Gets the synchronization root. This is the object that should be @@ -366,12 +290,12 @@ private void SetBasics() m_classname = m_xml.Substring(startIdx + 7, endIdx - 7 - startIdx); #endif #if SecondByStringManipulation // 3.407/3.518 (s) // Seems to be the fastest, to date. - var startIdx = RawXmlBytes.IndexOfSubArray(GuidEquals) + GuidEquals.Length; - m_guid = ((IServiceLocatorInternal)m_cache.ServiceLocator).IdentityMap.CreateObjectIdWithHvo(GuidFromByteSubArray(RawXmlBytes, startIdx)); + var startIdx = ((CmObjectXmlDTO)Xml).XMLBytes.IndexOfSubArray(GuidEquals) + GuidEquals.Length; + m_guid = ((IServiceLocatorInternal)m_cache.ServiceLocator).IdentityMap.CreateObjectIdWithHvo(GuidFromByteSubArray(((CmObjectXmlDTO)Xml).XMLBytes, startIdx)); - startIdx = RawXmlBytes.IndexOfSubArray(ClassEquals) + ClassEquals.Length; - var endIdx = Array.IndexOf(RawXmlBytes, QuoteChar, startIdx + 1); - SetClassName(Encoding.UTF8.GetString(RawXmlBytes, startIdx, endIdx - startIdx)); + startIdx = ((CmObjectXmlDTO)Xml).XMLBytes.IndexOfSubArray(ClassEquals) + ClassEquals.Length; + var endIdx = Array.IndexOf(((CmObjectXmlDTO)Xml).XMLBytes, QuoteChar, startIdx + 1); + SetClassName(Encoding.UTF8.GetString(((CmObjectXmlDTO)Xml).XMLBytes, startIdx, endIdx - startIdx)); #endif #if ThirdByStringManipulation // 4.371/4.479 (s) var haveGuid = false; @@ -434,16 +358,16 @@ private void SetBasics() /// /// Get the main XML string for the internal CmObject. /// - string ICmObjectOrSurrogate.XML + string XML { get { - string sXml = Xml; // Use local variable to prevent race conditions + string sXml = ((CmObjectXmlDTO)Xml).XML; // Use local variable to prevent race conditions if (sXml == null) { var asInternal = (ICmObjectInternal)(((ICmObjectSurrogate)this).Object); var result = asInternal.ToXmlString(); - Xml = result; + DTO = new CmObjectXmlDTO(result); return result; // avoids converting back again! } return sXml; @@ -453,7 +377,7 @@ string ICmObjectOrSurrogate.XML /// /// Get the main byte array of the XML string for the internal CmObject. /// - byte[] ICmObjectOrSurrogate.XMLBytes + byte[] XMLBytes { get { @@ -507,47 +431,12 @@ ICmObject ICmObjectOrSurrogate.Object // fluffing it up in the meantime. if (m_object == null || m_objectWasAttached) { - if (RawXmlBytes == null) + if (((CmObjectXmlDTO)Xml).XMLBytes == null) throw new InvalidOperationException("Can't load an object with no XML data."); - - sXml = Xml; // Must be inside the lock to prevent race conditions (FWR-3624) - var rtElement = XElement.Parse(sXml); - RawXmlBytes = null; if (!m_objectWasAttached) { - m_object = (ICmObject)s_classToConstructorInfo[m_classname].Invoke(null); - try - { - ((ICmObjectInternal)m_object).LoadFromDataStore( - m_cache, - rtElement, - ((IServiceLocatorInternal)m_cache.ServiceLocator).LoadingServices); - } - catch (InvalidOperationException) - { - // Asserting just so developers know that this is happening - Debug.Assert(false, "See LT-13574: something is corrupt in this database."); - // LT-13574 had a m_classname that was different from the that in rtElement. - // That causes attributes to be leftover or missing - hence the exception. - rtElement = XElement.Parse(sXml); // rtElement is consumed in loading, so re-init - var className = rtElement.Attribute("class").Value; - if (className != m_classname) - { - m_object = (ICmObject)s_classToConstructorInfo[className].Invoke(null); - ((ICmObjectInternal)m_object).LoadFromDataStore( - m_cache, - rtElement, - ((IServiceLocatorInternal)m_cache.ServiceLocator).LoadingServices); - } - } + return m_object = Xml.Transfer(m_cache, m_classname); } - - // Have to set m_objectWasAttached to false, before the registration, - // since RegisterActivatedSurrogate calls this' Object prop, - // and it would result in a stack overflow, with it still being true, - // as it would try again to create the object. - m_objectWasAttached = false; - ((IServiceLocatorInternal)m_cache.ServiceLocator).IdentityMap.RegisterActivatedSurrogate(this); } } Debug.Assert(m_object != null, "Surrogate should not exist without being able to create an object"); @@ -648,7 +537,7 @@ public void Reset(string className, string xml) if (m_classname != className) SetClassName(className); - Xml = xml; + DTO = new CmObjectXmlDTO(xml); } /// @@ -786,14 +675,14 @@ public ICmObjectSurrogate GetSurrogate(ICmObject obj) /// /// Factory for creating ICmObjectSurrogate instances. /// - internal sealed class CmObjectSurrogateFactory : ICmObjectSurrogateFactory + internal sealed class CmObjectXmlSurrogateFactory : ICmObjectSurrogateFactory { private readonly LcmCache m_cache; /// /// Constructor. /// - internal CmObjectSurrogateFactory(LcmCache cache) + internal CmObjectXmlSurrogateFactory(LcmCache cache) { if (cache == null) throw new ArgumentNullException("cache"); @@ -807,54 +696,27 @@ internal CmObjectSurrogateFactory(LcmCache cache) /// This gets the full XML string of the object from the BEP. /// /// - public ICmObjectSurrogate Create(string xmlData) + public ICmObjectSurrogate Create(ICmObjectDTO xmlData) { - return new CmObjectSurrogate(m_cache, xmlData); + return new CmObjectXmlSurrogate(m_cache, xmlData); } /// /// Create a surrogate from the data store. /// This gets the full XML string of the object from the BEP. /// - public ICmObjectSurrogate Create(byte[] xmlData) + public ICmObjectSurrogate Create(Guid guid, string classname, ICmObjectDTO xmlData) { - return new CmObjectSurrogate(m_cache, xmlData); + return new CmObjectXmlSurrogate(m_cache, guid, classname, xmlData); } /// /// Create a surrogate from the data store. /// This gets the full XML string of the object from the BEP. /// - public ICmObjectSurrogate Create(Guid guid, string classname, string xmlData) + public ICmObjectSurrogate Create(ICmObjectId objId, string classname, ICmObjectDTO xmlData) { - return new CmObjectSurrogate(m_cache, guid, classname, xmlData); - } - - /// - /// Create a surrogate from the data store. - /// This gets the full XML string of the object from the BEP. - /// - public ICmObjectSurrogate Create(Guid guid, string classname, byte[] xmlData) - { - return new CmObjectSurrogate(m_cache, guid, classname, xmlData); - } - - /// - /// Create a surrogate from the data store. - /// This gets the full XML string of the object from the BEP. - /// - public ICmObjectSurrogate Create(ICmObjectId objId, string classname, string xmlData) - { - return new CmObjectSurrogate(m_cache, objId, classname, xmlData); - } - - /// - /// Create a surrogate from the data store. - /// This gets the full XML string of the object from the BEP. - /// - public ICmObjectSurrogate Create(ICmObjectId objId, string classname, byte[] xmlData) - { - return new CmObjectSurrogate(m_cache, objId, classname, xmlData); + return new CmObjectXmlSurrogate(m_cache, objId, classname, xmlData); } /// @@ -875,13 +737,13 @@ public ICmObjectSurrogate Create(ICmObjectOrSurrogate source) // since we don't even want to think of just reusing the ICmObject. var asCmObject = (ICmObject)source; var asInternal = (ICmObjectInternal)asCmObject; - return new CmObjectSurrogate( + return new CmObjectXmlSurrogate( m_cache, CmObjectId.Create(asCmObject.Guid), asCmObject.ClassName, - asInternal.ToXmlString()); + new CmObjectXmlDTO(asInternal.ToXmlString())); } - return new CmObjectSurrogate(m_cache, sourceSurrogate); + return new CmObjectXmlSurrogate(m_cache, sourceSurrogate); } /// @@ -889,10 +751,8 @@ public ICmObjectSurrogate Create(ICmObjectOrSurrogate source) /// public ICmObjectSurrogate Create(ICmObject obj) { - return CmObjectSurrogate.CreateSnapshot(obj); + return CmObjectXmlSurrogate.CreateSnapshot(obj); } - - #endregion } } diff --git a/src/SIL.LCModel/Infrastructure/Impl/LcmMetaDataCache.cs b/src/SIL.LCModel/Infrastructure/Impl/LcmMetaDataCache.cs index c2646c2b..6cff4656 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/LcmMetaDataCache.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/LcmMetaDataCache.cs @@ -83,7 +83,7 @@ internal LcmMetaDataCache() var cmObjectTypesBaseFirst = CmObjectTypesBaseFirst(); - CmObjectSurrogate.InitializeConstructors(cmObjectTypesBaseFirst); + SurrogateConstructorInfo.InitializeConstructors(cmObjectTypesBaseFirst); InitializeMetaDataCache(cmObjectTypesBaseFirst); diff --git a/src/SIL.LCModel/Infrastructure/Impl/MemoryOnlyBackendProvider.cs b/src/SIL.LCModel/Infrastructure/Impl/MemoryOnlyBackendProvider.cs index ca6d38f0..b01e3ad5 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/MemoryOnlyBackendProvider.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/MemoryOnlyBackendProvider.cs @@ -20,10 +20,11 @@ internal sealed class MemoryOnlyBackendProvider : BackendProvider /// /// Constructor. /// - internal MemoryOnlyBackendProvider(LcmCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, - IFwMetaDataCacheManagedInternal mdc, IDataMigrationManager dataMigrationManager, ILcmUI ui, ILcmDirectories dirs, LcmSettings settings) - : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings) + internal MemoryOnlyBackendProvider(LcmCache cache, IdentityMap identityMap, IFwMetaDataCacheManagedInternal mdc, + IDataMigrationManager dataMigrationManager, ILcmUI ui, ILcmDirectories dirs, LcmSettings settings) + : base(cache, identityMap, mdc, dataMigrationManager, ui, dirs, settings) { + m_surrogateFactory = new CmObjectXmlSurrogateFactory(cache); m_projectSettingsStore = new MemorySettingsStore(); m_userSettingsStore = new MemorySettingsStore(); } @@ -99,6 +100,11 @@ protected override void UpdateVersionNumber() // Do nothing. } + public override ICmObjectDTO MakeDTO(ICmObject cmObject) + { + return new CmObjectXmlDTO(((ICmObjectInternal)cmObject).ToXmlBytes()); + } + /// /// Rename the database, which means renaming the files. /// diff --git a/src/SIL.LCModel/Infrastructure/Impl/ObjectSurrogateEquater.cs b/src/SIL.LCModel/Infrastructure/Impl/ObjectSurrogateEquater.cs index 0bbdca35..7f515b5f 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/ObjectSurrogateEquater.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/ObjectSurrogateEquater.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2015 SIL International +// Copyright (c) 2015 SIL International // This software is licensed under the LGPL, version 2.1 or later // (http://www.gnu.org/licenses/lgpl-2.1.html) @@ -69,6 +69,8 @@ public bool HasObject get { throw new NotImplementedException(); } } + public ICmObjectDTO DTO => throw new NotImplementedException(); + #endregion } } diff --git a/src/SIL.LCModel/Infrastructure/Impl/SharedXMLBackendProvider.cs b/src/SIL.LCModel/Infrastructure/Impl/SharedXMLBackendProvider.cs index 69043417..55cdfa9f 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/SharedXMLBackendProvider.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/SharedXMLBackendProvider.cs @@ -38,10 +38,11 @@ internal class SharedXMLBackendProvider : XMLBackendProvider private readonly Dictionary m_peerProcesses; private string m_commitLogDir; - internal SharedXMLBackendProvider(LcmCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc, + internal SharedXMLBackendProvider(LcmCache cache, IdentityMap identityMap, IFwMetaDataCacheManagedInternal mdc, IDataMigrationManager dataMigrationManager, ILcmUI ui, ILcmDirectories dirs, LcmSettings settings) - : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings) + : base(cache, identityMap, mdc, dataMigrationManager, ui, dirs, settings) { + m_surrogateFactory = new CmObjectXmlSurrogateFactory(cache); m_peerProcesses = new Dictionary(); m_peerID = Guid.NewGuid(); if (Platform.IsUnix) @@ -438,8 +439,8 @@ public override bool Commit(HashSet newbies, HashSet g.Guid).ToList(), - ObjectsAdded = newbies.Select(n => n.XMLBytes).ToList(), - ObjectsUpdated = dirtballs.Select(d => d.XMLBytes).ToList() + ObjectsAdded = newbies.Select(n => ((CmObjectXmlDTO)n.DTO).XMLBytes).ToList(), + ObjectsUpdated = dirtballs.Select(d => ((CmObjectXmlDTO)d.DTO).XMLBytes).ToList() }; using (var buffer = new MemoryStream()) @@ -562,7 +563,7 @@ private bool GetUnseenForeignChanges(CommitLogMetadata metadata, { foreach (byte[] dirtballXml in commitRec.ObjectsUpdated) { - ICmObjectSurrogate dirtballSurrogate = surrogateFactory.Create(dirtballXml); + ICmObjectSurrogate dirtballSurrogate = surrogateFactory.Create(new CmObjectXmlDTO(dirtballXml)); // This shouldn't be necessary; if a previous foreign transaction deleted it, it // should not show up as a dirtball in a later transaction until it has shown up as a newby. // goners.Remove(dirtball); @@ -576,7 +577,7 @@ private bool GetUnseenForeignChanges(CommitLogMetadata metadata, { foreach (byte[] newbyXml in commitRec.ObjectsAdded) { - ICmObjectSurrogate newObj = surrogateFactory.Create(newbyXml); + ICmObjectSurrogate newObj = surrogateFactory.Create(new CmObjectXmlDTO(newbyXml)); if (goners.Remove(newObj.Guid)) { // an object which an earlier transaction deleted is being re-created. diff --git a/src/SIL.LCModel/Infrastructure/Impl/UnitOfWorkService.cs b/src/SIL.LCModel/Infrastructure/Impl/UnitOfWorkService.cs index 45f1b966..99042d61 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/UnitOfWorkService.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/UnitOfWorkService.cs @@ -425,7 +425,7 @@ private void RevertToSavedState() public IReconcileChanges CreateReconciler( List foreignNewbies, List foreignDirtballs, List foreignGoners) { - return new ChangeReconciler(this, foreignNewbies, foreignDirtballs, foreignGoners); + return new XMLChangeReconciler(this, foreignNewbies, foreignDirtballs, foreignGoners); } public void GatherChanges(HashSet newbies, HashSet dirtballs, HashSet goners) diff --git a/src/SIL.LCModel/Infrastructure/Impl/XMLBackendProvider.cs b/src/SIL.LCModel/Infrastructure/Impl/XMLBackendProvider.cs index 1e85a1b6..c6f2fef2 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/XMLBackendProvider.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/XMLBackendProvider.cs @@ -11,6 +11,7 @@ using System.Xml; using System.Xml.Linq; using SIL.IO.FileLock; +using SIL.LCModel.DomainImpl; using SIL.LCModel.DomainServices.DataMigration; using SIL.LCModel.Utils; using SIL.Lexicon; @@ -33,10 +34,10 @@ public CommitWork(HashSet newbies, { Newbies = new SortedDictionary(); foreach (ICmObjectOrSurrogate newby in newbies) - Newbies.Add(newby.Id.Guid, newby.XMLBytes); + Newbies.Add(newby.Id.Guid, ((CmObjectXmlDTO)newby.DTO).XMLBytes); Dirtballs = new Dictionary(dirtballs.Count); foreach (ICmObjectOrSurrogate dirtball in dirtballs) - Dirtballs.Add(dirtball.Id.Guid, dirtball.XMLBytes); + Dirtballs.Add(dirtball.Id.Guid, ((CmObjectXmlDTO)dirtball.DTO).XMLBytes); // JohnT: strangely, this may actually help reduce the chance of running out of memory, // as compared to simply Goners = new HashSet(goners.Select(id => id.Guid)). // The problem is that a hashset created on an enumeration can't set its initial size, @@ -121,11 +122,11 @@ public void Combine(CommitWork work) /// /// Constructor. /// - internal XMLBackendProvider(LcmCache cache, IdentityMap identityMap, - ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc, + internal XMLBackendProvider(LcmCache cache, IdentityMap identityMap, IFwMetaDataCacheManagedInternal mdc, IDataMigrationManager dataMigrationManager, ILcmUI ui, ILcmDirectories dirs, LcmSettings settings) : - base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings) + base(cache, identityMap, mdc, dataMigrationManager, ui, dirs, settings) { + m_surrogateFactory = new CmObjectXmlSurrogateFactory(cache); } public IList ListOfDuplicateGuids @@ -758,6 +759,10 @@ protected override void UpdateVersionNumber() m_modelVersionOverride = ModelVersion; } + public override ICmObjectDTO MakeDTO(ICmObject cmObject) + { + return new CmObjectXmlDTO(((ICmObjectInternal)cmObject).ToXmlBytes()); + } #endregion IDataStorer implementation /// ------------------------------------------------------------------------------------ @@ -826,7 +831,7 @@ void MakeSurrogate(byte[] xmlBytes) var surrogate = m_surrogateFactory.Create( new Guid(GetAttribute(s_guid, xmlBytes)), GetAttribute(s_class, xmlBytes), - xmlBytes); + new CmObjectXmlDTO(xmlBytes)); if (m_identityMap.HasObject(surrogate.Guid)) { diff --git a/src/SIL.LCModel/Infrastructure/Impl/ChangeReconciler.cs b/src/SIL.LCModel/Infrastructure/Impl/XMLChangeReconciler.cs similarity index 99% rename from src/SIL.LCModel/Infrastructure/Impl/ChangeReconciler.cs rename to src/SIL.LCModel/Infrastructure/Impl/XMLChangeReconciler.cs index 86a83f13..ac827680 100644 --- a/src/SIL.LCModel/Infrastructure/Impl/ChangeReconciler.cs +++ b/src/SIL.LCModel/Infrastructure/Impl/XMLChangeReconciler.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2017 SIL International +// Copyright (c) 2015-2017 SIL International // This software is licensed under the LGPL, version 2.1 or later // (http://www.gnu.org/licenses/lgpl-2.1.html) @@ -32,14 +32,14 @@ namespace SIL.LCModel.Infrastructure.Impl /// will insert it, and our change to the LexDb will be modified to indiate a 'before' state that includes /// that entry. /// - class ChangeReconciler : IReconcileChanges + class XMLChangeReconciler : IReconcileChanges { private UnitOfWorkService UowService; private List m_foreignNewbies; private List m_foreignDirtballs; private List m_foreignGoners; - public ChangeReconciler(UnitOfWorkService uowService, List foreignNewbies, + public XMLChangeReconciler(UnitOfWorkService uowService, List foreignNewbies, List foreignDirtballs, List foreignGoners) { UowService = uowService; @@ -99,7 +99,7 @@ public bool OkToReconcileChanges() var gonerGuids = new HashSet(from id in goners select id.Guid); foreach (var surrogate in m_foreignNewbies.Concat(m_foreignDirtballs)) { - var xml = surrogate.XML; + var xml = ((CmObjectXmlDTO)surrogate.DTO).XML; // Scan all the objsur elements. for (int ich = 0; ; ) { @@ -205,7 +205,7 @@ public void ReconcileForeignChanges() var fakeService = new UowServiceSimulator(); foreach (var newby in m_foreignNewbies) { - var xml = newby.XML; // may be destroyed by getting the Object. + var xml = ((CmObjectXmlDTO)newby.DTO).XML; // may be destroyed by getting the Object. var objectCreation = new LcmStateChangeObjectCreation(newby.Object); objectCreation.SetAfterXml(xml); uow.AddAction(objectCreation); @@ -780,7 +780,7 @@ private void MakeChangeInfoFor(ICmObjectSurrogate dirtball, Func ClassToConstructorInfo; + internal static void InitializeConstructors(List cmObjectTypes) + { + if (ClassToConstructorInfo != null) return; + + ClassToConstructorInfo = new Dictionary(); + // Get default constructor. + // Only do this once, since they are stored in a static data member. + foreach (var lcmType in cmObjectTypes) + { + if (lcmType.IsAbstract) continue; + + ClassToConstructorInfo.Add(lcmType.Name, lcmType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null)); + } + } + } +} \ No newline at end of file diff --git a/src/SIL.LCModel/LcmCache.cs b/src/SIL.LCModel/LcmCache.cs index 7a427718..c9031ffb 100644 --- a/src/SIL.LCModel/LcmCache.cs +++ b/src/SIL.LCModel/LcmCache.cs @@ -353,6 +353,7 @@ private static void SaveOnlyLocalWritingSystems(WritingSystemManager writingSyst /// 7. A set of IWritingSystem to provide additional vernacular writing systems (default: no more) /// 8. OCM Data filename. (default: OCM-Frame.xml if available; else, null) /// 9. Indicates whether or not to use a memory-only writing system manager (default: false) + /// 10. Specifies the BackendProvider type to use in creating the project (default: kXML) /// /// Path of the newly created project file. /// Override DisplayUi to prevent progress dialog from showing. @@ -377,7 +378,14 @@ public static string CreateNewLangProj(IThreadedProgress progressDlg, params obj progressDlg.Message = Properties.Resources.kstidCreatingDB; } - var dbFileName = CreateNewDbFile(dirs.ProjectsDirectory, dirs.TemplateDirectory, ref projectName); + // Default to xml as the historical choice + BackendProviderType projectType = BackendProviderType.kXML; + if (parameters.Length > 10) + { + BackendProviderType.TryParse((string)parameters[10], out projectType); + } + + var dbFileName = CreateNewDbFile(dirs.ProjectsDirectory, dirs.TemplateDirectory, ref projectName, projectType); if (progressDlg != null) { @@ -386,7 +394,8 @@ public static string CreateNewLangProj(IThreadedProgress progressDlg, params obj } bool useMemoryOnlyWsManager = parameters.Length > 9 && (bool) parameters[9]; - var projectId = new SimpleProjectId(useMemoryOnlyWsManager ? BackendProviderType.kXMLWithMemoryOnlyWsMgr : BackendProviderType.kXML, dbFileName); + var adjustedProjType = GetProjTypeForWsManager(useMemoryOnlyWsManager, projectType); + var projectId = new SimpleProjectId(adjustedProjType, dbFileName); using (LcmCache cache = CreateCacheInternal(projectId, userIcuLocale, new SilentLcmUI(synchronizeInvoke), dirs, new LcmSettings(), dataSetup => dataSetup.StartupExtantLanguageProject(projectId, true, progressDlg))) { @@ -508,6 +517,31 @@ public static string CreateNewLangProj(IThreadedProgress progressDlg, params obj return dbFileName; } + private static BackendProviderType GetProjTypeForWsManager(bool useMemoryOnlyWsManager, BackendProviderType projectType) + { + switch (projectType) + { + case BackendProviderType.kXML: + return useMemoryOnlyWsManager + ? BackendProviderType.kXMLWithMemoryOnlyWsMgr + : BackendProviderType.kXML; + case BackendProviderType.kXMLWithMemoryOnlyWsMgr: + Debug.Assert(useMemoryOnlyWsManager, "Mismatched project type and memory manager."); + return BackendProviderType.kXMLWithMemoryOnlyWsMgr; + case BackendProviderType.kSharedXML: + return useMemoryOnlyWsManager + ? BackendProviderType.kSharedXMLWithMemoryOnlyWsMgr + : BackendProviderType.kSharedXML; + case BackendProviderType.kSharedXMLWithMemoryOnlyWsMgr: + Debug.Assert(useMemoryOnlyWsManager, "Mismatched project type and memory manager."); + return BackendProviderType.kSharedXMLWithMemoryOnlyWsMgr; + case BackendProviderType.kMemoryOnly: + return BackendProviderType.kMemoryOnly; + default: + throw new NotImplementedException($"{projectType} does not yet have project creation logic."); + } + } + /// Share Writing System data with SLDR by default (LT-19632) private static void SetDefaultProjectSettings(ISettingsStore projectSettingsStore) { @@ -671,38 +705,49 @@ private static void AddMissingWritingSystems(string fileName, WritingSystemManag /// Build the file name for the new project and copy the template file (NewLangProj.fwdata). /// /// ------------------------------------------------------------------------------------ - private static string CreateNewDbFile(string projectsDir, string templateDir, ref string projectName) + private static string CreateNewDbFile(string projectsDir, string templateDir, ref string projectName, BackendProviderType projectType) { projectName = MiscUtils.FilterForFileName(projectName, MiscUtils.FilenameFilterStrength.kFilterProjName); if (ProjectInfo.GetProjectInfoByName(projectsDir, projectName) != null) throw new ArgumentException("The specified project already exists.", "projectName"); string dbDirName = Path.Combine(projectsDir, projectName); - string dbFileName = Path.Combine(dbDirName, LcmFileHelper.GetXmlDataFileName(projectName)); + string dbFileName; try { Directory.CreateDirectory(dbDirName); CreateProjectSubfolders(dbDirName); - // Make a copy of the template database that will become the new database - File.Copy(Path.Combine(templateDir, - LcmFileHelper.GetXmlDataFileName("NewLangProj")), dbFileName, false); - File.SetAttributes(dbFileName, FileAttributes.Normal); - // Change the LangProject Guid to a new one to make it unique between projects, so Lift Bridge won't get cross with FLEx. - var doc = XDocument.Load(dbFileName); - var lpElement = doc.Element("languageproject").Elements("rt") - .Where(rtEl => rtEl.Attribute("class").Value == "LangProject") - .First(); - var newLpGuid = Guid.NewGuid().ToString().ToLowerInvariant(); - var guidAttr = lpElement.Attribute("guid"); - var oldLpGuid = guidAttr.Value.ToLowerInvariant(); - guidAttr.Value = newLpGuid; - - // Change all of the LP's owned stuff, so their ownerguid attrs are updated. - foreach (var ownedEl in doc.Element("languageproject").Elements("rt").Where(ownedRt => ownedRt.Attribute("ownerguid") != null && ownedRt.Attribute("ownerguid").Value.ToLowerInvariant() == oldLpGuid)) + switch (projectType) { - ownedEl.Attribute("ownerguid").Value = newLpGuid; + case BackendProviderType.kXML: + case BackendProviderType.kSharedXML: + dbFileName = Path.Combine(dbDirName, LcmFileHelper.GetXmlDataFileName(projectName)); + // Make a copy of the template database that will become the new database + File.Copy(Path.Combine(templateDir, + LcmFileHelper.GetXmlDataFileName("NewLangProj")), dbFileName, false); + File.SetAttributes(dbFileName, FileAttributes.Normal); + // Change the LangProject Guid to a new one to make it unique between projects, so Lift Bridge won't get cross with FLEx. + var doc = XDocument.Load(dbFileName); + var lpElement = doc.Element("languageproject").Elements("rt") + .Where(rtEl => rtEl.Attribute("class").Value == "LangProject") + .First(); + var newLpGuid = Guid.NewGuid().ToString().ToLowerInvariant(); + var guidAttr = lpElement.Attribute("guid"); + var oldLpGuid = guidAttr.Value.ToLowerInvariant(); + guidAttr.Value = newLpGuid; + + // Change all of the LP's owned stuff, so their ownerguid attrs are updated. + foreach (var ownedEl in doc.Element("languageproject").Elements("rt").Where(ownedRt => ownedRt.Attribute("ownerguid") != null && ownedRt.Attribute("ownerguid").Value.ToLowerInvariant() == oldLpGuid)) + { + ownedEl.Attribute("ownerguid").Value = newLpGuid; + } + + doc.Save(dbFileName); + break; + default: + throw new ArgumentException( + "Unhandled project type.", + nameof(projectType)); } - - doc.Save(dbFileName); } catch (Exception e) { diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000001Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000001Tests.cs index fb0e8382..62838e11 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000001Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000001Tests.cs @@ -27,7 +27,7 @@ public sealed class DataMigrationTests7000001 : DataMigrationTestsBase [Test] public void DataMigration7000001_and_Delint_Tests() { - var dtos = new HashSet(); + var dtos = new HashSet(); // 1. Add barebones LP. // LP will have one extra property to make sure it isnt; affected. // LP will also have a couple 'dangling' references for when 'Delint' is tested. @@ -54,7 +54,7 @@ public void DataMigration7000001_and_Delint_Tests() "{0}" + "{0}" + "", Environment.NewLine); - var lpDto = new DomainObjectDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", + var lpDto = new DomainObjectXMLDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", "LangProject", xml); dtos.Add(lpDto); @@ -69,7 +69,7 @@ public void DataMigration7000001_and_Delint_Tests() "{0}" + "{0}" + "", Environment.NewLine); - var wfiDto = new DomainObjectDTO("6C84F84A-5B99-4CF5-A7D5-A308DDC604E0", + var wfiDto = new DomainObjectXMLDTO("6C84F84A-5B99-4CF5-A7D5-A308DDC604E0", "WordformInventory", xml); dtos.Add(wfiDto); @@ -87,7 +87,7 @@ public void DataMigration7000001_and_Delint_Tests() "{0}" + "{0}" + "", Environment.NewLine); - var wf1Dto = new DomainObjectDTO("88304983-CDB2-460B-B3D5-5F95C66F27FF", + var wf1Dto = new DomainObjectXMLDTO("88304983-CDB2-460B-B3D5-5F95C66F27FF", "WfiWordform", xml); dtos.Add(wf1Dto); @@ -104,14 +104,14 @@ public void DataMigration7000001_and_Delint_Tests() "{0}" + "{0}" + "", Environment.NewLine); - var wf2Dto = new DomainObjectDTO("59821DAB-AB03-470E-B430-5696A0503A08", + var wf2Dto = new DomainObjectXMLDTO("59821DAB-AB03-470E-B430-5696A0503A08", "WfiWordform", xml); dtos.Add(wf2Dto); // Add zombie, which is where an object's owner does not exist. xml = @""; - var zombie = new DomainObjectDTO("3462BE3E-4817-4BBE-B2B9-30828B48E2C7", + var zombie = new DomainObjectXMLDTO("3462BE3E-4817-4BBE-B2B9-30828B48E2C7", "LexSense", xml); dtos.Add(zombie); @@ -119,7 +119,7 @@ public void DataMigration7000001_and_Delint_Tests() // which is where an object's owner *does* exist, // but it doesn't know it owns the zombie. xml = @""; - var zombie2 = new DomainObjectDTO("c1ecaa72-e382-11de-8a39-0800200c9a66", + var zombie2 = new DomainObjectXMLDTO("c1ecaa72-e382-11de-8a39-0800200c9a66", "Text", xml); dtos.Add(zombie2); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000002Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000002Tests.cs index c8595cc3..5dc6ad59 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000002Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000002Tests.cs @@ -25,7 +25,7 @@ public sealed class DataMigrationTests7000002 : DataMigrationTestsBase [Test] public void DataMigration7000002Test() { - var dtos = new HashSet(); + var dtos = new HashSet(); var sb = new StringBuilder(); // 1. Add barebones LP. sb.Append(""); @@ -39,18 +39,18 @@ public void DataMigration7000002Test() sb.Append(""); sb.Append(""); sb.Append(""); - var lpDto = new DomainObjectDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", + var lpDto = new DomainObjectXMLDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", "LangProject", sb.ToString()); dtos.Add(lpDto); // Add text dto. - var txtDto = new DomainObjectDTO(lpTextsGuids.textGuid.ToString(), + var txtDto = new DomainObjectXMLDTO(lpTextsGuids.textGuid.ToString(), "StText", lpTextsGuids.textXml); dtos.Add(txtDto); // Add text para dto. - var txtParaDto = new DomainObjectDTO(lpTextsGuids.paraGuid.ToString(), + var txtParaDto = new DomainObjectXMLDTO(lpTextsGuids.paraGuid.ToString(), "StTxtPara", lpTextsGuids.paraXml); dtos.Add(txtParaDto); @@ -64,7 +64,7 @@ public void DataMigration7000002Test() sb.Append(""); sb.Append(""); sb.Append(""); - var scrDto = new DomainObjectDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", + var scrDto = new DomainObjectXMLDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", "Scripture", sb.ToString()); dtos.Add(scrDto); @@ -89,29 +89,29 @@ public void DataMigration7000002Test() sb.Append(""); sb.Append(""); sb.Append(""); - var bookDto = new DomainObjectDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", + var bookDto = new DomainObjectXMLDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", "ScrBook", sb.ToString()); dtos.Add(bookDto); // Add title - var titleDto = new DomainObjectDTO(titleTextGuids.textGuid.ToString(), + var titleDto = new DomainObjectXMLDTO(titleTextGuids.textGuid.ToString(), "StText", titleTextGuids.textXml); dtos.Add(titleDto); // Title para - var titleParaDto = new DomainObjectDTO(titleTextGuids.paraGuid.ToString(), + var titleParaDto = new DomainObjectXMLDTO(titleTextGuids.paraGuid.ToString(), "StTxtPara", titleTextGuids.paraXml); dtos.Add(titleParaDto); // Add footnote - var footnoteDto = new DomainObjectDTO(footnoteGuids.textGuid.ToString(), + var footnoteDto = new DomainObjectXMLDTO(footnoteGuids.textGuid.ToString(), "StFootnote", footnoteGuids.textXml); dtos.Add(footnoteDto); // Footnote para - var footnoteParaDto = new DomainObjectDTO(footnoteGuids.paraGuid.ToString(), + var footnoteParaDto = new DomainObjectXMLDTO(footnoteGuids.paraGuid.ToString(), "StTxtPara", footnoteGuids.paraXml); dtos.Add(footnoteParaDto); @@ -131,29 +131,29 @@ public void DataMigration7000002Test() sb.Append(""); sb.Append(""); sb.Append(""); - var sectionDto = new DomainObjectDTO("834e1bf8-3a25-47d6-9f92-806b38b5f815", + var sectionDto = new DomainObjectXMLDTO("834e1bf8-3a25-47d6-9f92-806b38b5f815", "ScrSection", sb.ToString()); dtos.Add(sectionDto); // Add the contents - var contentsDto = new DomainObjectDTO(contentsTextGuids.textGuid.ToString(), + var contentsDto = new DomainObjectXMLDTO(contentsTextGuids.textGuid.ToString(), "StText", contentsTextGuids.textXml); dtos.Add(contentsDto); // Contents para - var contentsParaDto = new DomainObjectDTO(contentsTextGuids.paraGuid.ToString(), + var contentsParaDto = new DomainObjectXMLDTO(contentsTextGuids.paraGuid.ToString(), "StTxtPara", contentsTextGuids.paraXml); dtos.Add(contentsParaDto); // Add the heading to the xml - var headingDto = new DomainObjectDTO(headingTextGuids.textGuid.ToString(), + var headingDto = new DomainObjectXMLDTO(headingTextGuids.textGuid.ToString(), "StText", headingTextGuids.textXml); dtos.Add(headingDto); // heading para - var headingParaDto = new DomainObjectDTO(headingTextGuids.paraGuid.ToString(), + var headingParaDto = new DomainObjectXMLDTO(headingTextGuids.paraGuid.ToString(), "StTxtPara", headingTextGuids.paraXml); dtos.Add(headingParaDto); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000003Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000003Tests.cs index 4a3d0184..b521e36f 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000003Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000003Tests.cs @@ -24,7 +24,7 @@ public sealed class DataMigrationTests7000003 : DataMigrationTestsBase [Test] public void DataMigration7000003Test() { - var dtos = new HashSet(); + var dtos = new HashSet(); var sb = new StringBuilder(); // 1. Add barebones LP. sb.Append(""); @@ -34,7 +34,7 @@ public void DataMigration7000003Test() sb.Append(""); sb.Append(""); sb.Append(""); - var lpDto = new DomainObjectDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", + var lpDto = new DomainObjectXMLDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", "LangProject", sb.ToString()); dtos.Add(lpDto); @@ -48,7 +48,7 @@ public void DataMigration7000003Test() sb.Append(""); sb.Append(""); sb.Append(""); - var scrDto = new DomainObjectDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", + var scrDto = new DomainObjectXMLDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", "Scripture", sb.ToString()); dtos.Add(scrDto); @@ -66,17 +66,17 @@ public void DataMigration7000003Test() sb.Append(""); sb.Append(""); sb.Append(""); - var bookDto = new DomainObjectDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", + var bookDto = new DomainObjectXMLDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", "ScrBook", sb.ToString()); dtos.Add(bookDto); // Add footnote - var footnoteDto = new DomainObjectDTO(footnoteGuids.textGuid.ToString(), + var footnoteDto = new DomainObjectXMLDTO(footnoteGuids.textGuid.ToString(), "StFootnote", footnoteGuids.textXml); dtos.Add(footnoteDto); // Footnote para - var footnoteParaDto = new DomainObjectDTO(footnoteGuids.paraGuid.ToString(), + var footnoteParaDto = new DomainObjectXMLDTO(footnoteGuids.paraGuid.ToString(), "StTxtPara", footnoteGuids.paraXml); dtos.Add(footnoteParaDto); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000009Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000009Tests.cs index 27e49f83..271ff82a 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000009Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000009Tests.cs @@ -23,7 +23,7 @@ public sealed class DataMigrationTests7000009 : DataMigrationTestsBase [Test] public void DataMigration7000009Test() { - var dtos = new HashSet(); + var dtos = new HashSet(); var sb = new StringBuilder(); // 1. Add barebones LP. sb.Append(""); @@ -38,7 +38,7 @@ public void DataMigration7000009Test() sb.Append(""); sb.Append(""); var expectedLp = sb.ToString(); - var lpDto = new DomainObjectDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", + var lpDto = new DomainObjectXMLDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", "LangProject", expectedLp); dtos.Add(lpDto); @@ -58,7 +58,7 @@ public void DataMigration7000009Test() string expected = sb.ToString(); sb.Insert(index, " owningflid=\"6001040\" owningord=\"0\""); - var scrDto = new DomainObjectDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", + var scrDto = new DomainObjectXMLDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", "Scripture", sb.ToString()); dtos.Add(scrDto); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000010Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000010Tests.cs index 796ed832..f13f984d 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000010Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000010Tests.cs @@ -82,13 +82,13 @@ public void DataMigration7000010_AnnotationDefns_Removed_Test() IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000009, dtos, mockMDC, null, TestDirectoryFinder.LcmDirectories); // Collect the various annotation defns. - var annDefnDtos = new Dictionary(); + var annDefnDtos = new Dictionary(); foreach (var annDto in dtoRepos.AllInstancesSansSubclasses("CmAnnotationDefn")) annDefnDtos.Add(annDto.Guid.ToUpper(), annDto); - var stTextDtos = new Dictionary(); + var stTextDtos = new Dictionary(); foreach (var annDto in dtoRepos.AllInstancesSansSubclasses("StText")) stTextDtos.Add(annDto.Guid.ToUpper(), annDto); - var stTxtParaDtos = new Dictionary(); + var stTxtParaDtos = new Dictionary(); foreach (var annDto in dtoRepos.AllInstancesSansSubclasses("StTxtPara")) stTxtParaDtos.Add(annDto.Guid.ToUpper(), annDto); @@ -147,7 +147,7 @@ public void DataMigration7000010_BasicSegmentMigration_Test() Assert.AreEqual("en", run.Attribute("ws").Value, "Wrong IcuLocale."); Assert.AreEqual(".", run.Value, "Wrong punctuation form."); - var newNotesDtos = new List(dtoRepos.AllInstancesSansSubclasses("Note")); + var newNotesDtos = new List(dtoRepos.AllInstancesSansSubclasses("Note")); Assert.AreEqual(2, newNotesDtos.Count, "Wrong number of new Notes."); var noteAltValues = new List { "Note1.", "Note2.", "Nota1.", "Nota2." }; var noteGuids = new List(2); @@ -172,7 +172,7 @@ public void DataMigration7000010_BasicSegmentMigration_Test() "068DC680-CD40-4C47-BBE7-00E572EE2602", punctFormDto.Guid }; - DomainObjectDTO newSegmentDto; + DomainObjectXMLDTO newSegmentDto; var newSegmentInnerElement = CheckNewSegment(dtoRepos, 0, currentParaDto, newSegmentObjSurElements[0], out newSegmentDto); CheckComment(newSegmentInnerElement, "LiteralTranslation", true, 2); CheckComment(newSegmentInnerElement, "FreeTranslation", true, 2); @@ -216,7 +216,7 @@ public void DataMigration7000010_SegmentsNoXfics_Test() var lpElement = XElement.Parse(lpDto.Xml); Assert.IsNull(lpElement.Element("LangProject").Element("Annotations"), "Still has Annotations."); - var newNotesDtos = new List(dtoRepos.AllInstancesSansSubclasses("Note")); + var newNotesDtos = new List(dtoRepos.AllInstancesSansSubclasses("Note")); Assert.AreEqual(2, newNotesDtos.Count, "Wrong number of new Notes."); var noteAltValues = new List { "Note1.", "Note2.", "Nota1.", "Nota2." }; var noteGuids = new List(2); @@ -238,7 +238,7 @@ public void DataMigration7000010_SegmentsNoXfics_Test() var analysesGuids = new List() { }; - DomainObjectDTO newSegmentDto; + DomainObjectXMLDTO newSegmentDto; var newSegmentInnerElement = CheckNewSegment(dtoRepos, 0, currentParaDto, newSegmentObjSurElements[0], out newSegmentDto); CheckComment(newSegmentInnerElement, "LiteralTranslation", true, 2); CheckComment(newSegmentInnerElement, "FreeTranslation", true, 2); @@ -299,7 +299,7 @@ public void DataMigration7000010_TextTagMigration_Test() "068DC680-CD40-4C47-BBE6-00E572EE2602", punctFormDto.Guid }; - DomainObjectDTO newSegmentDto; + DomainObjectXMLDTO newSegmentDto; var newSegmentInnerElement = CheckNewSegment(dtoRepos, 0, currentParaDto, newSegmentObjSurElements[0], out newSegmentDto); CheckComment(newSegmentInnerElement, "LiteralTranslation", false, 0); CheckComment(newSegmentInnerElement, "FreeTranslation", false, 0); @@ -415,7 +415,7 @@ public void DataMigration7000010_PathologicalSegmentMigration_Test() { "068DC680-CD40-4C47-BBE6-00E572EE2602" }; - DomainObjectDTO newSegmentDto; + DomainObjectXMLDTO newSegmentDto; var newSegmentInnerElement = CheckNewSegment(dtoRepos, 0, currentParaDto, newSegmentObjSurElements[0], out newSegmentDto); CheckComment(newSegmentInnerElement, "LiteralTranslation", false, 0); CheckComment(newSegmentInnerElement, "FreeTranslation", false, 0); @@ -456,7 +456,7 @@ public void DataMigration7000010_PathologicalSegmentMigration_Test() // The previous version of the migration code ended up with "ChangeME" as the // segment in this case when converting a CCA that referenced that wfic. var oneSegmentParaDto = CheckPara(dtoRepos, "14f703d9-c849-4251-9b0f-09d964b6b69c", 1, true, false, out newSegmentObjSurElements); // all paragraphs now get reparsed on load - DomainObjectDTO oneSegmentDto; + DomainObjectXMLDTO oneSegmentDto; var oneSegmentInnerElement = CheckNewSegment(dtoRepos, 0, oneSegmentParaDto, newSegmentObjSurElements[0], out oneSegmentDto); Assert.AreEqual("0", oneSegmentInnerElement.Element("BeginOffset").Attribute("val").Value); @@ -554,7 +554,7 @@ public void DataMigration7000010_PathologicalSegmentMigration_Duplicates_Test() { "068DC680-CD40-4C47-BBE6-00E572EE2602" }; - DomainObjectDTO newSegmentDto; + DomainObjectXMLDTO newSegmentDto; var newSegmentInnerElement = CheckNewSegment(dtoRepos, 0, currentParaDto, newSegmentObjSurElements[0], out newSegmentDto); CheckComment(newSegmentInnerElement, "LiteralTranslation", false, 0); CheckComment(newSegmentInnerElement, "FreeTranslation", false, 0); @@ -788,7 +788,7 @@ public void DataMigration7000010_DiscoursePunctuation_Test() "d0c52468-ceb3-4860-8cbf-2e68ac5b68ad", punctPeriodDto.Guid }; - DomainObjectDTO newSegmentDto; + DomainObjectXMLDTO newSegmentDto; var newSegmentInnerElement = CheckNewSegment(dtoRepos, 0, paraDto, firstSegmentObjsur, out newSegmentDto); // 4 different twfics (one repeated) and 2 pfics. CheckXfics(dtoRepos, newSegmentInnerElement, 6, analysesGuids); @@ -1134,7 +1134,7 @@ private IDomainObjectDTORepository DoCommonBasics(IEnumerable extraDataF return dtoRepos; } - private static IDomainObjectDTORepository SetupMDC(HashSet dtos) + private static IDomainObjectDTORepository SetupMDC(HashSet dtos) { var mockMDC = new MockMDCForDataMigration(); mockMDC.AddClass(1, "CmObject", null, new List { "CmProject", "StPara", "CmAnnotation", @@ -1190,7 +1190,7 @@ private static void CheckXfics(IDomainObjectDTORepository dtoRepos, } } - private static void CheckNotes(IDomainObjectDTORepository dtoRepos, DomainObjectDTO newSegmentDto, ICollection noteGuids, XContainer newSegmentInnerElement, bool expectedToHaveNotes, int expectedNumberOfNotes) + private static void CheckNotes(IDomainObjectDTORepository dtoRepos, DomainObjectXMLDTO newSegmentDto, ICollection noteGuids, XContainer newSegmentInnerElement, bool expectedToHaveNotes, int expectedNumberOfNotes) { // Check Nts. var notesElements = newSegmentInnerElement.Elements("Notes"); @@ -1244,7 +1244,7 @@ private static void CheckAlternatives(XContainer multiStringElement, int altenat Assert.AreEqual(altenativeCount, alternativesNodes.Count(), "Wrong number of alternatives."); } - private static DomainObjectDTO CheckPara(IDomainObjectDTORepository dtoRepos, string paraGuid, + private static DomainObjectXMLDTO CheckPara(IDomainObjectDTORepository dtoRepos, string paraGuid, int segmentCount, bool checkForParseIsCurrent, bool expectedParseIsCurrentValue, out List newSegmentObjSurElements) { @@ -1276,7 +1276,7 @@ private static DomainObjectDTO CheckPara(IDomainObjectDTORepository dtoRepos, st return currentParaDto; } - private static XElement CheckNewSegment(IDomainObjectDTORepository dtoRepos, int beginOffset, DomainObjectDTO owningPara, XElement newSegmentObjSurElement, out DomainObjectDTO newSegmentDto) + private static XElement CheckNewSegment(IDomainObjectDTORepository dtoRepos, int beginOffset, DomainObjectXMLDTO owningPara, XElement newSegmentObjSurElement, out DomainObjectXMLDTO newSegmentDto) { newSegmentDto = dtoRepos.GetDTO(newSegmentObjSurElement.Attribute("guid").Value); Assert.IsNotNull(newSegmentDto, "Missing new Segment DTO."); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000011Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000011Tests.cs index a0db6966..8978c1a6 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000011Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000011Tests.cs @@ -23,7 +23,7 @@ public sealed class DataMigrationTests7000011 : DataMigrationTestsBase [Test] public void DataMigration7000011Test() { - var dtos = new HashSet(); + var dtos = new HashSet(); var sb = new StringBuilder(); // 1. Add barebones Notebook. sb.Append(""); @@ -34,7 +34,7 @@ public void DataMigration7000011Test() sb.Append(""); sb.Append(""); sb.Append(""); - var nbkDto = new DomainObjectDTO("2E237D40-853C-49D5-AAC6-EFF01121AC25", "RnResearchNbk", sb.ToString()); + var nbkDto = new DomainObjectXMLDTO("2E237D40-853C-49D5-AAC6-EFF01121AC25", "RnResearchNbk", sb.ToString()); dtos.Add(nbkDto); sb = new StringBuilder(); @@ -47,7 +47,7 @@ public void DataMigration7000011Test() sb.Append(""); sb.Append(""); sb.Append(""); - var recTypesDto = new DomainObjectDTO("513B370D-8EFC-4C94-8192-7707677A6F98", "CmPossibilityList", sb.ToString()); + var recTypesDto = new DomainObjectXMLDTO("513B370D-8EFC-4C94-8192-7707677A6F98", "CmPossibilityList", sb.ToString()); dtos.Add(recTypesDto); sb = new StringBuilder(); @@ -57,7 +57,7 @@ public void DataMigration7000011Test() sb.Append("Con"); sb.Append(""); sb.Append(""); - var conDto = new DomainObjectDTO("27C32299-3B41-4FAD-A85C-F47657BCF95A", "CmPossibility", sb.ToString()); + var conDto = new DomainObjectXMLDTO("27C32299-3B41-4FAD-A85C-F47657BCF95A", "CmPossibility", sb.ToString()); dtos.Add(conDto); sb = new StringBuilder(); @@ -70,7 +70,7 @@ public void DataMigration7000011Test() sb.Append(""); sb.Append(""); sb.Append(""); - var obsDto = new DomainObjectDTO("5E3D9C56-404C-44C5-B3CB-99BF390E322E", "CmPossibility", sb.ToString()); + var obsDto = new DomainObjectXMLDTO("5E3D9C56-404C-44C5-B3CB-99BF390E322E", "CmPossibility", sb.ToString()); dtos.Add(obsDto); sb = new StringBuilder(); @@ -80,7 +80,7 @@ public void DataMigration7000011Test() sb.Append("Per"); sb.Append(""); sb.Append(""); - var perDto = new DomainObjectDTO("9827CBE0-31F3-434E-80F7-5D5354C110B0", "CmPossibility", sb.ToString()); + var perDto = new DomainObjectXMLDTO("9827CBE0-31F3-434E-80F7-5D5354C110B0", "CmPossibility", sb.ToString()); dtos.Add(perDto); sb = new StringBuilder(); @@ -90,7 +90,7 @@ public void DataMigration7000011Test() sb.Append(""); sb.Append(""); sb.Append(""); - var recDto = new DomainObjectDTO("c84b721b-3617-43de-a436-9e0538837a66", "RnGenericRec", sb.ToString()); + var recDto = new DomainObjectXMLDTO("c84b721b-3617-43de-a436-9e0538837a66", "RnGenericRec", sb.ToString()); dtos.Add(recDto); // Set up mock MDC. diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000012Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000012Tests.cs index 77f87129..03728ed0 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000012Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000012Tests.cs @@ -63,7 +63,7 @@ public void DataMigration7000012_Unneeded_UserViewField_Removed_Test() Assert.AreEqual(40, dtoRepos.AllInstancesWithSubclasses("UserViewField").Count()); // Collect the UserViewField values. - var userViewFieldDtos = new Dictionary(); + var userViewFieldDtos = new Dictionary(); foreach (var uvfDto in dtoRepos.AllInstancesWithSubclasses("UserViewField")) userViewFieldDtos.Add(uvfDto.Guid.ToUpper(), uvfDto); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000014Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000014Tests.cs index 2ad6cc04..5d5d61e2 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000014Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000014Tests.cs @@ -74,7 +74,7 @@ public void DataMigration7000014Test() Assert.Contains(goner.Guid.ToLower(), gonerGuids, "Goner guid not found."); } - private void VerifyAnalysis(DomainObjectDTO analysis, string[] evaluations) + private void VerifyAnalysis(DomainObjectXMLDTO analysis, string[] evaluations) { var rtElement = XElement.Parse(analysis.Xml); var agentElt = rtElement.Element("WfiAnalysis"); @@ -94,7 +94,7 @@ private void VerifyReference(XElement objsur, HashSet wanted) Assert.IsTrue(wanted.Contains(guid)); } - private void VerifyAgent(DomainObjectDTO agent, IDomainObjectDTORepository dtoRepos, out string approvesGuid, out string disapprovesGuid) + private void VerifyAgent(DomainObjectXMLDTO agent, IDomainObjectDTORepository dtoRepos, out string approvesGuid, out string disapprovesGuid) { var rtElement = XElement.Parse(agent.Xml); var agentElement = rtElement.Element("CmAgent"); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000015Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000015Tests.cs index b842f794..c4d30814 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000015Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000015Tests.cs @@ -51,7 +51,7 @@ public void DataMigration7000015Test() VerifyObject(dtoRepos.GetDTO("C83E33DD-2A79-4A4B-84F6-92343C4F5325"), oldClassElementNames, expectedPropertyElements); } - private static void VerifyObject(DomainObjectDTO dto, IEnumerable oldClassElements, ICollection expectedPropertyElements) + private static void VerifyObject(DomainObjectXMLDTO dto, IEnumerable oldClassElements, ICollection expectedPropertyElements) { // Make sure the old class elements are gone. var rtElement = XElement.Parse(dto.Xml); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000016Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000016Tests.cs index a0cb92fc..414b6454 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000016Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000016Tests.cs @@ -53,8 +53,8 @@ public void DataMigration7000016Test() // Verification Phase Assert.AreEqual(7000016, repoDTO.CurrentModelVersion, "Wrong updated version."); - DomainObjectDTO nbkDto = null; - foreach (DomainObjectDTO dot in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) + DomainObjectXMLDTO nbkDto = null; + foreach (DomainObjectXMLDTO dot in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) { nbkDto = dot; break; @@ -69,7 +69,7 @@ public void DataMigration7000016Test() bool fFoundEvent = false; bool fFoundMethod = false; bool fFoundWeather = false; - foreach (DomainObjectDTO dto in repoDTO.GetDirectlyOwnedDTOs(ksguidRecTypesList)) + foreach (DomainObjectXMLDTO dto in repoDTO.GetDirectlyOwnedDTOs(ksguidRecTypesList)) { string sguid = dto.Guid.ToLowerInvariant(); Assert.AreNotEqual(sguid, ksguidObservation); @@ -99,9 +99,9 @@ public void DataMigration7000016Test() [Test] public void CheckOnNoPossibilitiesInListAtStart() { - var dtos = new HashSet + var dtos = new HashSet { - new DomainObjectDTO("D9D55B12-EA5E-11DE-95EF-0013722F8DEC".ToLowerInvariant(), "CmPossibilityList", + new DomainObjectXMLDTO("D9D55B12-EA5E-11DE-95EF-0013722F8DEC".ToLowerInvariant(), "CmPossibilityList", @"") }; var mockMdc = SetupMdc(); @@ -117,24 +117,24 @@ public void CheckOnNoPossibilitiesInListAtStart() private void CheckEventSubTypes(IDomainObjectDTORepository repoDTO) { - DomainObjectDTO dtoObs = GetDTOIfItExists(repoDTO, ksguidObservation); + DomainObjectXMLDTO dtoObs = GetDTOIfItExists(repoDTO, ksguidObservation); if (dtoObs != null) VerifyOwner(repoDTO, dtoObs, ksguidEvent); - DomainObjectDTO dtoCon = GetDTOIfItExists(repoDTO, ksguidConversation); + DomainObjectXMLDTO dtoCon = GetDTOIfItExists(repoDTO, ksguidConversation); if (dtoCon != null) VerifyOwner(repoDTO, dtoCon, ksguidEvent); - DomainObjectDTO dtoInt = GetDTOIfItExists(repoDTO, ksguidInterview); + DomainObjectXMLDTO dtoInt = GetDTOIfItExists(repoDTO, ksguidInterview); if (dtoInt != null) VerifyOwner(repoDTO, dtoInt, ksguidEvent); - DomainObjectDTO dtoPer = GetDTOIfItExists(repoDTO, ksguidPerformance); + DomainObjectXMLDTO dtoPer = GetDTOIfItExists(repoDTO, ksguidPerformance); if (dtoPer != null) VerifyOwner(repoDTO, dtoPer, ksguidEvent); } - private void VerifyOwner(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoTest, string sguidOwner) + private void VerifyOwner(IDomainObjectDTORepository repoDTO, DomainObjectXMLDTO dtoTest, string sguidOwner) { bool fFound = false; - foreach (DomainObjectDTO dto in repoDTO.GetDirectlyOwnedDTOs(sguidOwner)) + foreach (DomainObjectXMLDTO dto in repoDTO.GetDirectlyOwnedDTOs(sguidOwner)) { if (dto.Guid == dtoTest.Guid && dto.Xml == dtoTest.Xml) { @@ -145,7 +145,7 @@ private void VerifyOwner(IDomainObjectDTORepository repoDTO, DomainObjectDTO dto Assert.IsTrue(fFound); } - private static DomainObjectDTO GetDTOIfItExists(IDomainObjectDTORepository dtoRepository, string sGuid) + private static DomainObjectXMLDTO GetDTOIfItExists(IDomainObjectDTORepository dtoRepository, string sGuid) { try { diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000017Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000017Tests.cs index 4c511ce7..930a1b3b 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000017Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000017Tests.cs @@ -36,8 +36,8 @@ public void DeleteWeatherListAndField() // Verification Phase Assert.AreEqual(7000017, repoDTO.CurrentModelVersion, "Wrong updated version."); - DomainObjectDTO dtoLP = null; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject")) + DomainObjectXMLDTO dtoLP = null; + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject")) { Assert.IsNull(dtoLP, "Only one LangProject object should exist"); dtoLP = dto; @@ -47,8 +47,8 @@ public void DeleteWeatherListAndField() Assert.IsFalse(sXml.Contains(""), "The element should have disappeared"); string sLpOwnerGuid = GetGuidAsOwnerGuid(sXml); - DomainObjectDTO dtoNbk = null; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) + DomainObjectXMLDTO dtoNbk = null; + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) { Assert.IsNull(dtoNbk, "Only one RnResearchNbk should exist"); Assert.IsTrue(dto.Xml.Contains(sLpOwnerGuid), "The RnResearchNbk should be owned by the LangProject"); @@ -57,7 +57,7 @@ public void DeleteWeatherListAndField() Assert.NotNull(dtoNbk, "The RnResearchNbk should exist"); string sNbkOwnerGuid = GetGuidAsOwnerGuid(dtoNbk.Xml); int cList = 0; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("CmPossibilityList")) + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("CmPossibilityList")) { sXml = dto.Xml; Assert.IsTrue(sXml.Contains(sNbkOwnerGuid), "Possibility List must be owned by Data Notebook"); @@ -65,7 +65,7 @@ public void DeleteWeatherListAndField() } Assert.AreEqual(1, cList, "Only one CmPossibilityList should exist"); - foreach (DomainObjectDTO dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec")) + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec")) { Assert.IsFalse(dto.Xml.Contains(" element should have disappeared"); Assert.IsFalse(dto.Xml.Contains(" element should have been created"); @@ -138,8 +138,8 @@ private void ConvertWeatherToCustomListAndField(string datafile) // Verification Phase Assert.AreEqual(7000017, repoDTO.CurrentModelVersion, "Wrong updated version."); - DomainObjectDTO dtoLP = null; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject")) + DomainObjectXMLDTO dtoLP = null; + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject")) { Assert.IsNull(dtoLP, "Only one LangProject object should exist"); dtoLP = dto; @@ -149,8 +149,8 @@ private void ConvertWeatherToCustomListAndField(string datafile) Assert.IsFalse(sXml.Contains(""), "The element should have disappeared"); string sLpOwnerGuid = GetGuidAsOwnerGuid(sXml); - DomainObjectDTO dtoNbk = null; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) + DomainObjectXMLDTO dtoNbk = null; + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) { Assert.IsNull(dtoNbk, "Only one RnResearchNbk should exist"); Assert.IsTrue(dto.Xml.Contains(sLpOwnerGuid), "The RnResearchNbk should be owned by the LangProject"); @@ -159,8 +159,8 @@ private void ConvertWeatherToCustomListAndField(string datafile) Assert.NotNull(dtoNbk, "The RnResearchNbk should exist"); string sNbkOwnerGuid = GetGuidAsOwnerGuid(dtoNbk.Xml); int cList = 0; - DomainObjectDTO dtoTypeList = null; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("CmPossibilityList")) + DomainObjectXMLDTO dtoTypeList = null; + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("CmPossibilityList")) { sXml = dto.Xml; if (sXml.Contains(" ownerguid=")) @@ -173,7 +173,7 @@ private void ConvertWeatherToCustomListAndField(string datafile) } Assert.AreEqual(2, cList, "Two CmPossibilityList objects should still exist"); - foreach (DomainObjectDTO dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec")) + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec")) { sXml = dto.Xml; Assert.IsFalse(sXml.Contains(" element should have disappeared"); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000018Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000018Tests.cs index 8c531170..fcd15214 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000018Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000018Tests.cs @@ -39,24 +39,24 @@ public void PerformMigration7000018() // Verification Phase Assert.AreEqual(7000018, repoDTO.CurrentModelVersion, "Wrong updated version."); - DomainObjectDTO dtoLP = null; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject")) + DomainObjectXMLDTO dtoLP = null; + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject")) { Assert.IsNull(dtoLP, "Only one Language Project object should exist"); dtoLP = dto; } Assert.NotNull(dtoLP, "The Language Project object should exist"); - DomainObjectDTO dtoNtbk = null; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) + DomainObjectXMLDTO dtoNtbk = null; + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) { Assert.IsNull(dtoNtbk, "Only one Data Notebook object should exist"); dtoNtbk = dto; } Assert.NotNull(dtoNtbk, "The Data Notebook object should exist"); - DomainObjectDTO dtoLexDb = null; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LexDb")) + DomainObjectXMLDTO dtoLexDb = null; + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("LexDb")) { Assert.IsNull(dtoLexDb, "Only one Lexical Database object should exist"); dtoLexDb = dto; @@ -87,7 +87,7 @@ private void VerifyStylesRenamedOrDeleted(IDomainObjectDTORepository repoDTO) int cCustom = 0; bool gotHeading3 = false; bool gotHeading5 = false; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("StStyle")) + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("StStyle")) { Assert.That(dto.Guid.ToUpper(), Is.Not.EqualTo("71B2233D-8B14-42D5-A625-AAC8EDE7503B"), "Heading 3 in LexDb duplicates one in LangProj and should have been deleted"); @@ -115,7 +115,7 @@ private void VerifyStylesRenamedOrDeleted(IDomainObjectDTORepository repoDTO) } string sXml = dto.Xml; string sName = GetStyleName(sXml); - DomainObjectDTO dtoOwner = repoDTO.GetOwningDTO(dto); + DomainObjectXMLDTO dtoOwner = repoDTO.GetOwningDTO(dto); if (dtoOwner.Classname != "LangProject") { Assert.AreEqual(dtoOwner.Classname, "Scripture", "Either LangProject or Scripture owns the style"); @@ -205,7 +205,7 @@ private void VerifyStyleReferencesUpdated(IDomainObjectDTORepository repoDTO) int cWrtSysAbbr = 0; int cHyperUsed = 0; int cWSAUsed = 0; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("StTxtPara")) + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("StTxtPara")) { string sXml = dto.Xml; Assert.False(sXml.Contains(" namedStyle=\"External Link\""), "The External Link style should no longer be used"); @@ -245,7 +245,7 @@ private void VerifyScriptureStylesUnchanged(IDomainObjectDTORepository repoDTO) int cExternal = 0; int cInternal = 0; int cLangCode = 0; - foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("ScrTxtPara")) + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesSansSubclasses("ScrTxtPara")) { string sXml = dto.Xml; if (sXml.Contains(" namedStyle=\"External Link\"")) @@ -274,10 +274,10 @@ private void ValidateStyleReference(IDomainObjectDTORepository repoDTO, XElement xeObjsur = xeLink; XAttribute xa = xeObjsur.Attribute("guid"); Assert.IsNotNull(xa, sRefName + "/objsur must have a guid attribute"); - DomainObjectDTO dto; + DomainObjectXMLDTO dto; Assert.IsTrue(repoDTO.TryGetValue(xa.Value, out dto), sRefName + " must point to a valid object"); Assert.AreEqual("StStyle", dto.Classname, sRefName + " must point to a style"); - DomainObjectDTO dtoOwner; + DomainObjectXMLDTO dtoOwner; Assert.IsTrue(repoDTO.TryGetOwner(xa.Value, out dtoOwner), sRefName + " must point to a style with a valid owner"); Assert.AreEqual("LangProject", dtoOwner.Classname, sRefName + " must point to a style owned by LangProject"); } @@ -288,7 +288,7 @@ private void ValidateStyleReference(IDomainObjectDTORepository repoDTO, XElement private void VerifyNoDirectFormatting(IDomainObjectDTORepository repoDTO) { byte[] rgbRun = Encoding.UTF8.GetBytes(""); - foreach (DomainObjectDTO dto in repoDTO.AllInstancesWithSubclasses("StTxtPara")) + foreach (DomainObjectXMLDTO dto in repoDTO.AllInstancesWithSubclasses("StTxtPara")) { if (dto.XmlBytes.IndexOfSubArray(rgbStyleRules) <= 0) continue; diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000019Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000019Tests.cs index 8c930bd6..d13c001e 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000019Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000019Tests.cs @@ -107,12 +107,12 @@ public void DataMigration7000019Test() Assert.That(specialNode.Element(palaso + "languageName").Attribute("value").Value, Is.EqualTo("Kalaba")); Assert.That(specialNode.Element(palaso + "abbreviation").Attribute("value").Value, Is.EqualTo("KalIPA")); - DomainObjectDTO importSourceDto = dtoRepos.AllInstancesWithSubclasses("ScrImportSource").First(); + DomainObjectXMLDTO 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(dto => dto.Guid.Equals("F9FF6785-8BBF-40b6-9F80-CBB618F9ABD4", StringComparison.OrdinalIgnoreCase)); + DomainObjectXMLDTO mappingDto = dtoRepos.AllInstancesWithSubclasses("ScrMarkerMapping").First(dto => dto.Guid.Equals("F9FF6785-8BBF-40b6-9F80-CBB618F9ABD4", StringComparison.OrdinalIgnoreCase)); XElement mappingElem = XElement.Parse(mappingDto.Xml); Assert.AreEqual("fr-fonipa-x-etic", (string)mappingElem.Element("WritingSystem").Element("Uni")); Assert.IsNull(mappingElem.Element("ICULocale")); @@ -127,7 +127,7 @@ public void DataMigration7000019Test() Assert.AreEqual("sv-fonipa-x-etic-MINE", (string)mappingElem.Element("WritingSystem").Element("Uni")); Assert.IsNull(mappingElem.Element("ICULocale")); - DomainObjectDTO styleDto = dtoRepos.AllInstancesWithSubclasses("StStyle").First(); + DomainObjectXMLDTO styleDto = dtoRepos.AllInstancesWithSubclasses("StStyle").First(); XElement styleElem = XElement.Parse(styleDto.Xml); Assert.AreEqual("", (string)styleElem.Element("Rules").Element("Prop").Attribute("fontFamily")); } diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000027Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000027Tests.cs index ad4a4958..ce4a3532 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000027Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000027Tests.cs @@ -24,7 +24,7 @@ public sealed class DataMigrationTests7000027 : DataMigrationTestsBase [Test] public void DataMigration7000027Test() { - var dtos = new HashSet(); + var dtos = new HashSet(); var sb = new StringBuilder(); // 1. Add barebones LP. sb.Append(""); @@ -36,16 +36,16 @@ public void DataMigration7000027Test() sb.Append(""); sb.Append(""); sb.Append(""); - var lpDto = new DomainObjectDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", + var lpDto = new DomainObjectXMLDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", "LangProject", sb.ToString()); dtos.Add(lpDto); // Add text dto. - var txtDto = new DomainObjectDTO(lpTextsGuids.textGuid.ToString(), "StText", + var txtDto = new DomainObjectXMLDTO(lpTextsGuids.textGuid.ToString(), "StText", lpTextsGuids.textXml); dtos.Add(txtDto); // Add text para dto. - var txtParaDto = new DomainObjectDTO(lpTextsGuids.paraGuid.ToString(), "ScrTxtPara", + var txtParaDto = new DomainObjectXMLDTO(lpTextsGuids.paraGuid.ToString(), "ScrTxtPara", lpTextsGuids.paraXml); dtos.Add(txtParaDto); @@ -56,7 +56,7 @@ public void DataMigration7000027Test() sb.Append(""); sb.Append(""); sb.Append(""); - var scrDto = new DomainObjectDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", "Scripture", + var scrDto = new DomainObjectXMLDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", "Scripture", sb.ToString()); dtos.Add(scrDto); @@ -78,24 +78,24 @@ public void DataMigration7000027Test() sb.Append(""); sb.Append(""); sb.Append(""); - var bookDto = new DomainObjectDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", "ScrBook", sb.ToString()); + var bookDto = new DomainObjectXMLDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", "ScrBook", sb.ToString()); dtos.Add(bookDto); // Add title - var titleDto = new DomainObjectDTO(titleTextGuids.textGuid.ToString(), "StText", + var titleDto = new DomainObjectXMLDTO(titleTextGuids.textGuid.ToString(), "StText", titleTextGuids.textXml); dtos.Add(titleDto); // Title para - var titleParaDto = new DomainObjectDTO(titleTextGuids.paraGuid.ToString(), "ScrTxtPara", + var titleParaDto = new DomainObjectXMLDTO(titleTextGuids.paraGuid.ToString(), "ScrTxtPara", titleTextGuids.paraXml); dtos.Add(titleParaDto); // Add footnote - var footnoteDto = new DomainObjectDTO(footnoteGuids.textGuid.ToString(), "ScrFootnote", + var footnoteDto = new DomainObjectXMLDTO(footnoteGuids.textGuid.ToString(), "ScrFootnote", footnoteGuids.textXml); dtos.Add(footnoteDto); // Footnote para - var footnoteParaDto = new DomainObjectDTO(footnoteGuids.paraGuid.ToString(), "ScrTxtPara", + var footnoteParaDto = new DomainObjectXMLDTO(footnoteGuids.paraGuid.ToString(), "ScrTxtPara", footnoteGuids.paraXml); dtos.Add(footnoteParaDto); @@ -112,25 +112,25 @@ public void DataMigration7000027Test() sb.Append(""); sb.Append(""); sb.Append(""); - var sectionDto = new DomainObjectDTO("834e1bf8-3a25-47d6-9f92-806b38b5f815", "ScrSection", + var sectionDto = new DomainObjectXMLDTO("834e1bf8-3a25-47d6-9f92-806b38b5f815", "ScrSection", sb.ToString()); dtos.Add(sectionDto); // Add the contents - var contentsDto = new DomainObjectDTO(contentsTextGuids.textGuid.ToString(), "StText", + var contentsDto = new DomainObjectXMLDTO(contentsTextGuids.textGuid.ToString(), "StText", contentsTextGuids.textXml); dtos.Add(contentsDto); // Contents para - var contentsParaDto = new DomainObjectDTO(contentsTextGuids.paraGuid.ToString(), "ScrTxtPara", + var contentsParaDto = new DomainObjectXMLDTO(contentsTextGuids.paraGuid.ToString(), "ScrTxtPara", contentsTextGuids.paraXml); dtos.Add(contentsParaDto); // Add the heading to the xml - var headingDto = new DomainObjectDTO(headingTextGuids.textGuid.ToString(), "StText", + var headingDto = new DomainObjectXMLDTO(headingTextGuids.textGuid.ToString(), "StText", headingTextGuids.textXml); dtos.Add(headingDto); // heading para - var headingParaDto = new DomainObjectDTO(headingTextGuids.paraGuid.ToString(), "ScrTxtPara", + var headingParaDto = new DomainObjectXMLDTO(headingTextGuids.paraGuid.ToString(), "ScrTxtPara", headingTextGuids.paraXml); dtos.Add(headingParaDto); @@ -155,7 +155,7 @@ public void DataMigration7000027Test() Assert.AreEqual(7000027, dtoRepos.CurrentModelVersion, "Wrong updated version."); // Check that the ParaContainingOrc property in footnotes is set - DomainObjectDTO footnoteDTO = dtoRepos.GetDTO(footnoteGuids.textGuid.ToString()); + DomainObjectXMLDTO footnoteDTO = dtoRepos.GetDTO(footnoteGuids.textGuid.ToString()); XElement footnote = XElement.Parse(footnoteDTO.Xml); XElement paraContainingOrc = footnote.Element("ParaContainingOrc"); Assert.IsNotNull(paraContainingOrc); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000029Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000029Tests.cs index 0c5fc2be..3f9030c9 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000029Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000029Tests.cs @@ -122,7 +122,7 @@ public void DataMigration7000029Test() /// /// This should be a CmFile object. /// - private string GetCmFilePath(DomainObjectDTO fileDto) + private string GetCmFilePath(DomainObjectXMLDTO fileDto) { XElement cmFileXML = XElement.Parse(fileDto.Xml); var filePathFromCmFile = cmFileXML.XPathSelectElement("InternalPath").XPathSelectElement("Uni").Value; diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000030Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000030Tests.cs index c62bdad8..0ce31df2 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000030Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000030Tests.cs @@ -190,7 +190,7 @@ private void CheckCmFoldersAndCountsAfterMigration(Dictionary CmFolderDtos, Dictionary> CmFolders) + private void GetCmFolderNamesAndObjsurs(IEnumerable CmFolderDtos, Dictionary> CmFolders) { foreach (var folderDto in CmFolderDtos) { @@ -300,14 +300,14 @@ private void CheckCmFilePathsBeforeMigration(List filesPaths) Assert.That(filesPaths.ElementAt(6), Is.EqualTo(@"C:\FwWW\DistFiles\AudioVisual\NotInLinkedFilesPath.WMV")); } - private string GetCmFilePath(DomainObjectDTO fileDto) + private string GetCmFilePath(DomainObjectXMLDTO fileDto) { XElement cmFileXML = XElement.Parse(fileDto.Xml); var filePathMoreDirect = cmFileXML.XPathSelectElement("InternalPath").XPathSelectElement("Uni").Value; return filePathMoreDirect; } - private string GetCmFileGuid(DomainObjectDTO fileDto) + private string GetCmFileGuid(DomainObjectXMLDTO fileDto) { XElement cmFileXML = XElement.Parse(fileDto.Xml); var cmFileGuid = cmFileXML.Attribute("guid").Value; diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000035Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000035Tests.cs index fdf7fe32..7fb39b13 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000035Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000035Tests.cs @@ -25,7 +25,7 @@ public sealed class DataMigrationTests7000035 : DataMigrationTestsBase [Test] public void DataMigration7000035Test() { - var dtos = new HashSet(); + var dtos = new HashSet(); var sb = new StringBuilder(); // 1. Add barebones LP. sb.Append(""); @@ -37,16 +37,16 @@ public void DataMigration7000035Test() sb.Append(""); sb.Append(""); sb.Append(""); - var lpDto = new DomainObjectDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", + var lpDto = new DomainObjectXMLDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", "LangProject", sb.ToString()); dtos.Add(lpDto); // Add text dto. - var txtDto = new DomainObjectDTO(lpTextsGuids.textGuid.ToString(), "StText", + var txtDto = new DomainObjectXMLDTO(lpTextsGuids.textGuid.ToString(), "StText", lpTextsGuids.textXml); dtos.Add(txtDto); // Add text para dto. - var txtParaDto = new DomainObjectDTO(lpTextsGuids.paraGuid.ToString(), "ScrTxtPara", + var txtParaDto = new DomainObjectXMLDTO(lpTextsGuids.paraGuid.ToString(), "ScrTxtPara", lpTextsGuids.paraXml); dtos.Add(txtParaDto); @@ -57,7 +57,7 @@ public void DataMigration7000035Test() sb.Append(""); sb.Append(""); sb.Append(""); - var scrDto = new DomainObjectDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", "Scripture", + var scrDto = new DomainObjectXMLDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", "Scripture", sb.ToString()); dtos.Add(scrDto); @@ -80,24 +80,24 @@ public void DataMigration7000035Test() sb.Append(""); sb.Append(""); sb.Append(""); - var bookDto = new DomainObjectDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", "ScrBook", sb.ToString()); + var bookDto = new DomainObjectXMLDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", "ScrBook", sb.ToString()); dtos.Add(bookDto); // Add title - var titleDto = new DomainObjectDTO(titleTextGuids.textGuid.ToString(), "StText", + var titleDto = new DomainObjectXMLDTO(titleTextGuids.textGuid.ToString(), "StText", titleTextGuids.textXml); dtos.Add(titleDto); // Title para - var titleParaDto = new DomainObjectDTO(titleTextGuids.paraGuid.ToString(), "ScrTxtPara", + var titleParaDto = new DomainObjectXMLDTO(titleTextGuids.paraGuid.ToString(), "ScrTxtPara", titleTextGuids.paraXml); dtos.Add(titleParaDto); // Add footnote - var footnoteDto = new DomainObjectDTO(footnoteGuids.textGuid.ToString(), "ScrFootnote", + var footnoteDto = new DomainObjectXMLDTO(footnoteGuids.textGuid.ToString(), "ScrFootnote", footnoteGuids.textXml); dtos.Add(footnoteDto); // Footnote para - var footnoteParaDto = new DomainObjectDTO(footnoteGuids.paraGuid.ToString(), "ScrTxtPara", + var footnoteParaDto = new DomainObjectXMLDTO(footnoteGuids.paraGuid.ToString(), "ScrTxtPara", footnoteGuids.paraXml); dtos.Add(footnoteParaDto); @@ -115,29 +115,29 @@ public void DataMigration7000035Test() sb.Append(""); sb.Append(""); sb.Append(""); - var sectionDto = new DomainObjectDTO("834e1bf8-3a25-47d6-9f92-806b38b5f815", "ScrSection", + var sectionDto = new DomainObjectXMLDTO("834e1bf8-3a25-47d6-9f92-806b38b5f815", "ScrSection", sb.ToString()); dtos.Add(sectionDto); // Add the contents - var contentsDto = new DomainObjectDTO(contentsTextGuids.textGuid.ToString(), "StText", + var contentsDto = new DomainObjectXMLDTO(contentsTextGuids.textGuid.ToString(), "StText", contentsTextGuids.textXml); dtos.Add(contentsDto); // Contents para - var contentsParaDto = new DomainObjectDTO(contentsTextGuids.paraGuid.ToString(), "ScrTxtPara", + var contentsParaDto = new DomainObjectXMLDTO(contentsTextGuids.paraGuid.ToString(), "ScrTxtPara", contentsTextGuids.paraXml); dtos.Add(contentsParaDto); // BT of para - var btDto = new DomainObjectDTO(contentsTextGuids.btGuid.ToString(), "CmTranslation", + var btDto = new DomainObjectXMLDTO(contentsTextGuids.btGuid.ToString(), "CmTranslation", contentsTextGuids.btXml); dtos.Add(btDto); // Add the heading to the xml - var headingDto = new DomainObjectDTO(headingTextGuids.textGuid.ToString(), "StText", + var headingDto = new DomainObjectXMLDTO(headingTextGuids.textGuid.ToString(), "StText", headingTextGuids.textXml); dtos.Add(headingDto); // heading para - var headingParaDto = new DomainObjectDTO(headingTextGuids.paraGuid.ToString(), "ScrTxtPara", + var headingParaDto = new DomainObjectXMLDTO(headingTextGuids.paraGuid.ToString(), "ScrTxtPara", headingTextGuids.paraXml); dtos.Add(headingParaDto); @@ -162,7 +162,7 @@ public void DataMigration7000035Test() Assert.AreEqual(7000035, dtoRepos.CurrentModelVersion, "Wrong updated version."); // Check that the link to the footnote has been changed to an owniing link - DomainObjectDTO paraDTO = dtoRepos.GetDTO(contentsTextGuids.paraGuid.ToString()); + DomainObjectXMLDTO paraDTO = dtoRepos.GetDTO(contentsTextGuids.paraGuid.ToString()); XElement para = XElement.Parse(paraDTO.Xml); XElement contents = para.Element("Contents"); XElement str = contents.Element("Str"); @@ -172,7 +172,7 @@ public void DataMigration7000035Test() Assert.IsNotNull(linkAttr); Assert.AreEqual(footnoteGuids.textGuid.ToString(), linkAttr.Value); Assert.AreEqual(contentsTextGuids.btGuid.ToString(), para.Element("Translations").Element("objsur").Attribute("guid").Value); - DomainObjectDTO btDTO = dtoRepos.GetDTO(contentsTextGuids.btGuid.ToString()); + DomainObjectXMLDTO btDTO = dtoRepos.GetDTO(contentsTextGuids.btGuid.ToString()); XElement bt = XElement.Parse(btDTO.Xml); XElement btStr = bt.Element("Translation").Element("AStr"); XElement btRun = btStr.Element("Run"); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000036Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000036Tests.cs index b4eff86a..4057c78a 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000036Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000036Tests.cs @@ -27,7 +27,7 @@ public sealed class DataMigrationTests7000036 : DataMigrationTestsBase [Test] public void DataMigration7000036Test() { - var dtos = new HashSet(); + var dtos = new HashSet(); var sb = new StringBuilder(); // 1. Add barebones LP. sb.Append(""); @@ -39,16 +39,16 @@ public void DataMigration7000036Test() sb.Append(""); sb.Append(""); sb.Append(""); - var lpDto = new DomainObjectDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", + var lpDto = new DomainObjectXMLDTO("9719A466-2240-4DEA-9722-9FE0746A30A6", "LangProject", sb.ToString()); dtos.Add(lpDto); // Add text dto. - var txtDto = new DomainObjectDTO(lpTextsGuids.textGuid.ToString(), "StText", + var txtDto = new DomainObjectXMLDTO(lpTextsGuids.textGuid.ToString(), "StText", lpTextsGuids.textXml); dtos.Add(txtDto); // Add text para dto. - var txtParaDto = new DomainObjectDTO(lpTextsGuids.paraGuid.ToString(), "ScrTxtPara", + var txtParaDto = new DomainObjectXMLDTO(lpTextsGuids.paraGuid.ToString(), "ScrTxtPara", lpTextsGuids.paraXml); dtos.Add(txtParaDto); @@ -59,7 +59,7 @@ public void DataMigration7000036Test() sb.Append(""); sb.Append(""); sb.Append(""); - var scrDto = new DomainObjectDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", "Scripture", + var scrDto = new DomainObjectXMLDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", "Scripture", sb.ToString()); dtos.Add(scrDto); @@ -82,24 +82,24 @@ public void DataMigration7000036Test() sb.Append(""); sb.Append(""); sb.Append(""); - var bookDto = new DomainObjectDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", "ScrBook", sb.ToString()); + var bookDto = new DomainObjectXMLDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", "ScrBook", sb.ToString()); dtos.Add(bookDto); // Add title - var titleDto = new DomainObjectDTO(titleTextGuids.textGuid.ToString(), "StText", + var titleDto = new DomainObjectXMLDTO(titleTextGuids.textGuid.ToString(), "StText", titleTextGuids.textXml); dtos.Add(titleDto); // Title para - var titleParaDto = new DomainObjectDTO(titleTextGuids.paraGuid.ToString(), "ScrTxtPara", + var titleParaDto = new DomainObjectXMLDTO(titleTextGuids.paraGuid.ToString(), "ScrTxtPara", titleTextGuids.paraXml); dtos.Add(titleParaDto); // Add footnote - var footnoteDto = new DomainObjectDTO(footnoteGuids.textGuid.ToString(), "ScrFootnote", + var footnoteDto = new DomainObjectXMLDTO(footnoteGuids.textGuid.ToString(), "ScrFootnote", footnoteGuids.textXml); dtos.Add(footnoteDto); // Footnote para - var footnoteParaDto = new DomainObjectDTO(footnoteGuids.paraGuid.ToString(), "ScrTxtPara", + var footnoteParaDto = new DomainObjectXMLDTO(footnoteGuids.paraGuid.ToString(), "ScrTxtPara", footnoteGuids.paraXml); dtos.Add(footnoteParaDto); @@ -117,7 +117,7 @@ public void DataMigration7000036Test() sb.Append(""); sb.Append(""); sb.Append(""); - var sectionDto = new DomainObjectDTO("834e1bf8-3a25-47d6-9f92-806b38b5f815", "ScrSection", + var sectionDto = new DomainObjectXMLDTO("834e1bf8-3a25-47d6-9f92-806b38b5f815", "ScrSection", sb.ToString()); dtos.Add(sectionDto); @@ -126,29 +126,29 @@ public void DataMigration7000036Test() sb.Append(""); sb.Append(""); sb.Append(""); - var journalTextDto = new DomainObjectDTO("c1ecd177-e382-11de-8a39-0800200c9a66", "StJounalText", + var journalTextDto = new DomainObjectXMLDTO("c1ecd177-e382-11de-8a39-0800200c9a66", "StJounalText", sb.ToString()); dtos.Add(journalTextDto); // Add the contents - var contentsDto = new DomainObjectDTO(contentsTextGuids.textGuid.ToString(), "StText", + var contentsDto = new DomainObjectXMLDTO(contentsTextGuids.textGuid.ToString(), "StText", contentsTextGuids.textXml); dtos.Add(contentsDto); // Contents para - var contentsParaDto = new DomainObjectDTO(contentsTextGuids.paraGuid.ToString(), "ScrTxtPara", + var contentsParaDto = new DomainObjectXMLDTO(contentsTextGuids.paraGuid.ToString(), "ScrTxtPara", contentsTextGuids.paraXml); dtos.Add(contentsParaDto); // BT of para - var btDto = new DomainObjectDTO(contentsTextGuids.btGuid.ToString(), "CmTranslation", + var btDto = new DomainObjectXMLDTO(contentsTextGuids.btGuid.ToString(), "CmTranslation", contentsTextGuids.btXml); dtos.Add(btDto); // Add the heading to the xml - var headingDto = new DomainObjectDTO(headingTextGuids.textGuid.ToString(), "StText", + var headingDto = new DomainObjectXMLDTO(headingTextGuids.textGuid.ToString(), "StText", headingTextGuids.textXml); dtos.Add(headingDto); // heading para - var headingParaDto = new DomainObjectDTO(headingTextGuids.paraGuid.ToString(), "ScrTxtPara", + var headingParaDto = new DomainObjectXMLDTO(headingTextGuids.paraGuid.ToString(), "ScrTxtPara", headingTextGuids.paraXml); dtos.Add(headingParaDto); @@ -176,7 +176,7 @@ public void DataMigration7000036Test() Assert.AreEqual(7000036, dtoRepos.CurrentModelVersion, "Wrong updated version."); int cJournalTexts = 0; - foreach (DomainObjectDTO stTextDTO in dtoRepos.AllInstancesWithSubclasses("StText")) + foreach (DomainObjectXMLDTO stTextDTO in dtoRepos.AllInstancesWithSubclasses("StText")) { XElement stText = XElement.Parse(stTextDTO.Xml); Assert.AreEqual(1, stText.Elements("DateModified").Count()); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000041Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000041Tests.cs index 12b2d9f0..5d7ca8ba 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000041Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000041Tests.cs @@ -43,7 +43,7 @@ public void DataMigration7000041Test() TryThisProject(dtos, mockMDC, 1); // no Publications posibility list } - private void TryThisProject(HashSet dtos, MockMDCForDataMigration mockMDC, int numOfPubs) + private void TryThisProject(HashSet dtos, MockMDCForDataMigration mockMDC, int numOfPubs) { IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000040, dtos, mockMDC, @"C:\Path\Not\Used", TestDirectoryFinder.LcmDirectories); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000042Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000042Tests.cs index 5ce61ad4..f57ab3f6 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000042Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000042Tests.cs @@ -127,7 +127,7 @@ public void DataMigration7000042TestE() VerifyMigration(dtos); } - private void VerifyMigration(HashSet dtos) + private void VerifyMigration(HashSet dtos) { // Create all the Mock classes for the classes in my test data. var mockMDC = new MockMDCForDataMigration(); @@ -193,14 +193,14 @@ private void VerifyTypeLists(IDomainObjectDTORepository repoDto) var xaGuid = objsur.Attribute("guid"); Assert.IsNotNull(xaGuid, "objsur elements should always have a guid attribute."); var guid = xaGuid.Value; - DomainObjectDTO dtoPoss; + DomainObjectXMLDTO dtoPoss; Assert.IsTrue(repoDto.TryGetValue(guid, out dtoPoss), "Possibility Lists should point to valid objects."); VerifySubpossibilities(repoDto, dtoPoss); } } } - private void VerifySubpossibilities(IDomainObjectDTORepository repoDto, DomainObjectDTO dtoPoss) + private void VerifySubpossibilities(IDomainObjectDTORepository repoDto, DomainObjectXMLDTO dtoPoss) { var xePoss = XElement.Parse(dtoPoss.Xml); foreach (var objsur in xePoss.XPathSelectElements("SubPossibilities/objsur")) @@ -208,7 +208,7 @@ private void VerifySubpossibilities(IDomainObjectDTORepository repoDto, DomainOb var xaGuid = objsur.Attribute("guid"); Assert.IsNotNull(xaGuid, "objsur elements should always have a guid attribute."); var guid = xaGuid.Value; - DomainObjectDTO dtoSub; + DomainObjectXMLDTO dtoSub; Assert.IsTrue(repoDto.TryGetValue(guid, out dtoSub), "SubPossibility Lists should point to valid objects."); VerifySubpossibilities(repoDto, dtoSub); } @@ -227,7 +227,7 @@ private void VerifyLexEntryRefs(IDomainObjectDTORepository repoDto) var xaGuid = objsur.Attribute("guid"); Assert.IsNotNull(xaGuid, "objsur elements should always have a guid attribute."); var guid = xaGuid.Value; - DomainObjectDTO dtoType; + DomainObjectXMLDTO dtoType; Assert.IsTrue(repoDto.TryGetValue(guid, out dtoType), "LexEntryRef.ComplexEntryTypes should point to valid objects."); } foreach (var objsur in xeRef.XPathSelectElements("VariantEntryTypes/objsur")) @@ -235,7 +235,7 @@ private void VerifyLexEntryRefs(IDomainObjectDTORepository repoDto) var xaGuid = objsur.Attribute("guid"); Assert.IsNotNull(xaGuid, "objsur elements should always have a guid attribute."); var guid = xaGuid.Value; - DomainObjectDTO dtoType; + DomainObjectXMLDTO dtoType; Assert.IsTrue(repoDto.TryGetValue(guid, out dtoType), "LexEntryRef.VariantEntryTypes should point to valid objects."); } } @@ -246,7 +246,7 @@ private void VerifyLexEntryRefs(IDomainObjectDTORepository repoDto) /// private void VerifyEntryType(IDomainObjectDTORepository repoDto, string guid) { - DomainObjectDTO dto; + DomainObjectXMLDTO dto; Assert.IsTrue(repoDto.TryGetValue(guid, out dto), String.Format("Check for known guid of LexEntryType ({0}).", m_mapGuidToName[guid])); var xeType = XElement.Parse(dto.Xml); @@ -270,9 +270,9 @@ private static void VerifyEntryTypeOwners(IDomainObjectDTORepository repoDto) { foreach (var dto in repoDto.AllInstancesWithSubclasses("LexEntryType")) { - DomainObjectDTO dtoOwner; + DomainObjectXMLDTO dtoOwner; Assert.IsTrue(repoDto.TryGetOwner(dto.Guid, out dtoOwner), "All entry types should have valid owners!"); - DomainObjectDTO dtoOwnedOk = null; + DomainObjectXMLDTO dtoOwnedOk = null; foreach (var dtoT in repoDto.GetDirectlyOwnedDTOs(dtoOwner.Guid)) { if (dtoT == dto) diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000047Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000047Tests.cs index c43b984a..bbcfadea 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000047Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000047Tests.cs @@ -23,7 +23,7 @@ public sealed class DataMigrationTests7000047 : DataMigrationTestsBase [Test] public void DataMigration7000047Test() { - var dtos = new HashSet(); + var dtos = new HashSet(); var sb = new StringBuilder(); // Add Lang Project dto. const string sLpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; @@ -32,7 +32,7 @@ public void DataMigration7000047Test() sb.Append(""); sb.Append(""); sb.Append(""); - dtos.Add(new DomainObjectDTO(sLpGuid, "LangProject", sb.ToString())); + dtos.Add(new DomainObjectXMLDTO(sLpGuid, "LangProject", sb.ToString())); sb.Length = 0; // Add Key Terms List dto. @@ -42,7 +42,7 @@ public void DataMigration7000047Test() sb.Append(""); sb.Append(""); sb.Append(""); - dtos.Add(new DomainObjectDTO(LangProjectTags.kguidChkKeyTermsList.ToString(), "CmPossibilityList", sb.ToString())); + dtos.Add(new DomainObjectXMLDTO(LangProjectTags.kguidChkKeyTermsList.ToString(), "CmPossibilityList", sb.ToString())); sb.Length = 0; // Add Key Term 1 dto. @@ -52,7 +52,7 @@ public void DataMigration7000047Test() sb.Append(""); // valid rendering sb.Append(""); sb.Append(""); - DomainObjectDTO term1 = new DomainObjectDTO("22E6AF17-34BD-4433-BFDA-16C736E1F3F0", "ChkTerm", sb.ToString()); + DomainObjectXMLDTO term1 = new DomainObjectXMLDTO("22E6AF17-34BD-4433-BFDA-16C736E1F3F0", "ChkTerm", sb.ToString()); dtos.Add(term1); sb.Length = 0; @@ -63,12 +63,12 @@ public void DataMigration7000047Test() sb.Append(""); // bogus rendering 3 sb.Append(""); sb.Append(""); - DomainObjectDTO term2 = new DomainObjectDTO("B6C6C9B1-664A-4033-9937-DDA00C4000A7", "ChkTerm", sb.ToString()); + DomainObjectXMLDTO term2 = new DomainObjectXMLDTO("B6C6C9B1-664A-4033-9937-DDA00C4000A7", "ChkTerm", sb.ToString()); dtos.Add(term2); sb.Length = 0; // Add bogus ChkRendering 1 dto. - DomainObjectDTO bogusRendering1 = new DomainObjectDTO("27C32299-3B41-4FAD-A85C-F47657BCF95A", "ChkRendering", + DomainObjectXMLDTO bogusRendering1 = new DomainObjectXMLDTO("27C32299-3B41-4FAD-A85C-F47657BCF95A", "ChkRendering", ""); dtos.Add(bogusRendering1); @@ -78,17 +78,17 @@ public void DataMigration7000047Test() sb.Append(""); sb.Append(""); sb.Append(""); - DomainObjectDTO validRendering = new DomainObjectDTO("5E3D9C56-404C-44C5-B3CB-99BF390E322E", "ChkRendering", sb.ToString()); + DomainObjectXMLDTO validRendering = new DomainObjectXMLDTO("5E3D9C56-404C-44C5-B3CB-99BF390E322E", "ChkRendering", sb.ToString()); dtos.Add(validRendering); sb.Length = 0; // Add bogus ChkRendering 2 dto. - DomainObjectDTO bogusRendering2 = new DomainObjectDTO("5FB86AAE-5E05-4d57-92B8-FFD0B67545CA", "ChkRendering", + DomainObjectXMLDTO bogusRendering2 = new DomainObjectXMLDTO("5FB86AAE-5E05-4d57-92B8-FFD0B67545CA", "ChkRendering", ""); dtos.Add(bogusRendering2); // Add bogus ChkRendering 3 dto. - DomainObjectDTO bogusRendering3 = new DomainObjectDTO("B86AD2DF-98D0-4ec7-93DC-723D90A209EC", "ChkRendering", + DomainObjectXMLDTO bogusRendering3 = new DomainObjectXMLDTO("B86AD2DF-98D0-4ec7-93DC-723D90A209EC", "ChkRendering", ""); dtos.Add(bogusRendering3); @@ -98,7 +98,7 @@ public void DataMigration7000047Test() sb.Append("carro"); sb.Append(""); sb.Append(""); - DomainObjectDTO wordForm = new DomainObjectDTO("BD8B2BE2-BDC7-476a-A627-5B59480A6490", "WfiWordform", sb.ToString()); + DomainObjectXMLDTO wordForm = new DomainObjectXMLDTO("BD8B2BE2-BDC7-476a-A627-5B59480A6490", "WfiWordform", sb.ToString()); dtos.Add(wordForm); sb.Length = 0; diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000051Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000051Tests.cs index 5be96073..44d93eda 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000051Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000051Tests.cs @@ -25,7 +25,7 @@ public sealed class DataMigrationTests7000051 : DataMigrationTestsBase [Test] public void DataMigration7000051Test() { - var dtos = new HashSet(); + var dtos = new HashSet(); var sb = new StringBuilder(); // Add Lang Project dto. const string sLpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; @@ -35,12 +35,12 @@ public void DataMigration7000051Test() sb.AppendFormat("", afxCatGuid); sb.Append(""); sb.Append(""); - var oldDto = new DomainObjectDTO(sLpGuid, "LangProject", sb.ToString()); + var oldDto = new DomainObjectXMLDTO(sLpGuid, "LangProject", sb.ToString()); dtos.Add(oldDto); sb.Length = 0; sb.AppendFormat("", afxCatGuid, sLpGuid); - var afxCatDto = new DomainObjectDTO(afxCatGuid, "CmPossibilityList", sb.ToString()); + var afxCatDto = new DomainObjectXMLDTO(afxCatGuid, "CmPossibilityList", sb.ToString()); dtos.Add(afxCatDto); // Set up mock MDC. @@ -55,7 +55,7 @@ public void DataMigration7000051Test() Assert.AreEqual(7000051, dtoRepos.CurrentModelVersion, "Wrong updated version."); // Check that the old LP is not present. - DomainObjectDTO gonerDto; + DomainObjectXMLDTO gonerDto; Assert.IsFalse(dtoRepos.TryGetValue(sLpGuid, out gonerDto)); Assert.IsTrue(((DomainObjectDtoRepository)dtoRepos).Goners.Contains(oldDto)); var newDto = dtoRepos.AllInstancesSansSubclasses("LangProject").FirstOrDefault(); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000052Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000052Tests.cs index 1bef0e48..3f699c98 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000052Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000052Tests.cs @@ -25,7 +25,7 @@ public sealed class DataMigrationTests7000052 : DataMigrationTestsBase [Test] public void DataMigration7000052Test() { - var dtos = new HashSet(); + var dtos = new HashSet(); var sb = new StringBuilder(); // Add WfiMorphBundle that already has a form. const string sGuid_wmbWithForm = "00b35f9f-86ce-4f07-bde7-b65c28503641"; @@ -37,7 +37,7 @@ public void DataMigration7000052Test() sb.Append(""); sb.Append(""); sb.Append(""); - var dtoWithForm = new DomainObjectDTO(sGuid_wmbWithForm, "WfiMorphBundle", sb.ToString()); + var dtoWithForm = new DomainObjectXMLDTO(sGuid_wmbWithForm, "WfiMorphBundle", sb.ToString()); dtos.Add(dtoWithForm); sb.Length = 0; @@ -48,7 +48,7 @@ public void DataMigration7000052Test() sb.AppendFormat("{0}", "morphForm1"); sb.Append(""); sb.Append(""); - var dtoMoAffix = new DomainObjectDTO(sGuid_moAffixAllomorph, "MoAffixAllomorph", sb.ToString()); + var dtoMoAffix = new DomainObjectXMLDTO(sGuid_moAffixAllomorph, "MoAffixAllomorph", sb.ToString()); dtos.Add(dtoMoAffix); sb.Length = 0; @@ -63,7 +63,7 @@ public void DataMigration7000052Test() sb.AppendFormat("", sGuid_moAffixAllomorph); sb.Append(""); sb.Append(""); - var dtoNoForm = new DomainObjectDTO(sGuid_wmbNoForm, "WfiMorphBundle", sb.ToString()); + var dtoNoForm = new DomainObjectXMLDTO(sGuid_wmbNoForm, "WfiMorphBundle", sb.ToString()); dtos.Add(dtoNoForm); sb.Length = 0; @@ -80,7 +80,7 @@ public void DataMigration7000052Test() // check that MorphBundle with form still has its form. { - DomainObjectDTO dtoWithFormTest; + DomainObjectXMLDTO dtoWithFormTest; dtoRepos.TryGetValue(sGuid_wmbWithForm, out dtoWithFormTest); var eltWmbWithFormTest = XElement.Parse(dtoWithFormTest.Xml); var eltFormTest = eltWmbWithFormTest.Element("Form"); @@ -100,7 +100,7 @@ public void DataMigration7000052Test() // check that MorphBundle without form now has a new alternative forms, // identical to the Morph alternative Form. { - DomainObjectDTO dtoNewFormTest; + DomainObjectXMLDTO dtoNewFormTest; dtoRepos.TryGetValue(sGuid_wmbNoForm, out dtoNewFormTest); var eltWmbNewFormTest = XElement.Parse(dtoNewFormTest.Xml); var eltFormTest = eltWmbNewFormTest.Element("Form"); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000056Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000056Tests.cs index b84a4ac2..8b844193 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000056Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000056Tests.cs @@ -37,13 +37,13 @@ public void DataMigration7000056Test() // check that PhPhonData has the PhonRuleFeats possibility list { var dtosList = dtoRepos.AllInstancesSansSubclasses("PhPhonData"); - DomainObjectDTO dtoPhPhonDataTest = dtosList.First(); + DomainObjectXMLDTO dtoPhPhonDataTest = dtosList.First(); CheckPhPhonData(dtoPhPhonDataTest, dtoRepos); } // In the extremely unlikely event that there is no PhPhonData yet, check that we add it { - dtos = new HashSet(); + dtos = new HashSet(); var sb = new StringBuilder(); // Add WfiMorphBundle that already has a form. @@ -51,7 +51,7 @@ public void DataMigration7000056Test() sb.AppendFormat("", sGuid_wmbLangProj); sb.Append(""); - var dtoLangProj = new DomainObjectDTO(sGuid_wmbLangProj, "LangProj", sb.ToString()); + var dtoLangProj = new DomainObjectXMLDTO(sGuid_wmbLangProj, "LangProj", sb.ToString()); dtos.Add(dtoLangProj); sb.Length = 0; @@ -61,7 +61,7 @@ public void DataMigration7000056Test() Assert.AreEqual(7000056, dtoRepos.CurrentModelVersion, "Wrong updated version."); var dtosList = dtoRepos.AllInstancesSansSubclasses("LangProj"); - DomainObjectDTO dtoLangProjTest = dtosList.First(); + DomainObjectXMLDTO dtoLangProjTest = dtosList.First(); var eltWmbLangProjTest = XElement.Parse(dtoLangProjTest.Xml); // get phon rule feats var eltPhonologicalDataTest = eltWmbLangProjTest.Element("PhonologicalData"); @@ -71,7 +71,7 @@ public void DataMigration7000056Test() // get possibility list itself var guidPhPhonDataTest = eltObjsurTest.Attribute("guid").Value; Assert.IsNotNull(guidPhPhonDataTest); - DomainObjectDTO dtoPhPhonDataTest; + DomainObjectXMLDTO dtoPhPhonDataTest; dtoRepos.TryGetValue(guidPhPhonDataTest, out dtoPhPhonDataTest); Assert.IsNotNull(dtoPhPhonDataTest); CheckPhPhonData(dtoPhPhonDataTest, dtoRepos); @@ -79,7 +79,7 @@ public void DataMigration7000056Test() } } - private static void CheckPhPhonData(DomainObjectDTO dtoPhPhonDataTest, IDomainObjectDTORepository dtoRepos) + private static void CheckPhPhonData(DomainObjectXMLDTO dtoPhPhonDataTest, IDomainObjectDTORepository dtoRepos) { var eltWmbPhPhonDataTest = XElement.Parse(dtoPhPhonDataTest.Xml); // get phon rule feats @@ -90,7 +90,7 @@ private static void CheckPhPhonData(DomainObjectDTO dtoPhPhonDataTest, IDomainOb // get possibility list itself var guidPossibilityListTest = eltObjsurTest.Attribute("guid").Value; Assert.IsNotNull(guidPossibilityListTest); - DomainObjectDTO dtoCmPossiblityTest; + DomainObjectXMLDTO dtoCmPossiblityTest; dtoRepos.TryGetValue(guidPossibilityListTest, out dtoCmPossiblityTest); Assert.IsNotNull(dtoCmPossiblityTest); var eltWmbCmPossibilityListTest = XElement.Parse(dtoCmPossiblityTest.Xml); diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000060Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000060Tests.cs index ebbc1024..3b392088 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000060Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000060Tests.cs @@ -39,7 +39,7 @@ public void DataMigration7000060Test() File.WriteAllText(otherFile, "rubbish", Encoding.UTF8); var mockMDC = new MockMDCForDataMigration(); // no classes to migrate here - var dtos = new HashSet(); // no objects to migrate + var dtos = new HashSet(); // no objects to migrate IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000059, dtos, mockMDC, projectFolder, TestDirectoryFinder.LcmDirectories); // Do the migration. diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000061Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000061Tests.cs index 6f6a5fd5..2400b2a9 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000061Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000061Tests.cs @@ -52,7 +52,7 @@ public void DataMigration7000061Test() // Check Step 1.A. // - DomainObjectDTO dto; + DomainObjectXMLDTO dto; dtoRepos.TryGetValue("bb68f6bc-f233-4cd4-8894-c33b4b4c43ba", out dto); Assert.IsNull(dto); // Step 1.A. Control diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000062Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000062Tests.cs index 145bdfea..b296553f 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000062Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000062Tests.cs @@ -36,7 +36,7 @@ public void DataMigration7000062Test() // Check Step 1.A. // - DomainObjectDTO dto; + DomainObjectXMLDTO dto; dtoRepos.TryGetValue("bb68f6bc-f233-4cd4-8894-c33b4b4c43ba", out dto); Assert.IsNull(dto); // Step 1.A. Control diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000071Tests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000071Tests.cs index 9214a0d2..92b35ce8 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000071Tests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigration7000071Tests.cs @@ -83,7 +83,7 @@ public void DataMigration7000071Test() File.Copy(Path.Combine(TestDirectoryFinder.TestDataDirectory, "am-Ethi-fonipa_7000070.ldml"), xkalFonipaPath); File.SetAttributes(xkalFonipaPath, FileAttributes.Normal); // don't want to copy readonly property. - HashSet dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000071.xml"); + HashSet dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000071.xml"); // Create all the Mock classes for the classes in my test data. var mockMdc = new MockMDCForDataMigration(); mockMdc.AddClass(1, "CmObject", null, new List diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigrationBasicTests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigrationBasicTests.cs index 156d7c7e..1f800133 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigrationBasicTests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigrationBasicTests.cs @@ -36,7 +36,7 @@ public void DowngradeMigrationTest() { var mockMDC = new MockMDCForDataMigration(); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7100000, - new HashSet(), mockMDC, null, TestDirectoryFinder.LcmDirectories); + new HashSet(), mockMDC, null, TestDirectoryFinder.LcmDirectories); Assert.That(() => m_dataMigrationManager.PerformMigration(dtoRepos, 7000000, null), Throws.TypeOf()); } diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigrationTestServices.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigrationTestServices.cs index 82c758f0..c60d7ecd 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigrationTestServices.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/DataMigrationTestServices.cs @@ -15,9 +15,9 @@ namespace SIL.LCModel.DomainServices.DataMigration /// internal static class DataMigrationTestServices { - internal static void CheckDtoRemoved(IDomainObjectDTORepository dtoRepos, DomainObjectDTO goner) + internal static void CheckDtoRemoved(IDomainObjectDTORepository dtoRepos, DomainObjectXMLDTO goner) { - DomainObjectDTO dto; + DomainObjectXMLDTO dto; if (dtoRepos.TryGetValue(goner.Guid, out dto)) { Assert.Fail("Still has deleted (or zombie) DTO."); @@ -31,12 +31,12 @@ internal static void CheckDtoRemoved(IDomainObjectDTORepository dtoRepos, Domain /// It looks in the TestData directory for the specified project file. /// /// ------------------------------------------------------------------------------------ - internal static HashSet ParseProjectFile(string filename) + internal static HashSet ParseProjectFile(string filename) { var lpElement = XElement.Load(Path.Combine(TestDirectoryFinder.TestDataDirectory, filename)); - return new HashSet( + return new HashSet( from elem in lpElement.Elements("rt") - select new DomainObjectDTO(elem.Attribute("guid").Value, elem.Attribute("class").Value, + select new DomainObjectXMLDTO(elem.Attribute("guid").Value, elem.Attribute("class").Value, elem.ToString())); } } diff --git a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/IDomainObjectDTORepositoryTests.cs b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/IDomainObjectDTORepositoryTests.cs index 0aff2554..fea775bf 100644 --- a/tests/SIL.LCModel.Tests/DomainServices/DataMigration/IDomainObjectDTORepositoryTests.cs +++ b/tests/SIL.LCModel.Tests/DomainServices/DataMigration/IDomainObjectDTORepositoryTests.cs @@ -59,7 +59,7 @@ public void NulldtosParamTest() [Test] public void NullmdcParamTest() { - Assert.That(() => new DomainObjectDtoRepository(1, new HashSet(), null, null, TestDirectoryFinder.LcmDirectories), + Assert.That(() => new DomainObjectDtoRepository(1, new HashSet(), null, null, TestDirectoryFinder.LcmDirectories), Throws.TypeOf()); } @@ -73,7 +73,7 @@ public void NonExistantGuidTest() { IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository( 1, - new HashSet(), + new HashSet(), m_mdc, null, TestDirectoryFinder.LcmDirectories); Assert.That(() => dtoRepos.GetDTO(Guid.NewGuid().ToString()), @@ -88,7 +88,7 @@ public void NonExistantGuidTest() [Test] public void ExtantGuidFindsDTOTest() { - var dtos = new HashSet(); + var dtos = new HashSet(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; var lpDto = CreatoDTO(dtos, lpGuid, "LangProject", null); @@ -105,12 +105,12 @@ public void ExtantGuidFindsDTOTest() [Test] public void TryGetValueTests() { - var dtos = new HashSet(); + var dtos = new HashSet(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; CreatoDTO(dtos, lpGuid, "LangProject", null); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, TestDirectoryFinder.LcmDirectories); - DomainObjectDTO dto; + DomainObjectXMLDTO dto; var retval = dtoRepos.TryGetValue(Guid.NewGuid().ToString().ToLower(), out dto); Assert.IsNull(dto, "Oops.It does exist."); Assert.IsFalse(retval, "Reportedly, it does exist."); @@ -120,12 +120,12 @@ public void TryGetValueTests() Assert.IsTrue(retval, "Reportedly, it does not exist."); } - private static DomainObjectDTO CreatoDTO(ICollection dtos, string guid, string classname, string ownerGuid) + private static DomainObjectXMLDTO CreatoDTO(ICollection dtos, string guid, string classname, string ownerGuid) { var xml = ownerGuid == null ? string.Format("", classname, guid) : string.Format("", classname, guid, ownerGuid); - var dto = new DomainObjectDTO( + var dto = new DomainObjectXMLDTO( guid, classname, xml); @@ -142,14 +142,14 @@ private static DomainObjectDTO CreatoDTO(ICollection dtos, stri [Test] public void DtosByClassButNoSubclassesTest() { - var dtos = new HashSet(); + var dtos = new HashSet(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; CreatoDTO(dtos, lpGuid, "LangProject", null); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, TestDirectoryFinder.LcmDirectories); - var result = new List(dtoRepos.AllInstancesSansSubclasses("CmObject")); + var result = new List(dtoRepos.AllInstancesSansSubclasses("CmObject")); Assert.AreEqual(0, result.Count, "Wrong number of DTOs (expected 0)."); - result = new List(dtoRepos.AllInstancesSansSubclasses("LangProject")); + result = new List(dtoRepos.AllInstancesSansSubclasses("LangProject")); Assert.AreEqual(1, result.Count, "Wrong number of DTOs (expected 1)."); } @@ -161,14 +161,14 @@ public void DtosByClassButNoSubclassesTest() [Test] public void DtosByClassWithSubclassesTest() { - var dtos = new HashSet(); + var dtos = new HashSet(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; CreatoDTO(dtos, lpGuid, "LangProject", null); const string lexDbGuid = "6C84F84A-5B99-4CF5-A7D5-A308DDC604E0"; CreatoDTO(dtos, lexDbGuid, "LexDb", null); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, TestDirectoryFinder.LcmDirectories); - var result = new List(dtoRepos.AllInstancesWithSubclasses("CmObject")); + var result = new List(dtoRepos.AllInstancesWithSubclasses("CmObject")); Assert.AreEqual(2, result.Count, "Wrong number of DTOs (expected 2)."); } @@ -180,7 +180,7 @@ public void DtosByClassWithSubclassesTest() [Test] public void OwningDtoTest() { - var dtos = new HashSet(); + var dtos = new HashSet(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; var lpDto = CreatoDTO(dtos, lpGuid, "LangProject", null); @@ -202,7 +202,7 @@ public void OwningDtoTest() [Test] public void AddNewDtoTest() { - var dtos = new HashSet(); + var dtos = new HashSet(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; CreatoDTO(dtos, lpGuid, "LangProject", null); @@ -212,7 +212,7 @@ public void AddNewDtoTest() // Create new DTO and add it. var newGuid = Guid.NewGuid(); - var newby = new DomainObjectDTO(newGuid.ToString(), "LexEntry", ""); + var newby = new DomainObjectXMLDTO(newGuid.ToString(), "LexEntry", ""); dtoRepos.Add(newby); Assert.AreSame(newby, dtoRepos.GetDTO(newGuid.ToString()), "Wrong new DTO from guid."); Assert.AreSame(newby, dtoRepos.AllInstancesSansSubclasses("LexEntry").First(), "Wrong new DTO from class."); @@ -227,7 +227,7 @@ public void AddNewDtoTest() [Test] public void RemoveDtoTest() { - var dtos = new HashSet(); + var dtos = new HashSet(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; var lpDto = CreatoDTO(dtos, lpGuid, "LangProject", null); @@ -248,7 +248,7 @@ public void RemoveDtoTest() [Test] public void UpdateDtoTest() { - var dtos = new HashSet(); + var dtos = new HashSet(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; var lpDto = CreatoDTO(dtos, lpGuid, "LangProject", null); @@ -266,14 +266,14 @@ public void UpdateDtoTest() [Test] public void UpdateUnknownDtoTest() { - var dtos = new HashSet(); + var dtos = new HashSet(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; CreatoDTO(dtos, lpGuid, "LangProject", null); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, TestDirectoryFinder.LcmDirectories); var newGuid = Guid.NewGuid(); - var newby = new DomainObjectDTO(newGuid.ToString(), "LexEntry", ""); + var newby = new DomainObjectXMLDTO(newGuid.ToString(), "LexEntry", ""); Assert.That(() => dtoRepos.Update(newby), Throws.TypeOf()); } }