Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets the Name property for several CmPossibilityLists to match what is displayed
        /// in the Lists area. Sets Name for en, es, fa, fr, id, pt, ru and zh_CN wss.
        /// </summary>
        /// <param name="dtoRepos">
        /// 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 dtoRepos)
        {
            DataMigrationServices.CheckVersionNumber(dtoRepos, 7000021);

            // We need 'LangProject' and its DsDiscourseData, LexDb and RnResearchNbk objects.
            var lpDto     = dtoRepos.AllInstancesSansSubclasses("LangProject").FirstOrDefault();
            var lpElement = lpDto == null ? null : XElement.Parse(lpDto.Xml);

            var discourseDataDto = dtoRepos.AllInstancesSansSubclasses("DsDiscourseData").FirstOrDefault();
            var dsDataElement    = discourseDataDto == null ? null : XElement.Parse(discourseDataDto.Xml);

            var lexDbDto     = dtoRepos.AllInstancesSansSubclasses("LexDb").FirstOrDefault();
            var lexDbElement = lexDbDto == null ? null : XElement.Parse(lexDbDto.Xml);

            var nbkDto     = dtoRepos.AllInstancesSansSubclasses("RnResearchNbk").FirstOrDefault();
            var nbkElement = nbkDto == null ? null : XElement.Parse(nbkDto.Xml);

            for (var i = 0; i < m_listNames.GetLength(0); i++)
            {
                var      owner = (ListOwner)Int32.Parse(m_listNames[i, 0]);
                XElement owningElem;
                switch (owner)
                {
                case ListOwner.Discourse:
                    owningElem = dsDataElement;
                    break;

                case ListOwner.LexDb:
                    owningElem = lexDbElement;
                    break;

                case ListOwner.RNbk:
                    owningElem = nbkElement;
                    break;

                default:
                    owningElem = lpElement;
                    break;
                }
                if (owningElem == null)
                {
                    continue;
                }
                var listDto = GetListDto(dtoRepos, owningElem, m_listNames[i, 1]);
                if (listDto == null || listDto.Xml == null)
                {
                    continue;
                }
                var listElement = XElement.Parse(listDto.Xml);
                var nameElem    = GetListNameElement(listElement) ?? MakeEmptyNameElementInList(listElement);
                for (var j = 2; j < m_listNames.GetLength(1); j++)
                {
                    AddReplaceLocalizedListName(nameElem, GetWsStrForColumn(j), i, j);
                }

                DataMigrationServices.UpdateDTO(dtoRepos, listDto, listElement.ToString());
            }

            DataMigrationServices.IncrementVersionNumber(dtoRepos);
        }
Ejemplo n.º 3
0
        public void PerformMigration(IDomainObjectDTORepository repoDto)
        {
            DataMigrationServices.CheckVersionNumber(repoDto, 7000019);

            var viewsToDelete = new List <DomainObjectDTO>();

            foreach (var dtoView in repoDto.AllInstancesSansSubclasses("UserView"))
            {
                var xeView = XElement.Parse(dtoView.Xml);
                var xeApp  = xeView.Element("App");
                if (xeApp == null)
                {
                    continue;
                }
                var val = xeApp.Attribute("val");
                if (val == null)
                {
                    continue;
                }
                var guidApp = new Guid(val.Value);
                if (guidApp == m_guidNotebook || guidApp == m_guidListEditor)
                {
                    viewsToDelete.Add(dtoView);
                }
            }
            foreach (var dto in viewsToDelete)
            {
                DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, dto, false);
            }
            viewsToDelete.Clear();

            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
