コード例 #1
0
        /// <summary>
        ///	1. Remove objects (zombies) that:
        ///		A. claim to have owners, but the owners do not exist, or
        ///		B. owners don't know they own it, or
        ///		C. objects with no owners that are not supported as allowing no owners.
        ///	2. Remove 'dangling' references to objects that no longer exist.
        /// 3. Remove properties that have no attributes or content.
        /// </summary>
        internal static void Delint(IDomainObjectDTORepository dtoRepos)
        {
            // Remove zombies.
            // By removing zombies first, any references to them will be 'dangling',
            // so can be removed in the following step.
            var allInstancesWithValidClasses = dtoRepos.AllInstancesWithValidClasses().ToList();

            RemoveZombies(dtoRepos, allInstancesWithValidClasses);
            // Ask again, since zombies will have been removed.
            allInstancesWithValidClasses = dtoRepos.AllInstancesWithValidClasses().ToList();
            RemoveDanglingReferences(dtoRepos, allInstancesWithValidClasses);
            // Get rid of all property elements that are empty,
            // since the xml loader code isn't happy with certain empty elements.
            RemoveEmptyPropertyElements(dtoRepos, allInstancesWithValidClasses);
        }
コード例 #2
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);
        }
コード例 #3
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);
		}
コード例 #4
0
        private List <string> ProcessExternalLinksRelativePaths(IDomainObjectDTORepository dtoRepos, String linkedFilesRootDir)
        {
            var filePathsInTsStrings = new List <string>();

            foreach (var dto in dtoRepos.AllInstancesWithValidClasses())              //Get the Elements for all CmObjects
            {
                if (dto.XmlBytes.IndexOfSubArray(externalLinkTag) < 0)
                {
                    continue;
                }
                var dtoXML = XElement.Parse(dto.Xml);
                foreach (var runXMLElement in dtoXML.XPathSelectElements("//Run"))
                {
                    var externalLinkAttributeForThisRun = runXMLElement.Attribute("externalLink");
                    if (externalLinkAttributeForThisRun != null)
                    {
                        try
                        {
                            //Convert the file paths which should be stored as relative paths
                            if (Path.IsPathRooted(FileUtils.ChangeWindowsPathIfLinux(externalLinkAttributeForThisRun.Value)))
                            {
                                var filePath = FileUtils.ChangeWindowsPathIfLinux(externalLinkAttributeForThisRun.Value);
                                //Check the path and if it is a rooted path which is relative to the LinkedFilesRootDir
                                //then we will have to confirm that is was changed to a relative path after the migration.
                                var fileAsRelativePath = LinkedFilesRelativePathHelper.GetRelativeLinkedFilesPath(filePath,
                                                                                                                  linkedFilesRootDir);
                                //Save the file paths so they can be turned into CmFiles
                                filePathsInTsStrings.Add(fileAsRelativePath);
                                //If these two strings do not match then a full path was converted to a LinkedFiles relative path
                                //so replace the path in the CmFile object.
                                if (!String.Equals(fileAsRelativePath, filePath))
                                {
                                    runXMLElement.Attribute("externalLink").Value = fileAsRelativePath;
                                    UpdateDto(dtoRepos, dto, dtoXML);
                                }
                            }
                            else
                            {
                                //if the file path was already relative we want to save it and turn it into a CmFiles
                                if (FileUtils.IsFileUriOrPath(externalLinkAttributeForThisRun.Value) && FileUtils.IsFilePathValid(externalLinkAttributeForThisRun.Value))
                                {
                                    filePathsInTsStrings.Add(externalLinkAttributeForThisRun.Value);
                                }
                            }
                        }
                        catch (ArgumentException)
                        {
                            Logger.WriteEvent("Invalid path for external link - no CmFile created: " + externalLinkAttributeForThisRun);
                        }
                    }
                }
            }
            return(filePathsInTsStrings);
        }
コード例 #5
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);
		}
コード例 #6
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);
        }
コード例 #7
0
		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000036);

			string path = domainObjectDtoRepository.ProjectFolder;
			string project = Path.GetFileName(path);

			foreach (var dto in domainObjectDtoRepository.AllInstancesWithValidClasses())
			{
				if (dto.XmlBytes.IndexOfSubArray(s_externalLinkTag) < 0)
					continue;
				XElement xel = XElement.Parse(dto.Xml);
				if (FixExternalLinks(xel, project))
					DataMigrationServices.UpdateDTO(domainObjectDtoRepository, dto, xel.ToString());
			}

			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
