示例#1
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);
        }
示例#2
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);
        }
示例#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);
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
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);
        }
示例#11
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);
        }
示例#12
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);
        }
示例#13
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);
        }
示例#14
0
        public void PerformMigration(IDomainObjectDTORepository repoDto)
        {
            DataMigrationServices.CheckVersionNumber(repoDto, 7000069);

            CleanOutBadRefTypes(repoDto);
            RenameDuplicateCustomListsAndFixBadLists(repoDto);

            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
示例#15
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);
        }
示例#16
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);
        }
示例#17
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);
        }
示例#18
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);
        }
示例#19
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);
        }
示例#20
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);
        }
示例#21
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Change all guids to lowercase to help the Chorus diff/merge code.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000022);

            foreach (var dto in domainObjectDtoRepository.AllInstancesWithValidClasses())
            {
                var rtElement = XElement.Parse(dto.Xml);
                if (ShiftCase(rtElement))
                {
                    DataMigrationServices.UpdateDTO(domainObjectDtoRepository, dto, rtElement.ToString());
                }
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
示例#22
0
 public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
 {
     DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000057);
     {
         // LT-13312 Note some projects may not have these guids.
         DomainObjectDTO dtoVariantType;
         if (domainObjectDtoRepository.TryGetValue(LexEntryTypeTags.kguidLexTypPluralVar.ToString(), out dtoVariantType))
         {
             AddGlossAppendIfEmpty(domainObjectDtoRepository, dtoVariantType, ".pl");
         }
         if (domainObjectDtoRepository.TryGetValue(LexEntryTypeTags.kguidLexTypPastVar.ToString(), out dtoVariantType))
         {
             AddGlossAppendIfEmpty(domainObjectDtoRepository, dtoVariantType, ".pst");
         }
     }
     DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
 }
示例#23
0
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
示例#24
0
        public void PerformMigration(IDomainObjectDTORepository repoDto)
        {
            DataMigrationServices.CheckVersionNumber(repoDto, 7000068);

            UpdateRestrictions(repoDto);
            RemoveEmptyLexEntryRefs(repoDto);
            AddDefaultLexEntryRefType(repoDto);
            AddReverseNameAndSwapAbbreviationFields(repoDto);
            MigrateIntoNewMultistringField(repoDto, "Exemplar");
            MigrateIntoNewMultistringField(repoDto, "UsageNote");
            AugmentEtymologyCluster(repoDto);
            AddNewExtendedNoteCluster(repoDto);
            AddDialectLabelsList(repoDto);
            //VerifyExistenceOfMinimalPublicationType(repoDto); DM 7000041 does this already

            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
示例#25
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Makes Texts (IText) 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, 7000058);

            // Remove LangProject Texts property
            var lpDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject").First();
            var lp    = XElement.Parse(lpDto.Xml);
            var texts = lp.Element("Texts");

            if (texts != null)
            {
                texts.Remove();
                DataMigrationServices.UpdateDTO(domainObjectDtoRepository, lpDto, lp.ToString());
            }

            // Change RnGenericRec Text property from owned to reference
            foreach (var rnRecDto in domainObjectDtoRepository.AllInstancesSansSubclasses("RnGenericRec"))
            {
                var rec     = XElement.Parse(rnRecDto.Xml);
                var textElt = rec.Element("Text");
                if (textElt != null)
                {
                    var objsurElt = textElt.Element("objsur");
                    if (objsurElt != null && objsurElt.Attribute("t") != null)
                    {
                        objsurElt.Attribute("t").SetValue("r");
                        DataMigrationServices.UpdateDTO(domainObjectDtoRepository, rnRecDto, rec.ToString());
                    }
                }
            }

            // Remove owner from all Texts
            foreach (var textDto in domainObjectDtoRepository.AllInstancesSansSubclasses("Text"))
            {
                XElement text      = XElement.Parse(textDto.Xml);
                var      ownerAttr = text.Attribute("ownerguid");
                if (ownerAttr != null)
                {
                    ownerAttr.Remove();
                    DataMigrationServices.UpdateDTO(domainObjectDtoRepository, textDto, text.ToString());
                }
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
示例#26
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Cleans up legacy ChkRendering objects with null SurfaceForms.
        /// </summary>
        /// <param name="repoDto">
        /// 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 repoDto)
        {
            DataMigrationServices.CheckVersionNumber(repoDto, 7000046);

            Dictionary <Guid, DomainObjectDTO> mapOfRenderingsToChk = new Dictionary <Guid, DomainObjectDTO>();
            HashSet <DomainObjectDTO>          renderingsToDelete   = new HashSet <DomainObjectDTO>();

            foreach (DomainObjectDTO dto in repoDto.AllInstances())
            {
                XElement   data      = XElement.Parse(dto.Xml);
                XAttribute classAttr = data.Attribute("class");
                if (classAttr.Value == "ChkTerm")
                {
                    XElement renderings = data.Element("Renderings");
                    if (renderings != null)
                    {
                        foreach (XElement r in renderings.Elements())
                        {
                            mapOfRenderingsToChk[new Guid(r.Attribute("guid").Value)] = dto;
                        }
                    }
                }
                else if (classAttr.Value == "ChkRendering")
                {
                    XElement surfaceForm = data.Element("SurfaceForm");
                    if (surfaceForm == null || !surfaceForm.HasElements)
                    {
                        renderingsToDelete.Add(dto);
                    }
                }
            }

            foreach (DomainObjectDTO rendering in renderingsToDelete)
            {
                DomainObjectDTO 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));
                bogusRendering.Remove();
                DataMigrationServices.UpdateDTO(repoDto, chkTerm, termData.ToString());
                repoDto.Remove(rendering);
            }

            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