Ejemplo n.º 4
0
        private static void ChangeMultiUnicodeElementToMultiString(IDomainObjectDTORepository repoDto, DomainObjectDTO dto,
                                                                   string xpathToMultiUnicodeElement)
        {
            const string auniXpath = "/AUni";
            var          changed   = false;
            var          dataElt   = XElement.Parse(dto.Xml);

            foreach (var elt in dataElt.XPathSelectElements(xpathToMultiUnicodeElement + auniXpath))
            {
                elt.Name = "AStr";
                var unicodeData = elt.Value;
                elt.Value = string.Empty;
                var wsAttr = elt.Attribute("ws");
                var runElt = new XElement("Run")
                {
                    Value = unicodeData
                };
                runElt.SetAttributeValue("ws", wsAttr.Value);
                elt.Add(runElt);
                changed = true;
            }
            if (changed)
            {
                DataMigrationServices.UpdateDTO(repoDto, dto, dataElt.ToString());
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Remove the owningFlid attribute from every "rt" element.
        /// </summary>
        /// <param name="domainObjectDtoRepository"></param>
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000008);

            foreach (var dto in domainObjectDtoRepository.AllInstancesWithValidClasses())
            {
                byte[] contents = dto.XmlBytes;
                int    index    = contents.IndexOfSubArray(owningFlidTag);
                if (index >= 0)
                {
                    contents = contents.ReplaceSubArray(index,
                                                        Array.IndexOf(contents, closeQuote, index + owningFlidTag.Length) - index + 1,
                                                        new byte[0]);
                }
                int index2 = contents.IndexOfSubArray(owningOrdTag);
                if (index2 >= 0)
                {
                    contents = contents.ReplaceSubArray(index2,
                                                        Array.IndexOf(contents, closeQuote, index2 + owningOrdTag.Length) - index2 + 1,
                                                        new byte[0]);
                }
                if (index >= 0 || index2 >= 0)
                {
                    DataMigrationServices.UpdateDTO(domainObjectDtoRepository, dto, contents);
                }
            }
            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 6
0
        internal static void AddRefType(XElement data, IDomainObjectDTORepository repoDto, DomainObjectDTO dto, string tagName, string guid, bool owned)
        {
            var varElementTag = data.Element(tagName);

            if (varElementTag == null)
            {
                var varTypeReference = new XElement(tagName);
                var typeReference    = new XElement("objsur");
                typeReference.SetAttributeValue("guid", guid);
                typeReference.SetAttributeValue("t", owned ? "o" : "r");
                varTypeReference.Add(typeReference);
                data.Add(varTypeReference);
                DataMigrationServices.UpdateDTO(repoDto, dto, data.ToString());
            }
            else
            {
                varElementTag = data.Element(tagName);
                var typeObject = new XElement("objsur");
                typeObject.SetAttributeValue("guid", guid);
                typeObject.SetAttributeValue("t", owned ? "o" : "r");
                if (varElementTag != null)
                {
                    varElementTag.Add(typeObject);
                }
                DataMigrationServices.UpdateDTO(repoDto, dto, data.ToString());
            }
        }
Ejemplo n.º 7
0
        private void CleanOutBadRefTypes(IDomainObjectDTORepository repoDto)
        {
            const string unspecComplexEntryTypeGuid = "fec038ed-6a8c-4fa5-bc96-a4f515a98c50";
            const string unspecVariantEntryTypeGuid = "3942addb-99fd-43e9-ab7d-99025ceb0d4e";

            foreach (var dto in repoDto.AllInstancesWithSubclasses("LexEntryRef"))
            {
                var data                = XElement.Parse(dto.Xml);
                var refTypeElt          = data.Element("RefType");
                var varientEntryTypeElt = data.Element("VariantEntryTypes");
                var complexEntryTypeElt = data.Element("ComplexEntryTypes");
                if (refTypeElt.FirstAttribute.Value == LexEntryRefTags.krtComplexForm.ToString() && varientEntryTypeElt != null)
                {
                    varientEntryTypeElt.Remove();
                    DataMigrationServices.UpdateDTO(repoDto, dto, data.ToString());
                }
                else if (refTypeElt.FirstAttribute.Value == LexEntryRefTags.krtVariant.ToString() && complexEntryTypeElt != null)
                {
                    complexEntryTypeElt.Remove();
                    DataMigrationServices.UpdateDTO(repoDto, dto, data.ToString());
                }
                // Re-do the DM69 bit correctly if necessary
                if (refTypeElt.FirstAttribute.Value == LexEntryRefTags.krtComplexForm.ToString() && complexEntryTypeElt == null)
                {
                    DataMigration7000069.AddRefType(data, repoDto, dto, "ComplexEntryTypes", unspecComplexEntryTypeGuid, false);
                }
                else if (refTypeElt.FirstAttribute.Value == LexEntryRefTags.krtVariant.ToString() && varientEntryTypeElt == null)
                {
                    DataMigration7000069.AddRefType(data, repoDto, dto, "VariantEntryTypes", unspecVariantEntryTypeGuid, false);
                }
            }
        }
Ejemplo n.º 8
0
        private void RemoveInvalidFiles(IDomainObjectDTORepository repoDto,
                                        DomainObjectDTO langProj, DomainObjectDTO folder)
        {
            var langProjElement = XElement.Parse(langProj.Xml);
            var pictures        = langProjElement.Element("Pictures");
            var fileMap         = CreateFilePathToGuidMap(repoDto, folder);
            var pictureMap      = CreateFileGuidToPictureMap(repoDto);

            foreach (var x in pictures.Elements())
            {
                var xObj = repoDto.GetDTO(x.Attribute("guid").Value);
                if (xObj.Classname == "CmFile")
                {
                    string replacementFileGuid;
                    string filePath = GetFilePath(xObj);
                    if (filePath != null &&
                        fileMap.TryGetValue(filePath.ToLowerInvariant(), out replacementFileGuid))
                    {
                        UpdatePictureReferences(repoDto, xObj, replacementFileGuid, pictureMap);
                        DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, xObj, true);
                    }
                    else if (!pictureMap.ContainsKey(xObj.Guid))
                    {
                        DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, xObj, true);
                    }
                    else
                    {
                        MoveFileToFolder(repoDto, folder, xObj);
                        RemoveReferenceFromPictures(repoDto, langProj, xObj.Guid);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public void PerformMigration(IDomainObjectDTORepository repoDto)
        {
            DataMigrationServices.CheckVersionNumber(repoDto, 7000043);

            if (repoDto.ProjectFolder != Path.GetTempPath())
            {
                // Skip migrating the global repository if we're just running tests. Slow and may not be wanted.
                // In a real project we do this first; thus if by any chance a WS is differently renamed in
                // the two folders, the renaming that is right for this project wins.
                var globalWsFolder = LcmFileHelper.OldGlobalWritingSystemStoreDirectory;
                var globalMigrator = new LdmlInFolderWritingSystemRepositoryMigrator(globalWsFolder, NoteMigration, 2);
                globalMigrator.Migrate();
            }

            var ldmlFolder = Path.Combine(repoDto.ProjectFolder, LcmFileHelper.ksWritingSystemsDir);
            var migrator   = new LdmlInFolderWritingSystemRepositoryMigrator(ldmlFolder, NoteMigration, 2);

            migrator.Migrate();

            var wsIdMigrator = new WritingSystemIdMigrator(repoDto, TryGetNewTag, "*_Layouts.xml");

            wsIdMigrator.Migrate();

            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
Ejemplo n.º 10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Change all guids to lowercase to help the Chorus diff/merge code.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000024);

            const string dateCreated = "DateCreated";
            var          properties  = new List <string> {
                dateCreated, "DateModified"
            };

            ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("CmProject"), properties);            // Tested
            ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("CmMajorObject"), properties);        // Tested
            ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("CmPossibility"), properties);        // Tested
            ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("CmAnnotation"), properties);         // Tested
            ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("StJournalText"), properties);        // Tested
            ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("LexEntry"), properties);             // Tested
            ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("RnGenericRec"), properties);         // Tested
            // Since ScrScriptureNote derives from CmBaseAnnotation, which has already had it DateCreated & DateModified updated,
            // we have to clear those two out of the dictioanry, or they will be updated twice, and the test on ScrScriptureNote will fail.
            properties.Clear();
            properties.Add("DateResolved");
            ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("ScrScriptureNote"), properties);             // Tested
            properties.Clear();
            properties.Add(dateCreated);
            ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("ScrDraft"), properties);
            properties.Clear();
            properties.Add("RunDate");
            ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("ScrCheckRun"), properties);

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Delete all UserViews
        /// </summary>
        /// <param name="repoDto">
        /// Repository of all CmObject DTOs available for one migration step.
        /// </param>
        /// <remarks>
        /// The method must remove DTOs from the repository.
        ///
        /// 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 repoDto)
        {
            DataMigrationServices.CheckVersionNumber(repoDto, 7000030);

            List <DomainObjectDTO> viewsToDelete = new List <DomainObjectDTO>();

            foreach (DomainObjectDTO dtoView in repoDto.AllInstancesSansSubclasses("UserView"))
            {
                XElement xeView = XElement.Parse(dtoView.Xml);
                XElement xeApp  = xeView.Element("App");
                if (xeApp == null)
                {
                    continue;
                }
                XAttribute val = xeApp.Attribute("val");
                if (val == null)
                {
                    continue;
                }
                viewsToDelete.Add(dtoView);
            }
            foreach (var dto in viewsToDelete)
            {
                DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, dto, false);
            }
            viewsToDelete.Clear();

            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
