private SchemaComparableList <ObjectClass> ConstructObjectClassList(List <LdapValue> ocVals, List <LdapValue> crVals) { SchemaComparableList <ObjectClass> ocList = new SchemaComparableList <ObjectClass>(); SchemaComparableList <ContentRule> crList = new SchemaComparableList <ContentRule>(); foreach (LdapValue v in ocVals) { ocList.Add(new ObjectClass(v.StringValue)); } ocList.Sort(); foreach (LdapValue v in crVals) { crList.Add(new ContentRule(v.StringValue)); } crList.Sort(); for (int i = 0, j = 0; i < ocList.Count && j < crList.Count; i++) { if (ocList[i].NameCompareTo(crList[j]) == 0) { ocList[i].MergeContentRule(crList[j]); j++; } } return(ocList); }
public void GetDiffTest() { SchemaComparableList <TestSchemaComparable> scList1 = new SchemaComparableList <TestSchemaComparable>(testList1); SchemaComparableList <TestSchemaComparable> scList2 = new SchemaComparableList <TestSchemaComparable>(testList2); TupleList <TestSchemaComparable, TestSchemaComparable> diff = scList1.GetDiff(scList2); Assert.AreEqual("C-CCC", diff[0].Item1.full); Assert.AreEqual("C-CC", diff[0].Item2.full); Assert.AreEqual("D-DDD", diff[1].Item1.full); Assert.AreEqual("D-DD", diff[1].Item2.full); Assert.IsNull(diff[2].Item1); Assert.AreEqual("E-EEE", diff[2].Item2.full); Assert.AreEqual("F-FFF", diff[3].Item1.full); Assert.IsNull(diff[3].Item2); Assert.AreEqual("G-GGG", diff[4].Item1.full); Assert.IsNull(diff[4].Item2); }
public SchemaMetadataDiff( SchemaComparableList <SchemaEntry> baseAtEntries, SchemaComparableList <SchemaEntry> baseOcEntries, SchemaComparableList <SchemaEntry> otherAtEntries, SchemaComparableList <SchemaEntry> otherOcEntries) { attributeTypeDiff = baseAtEntries.GetDiff(otherAtEntries); objectClassDiff = baseOcEntries.GetDiff(otherOcEntries); }
public SubSchemaSubEntry(ILdapEntry entry) { List <LdapValue> atVals = entry.getAttributeValues(AttributeConstants.ATTRIBUTE_TYPES); List <LdapValue> ocVals = entry.getAttributeValues(AttributeConstants.OBJECT_CLASSES); List <LdapValue> crVals = entry.getAttributeValues(AttributeConstants.DIT_CONTENT_RULES); attributeTypeList = ConstructAttributeTypeList(atVals); objectClassList = ConstructObjectClassList(ocVals, crVals); }
public SchemaEntry(ILdapEntry entry) { LdapValue val = entry.getAttributeValues(AttributeConstants.CN)[0]; defName = val.StringValue; List <LdapValue> vals = entry.getAttributeValues(AttributeConstants.ATTRIBUTE_METADATA); metadataList = ConstructMetadataList(vals); }
private SchemaComparableList <AttributeMetadata> ConstructMetadataList(List <LdapValue> vals) { SchemaComparableList <AttributeMetadata> list = new SchemaComparableList <AttributeMetadata>(); foreach (LdapValue v in vals) { list.Add(new AttributeMetadata(v.StringValue)); } list.Sort(); return(list); }
private SchemaComparableList <AttributeType> ConstructAttributeTypeList(List <LdapValue> atVals) { SchemaComparableList <AttributeType> atList = new SchemaComparableList <AttributeType>(); foreach (LdapValue v in atVals) { atList.Add(new AttributeType(v.StringValue)); } atList.Sort(); return(atList); }
public SchemaDefinitionDiff(SubSchemaSubEntry baseSubSchema, SubSchemaSubEntry otherSubSchema) { SchemaComparableList <AttributeType> baseAtList = baseSubSchema.GetAttributeTypeList(); SchemaComparableList <AttributeType> otherAtList = otherSubSchema.GetAttributeTypeList(); attributeTypeDiff = baseAtList.GetDiff(otherAtList); SchemaComparableList <ObjectClass> baseOcList = baseSubSchema.GetObjectClassList(); SchemaComparableList <ObjectClass> otherOcList = otherSubSchema.GetObjectClassList(); objectClassDiff = baseOcList.GetDiff(otherOcList); }
private static void listSchemaMetadataDiffBreakdown(SchemaEntry e1, SchemaEntry e2) { SchemaComparableList <AttributeMetadata> mdList1 = null; SchemaComparableList <AttributeMetadata> mdList2 = null; if (e1 != null && e2 != null) { mdList1 = e1.GetMetadataList(); mdList2 = e2.GetMetadataList(); TupleList <AttributeMetadata, AttributeMetadata> diff = mdList1.GetDiff(mdList2); Console.WriteLine("\tBASE: {0}", e1.defName); foreach (Tuple <AttributeMetadata, AttributeMetadata> t in diff) { Console.WriteLine("\t\t{0}", t.Item1); } Console.WriteLine("\tOTHE: {0}", e2.defName); foreach (Tuple <AttributeMetadata, AttributeMetadata> t in diff) { Console.WriteLine("\t\t{0}", t.Item2); } } else if (e1 != null) { mdList1 = e1.GetMetadataList(); Console.WriteLine("\tBASE: {0}", e1.defName); foreach (AttributeMetadata md in mdList1) { Console.WriteLine("\t\t{0}", md); } Console.WriteLine("\tOTHE:"); } else { mdList2 = e2.GetMetadataList(); Console.WriteLine("\tBASE:"); Console.WriteLine("\tOTHE: {0}", e2.defName); foreach (AttributeMetadata md in mdList2) { Console.WriteLine("\t\t{0}", md); } } Console.WriteLine("\t-----"); }
public void GetDiffNullArgumentTest() { SchemaComparableList <TestSchemaComparable> scList1 = new SchemaComparableList <TestSchemaComparable>(testList1); try { scList1.GetDiff(null); Assert.Fail(); } catch (ArgumentNullException) { // pass } catch (Exception) { Assert.Fail(); } }
private void listSchemaMetadataDiffBreakdown(SchemaEntry e1, SchemaEntry e2) { SchemaComparableList <AttributeMetadata> mdList1 = null; SchemaComparableList <AttributeMetadata> mdList2 = null; if (e1 != null && e2 != null) { mdList1 = e1.GetMetadataList(); mdList2 = e2.GetMetadataList(); VmDirInterop.Schema.Utils.TupleList <AttributeMetadata, AttributeMetadata> diff = mdList1.GetDiff(mdList2); foreach (VmDirInterop.Schema.Utils.Tuple <AttributeMetadata, AttributeMetadata> t in diff) { //baseMetaData string baseData = (t.item1 != null) ? e1.defName + " : " + t.item1.ToString() : VMDirSchemaConstants.MISING_METADATA; string currentData = (t.item2 != null) ? e1.defName + " : " + t.item2.ToString() : VMDirSchemaConstants.MISING_METADATA; MetaDataDiff.Add(new KeyValuePair <string, string>(baseData, currentData)); } } else if (e1 != null) { mdList1 = e1.GetMetadataList(); foreach (AttributeMetadata md in mdList1) { string baseData = e1.defName + " : " + md; string currentData = VMDirSchemaConstants.MISING_METADATA; MetaDataDiff.Add(new KeyValuePair <string, string>(baseData, currentData)); } } else { mdList2 = e2.GetMetadataList(); foreach (AttributeMetadata md in mdList2) { string currentData = e1.defName + " : " + md; string baseData = VMDirSchemaConstants.MISING_METADATA; MetaDataDiff.Add(new KeyValuePair <string, string>(baseData, currentData)); } } }
public void SchemaComparableListConstructorTest() { SchemaComparableList <TestSchemaComparable> scList1 = new SchemaComparableList <TestSchemaComparable>(testList1); Assert.AreEqual(testList1[0], scList1[0]); Assert.AreEqual(testList1[1], scList1[1]); Assert.AreEqual(testList1[2], scList1[2]); Assert.AreEqual(testList1[3], scList1[3]); Assert.AreEqual(testList1[4], scList1[4]); Assert.AreEqual(testList1[5], scList1[5]); SchemaComparableList <TestSchemaComparable> scList2 = new SchemaComparableList <TestSchemaComparable>(testList2); // Elements are always sorted Assert.AreEqual(testList2[4], scList2[0]); Assert.AreEqual(testList2[0], scList2[1]); Assert.AreEqual(testList2[3], scList2[2]); Assert.AreEqual(testList2[2], scList2[3]); Assert.AreEqual(testList2[1], scList2[4]); }
public SchemaEntry(String defName, IList <AttributeMetadata> metadataList) { this.defName = defName; this.metadataList = new SchemaComparableList <AttributeMetadata>(metadataList); }
public SubSchemaSubEntry(IList <AttributeType> attributeTypes, IList <ObjectClass> objectClasses) { attributeTypeList = new SchemaComparableList <AttributeType>(attributeTypes); objectClassList = new SchemaComparableList <ObjectClass>(objectClasses); }