/// <summary>
		/// Updates the Data Notebook RecordTypes possibilities to use specific GUIDs.
		/// </summary>
		/// <param name="domainObjectDtoRepository">Repository of all CmObject DTOs available for one migration step.</param>
		public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
		{
			DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000010);

			DomainObjectDTO nbkDto = domainObjectDtoRepository.AllInstancesSansSubclasses("RnResearchNbk").First();
			XElement nbkElem = XElement.Parse(nbkDto.Xml);
			var recTypesGuid = (string) nbkElem.XPathSelectElement("RnResearchNbk/RecTypes/objsur").Attribute("guid");
			var stack = new Stack<DomainObjectDTO>(domainObjectDtoRepository.GetDirectlyOwnedDTOs(recTypesGuid));
			IEnumerable<DomainObjectDTO> recDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("RnGenericRec");
			IEnumerable<DomainObjectDTO> overlayDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("CmOverlay");
			while (stack.Count > 0)
			{
				DomainObjectDTO dto = stack.Pop();
				foreach (DomainObjectDTO childDto in domainObjectDtoRepository.GetDirectlyOwnedDTOs(dto.Guid))
					stack.Push(childDto);
				XElement posElem = XElement.Parse(dto.Xml);
				XElement uniElem = posElem.XPathSelectElement("CmPossibility/Abbreviation/AUni[@ws='en']");
				if (uniElem != null)
				{
					string newGuid = null;
					switch (uniElem.Value)
					{
						case "Con":
							newGuid = "B7B37B86-EA5E-11DE-80E9-0013722F8DEC";
							break;
						case "Intv":
							newGuid = "B7BF673E-EA5E-11DE-9C4D-0013722F8DEC";
							break;
						case "Str":
							newGuid = "B7C8F092-EA5E-11DE-8D7D-0013722F8DEC";
							break;
						case "Uns":
							newGuid = "B7D4DC4A-EA5E-11DE-867C-0013722F8DEC";
							break;
						case "Lit":
							newGuid = "B7E0C7F8-EA5E-11DE-82CC-0013722F8DEC";
							break;
						case "Obs":
							newGuid = "B7EA5156-EA5E-11DE-9F9C-0013722F8DEC";
							break;
						case "Per":
							newGuid = "B7F63D0E-EA5E-11DE-9F02-0013722F8DEC";
							break;
						case "Ana":
							newGuid = "82290763-1633-4998-8317-0EC3F5027FBD";
							break;
					}
					if (newGuid != null)
						DataMigrationServices.ChangeGuid(domainObjectDtoRepository, dto, newGuid, recDtos.Concat(overlayDtos));
				}
			}

			DomainObjectDTO recTypesDto = domainObjectDtoRepository.GetDTO(recTypesGuid);
			DataMigrationServices.ChangeGuid(domainObjectDtoRepository, recTypesDto, "D9D55B12-EA5E-11DE-95EF-0013722F8DEC", overlayDtos);
			DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
		}
Example #2
0
 /// <summary>
 /// Remove a number of objects with a common owner, and everything they own.
 /// </summary>
 internal static void RemoveMultipleIncludingOwnedObjects(IDomainObjectDTORepository dtoRepos,
                                                          List <DomainObjectDTO> goners, DomainObjectDTO ownerDto)
 {
     if (ownerDto != null)
     {
         var ownerElement = XElement.Parse(ownerDto.Xml);
         foreach (var goner in goners)
         {
             var goner1           = goner;
             var ownObjSurElement = (from objSurNode in ownerElement.Descendants("objsur")
                                     where
                                     objSurNode.Attribute("t").Value == "o" &&
                                     objSurNode.Attribute("guid").Value.ToLower() == goner1.Guid.ToLower()
                                     select objSurNode).FirstOrDefault();                                             // Ought not be null, but play it safe.
             if (ownObjSurElement != null)
             {
                 ownObjSurElement.Remove();
             }
         }
         if (!RemoveEmptyPropertyElements(dtoRepos, ownerDto, ownerElement))
         {
             // No empty property elememtns removed, so we have to do the update.
             UpdateDTO(dtoRepos, ownerDto, ownerElement.ToString());
         }
     }
     foreach (var goner in goners)
     {
         foreach (var ownedDto in dtoRepos.GetDirectlyOwnedDTOs(goner.Guid))
         {
             RemoveIncludingOwnedObjects(dtoRepos, ownedDto, false);
         }
         dtoRepos.Remove(goner);
     }
 }
		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);
		}
        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);
        }
Example #5
0
 /// <summary>
 /// Add to weatherItems the guids of all the things owned directly or indirectly by dtoRoot.
 /// Does not include the root itself.
 /// </summary>
 private void CollectItems(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoRoot, HashSet <string> guidCollector)
 {
     foreach (var dto in repoDTO.GetDirectlyOwnedDTOs(dtoRoot.Guid))
     {
         guidCollector.Add(dto.Guid);
         CollectItems(repoDTO, dto, guidCollector);
     }
 }
Example #6
0
 private void GatherDeadObjects(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoDead,
                                List <DomainObjectDTO> rgdtoDead)
 {
     rgdtoDead.Add(dtoDead);
     foreach (var dto in repoDTO.GetDirectlyOwnedDTOs(dtoDead.Guid))
     {
         GatherDeadObjects(repoDTO, dto, rgdtoDead);
     }
 }
		void ChangeClassOfOwnerAndChildren(IDomainObjectDTORepository dtoRepo, DomainObjectDTO dtoToChange, string oldClassname, string newClassname)
		{
			// bail out if we've already changed the class name (assume we've already changed its children too).
			if (!TryChangeOwnerClass(dtoRepo, dtoToChange, oldClassname, newClassname))
				return;
			foreach (var dtoChild in dtoRepo.GetDirectlyOwnedDTOs(dtoToChange.Guid))
			{
				ChangeClassOfOwnerAndChildren(dtoRepo, dtoChild, oldClassname, newClassname);
			}
		}
Example #8
0
 void ChangeClassOfOwnerAndChildren(IDomainObjectDTORepository dtoRepo, DomainObjectDTO dtoToChange, string oldClassname, string newClassname)
 {
     // bail out if we've already changed the class name (assume we've already changed its children too).
     if (!TryChangeOwnerClass(dtoRepo, dtoToChange, oldClassname, newClassname))
     {
         return;
     }
     foreach (var dtoChild in dtoRepo.GetDirectlyOwnedDTOs(dtoToChange.Guid))
     {
         ChangeClassOfOwnerAndChildren(dtoRepo, dtoChild, oldClassname, newClassname);
     }
 }
Example #9
0
        private void VerifyOwner(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoTest, string sguidOwner)
        {
            bool fFound = false;

            foreach (DomainObjectDTO dto in repoDTO.GetDirectlyOwnedDTOs(sguidOwner))
            {
                if (dto.Guid == dtoTest.Guid && dto.Xml == dtoTest.Xml)
                {
                    fFound = true;
                    break;
                }
            }
            Assert.IsTrue(fFound);
        }
 /// <summary>
 /// Verify that every LexEntryType points back to a valid owner after migration, and that
 /// the owner points to the LexEntryType.
 /// </summary>
 /// <param name="repoDto"></param>
 private static void VerifyEntryTypeOwners(IDomainObjectDTORepository repoDto)
 {
     foreach (var dto in repoDto.AllInstancesWithSubclasses("LexEntryType"))
     {
         DomainObjectDTO dtoOwner;
         Assert.IsTrue(repoDto.TryGetOwner(dto.Guid, out dtoOwner), "All entry types should have valid owners!");
         DomainObjectDTO dtoOwnedOk = null;
         foreach (var dtoT in repoDto.GetDirectlyOwnedDTOs(dtoOwner.Guid))
         {
             if (dtoT == dto)
             {
                 dtoOwnedOk = dtoT;
                 break;
             }
         }
         Assert.AreEqual(dto, dtoOwnedOk, "The owner should own the entry type!");
     }
 }