Ejemplo n.º 12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Change any bogus non-owning footnote links in the vernacular (but NOT in the BT)
        /// to be owning links
        /// </summary>
        /// <param name="domainObjectDtoRepository">
        /// Repository of all CmObject DTOs available for one migration step.
        /// </param>
        /// ------------------------------------------------------------------------------------
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000034);

            foreach (var scrTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("ScrTxtPara"))
            {
                XElement para     = XElement.Parse(scrTxtPara.Xml);
                XElement contents = para.Element("Contents");
                if (contents == null)
                {
                    continue;
                }
                XElement str = contents.Element("Str");
                if (str == null)
                {
                    continue;
                }

                foreach (XElement run in str.Elements("Run"))
                {
                    XAttribute linkAttr = run.Attribute("link");
                    if (linkAttr == null)
                    {
                        continue;                         // Run doesn't contain an unowned hot-link
                    }
                    XAttribute ownedLinkAttr = new XAttribute("ownlink", linkAttr.Value);
                    run.Add(ownedLinkAttr);
                    linkAttr.Remove();
                    DataMigrationServices.UpdateDTO(domainObjectDtoRepository, scrTxtPara, para.ToString());
                }
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Makes LexEntries be unowned.
        /// </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, 7000027);

            var lexDbDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LexDb").First();
            var lexDb    = XElement.Parse(lexDbDto.Xml);
            var entries  = lexDb.Element("Entries");

            if (entries != null)
            {
                entries.Remove();
                DataMigrationServices.UpdateDTO(domainObjectDtoRepository, lexDbDto, lexDb.ToString());
            }

            foreach (var entryDto in domainObjectDtoRepository.AllInstancesSansSubclasses("LexEntry"))
            {
                XElement entry     = XElement.Parse(entryDto.Xml);
                var      ownerAttr = entry.Attribute("ownerguid");
                if (ownerAttr != null)
                {
                    ownerAttr.Remove();
                    DataMigrationServices.UpdateDTO(domainObjectDtoRepository, entryDto, entry.ToString());
                }
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 14
0
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000050);

            var          newGuidValue = Guid.NewGuid().ToString().ToLowerInvariant();
            const string className    = "LangProject";
            var          lpDto        = domainObjectDtoRepository.AllInstancesSansSubclasses(className).First();
            var          ownedDtos    = domainObjectDtoRepository.GetDirectlyOwnedDTOs(lpDto.Guid).ToList();
            var          data         = lpDto.Xml;

            domainObjectDtoRepository.Remove(lpDto);             // It is pretty hard to change an immutable Guid identifier in BEP-land, so nuke it, and make a new one.

            var lpElement = XElement.Parse(data);

            lpElement.Attribute("guid").Value = newGuidValue;
            var newLpDto = new DomainObjectDTO(newGuidValue, className, lpElement.ToString());

            domainObjectDtoRepository.Add(newLpDto);

            // Change ownerguid attr for each owned item to new guid.
            foreach (var ownedDto in ownedDtos)
            {
                var ownedElement = XElement.Parse(ownedDto.Xml);
                ownedElement.Attribute("ownerguid").Value = newGuidValue;
                ownedDto.Xml = ownedElement.ToString();
                domainObjectDtoRepository.Update(ownedDto);
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 15
0
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000062);

            var wmbLangProjList = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject");
            var wmbLangProj     = wmbLangProjList.First();
            var wmbLangProjElt  = XElement.Parse(wmbLangProj.Xml);
            // get the default vernacular ws - it's the 1st in the list of current ones.
            var vernWss = wmbLangProjElt.Element("CurVernWss");             // has to be only one

            // a new project migrates before adding writing systems to the cache, so if there are no CurVernWss, bail out
            if (vernWss != null)
            {
                var vernWssUni  = vernWss.Element("Uni");        // only one
                var vernWsList  = vernWssUni.Value.Split(' ');   // at least one
                var vernDefault = vernWsList[0];                 // the default

                // Create the new property
                var sb = new StringBuilder();
                sb.Append("<HomographWs>");
                sb.AppendFormat("<Uni>{0}</Uni>", vernDefault);
                sb.Append("</HomographWs>");
                var hgWsElt = XElement.Parse(sb.ToString());
                wmbLangProjElt.Add(hgWsElt);
                DataMigrationServices.UpdateDTO(domainObjectDtoRepository, wmbLangProj, wmbLangProjElt.ToString());
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 16
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Change model for Data Notebook to combine the RnEvent and RnAnalysis classes
        /// into RnGenericRec
        /// </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 its 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, 7000004);

            // 1. Change EventTypes field to RecTypes
            var nbkDto            = domainObjectDtoRepository.AllInstancesSansSubclasses("RnResearchNbk").First();
            var nbkElement        = XElement.Parse(nbkDto.Xml);
            var nbkClsElement     = nbkElement.Element("RnResearchNbk");
            var typesFieldElement = nbkClsElement.Element("EventTypes");
            var typesSurElement   = typesFieldElement.Element("objsur");

            nbkClsElement.Add(new XElement("RecTypes", typesSurElement));
            typesFieldElement.Remove();
            DataMigrationServices.UpdateDTO(domainObjectDtoRepository, nbkDto, nbkElement.ToString());

            // 2. Add Analysis possibility to Record Types list
            var typesGuid    = typesSurElement.Attribute("guid").Value;
            var typesDto     = domainObjectDtoRepository.GetDTO(typesGuid);
            var typesElement = XElement.Parse(typesDto.Xml);

            typesElement.XPathSelectElement("CmMajorObject/Name/AUni[@ws='en']").SetValue("Entry Types");
            var posElement = typesElement.XPathSelectElement("CmPossibilityList/Possibilities");

            posElement.Add(
                DataMigrationServices.CreateOwningObjSurElement("82290763-1633-4998-8317-0EC3F5027FBD"));
            DataMigrationServices.UpdateDTO(domainObjectDtoRepository, typesDto,
                                            typesElement.ToString());
            var ord = posElement.Elements().Count();

            var nowStr      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
            var typeElement = new XElement("rt", new XAttribute("class", "CmPossibility"),
                                           new XAttribute("guid", "82290763-1633-4998-8317-0EC3F5027FBD"),
                                           new XAttribute("ownerguid", typesGuid),
                                           new XAttribute("owningflid", "8008"), new XAttribute("owningord", ord.ToString()),
                                           new XElement("CmObject"),
                                           new XElement("CmPossibility",
                                                        new XElement("Abbreviation",
                                                                     new XElement("AUni", new XAttribute("ws", "en"), "Ana")),
                                                        new XElement("BackColor", new XAttribute("val", "16711680")),
                                                        new XElement("DateCreated", new XAttribute("val", nowStr)),
                                                        new XElement("DateModified", new XAttribute("val", nowStr)),
                                                        new XElement("Description",
                                                                     new XElement("AStr", new XAttribute("ws", "en"),
                                                                                  new XElement("Run", new XAttribute("ws", "en"), "Reflection on events and other types of data, such as literature summaries or interviews. An analysis does not add data; it interprets and organizes data. An analysis entry may synthesize emerging themes. It may draw connections between observations. It is a place to speculate and hypothesize, or document moments of discovery and awareness. Analytic notes can be turned into articles. Or, they may just be steps on the stairway toward greater understanding."))),
                                                        new XElement("ForeColor", new XAttribute("val", "16777215")),
                                                        new XElement("Name",
                                                                     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",
                                                              "CmPossibility", typeElement.ToString()));

            // 3. Move the attributes that are in RnEvent and RnAnalysis into RnGenericRec.
            MigrateSubclassOfGenRec(domainObjectDtoRepository, "RnEvent");
            MigrateSubclassOfGenRec(domainObjectDtoRepository, "RnAnalysis");

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 17
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// 1) Remove orphaned CmBaseAnnotations, as per FWR-98:
        /// "Since we won't try to reuse wfic or segment annotations that no longer have
        /// BeginObject point to a paragraph, we should remove (ignore) these annotations
        /// when migrating an old database (FW 6.0 or older) into the new architecture"
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000007);

/* Expected data (relevant data, that is) format.
 *                      <rt guid="22a8431f-f974-412f-a261-8bd1a4e1be1b" class="CmBaseAnnotation">
 *                              <CmObject />
 *                              <CmAnnotation>
 *                                      <AnnotationType> <!-- Entire element will be missing if prop is null. -->
 *                                              <objsur guid="eb92e50f-ba96-4d1d-b632-057b5c274132" t="r" />
 *                                      </AnnotationType>
 *                              </CmAnnotation>
 *                              <CmBaseAnnotation>
 *                                      <BeginObject> <!-- Entire element will be missing if prop is null. -->
 *                                              <objsur guid="93dcb15d-f622-4329-b1b5-e5cc832daf01" t="r" />
 *                                      </BeginObject>
 *                              </CmBaseAnnotation>
 *                      </rt>
 */
            var interestingAnnDefIds = new List <string>
            {
                DataMigrationServices.kSegmentAnnDefnGuid.ToLower(),
                DataMigrationServices.kTwficAnnDefnGuid.ToLower(),
                DataMigrationServices.kPficAnnDefnGuid.ToLower(),
                DataMigrationServices.kConstituentChartAnnotationAnnDefnGuid.ToLower()
            };

            //Collect up the ones to be removed.
            var goners = new List <DomainObjectDTO>();

            foreach (var annDTO in domainObjectDtoRepository.AllInstancesSansSubclasses("CmBaseAnnotation"))
            {
                var annElement  = XElement.Parse(annDTO.Xml);
                var typeElement = annElement.Element("CmAnnotation").Element("AnnotationType");
                if (typeElement == null ||
                    !interestingAnnDefIds.Contains(typeElement.Element("objsur").Attribute("guid").Value.ToLower()))
                {
                    continue;                     // uninteresing annotation type, so skip it.
                }
                // annDTO is a segment, wordform, punctform, or constituent chart annotation.
                if (annElement.Element("CmBaseAnnotation").Element("BeginObject") != null)
                {
                    continue;                     // Has data in BeginObject property, so skip it.
                }
                goners.Add(annDTO);
            }

            // Remove them.
            foreach (var goner in goners)
            {
                DataMigrationServices.RemoveIncludingOwnedObjects(domainObjectDtoRepository, goner, true);
            }

            // Some stuff may reference the defective Discourse Cahrt Annotation, so clear out the refs to them.
            DataMigrationServices.Delint(domainObjectDtoRepository);

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 18
0
        public void PerformMigration(IDomainObjectDTORepository repoDto)
        {
            DataMigrationServices.CheckVersionNumber(repoDto, 7000069);

            CleanOutBadRefTypes(repoDto);
            RenameDuplicateCustomListsAndFixBadLists(repoDto);

            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
Ejemplo n.º 19
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// locate all files in %appdata%/SIL/FieldWorks/Language Explorer/db$projectname$*.* and move them
        /// to projects/projectname/ConfigurationSettings/db$local$*.*
        /// </summary>
        /// <param name="repoDto">
        /// Repository of all CmObject DTOs available for one migration step.
        /// </param>
        /// <remarks>
        /// 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 repoDto)
        {
            DataMigrationServices.CheckVersionNumber(repoDto, 7000031);
            var projectFolder = repoDto.ProjectFolder;
            var projectName   = Path.GetFileNameWithoutExtension(projectFolder);
            // This is equivalent to DirectoryFinder.UserAppDataFolder("Language Explorer") at the time of creating
            // the migration, but could conceivably change later.
            var sourceDir = Path.Combine(
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SIL"),
                "Language Explorer");
            // This is equivalent to DirectoryFinder.GetConfigSettingsDir(projectFolder) at the time of creating
            // the migration, but could conceivably change later.
            var targetDir = Path.Combine(projectFolder, "ConfigurationSettings");

            if (Directory.Exists(sourceDir))
            {
                Directory.CreateDirectory(targetDir);
                string       oldPrefix = "db$" + projectName + "$";
                const string newPrefix = "db$local$";
                foreach (var path in Directory.GetFiles(sourceDir, oldPrefix + "*.*"))
                {
                    var filename = Path.GetFileName(path);
                    if (filename == null)
                    {
                        continue;
                    }
                    var targetName = filename.Substring(oldPrefix.Length);
                    if (targetName.ToLowerInvariant() == "settings.xml")
                    {
                        targetName = newPrefix + targetName;
                        var destFileName1 = Path.Combine(targetDir, targetName);
                        if (!File.Exists(destFileName1))
                        {
                            // The settings file contains saved properties that begin with db$ProjectName$ and need to be db$Local$
                            using (var reader = new StreamReader(path, Encoding.UTF8))
                            {
                                using (var writer = FileUtils.OpenFileForWrite(destFileName1, Encoding.UTF8))
                                {
                                    while (!reader.EndOfStream)
                                    {
                                        writer.WriteLine(reader.ReadLine().Replace(oldPrefix, newPrefix));
                                    }
                                }
                            }
                        }
                    }
                    var destFileName = Path.Combine(targetDir, targetName);
                    if (!File.Exists(destFileName))
                    {
                        File.Copy(path, destFileName);
                    }
                }
            }

            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
Ejemplo n.º 20
0
        private void AppendCustomToNamesAndUpdate(IDomainObjectDTORepository repoDto, DomainObjectDTO dto, XElement dtoXml)
        {
            var names = dtoXml.Elements("Name");

            foreach (var titleElement in names.Select(name => name.Element("AUni")).Where(titleElement => titleElement != null))
            {
                titleElement.Value = titleElement.Value + "-Custom";
            }
            DataMigrationServices.UpdateDTO(repoDto, dto, dtoXml.ToString());
        }
Ejemplo n.º 21
0
        /// <summary>
        /// If user created a Custom "Exemplar" or "UsageNote" of type MultiString or MultiUnicode,
        /// copy that data into the new built-in MultiString element and, if MultiString, remove the Custom Field.
        /// If a conflicting Custom Field cannot be migrated and removed, rename it to avoid conflict.
        /// </summary>
        internal static void MigrateIntoNewMultistringField(IDomainObjectDTORepository repoDto, string fieldName)
        {
            // This is the same algorithm used by BackendProvider.PreLoadCustomFields to prevent naming conflicts with existing Custom Fields
            var nameSuffix   = 0;
            var lexSenseClid = repoDto.MDC.GetClassId("LexSense");

            while (repoDto.MDC.FieldExists(lexSenseClid, fieldName + nameSuffix, false))
            {
                ++nameSuffix;
            }
            var newFieldName = fieldName + nameSuffix;

            foreach (var dto in repoDto.AllInstancesSansSubclasses("LexSense"))
            {
                var data = XElement.Parse(dto.Xml);

                var customElt = data.Elements("Custom").FirstOrDefault(elt => elt.Attribute("name").Value == fieldName);
                if (customElt == null)
                {
                    continue;
                }
                customElt.SetAttributeValue("name", newFieldName);                 // rename to the new custom Exemplar name

                var builtInElt     = new XElement(fieldName);
                var isFieldBuiltIn = false;
                foreach (var multiStrElt in customElt.Elements("AStr"))
                {
                    builtInElt.Add(multiStrElt);
                    isFieldBuiltIn = true;
                }
                foreach (var multiStrElt in customElt.Elements("AUni"))
                {
                    multiStrElt.Name = "AStr";
                    var mutiStrData = multiStrElt.Value;
                    multiStrElt.Value = string.Empty;
                    var wsAttr = multiStrElt.Attribute("ws");
                    var runElt = new XElement("Run")
                    {
                        Value = mutiStrData
                    };
                    runElt.SetAttributeValue("ws", wsAttr.Value);
                    multiStrElt.Add(runElt);
                    builtInElt.Add(multiStrElt);
                    isFieldBuiltIn = true;
                }
                if (isFieldBuiltIn)
                {
                    customElt.Remove();
                    data.Add(builtInElt);
                }
                DataMigrationServices.UpdateDTO(repoDto, dto, data.ToString());
            }
        }
Ejemplo n.º 22
0
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000065);

            // Cache all basic data properties for each class in the mdc.
            var mdc = domainObjectDtoRepository.MDC;
            var cachedBasicProperties = CacheBasicProperties(mdc);

            foreach (var kvp in cachedBasicProperties)
            {
                var className = kvp.Key;
                if (mdc.GetAbstract(mdc.GetClassId(className)))
                {
                    continue;                     // Won't find any of those as dtos.
                }
                var basicProps = kvp.Value;
                foreach (var dto in domainObjectDtoRepository.AllInstancesSansSubclasses(className))
                {
                    var rootElementChanged = false;
                    var rootElement        = XElement.Parse(dto.Xml);
                    foreach (var basicPropertyInfo in basicProps)
                    {
                        if (basicPropertyInfo.m_isCustom)
                        {
                            var customPropElement = rootElement.Elements("Custom").FirstOrDefault(element => element.Attribute("name").Value == basicPropertyInfo.m_propertyName);
                            if (customPropElement == null)
                            {
                                CreateCustomProperty(rootElement, basicPropertyInfo);
                                rootElementChanged = true;
                            }
                        }
                        else
                        {
                            var basicPropertyElement = rootElement.Element(basicPropertyInfo.m_propertyName);
                            if (basicPropertyElement == null && !SkipTheseBasicPropertyNames.Contains(basicPropertyInfo.m_propertyName) && !basicPropertyInfo.m_isVirtual)
                            {
                                CreateBasicProperty(rootElement, basicPropertyInfo);
                                rootElementChanged = true;
                            }
                        }
                    }
                    if (!rootElementChanged)
                    {
                        continue;
                    }

                    dto.Xml = rootElement.ToString();
                    domainObjectDtoRepository.Update(dto);
                }
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 1) Add the reference collection of Senses to each reversal index and
        /// fill it with the Senses that referenced the ReversalIndexEntry
        /// 2) Remove the collection of ReversalIndexEntry from each Sense
        /// 3) Migrate any VirtualOrdering objects if necessary
        /// </summary>
        public void PerformMigration(IDomainObjectDTORepository repoDto)
        {
            DataMigrationServices.CheckVersionNumber(repoDto, 7000071);

            AddSensesToReversalIndexEntry(repoDto);

            RemoveReversalEntriesFromSenses(repoDto);

            ChangeReferringSensesToSenses(repoDto);

            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Change LexEntry.Etymology to Owned Sequence, add several fields to LexEtymology
        /// Change some existing field signatures. Remove Source and put its data in LanguageNotes
        /// in a slightly different format (Unicode -> MultiString). Also add a new list Languages
        /// owned by LexDb. Languages list will be initially empty.
        /// </summary>
        /// <remarks>internal for testing</remarks>
        internal static void AugmentEtymologyCluster(IDomainObjectDTORepository repoDto)
        {
            const string languagesListGuid = "487c15b0-2ced-4417-8b77-9075f4a21e5f";
            var          lexDbDTO          = repoDto.AllInstancesSansSubclasses("LexDb").FirstOrDefault();

            if (lexDbDTO == null)
            {
                return;                 // This must be a test that doesn't care about LexDb.
            }
            var lexDbElt = XElement.Parse(lexDbDTO.Xml);

            CreateNewLexDbProperty(lexDbElt, "Languages", languagesListGuid);
            var lexDbGuid = lexDbElt.Attribute("guid").Value;

            // create Languages' possibility list
            DataMigrationServices.CreatePossibilityList(repoDto, languagesListGuid, lexDbGuid,
                                                        new[]
            {
                new Tuple <string, string, string>("en", "Lgs", "Languages"),
                new Tuple <string, string, string>("fr", "Lgs", "Langues"),
                new Tuple <string, string, string>("es", "Ids", "Idiomas")
            },
                                                        new DateTime(2016, 7, 25, 18, 48, 18), WritingSystemServices.kwsAnals);
            DataMigrationServices.UpdateDTO(repoDto, lexDbDTO, lexDbElt.ToString());             // update LexDb object

            // Augment existing Etymologies
            var etymologyDtos = repoDto.AllInstancesSansSubclasses("LexEtymology");

            if (!etymologyDtos.Any())
            {
                return;
            }
            var primaryAnalysisWs = ExtractPrimaryWsFromLangProj(repoDto, true);

            foreach (var etymologyDto in etymologyDtos)
            {
                ChangeMultiUnicodeElementToMultiString(repoDto, etymologyDto, "//Form");
                ChangeMultiUnicodeElementToMultiString(repoDto, etymologyDto, "//Gloss");
                var dataElt   = XElement.Parse(etymologyDto.Xml);
                var sourceElt = dataElt.Element("Source");
                if (sourceElt == null)
                {
                    continue;
                }
                sourceElt.Name = "LanguageNotes";                 // sourceElt is now the languageNotesElt!
                var oldSourceData = sourceElt.Element("Uni").Value;
                var multiStrElt   = BuildMultiStringElement(primaryAnalysisWs, oldSourceData);
                sourceElt.RemoveAll();
                sourceElt.Add(multiStrElt);
                DataMigrationServices.UpdateDTO(repoDto, etymologyDto, dataElt.ToString());
            }
        }
Ejemplo n.º 25
0
        internal static void RemoveEmptyLexEntryRefs(IDomainObjectDTORepository repoDto)
        {
            foreach (var dto in repoDto.AllInstancesWithSubclasses("LexEntryRef"))
            {
                XElement data = XElement.Parse(dto.Xml);

                var components = data.Element("ComponentLexemes");
                if (components == null || !components.HasElements)
                {
                    DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, dto, true);
                }
            }
        }
Ejemplo n.º 26
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets the ParaContainingOrc property for all 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, 7000026);

            foreach (var scrTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("ScrTxtPara"))
            {
                XElement para     = XElement.Parse(scrTxtPara.Xml);
                XElement contents = para.Element("Contents");
                if (contents == null)
                {
                    continue;
                }
                XElement str = contents.Element("Str");
                if (str == null)
                {
                    continue;
                }

                foreach (XElement run in str.Elements("Run"))
                {
                    XAttribute linkAttr = run.Attribute("ownlink");
                    if (linkAttr == null)
                    {
                        continue;                         // Run doesn't contain a link
                    }
                    DomainObjectDTO linkObj;
                    // skip links to missing footnotes - user will have to clean these up later.
                    if (!domainObjectDtoRepository.TryGetValue(linkAttr.Value, out linkObj))
                    {
                        continue;
                    }
                    XElement footnote = XElement.Parse(linkObj.Xml);
                    if (footnote.Attribute("class").Value != "ScrFootnote")
                    {
                        continue;                         // Link is not for a footnote
                    }
                    if (footnote.Element("ParaContainingOrc") == null)
                    {
                        // ParaContainingOrc property is not present in the footnote, so it needs
                        // to be added.
                        XElement paraContainingOrcElm = XElement.Parse("<ParaContainingOrc><objsur guid=\"" +
                                                                       scrTxtPara.Guid + "\" t=\"r\" /></ParaContainingOrc>");
                        footnote.Add(paraContainingOrcElm);

                        DataMigrationServices.UpdateDTO(domainObjectDtoRepository, linkObj, footnote.ToString());
                    }
                }
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 27
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Perform one increment migration step.
        /// </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, 7000061);

            // Step 1.
            foreach (var resourceDto in domainObjectDtoRepository.AllInstancesSansSubclasses("CmResource"))
            {
                var resourceElement     = XElement.Parse(resourceDto.Xml);
                var resourceNameElement = resourceElement.Element("Name");
                if (resourceNameElement == null)
                {
                    continue;
                }
                var uniElement = resourceNameElement.Element("Uni");
                if (uniElement == null)
                {
                    continue;
                }
                string oldVersion;
                switch (uniElement.Value)
                {
                case "TeStyles":
                    oldVersion = "700176e1-4f42-4abd-8fb5-3c586670085d";
                    break;

                case "FlexStyles":
                    oldVersion = "13c213b9-e409-41fc-8782-7ca0ee983b2c";
                    break;

                default:
                    continue;
                }
                var versionElement = resourceElement.Element("Version");
                if (versionElement == null)
                {
                    resourceElement.Add(new XElement("Version", new XAttribute("val", oldVersion)));
                }
                else
                {
                    versionElement.Attribute("val").Value = oldVersion;
                }
                resourceDto.Xml = resourceElement.ToString();
                domainObjectDtoRepository.Update(resourceDto);
            }

            // Step 2.
            DataMigrationServices.Delint(domainObjectDtoRepository);

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 28
0
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000051);

            const string className = "WfiMorphBundle";
            var          wmbList   = domainObjectDtoRepository.AllInstancesSansSubclasses(className);

            foreach (var wmb in wmbList)
            {
                XElement wmbElt   = XElement.Parse(wmb.Xml);
                var      morphElt = wmbElt.Element("Morph");
                // if we don't have a morph reference,
                // then there's nothing to copy into the form field.
                if (morphElt == null)
                {
                    continue;
                }
                var objsurElt      = morphElt.Element("objsur");
                var dtoMorphTarget = domainObjectDtoRepository.GetDTO(objsurElt.Attribute("guid").Value);
                // for each form alternative, copy the writing system

                // if for some reason there is a morphbundle form that already exists, delete it before inserting another.
                var formElt = wmbElt.Element("Form");
                if (formElt != null)
                {
                    formElt.Remove();
                }

                var morphTargetElt     = XElement.Parse(dtoMorphTarget.Xml);
                var morphTargetFormElt = morphTargetElt.Element("Form");
                if (morphTargetFormElt == null)
                {
                    continue;
                }
                formElt = XElement.Parse("<Form/>");
                wmbElt.AddFirst(formElt);
                foreach (var aUniElt in morphTargetFormElt.Elements("AUni"))
                {
                    string ws            = aUniElt.Attribute("ws").Value;
                    string form          = aUniElt.Value;
                    var    newFormAltElt = XElement.Parse(String.Format("<AStr ws=\"{0}\"/>", ws));
                    formElt.Add(newFormAltElt);
                    var newRunElt = XElement.Parse(String.Format("<Run ws=\"{0}\">{1}</Run>", ws, XmlUtils.MakeSafeXml(form)));
                    newFormAltElt.Add(newRunElt);
                }
                DataMigrationServices.UpdateDTO(domainObjectDtoRepository, wmb, wmbElt.ToString());
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
Ejemplo n.º 29
0
        bool TryChangeOwnerClass(IDomainObjectDTORepository dtoRepo, DomainObjectDTO dtoToChange, string oldClassname, string newClassname)
        {
            XElement dtoToChangeElt = XElement.Parse(dtoToChange.Xml);

            if (dtoToChangeElt.Attribute("class").Value != oldClassname)
            {
                return(false);
            }
            dtoToChangeElt.Attribute("class").Value = newClassname;
            dtoToChange.Classname = newClassname;
            // next go through all the children of these known system variant types and change all of their children's classes.

            DataMigrationServices.UpdateDTO(dtoRepo, dtoToChange, dtoToChangeElt.ToString(), oldClassname);
            return(true);
        }
Ejemplo n.º 30
0
        private void RemoveReferenceFromPictures(IDomainObjectDTORepository repoDto, DomainObjectDTO langProj,
                                                 string guid)
        {
            var langProjElement = XElement.Parse(langProj.Xml);

            foreach (var x in langProjElement.Element("Pictures").Elements())
            {
                if (x.Attribute("guid").Value == guid)
                {
                    x.Remove();
                    break;
                }
            }
            DataMigrationServices.UpdateDTO(repoDto, langProj, langProjElement.ToString());
        }