コード例 #8
0
		private void CollectionNonSilfwLinks(IDomainObjectDTORepository dtoRepos)
		{
			foreach (var dto in dtoRepos.AllInstancesWithValidClasses())
			{
				string xml = dto.Xml;
				Assert.IsTrue(xml.Contains("externalLink"), "Every object in the test has an externalLink");
				var dtoXML = XElement.Parse(xml);
				foreach (var run in dtoXML.XPathSelectElements("//Run"))
				{
					var externalLinkAttr = run.Attribute("externalLink");
					if (externalLinkAttr != null)
					{
						string value = externalLinkAttr.Value;
						if (value.StartsWith("http://") || value.StartsWith("libronixdls:"))
							m_rgsOtherLinks.Add(value);
						++m_cLinks;
					}
				}
			}

		}
コード例 #9
0
 private void VerifyNoDirectFormatting(IDomainObjectDTORepository repoDTO)
 {
     byte[] rgbRun = Encoding.UTF8.GetBytes("<Run ");
     foreach (DomainObjectDTO dto in repoDTO.AllInstancesWithValidClasses())
     {
         if (dto.XmlBytes.IndexOfSubArray(rgbRun) <= 0)
         {
             continue;
         }
         XElement xeObj = XElement.Parse(dto.Xml);
         foreach (XElement xe in xeObj.Descendants("Run"))
         {
             foreach (XAttribute xa in xe.Attributes())
             {
                 Assert.IsTrue(xa.Name.LocalName == "ws" ||
                               xa.Name.LocalName == "namedStyle" ||
                               xa.Name.LocalName == "externalLink",
                               "only ws, namedStyle, and externalLink should exist as Run attributes in the test data");
             }
         }
     }
     byte[] rgbStyleRules = Encoding.UTF8.GetBytes("<StyleRules>");
     foreach (DomainObjectDTO dto in repoDTO.AllInstancesWithSubclasses("StTxtPara"))
     {
         if (dto.XmlBytes.IndexOfSubArray(rgbStyleRules) <= 0)
         {
             continue;
         }
         XElement xeObj = XElement.Parse(dto.Xml);
         foreach (XElement xe in xeObj.Descendants("Prop"))
         {
             foreach (XAttribute xa in xe.Attributes())
             {
                 Assert.AreEqual("namedStyle", xa.Name.LocalName,
                                 "Direct formatting of paragraphs should not exist (" + xa.Name + ")");
             }
         }
     }
 }
コード例 #10
0
 private void CollectionNonSilfwLinks(IDomainObjectDTORepository dtoRepos)
 {
     foreach (var dto in dtoRepos.AllInstancesWithValidClasses())
     {
         string xml = dto.Xml;
         Assert.IsTrue(xml.Contains("externalLink"), "Every object in the test has an externalLink");
         var dtoXML = XElement.Parse(xml);
         foreach (var run in dtoXML.XPathSelectElements("//Run"))
         {
             var externalLinkAttr = run.Attribute("externalLink");
             if (externalLinkAttr != null)
             {
                 string value = externalLinkAttr.Value;
                 if (value.StartsWith("http://") || value.StartsWith("libronixdls:"))
                 {
                     m_rgsOtherLinks.Add(value);
                 }
                 ++m_cLinks;
             }
         }
     }
 }
コード例 #11
0
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000036);

            string path    = domainObjectDtoRepository.ProjectFolder;
            string project = Path.GetFileName(path);

            foreach (var dto in domainObjectDtoRepository.AllInstancesWithValidClasses())
            {
                if (dto.XmlBytes.IndexOfSubArray(s_externalLinkTag) < 0)
                {
                    continue;
                }
                XElement xel = XElement.Parse(dto.Xml);
                if (FixExternalLinks(xel, project))
                {
                    DataMigrationServices.UpdateDTO(domainObjectDtoRepository, dto, xel.ToString());
                }
            }

            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
コード例 #12
0
		/// <summary>
		///	1. Remove objects (zombies) that:
		///		A. claim to have owners, but the owners do not exist, or
		///		B. owners don't know they own it, or
		///		C. objects with no owners that are not supported as allowing no owners.
		///	2. Remove 'dangling' references to objects that no longer exist.
		/// 3. Remove properties that have no attributes or content.
		/// </summary>
		internal static void Delint(IDomainObjectDTORepository dtoRepos)
		{
			// Remove zombies.
			// By removing zombies first, any references to them will be 'dangling',
			// so can be removed in the following step.
			var allInstancesWithValidClasses = dtoRepos.AllInstancesWithValidClasses().ToList();
			RemoveZombies(dtoRepos, allInstancesWithValidClasses);
			// Ask again, since zombies will have been removed.
			allInstancesWithValidClasses = dtoRepos.AllInstancesWithValidClasses().ToList();
			RemoveDanglingReferences(dtoRepos, allInstancesWithValidClasses);
			// Get rid of all property elements that are empty,
			// since the xml loader code isn't happy with certain empty elements.
			RemoveEmptyPropertyElements(dtoRepos, allInstancesWithValidClasses);
		}