Example #11
0
        /// <summary>
        /// Remove <paramref name="goner"/> and everything it owns.
        /// Be sure to include removing goner from its optional owning property.
        /// </summary>
        internal static void RemoveIncludingOwnedObjects(IDomainObjectDTORepository dtoRepos, DomainObjectDTO goner, bool removeFromOwner)
        {
            DomainObjectDTO gonerActual;

            if (!dtoRepos.TryGetValue(goner.Guid, out gonerActual))
            {
                return;                 // Not in repos.
            }
            if (removeFromOwner)
            {
                var ownerDto = dtoRepos.GetOwningDTO(goner);
                if (ownerDto != null)
                {
                    var ownerElement     = XElement.Parse(ownerDto.Xml);
                    var ownObjSurElement = (from objSurNode in ownerElement.Descendants("objsur")
                                            where objSurNode.Attribute("t").Value == "o" && objSurNode.Attribute("guid").Value.ToLower() == goner.Guid.ToLower()
                                            select objSurNode).FirstOrDefault();                                             // Ought not be null, but play it safe.
                    if (ownObjSurElement != null)
                    {
                        ownObjSurElement.Remove();
                    }

                    if (!RemoveEmptyPropertyElements(dtoRepos, ownerDto, ownerElement))
                    {
                        // No empty property elements removed, so we have to do the update.
                        UpdateDTO(dtoRepos, ownerDto, ownerElement.ToString());
                    }
                }
            }

            foreach (var ownedDto in dtoRepos.GetDirectlyOwnedDTOs(goner.Guid))
            {
                RemoveIncludingOwnedObjects(dtoRepos, ownedDto, false);
            }

            dtoRepos.Remove(goner);
        }
