public void RefColPropertiesAreChangedToRefseq() { var rt = new XElement(SharedConstants.RtTag, new XAttribute(SharedConstants.Class, "CmPossibility"), new XAttribute(SharedConstants.GuidStr, "c1ed6dc8-e382-11de-8a39-0800200c9a66"), new XElement("Restrictions", BaseDomainServices.CreateObjSurElement("0039739a-7fcf-4838-8b75-566b8815a29f", "r"), BaseDomainServices.CreateObjSurElement("00b560a2-9af0-4185-bbeb-c0eb3c5e3769", "r"))); var classData = new Dictionary <string, SortedDictionary <string, byte[]> >(); var data = new SortedDictionary <string, byte[]> { { "c1ed6dc8-e382-11de-8a39-0800200c9a66", SharedConstants.Utf8.GetBytes(rt.ToString()) } }; classData.Add("CmPossibility", data); var guidToClassMapping = new Dictionary <string, string> { { "c1ed6dc8-e382-11de-8a39-0800200c9a66", "CmPossibility" } }; CmObjectNestingService.NestObject(false, rt, classData, guidToClassMapping); var result = rt.ToString(); Assert.IsTrue(result.Contains(SharedConstants.Refcol)); }
public void OneItemInCollectionRemains() { var collData = new XElement("CollectionProperty", BaseDomainServices.CreateObjSurElement("c1ecf889-e382-11de-8a39-0800200c9a66")); DataSortingService.SortCollectionProperties(collData); Assert.AreEqual("CollectionProperty", collData.Name.LocalName); Assert.AreEqual(1, collData.Elements().Count()); Assert.AreEqual("c1ecf889-e382-11de-8a39-0800200c9a66", collData.Element(SharedConstants.Objsur).Attribute(SharedConstants.GuidStr).Value); }
/// <summary> /// Flatten an owned object and add an appropriate objsur to the specified property of the owning object. /// </summary> internal static void FlattenOwnedObject(string pathname, SortedDictionary <string, XElement> sortedData, XElement element, string ownerguid, XContainer owningElement, string propertyName) { FlattenObjectCore(pathname, sortedData, element, ownerguid); // We MUST create the objsur AFTER flattening the object, which may pathologically change its guid. var guid = element.Attribute(SharedConstants.GuidStr).Value.ToLowerInvariant(); BaseDomainServices.RestoreObjsurElement(owningElement, propertyName, BaseDomainServices.CreateObjSurElement(guid)); }
public void CollectionPropertyIsSorted() { var collData = new XElement("CollectionProperty", BaseDomainServices.CreateObjSurElement("c1ecf88b-e382-11de-8a39-0800200c9a66"), BaseDomainServices.CreateObjSurElement("c1ecf88a-e382-11de-8a39-0800200c9a66")); DataSortingService.SortCollectionProperties(collData); Assert.AreEqual("CollectionProperty", collData.Name.LocalName); Assert.AreEqual(2, collData.Elements().Count()); Assert.AreEqual("c1ecf88a-e382-11de-8a39-0800200c9a66", collData.Elements().ElementAt(0).Attribute(SharedConstants.GuidStr).Value); Assert.AreEqual("c1ecf88b-e382-11de-8a39-0800200c9a66", collData.Elements().ElementAt(1).Attribute(SharedConstants.GuidStr).Value); }
private void AddOwnedObjects() { // Add two entries, the first one having a nested entry. var rtGuid = _rt.Attribute(SharedConstants.GuidStr).Value; var data = new SortedDictionary <string, byte[]>(); var entry1 = new XElement(SharedConstants.RtTag, new XAttribute(SharedConstants.Class, "ReversalIndexEntry"), new XAttribute(SharedConstants.GuidStr, "0039739a-7fcf-4838-8b75-566b8815a29f"), new XAttribute(SharedConstants.OwnerGuid, rtGuid)); data.Add("0039739a-7fcf-4838-8b75-566b8815a29f", SharedConstants.Utf8.GetBytes(entry1.ToString())); _guidToClassMapping.Add("0039739a-7fcf-4838-8b75-566b8815a29f", "ReversalIndexEntry"); var subentry1 = new XElement(SharedConstants.RtTag, new XAttribute(SharedConstants.Class, "ReversalIndexEntry"), new XAttribute(SharedConstants.GuidStr, "14a6b4bc-1bb3-4c67-b70c-5a195e411e27"), new XAttribute(SharedConstants.OwnerGuid, "0039739a-7fcf-4838-8b75-566b8815a29f")); data.Add("14a6b4bc-1bb3-4c67-b70c-5a195e411e27", SharedConstants.Utf8.GetBytes(subentry1.ToString())); _guidToClassMapping.Add("14a6b4bc-1bb3-4c67-b70c-5a195e411e27", "ReversalIndexEntry"); var entry2 = new XElement(SharedConstants.RtTag, new XAttribute(SharedConstants.Class, "ReversalIndexEntry"), new XAttribute(SharedConstants.GuidStr, "00b560a2-9af0-4185-bbeb-c0eb3c5e3769"), new XAttribute(SharedConstants.OwnerGuid, rtGuid)); data.Add("00b560a2-9af0-4185-bbeb-c0eb3c5e3769", SharedConstants.Utf8.GetBytes(entry2.ToString())); _guidToClassMapping.Add("00b560a2-9af0-4185-bbeb-c0eb3c5e3769", "ReversalIndexEntry"); _classData.Add("ReversalIndexEntry", data); var entriesElement = new XElement("Entries", BaseDomainServices.CreateObjSurElement("0039739a-7fcf-4838-8b75-566b8815a29f"), BaseDomainServices.CreateObjSurElement("00b560a2-9af0-4185-bbeb-c0eb3c5e3769")); _rt.Add(entriesElement); entriesElement = new XElement("Subentries", BaseDomainServices.CreateObjSurElement("14a6b4bc-1bb3-4c67-b70c-5a195e411e27")); entry1.Add(entriesElement); // Add the POS list, with two possibilities (own-seq prop). const string posListGuid = "fb5e83e5-6576-455d-aba0-0b7a722b9b5d"; var posList = new XElement(SharedConstants.RtTag, new XAttribute(SharedConstants.Class, SharedConstants.CmPossibilityList), new XAttribute(SharedConstants.GuidStr, posListGuid), new XAttribute(SharedConstants.OwnerGuid, rtGuid)); var pos1 = new XElement(SharedConstants.RtTag, new XAttribute(SharedConstants.Class, "PartOfSpeech"), new XAttribute(SharedConstants.GuidStr, "c1ed6dc6-e382-11de-8a39-0800200c9a66"), new XAttribute(SharedConstants.OwnerGuid, posListGuid), new XElement("DateCreated", new XAttribute(SharedConstants.Val, "created"))); var pos2 = new XElement(SharedConstants.RtTag, new XAttribute(SharedConstants.Class, "PartOfSpeech"), new XAttribute(SharedConstants.GuidStr, "c1ed6dc7-e382-11de-8a39-0800200c9a66"), new XAttribute(SharedConstants.OwnerGuid, posListGuid), new XElement("DateCreated", new XAttribute(SharedConstants.Val, "created"))); entriesElement = new XElement("Possibilities", BaseDomainServices.CreateObjSurElement("c1ed6dc6-e382-11de-8a39-0800200c9a66"), BaseDomainServices.CreateObjSurElement("c1ed6dc7-e382-11de-8a39-0800200c9a66")); _guidToClassMapping.Add("c1ed6dc6-e382-11de-8a39-0800200c9a66", "PartOfSpeech"); _guidToClassMapping.Add("c1ed6dc7-e382-11de-8a39-0800200c9a66", "PartOfSpeech"); data = new SortedDictionary <string, byte[]> { { "c1ed6dc6-e382-11de-8a39-0800200c9a66", SharedConstants.Utf8.GetBytes(pos1.ToString()) }, { "c1ed6dc7-e382-11de-8a39-0800200c9a66", SharedConstants.Utf8.GetBytes(pos2.ToString()) } }; _classData.Add("PartOfSpeech", data); posList.Add(entriesElement); entriesElement = new XElement("PartsOfSpeech", BaseDomainServices.CreateObjSurElement(posListGuid)); _guidToClassMapping.Add(posListGuid, SharedConstants.CmPossibilityList); data = new SortedDictionary <string, byte[]> { { posListGuid, SharedConstants.Utf8.GetBytes(posList.ToString()) } }; _classData.Add(SharedConstants.CmPossibilityList, data); _rt.Add(entriesElement); }