コード例 #13
0
		private void VerifyNoDirectFormatting(IDomainObjectDTORepository repoDTO)
		{
			byte[] rgbRun = Encoding.UTF8.GetBytes("<Run ");
			foreach (DomainObjectDTO dto in repoDTO.AllInstancesWithValidClasses())
			{
				if (dto.XmlBytes.IndexOfSubArray(rgbRun) <= 0)
					continue;
				XElement xeObj = XElement.Parse(dto.Xml);
				foreach (XElement xe in xeObj.Descendants("Run"))
				{
					foreach (XAttribute xa in xe.Attributes())
					{
						Assert.IsTrue(xa.Name.LocalName == "ws" ||
							xa.Name.LocalName == "namedStyle" ||
							xa.Name.LocalName == "externalLink",
							"only ws, namedStyle, and externalLink should exist as Run attributes in the test data");
					}
				}
			}
			byte[] rgbStyleRules = Encoding.UTF8.GetBytes("<StyleRules>");
			foreach (DomainObjectDTO dto in repoDTO.AllInstancesWithSubclasses("StTxtPara"))
			{
				if (dto.XmlBytes.IndexOfSubArray(rgbStyleRules) <= 0)
					continue;
				XElement xeObj = XElement.Parse(dto.Xml);
				foreach (XElement xe in xeObj.Descendants("Prop"))
				{
					foreach (XAttribute xa in xe.Attributes())
					{
						Assert.AreEqual("namedStyle", xa.Name.LocalName,
							"Direct formatting of paragraphs should not exist (" + xa.Name + ")");
					}
				}
			}
		}
コード例 #14
0
		private List<string> ProcessExternalLinksRelativePaths(IDomainObjectDTORepository dtoRepos, String linkedFilesRootDir)
		{
			var filePathsInTsStrings = new List<string>();
			foreach (var dto in dtoRepos.AllInstancesWithValidClasses())  //Get the Elements for all CmObjects
			{
				if (dto.XmlBytes.IndexOfSubArray(externalLinkTag) < 0)
					continue;
				var dtoXML = XElement.Parse(dto.Xml);
				foreach (var runXMLElement in dtoXML.XPathSelectElements("//Run"))
				{
					var externalLinkAttributeForThisRun = runXMLElement.Attribute("externalLink");
					if (externalLinkAttributeForThisRun != null)
					{
						try
						{

						//Convert the file paths which should be stored as relative paths
						if (Path.IsPathRooted(FileUtils.ChangeWindowsPathIfLinux(externalLinkAttributeForThisRun.Value)))
						{
							var filePath = FileUtils.ChangeWindowsPathIfLinux(externalLinkAttributeForThisRun.Value);
							//Check the path and if it is a rooted path which is relative to the LinkedFilesRootDir
							//then we will have to confirm that is was changed to a relative path after the migration.
							var fileAsRelativePath = LinkedFilesRelativePathHelper.GetRelativeLinkedFilesPath(filePath,
																											 linkedFilesRootDir);
							//Save the file paths so they can be turned into CmFiles
							filePathsInTsStrings.Add(fileAsRelativePath);
							//If these two strings do not match then a full path was converted to a LinkedFiles relative path
							//so replace the path in the CmFile object.
							if (!String.Equals(fileAsRelativePath, filePath))
							{
								runXMLElement.Attribute("externalLink").Value = fileAsRelativePath;
								UpdateDto(dtoRepos, dto, dtoXML);
							}
						}
						else
						{
							//if the file path was already relative we want to save it and turn it into a CmFiles
							if (FileUtils.IsFileUriOrPath(externalLinkAttributeForThisRun.Value) && FileUtils.IsFilePathValid(externalLinkAttributeForThisRun.Value))
								filePathsInTsStrings.Add(externalLinkAttributeForThisRun.Value);
						}
						}
						catch (ArgumentException)
						{
							Logger.WriteEvent("Invalid path for external link - no CmFile created: " + externalLinkAttributeForThisRun);
						}
					}
				}
			}
			return filePathsInTsStrings;
		}