Example #12
0
        /// <summary>
        /// Changes the GUID of the specified DTO. It updates the owner and all specified referrers to point to the new GUID.
        /// </summary>
        /// <param name="dtoRepos">The dto repos.</param>
        /// <param name="dto">The dto.</param>
        /// <param name="newGuid">The new GUID.</param>
        /// <param name="possibleReferrers">The possible referrers.</param>
        internal static void ChangeGuid(IDomainObjectDTORepository dtoRepos, DomainObjectDTO dto, string newGuid,
                                        IEnumerable <DomainObjectDTO> possibleReferrers)
        {
            // if the DTO already has the new GUID, don't do anything
            if (dto.Guid.ToLowerInvariant() == newGuid.ToLowerInvariant())
            {
                return;
            }

            XElement rtElem = XElement.Parse(dto.Xml);

            rtElem.Attribute("guid").Value = newGuid;
            dtoRepos.Add(new DomainObjectDTO(newGuid, dto.Classname, rtElem.ToString()));
            foreach (DomainObjectDTO ownedDto in dtoRepos.GetDirectlyOwnedDTOs(dto.Guid))
            {
                XElement ownedElem = XElement.Parse(ownedDto.Xml);
                ownedElem.Attribute("ownerguid").Value = newGuid;
                UpdateDTO(dtoRepos, ownedDto, ownedElem.ToString());
            }

            var ownerDto = dtoRepos.GetOwningDTO(dto);

            if (ownerDto != null)
            {
                UpdateObjSurElement(dtoRepos, ownerDto, dto.Guid, newGuid);
            }

            if (possibleReferrers != null)
            {
                foreach (DomainObjectDTO referrer in possibleReferrers)
                {
                    UpdateObjSurElement(dtoRepos, referrer, dto.Guid, newGuid);
                }
            }
            dtoRepos.Remove(dto);
        }
		private void GatherDeadObjects(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoDead,
			List<DomainObjectDTO> rgdtoDead)
		{
			rgdtoDead.Add(dtoDead);
			foreach (var dto in repoDTO.GetDirectlyOwnedDTOs(dtoDead.Guid))
				GatherDeadObjects(repoDTO, dto, rgdtoDead);
		}
		private void FixOwnershipOfSubtypes(IDomainObjectDTORepository repoDto)
		{
			var types = repoDto.AllInstancesWithSubclasses("LexEntryType");
			var cFixedFirst = 0;
			foreach (var dto in types)
			{
				var xml = dto.Xml;
				var fFixed = false;
				foreach (var badGuid in m_mapBadGoodGuids.Keys)
				{
					if (xml.Contains(badGuid))
					{
						var bad = String.Format("guid=\"{0}\"", badGuid);
						var good = String.Format("guid=\"{0}\"", m_mapBadGoodGuids[badGuid]);
						xml = xml.Replace(bad, good);
						var bad2 = String.Format("guid='{0}'", badGuid);
						var good2 = String.Format("guid='{0}'", m_mapBadGoodGuids[badGuid]);
						xml = xml.Replace(bad2, good2);	// probably pure paranoia...
						fFixed = true;
					}
				}
				if (fFixed)
				{
					dto.Xml = xml;
					repoDto.Update(dto);
					++cFixedFirst;
				}
				var cFixed = 0;
				foreach (var dtoSub in repoDto.GetDirectlyOwnedDTOs(dto.Guid))
				{
					DomainObjectDTO dtoOwner;
					if (!repoDto.TryGetOwner(dtoSub.Guid, out dtoOwner) || dtoOwner != dto)
					{
						// we have a broken ownership link -- fix it!
						var xeSub = XElement.Parse(dtoSub.Xml);
						var xaOwner = xeSub.Attribute("ownerguid");
						if (xaOwner == null)
							xeSub.Add(new XAttribute("ownerguid", dto.Guid));
						else
							xaOwner.Value = dto.Guid;
						dtoSub.Xml = xeSub.ToString();
						repoDto.Update(dtoSub);
						++cFixed;
					}
				}
			}
		}
		/// <summary>
		/// Verify that every LexEntryType points back to a valid owner after migration, and that
		/// the owner points to the LexEntryType.
		/// </summary>
		/// <param name="repoDto"></param>
		private static void VerifyEntryTypeOwners(IDomainObjectDTORepository repoDto)
		{
			foreach (var dto in repoDto.AllInstancesWithSubclasses("LexEntryType"))
			{
				DomainObjectDTO dtoOwner;
				Assert.IsTrue(repoDto.TryGetOwner(dto.Guid, out dtoOwner), "All entry types should have valid owners!");
				DomainObjectDTO dtoOwnedOk = null;
				foreach (var dtoT in repoDto.GetDirectlyOwnedDTOs(dtoOwner.Guid))
				{
					if (dtoT == dto)
					{
						dtoOwnedOk = dtoT;
						break;
					}
				}
				Assert.AreEqual(dto, dtoOwnedOk, "The owner should own the entry type!");
			}
		}
		/// <summary>
		/// Remove a number of objects with a common owner, and everything they own.
		/// </summary>
		internal static void RemoveMultipleIncludingOwnedObjects(IDomainObjectDTORepository dtoRepos,
			List<DomainObjectDTO> goners, DomainObjectDTO ownerDto)
		{
			if (ownerDto != null)
			{
				var ownerElement = XElement.Parse(ownerDto.Xml);
				foreach (var goner in goners)
				{
					var goner1 = goner;
					var ownObjSurElement = (from objSurNode in ownerElement.Descendants("objsur")
											where
												objSurNode.Attribute("t").Value == "o" &&
												objSurNode.Attribute("guid").Value.ToLower() == goner1.Guid.ToLower()
											select objSurNode).FirstOrDefault(); // Ought not be null, but play it safe.
					if (ownObjSurElement != null)
						ownObjSurElement.Remove();
				}
				if (!RemoveEmptyPropertyElements(dtoRepos, ownerDto, ownerElement))
				{
					// No empty property elememtns removed, so we have to do the update.
					UpdateDTO(dtoRepos, ownerDto, ownerElement.ToString());
				}
			}
			foreach (var goner in goners)
			{
				foreach (var ownedDto in dtoRepos.GetDirectlyOwnedDTOs(goner.Guid))
					RemoveIncludingOwnedObjects(dtoRepos, ownedDto, false);
				dtoRepos.Remove(goner);
			}
		}
Example #17
0
        /// <summary>
        /// Updates the Data Notebook RecordTypes possibilities to use specific GUIDs.
        /// </summary>
        /// <param name="domainObjectDtoRepository">Repository of all CmObject DTOs available for one migration step.</param>
        public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
        {
            DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000010);

            DomainObjectDTO nbkDto                    = domainObjectDtoRepository.AllInstancesSansSubclasses("RnResearchNbk").First();
            XElement        nbkElem                   = XElement.Parse(nbkDto.Xml);
            var             recTypesGuid              = (string)nbkElem.XPathSelectElement("RnResearchNbk/RecTypes/objsur").Attribute("guid");
            var             stack                     = new Stack <DomainObjectDTO>(domainObjectDtoRepository.GetDirectlyOwnedDTOs(recTypesGuid));
            IEnumerable <DomainObjectDTO> recDtos     = domainObjectDtoRepository.AllInstancesSansSubclasses("RnGenericRec");
            IEnumerable <DomainObjectDTO> overlayDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("CmOverlay");

            while (stack.Count > 0)
            {
                DomainObjectDTO dto = stack.Pop();
                foreach (DomainObjectDTO childDto in domainObjectDtoRepository.GetDirectlyOwnedDTOs(dto.Guid))
                {
                    stack.Push(childDto);
                }
                XElement posElem = XElement.Parse(dto.Xml);
                XElement uniElem = posElem.XPathSelectElement("CmPossibility/Abbreviation/AUni[@ws='en']");
                if (uniElem != null)
                {
                    string newGuid = null;
                    switch (uniElem.Value)
                    {
                    case "Con":
                        newGuid = "B7B37B86-EA5E-11DE-80E9-0013722F8DEC";
                        break;

                    case "Intv":
                        newGuid = "B7BF673E-EA5E-11DE-9C4D-0013722F8DEC";
                        break;

                    case "Str":
                        newGuid = "B7C8F092-EA5E-11DE-8D7D-0013722F8DEC";
                        break;

                    case "Uns":
                        newGuid = "B7D4DC4A-EA5E-11DE-867C-0013722F8DEC";
                        break;

                    case "Lit":
                        newGuid = "B7E0C7F8-EA5E-11DE-82CC-0013722F8DEC";
                        break;

                    case "Obs":
                        newGuid = "B7EA5156-EA5E-11DE-9F9C-0013722F8DEC";
                        break;

                    case "Per":
                        newGuid = "B7F63D0E-EA5E-11DE-9F02-0013722F8DEC";
                        break;

                    case "Ana":
                        newGuid = "82290763-1633-4998-8317-0EC3F5027FBD";
                        break;
                    }
                    if (newGuid != null)
                    {
                        DataMigrationServices.ChangeGuid(domainObjectDtoRepository, dto, newGuid, recDtos.Concat(overlayDtos));
                    }
                }
            }

            DomainObjectDTO recTypesDto = domainObjectDtoRepository.GetDTO(recTypesGuid);

            DataMigrationServices.ChangeGuid(domainObjectDtoRepository, recTypesDto, "D9D55B12-EA5E-11DE-95EF-0013722F8DEC", overlayDtos);
            DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
        }
		/// <summary>
		/// Remove <paramref name="goner"/> and everything it owns.
		/// Be sure to include removing goner from its optional owning property.
		/// </summary>
		internal static void RemoveIncludingOwnedObjects(IDomainObjectDTORepository dtoRepos, DomainObjectDTO goner, bool removeFromOwner)
		{
			DomainObjectDTO gonerActual;
			if (!dtoRepos.TryGetValue(goner.Guid, out gonerActual))
				return; // Not in repos.

			if (removeFromOwner)
			{
				var ownerDto = dtoRepos.GetOwningDTO(goner);
				if (ownerDto != null)
				{
					var ownerElement = XElement.Parse(ownerDto.Xml);
					var ownObjSurElement = (from objSurNode in ownerElement.Descendants("objsur")
											where objSurNode.Attribute("t").Value == "o" && objSurNode.Attribute("guid").Value.ToLower() == goner.Guid.ToLower()
											select objSurNode).FirstOrDefault(); // Ought not be null, but play it safe.
					if (ownObjSurElement != null)
						ownObjSurElement.Remove();

					if (!RemoveEmptyPropertyElements(dtoRepos, ownerDto, ownerElement))
					{
						// No empty property elements removed, so we have to do the update.
						UpdateDTO(dtoRepos, ownerDto, ownerElement.ToString());
					}
				}
			}

			foreach (var ownedDto in dtoRepos.GetDirectlyOwnedDTOs(goner.Guid))
				RemoveIncludingOwnedObjects(dtoRepos, ownedDto, false);

			dtoRepos.Remove(goner);
		}
		/// <summary>
		/// Add to weatherItems the guids of all the things owned directly or indirectly by dtoRoot.
		/// Does not include the root itself.
		/// </summary>
		private void CollectItems(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoRoot, HashSet<string> guidCollector)
		{
			foreach (var dto in repoDTO.GetDirectlyOwnedDTOs(dtoRoot.Guid))
			{
				guidCollector.Add(dto.Guid);
				CollectItems(repoDTO, dto, guidCollector);
			}
		}
		/// <summary>
		/// Changes the GUID of the specified DTO. It updates the owner and all specified referrers to point to the new GUID.
		/// </summary>
		/// <param name="dtoRepos">The dto repos.</param>
		/// <param name="dto">The dto.</param>
		/// <param name="newGuid">The new GUID.</param>
		/// <param name="possibleReferrers">The possible referrers.</param>
		internal static void ChangeGuid(IDomainObjectDTORepository dtoRepos, DomainObjectDTO dto, string newGuid,
			IEnumerable<DomainObjectDTO> possibleReferrers)
		{
			// if the DTO already has the new GUID, don't do anything
			if (dto.Guid.ToLowerInvariant() == newGuid.ToLowerInvariant())
				return;

			XElement rtElem = XElement.Parse(dto.Xml);
			rtElem.Attribute("guid").Value = newGuid;
			dtoRepos.Add(new DomainObjectDTO(newGuid, dto.Classname, rtElem.ToString()));
			foreach (DomainObjectDTO ownedDto in dtoRepos.GetDirectlyOwnedDTOs(dto.Guid))
			{
				XElement ownedElem = XElement.Parse(ownedDto.Xml);
				ownedElem.Attribute("ownerguid").Value = newGuid;
				UpdateDTO(dtoRepos, ownedDto, ownedElem.ToString());
			}

			var ownerDto = dtoRepos.GetOwningDTO(dto);
			if (ownerDto != null)
				UpdateObjSurElement(dtoRepos, ownerDto, dto.Guid, newGuid);

			if (possibleReferrers != null)
			{
				foreach (DomainObjectDTO referrer in possibleReferrers)
					UpdateObjSurElement(dtoRepos, referrer, dto.Guid, newGuid);
			}
			dtoRepos.Remove(dto);
		}
		private void VerifyOwner(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoTest, string sguidOwner)
		{
			bool fFound = false;
			foreach (DomainObjectDTO dto in repoDTO.GetDirectlyOwnedDTOs(sguidOwner))
			{
				if (dto.Guid == dtoTest.Guid && dto.Xml == dtoTest.Xml)
				{
					fFound = true;
					break;
				}
			}
			Assert.IsTrue(fFound);
		}