/// ------------------------------------------------------------------------------------ /// <summary> /// Changes all StFootnotes to ScrFootnotes /// </summary> /// <param name="domainObjectDtoRepository"> /// Repository of all CmObject DTOs available for one migration step. /// </param> /// <remarks> /// The method must add/remove/update the DTOs to the repository, /// as it adds/removes objects as part of it work. /// /// Implementors of this interface should ensure the Repository's /// starting model version number is correct for the step. /// Implementors must also increment the Repository's model version number /// at the end of its migration work. /// /// The method also should normally modify the xml string(s) /// of relevant DTOs, since that string will be used by the main /// data migration calling client (ie. BEP). /// </remarks> /// ------------------------------------------------------------------------------------ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository) { DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000002); var footnotesToChangeClasses = new List <DomainObjectDTO>(); foreach (var footnote in domainObjectDtoRepository.AllInstancesSansSubclasses("StFootnote")) { XElement footnoteEl = XElement.Parse(footnote.Xml); footnoteEl.Attribute("class").Value = "ScrFootnote"; // Add the empty ScrFootnote element to the ScrFootnote footnoteEl.Add(new XElement("ScrFootnote")); // Update the object XML footnote.Xml = footnoteEl.ToString(); footnote.Classname = "ScrFootnote"; footnotesToChangeClasses.Add(footnote); } // Udate the repository var startingStructure = new ClassStructureInfo("StText", "StFootnote"); var endingStructure = new ClassStructureInfo("StFootnote", "ScrFootnote"); foreach (var changedPara in footnotesToChangeClasses) { domainObjectDtoRepository.Update(changedPara, startingStructure, endingStructure); } DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Changes Chart 'missing' markers from invalid ConstChartWordGroup references to /// ConstChartTag objects with null Tag property. /// </summary> /// <param name="domainObjectDtoRepository">Repository of all CmObject DTOs available for /// one migration step.</param> /// ------------------------------------------------------------------------------------ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository) { DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000012); // 1) Select the ConstChartWordGroup class objects. // 2) Convert any with null BeginSegment reference to ConstChartTag objects with null Tag reference. var objsToChangeClasses = new List <DomainObjectDTO>(); foreach (var cellPartDto in domainObjectDtoRepository.AllInstancesSansSubclasses("ConstChartWordGroup")) { var rtElement = XElement.Parse(cellPartDto.Xml); // Only migrate the ones that have no BeginSegment var wordGrp = rtElement.Element("ConstChartWordGroup"); if (wordGrp.Element("BeginSegment") != null) { continue; // Don't migrate this one, it has a BeginSegment reference! } // change its class value rtElement.Attribute("class").Value = "ConstChartTag"; // Add the empty ConstChartTag element rtElement.Add(new XElement("ConstChartTag")); // Remove the old WordGroup element RemoveField(cellPartDto, rtElement, "ConstChartWordGroup"); // Update the object XML cellPartDto.Xml = rtElement.ToString(); cellPartDto.Classname = "ConstChartTag"; objsToChangeClasses.Add(cellPartDto); } // Update the repository var startingStructure = new ClassStructureInfo("ConstituentChartCellPart", "ConstChartWordGroup"); var endingStructure = new ClassStructureInfo("ConstituentChartCellPart", "ConstChartTag"); foreach (var changedCellPart in objsToChangeClasses) { domainObjectDtoRepository.Update(changedCellPart, startingStructure, endingStructure); } DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository); }
/// <summary> /// Let the Repository know that <paramref name="dirtball"/> has been modified, /// by at least a change of class. /// </summary> /// <param name="dirtball">The object that was modified.</param> /// <param name="oldClassStructure">Previous superclass structure</param> /// <param name="newClassStructure">New class structure</param> /// <remarks> /// The underlying CmObject won't be changed, until the end of the current /// migration is finished. /// </remarks> public void Update(DomainObjectDTO dirtball, ClassStructureInfo oldClassStructure, ClassStructureInfo newClassStructure) { if (oldClassStructure == null) { throw new ArgumentNullException("oldClassStructure"); } if (newClassStructure == null) { throw new ArgumentNullException("newClassStructure"); } if (dirtball.Classname != newClassStructure.m_className) { throw new ArgumentException("Mis-match between class names in 'dirtball' and 'newClassStructure'"); } AsInterface.Update(dirtball); RemoveFromClassList(dirtball, oldClassStructure.m_className); AddToClassList(dirtball); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Changes all StTxtParas that are owned by Scripture to be ScrTxtParas /// </summary> /// <param name="domainObjectDtoRepository"> /// Repository of all CmObject DTOs available for one migration step. /// </param> /// <remarks> /// The method must add/remove/update the DTOs to the repository, /// as it adds/removes objects as part of it work. /// /// Implementors of this interface should ensure the Repository's /// starting model version number is correct for the step. /// Implementors must also increment the Repository's model version number /// at the end of its migration work. /// /// The method also should normally modify the xml string(s) /// of relevant DTOs, since that string will be used by the main /// data migration calling client (ie. BEP). /// </remarks> /// ------------------------------------------------------------------------------------ public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository) { DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000001); var parasToChangeClasses = new List <DomainObjectDTO>(); foreach (var stTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("StTxtPara")) { var paraOwner = domainObjectDtoRepository.GetOwningDTO(stTxtPara); if (paraOwner.Classname != "StText" && paraOwner.Classname != "StFootnote") { continue; // Paragraph is not owned by an StText or StFootnote (shouldn't ever happen) } var textOwner = domainObjectDtoRepository.GetOwningDTO(paraOwner); if (textOwner.Classname != "ScrBook" && textOwner.Classname != "ScrSection") { continue; // StText is not part of Scripture, don't change. } // Its one of the paragraphs that we care about. We just need to change the // class in the xml to be a ScrTxtPara and change the objectsByClass map. DataMigrationServices.ChangeToSubClass(stTxtPara, "StTxtPara", "ScrTxtPara"); parasToChangeClasses.Add(stTxtPara); } // Udate the repository var startingStructure = new ClassStructureInfo("StPara", "StTxtPara"); var endingStructure = new ClassStructureInfo("StTxtPara", "ScrTxtPara"); foreach (var changedPara in parasToChangeClasses) { domainObjectDtoRepository.Update(changedPara, startingStructure, endingStructure); } DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository); }