示例#27
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Looks for CmFile objects included in LangProject. If found, will look for CmFile in
        /// correct location and replace reference on CmPicture with that new CmFile.
        /// </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, 7000033);
            var langProj        = repoDto.AllInstancesSansSubclasses("LangProject").First();
            var langProjElement = XElement.Parse(langProj.Xml);
            var pictures        = langProjElement.Element("Pictures");

            if (pictures != null && pictures.Elements().Count() > 1)
            {
                DomainObjectDTO folder     = null;
                bool            foundFiles = false;
                foreach (var x in pictures.Elements())
                {
                    var xObj = repoDto.GetDTO(x.Attribute("guid").Value);
                    if (xObj.Classname == "CmFolder")
                    {
                        // empty folders can just be removed
                        var xObjElement = XElement.Parse(xObj.Xml);
                        if (xObjElement.Element("Files") == null)
                        {
                            DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, xObj, true);
                        }
                        else if (folder == null)
                        {
                            folder = xObj;
                        }
                        else
                        {
                            MoveFileReferences(repoDto, langProj, xObj, folder);
                        }
                    }
                    else
                    {
                        foundFiles = true;
                    }
                }

                if (folder != null && foundFiles)
                {
                    RemoveInvalidFiles(repoDto, langProj, folder);
                }
            }
            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
示例#28
0
        public void PerformMigration(IDomainObjectDTORepository repoDto)
        {
            DataMigrationServices.CheckVersionNumber(repoDto, 7000059);

            var configFolder = Path.Combine(repoDto.ProjectFolder, LcmFileHelper.ksConfigurationSettingsDir);

            if (Directory.Exists(configFolder))             // Some of Randy's test data doesn't have the config folder, so it crashes here.
            {
                const string layoutSuffix  = "_Layouts.xml";
                var          filesToRename = Directory.GetFiles(configFolder, "*" + layoutSuffix);
                foreach (var path in filesToRename)
                {
                    var newPath = path.Substring(0, path.Length - layoutSuffix.Length) + ".fwlayout";
                    File.Move(path, newPath);
                }
            }

            DataMigrationServices.IncrementVersionNumber(repoDto);
        }
示例#29
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Deletes unused fields in UserViewField.
        /// </summary>
        /// <param name="domainObjectDtoRepository">Repository of all CmObject DTOs available for
        /// one migration step.</param>
        /// ------------------------------------------------------------------------------------
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000011);

            // 1) Select the UserViewField classes.
            // 2) Delete the following attributes: Details, Visibility, IsCustomField, SubfieldOf, PossList
            foreach (var uvfDto in domainObjectDtoRepository.AllInstancesSansSubclasses("UserViewField"))
            {
                XElement rtElement  = XElement.Parse(uvfDto.Xml);
                XElement uvfElement = rtElement.Element("UserViewField");
                RemoveField(uvfDto, uvfElement, "Details");
                RemoveField(uvfDto, uvfElement, "Visibility");
                RemoveField(uvfDto, uvfElement, "SubfieldOf");
                RemoveField(uvfDto, uvfElement, "IsCustomField");
                DataMigrationServices.UpdateDTO(domainObjectDtoRepository, uvfDto, rtElement.ToString());
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
示例#30
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// FWR-2461 Data Migration: for links to files in TsStrings
        ///--turn paths into relative paths to the LinkedFiledRootDir where possible
        ///--create a CmFile for each link found in a TsString owned by a CmFolder)
        /// </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, 7000029);

            var    langProjDto               = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject").First();
            var    langProjElement           = XElement.Parse(langProjDto.Xml);
            var    linkedFilesRootDirElement = langProjElement.Element("LinkedFilesRootDir");
            string persistedLinkedFilesRootDir;

            if (linkedFilesRootDirElement == null)
            {
                persistedLinkedFilesRootDir = Path.Combine(domainObjectDtoRepository.ProjectFolder, LcmFileHelper.ksLinkedFilesDir);
            }
            else
            {
                persistedLinkedFilesRootDir = linkedFilesRootDirElement.Value;
            }
            var linkedFilesRootDir = LinkedFilesRelativePathHelper.GetLinkedFilesFullPathFromRelativePath(domainObjectDtoRepository.Directories.ProjectsDirectory,
                                                                                                          persistedLinkedFilesRootDir, domainObjectDtoRepository.ProjectFolder);

            //-------------------------------------------------
            var             langProjectGuid             = langProjElement.Attribute("guid").Value;
            var             filePathsInTsStringsElement = AddFilePathsInTsStringsElement(langProjElement);
            DomainObjectDTO cmFolderDto;
            var             cmFolderXElement = MakeCmFolder(domainObjectDtoRepository, langProjectGuid, filePathsInTsStringsElement, CmFolderTags.LocalFilePathsInTsStrings,
                                                            out cmFolderDto);

            UpdateDto(domainObjectDtoRepository, langProjDto, langProjElement);
            //--------------------------------------------------
            var cmFolderGuid = cmFolderXElement.Attribute("guid").Value;

            var filePathsInTsStrings = ProcessExternalLinksRelativePaths(domainObjectDtoRepository, linkedFilesRootDir);

            foreach (var filePath in filePathsInTsStrings)
            {
                MakeCmFile(domainObjectDtoRepository, cmFolderGuid, cmFolderXElement, filePath);
            }

            //Now that all the CmFile references have been added to the CmFolder update it in the repository.
            UpdateDto(domainObjectDtoRepository, cmFolderDto, cmFolderXElement);

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }