RemoveIncludingOwnedObjects() static private method

Remove goner and everything it owns. Be sure to include removing goner from its optional owning property.
static private RemoveIncludingOwnedObjects ( IDomainObjectDTORepository dtoRepos, DomainObjectDTO goner, bool removeFromOwner ) : void
dtoRepos IDomainObjectDTORepository
goner DomainObjectDTO
removeFromOwner bool
return void
コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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);
                    }
                }
            }
        }
コード例 #4
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);
        }
コード例 #5
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);
                }
            }
        }
コード例 #6
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);
        }