public void Test_mapping_complex_type_with_one_attribute_to_single_acc() { string mappingFile = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_complex_type_with_one_attribute_to_single_acc\mapping.mfd"); string[] schemaFiles = new[] { TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_complex_type_with_one_attribute_to_single_acc\source.xsd") }; new MappingImporter(new[] { mappingFile }, schemaFiles, ccLibrary, bLibrary, DocLibraryName, BieLibraryName, BdtLibraryName, Qualifier, RootElementName, cctsRepository).ImportMapping(); var bieLibrary = ShouldContainBieLibrary(BieLibraryName); IBdtLibrary bdtLibrary = ShouldContainBdtLibrary(BdtLibraryName); IBdt bdtText = ShouldContainBdt(bdtLibrary, "String_Text", "Text", null); Assert.That(bdtLibrary.Bdts.Count(), Is.EqualTo(1)); IAbie bieAddress = ShouldContainAbie(bieLibrary, "AddressType_Address", "Address", new[] { new BbieDescriptor("Town_CityName", bdtText.Id) }, null); var docLibrary = ShouldContainDocLibrary(DocLibraryName); ShouldContainMa(docLibrary, "test_Invoice", new[] { new AsmaDescriptor("Address", bieAddress.Id), }); }
public void Test_mapping_with_semisemantic_loss() { string mappingFile = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_with_semisemantic_loss\mapping.mfd"); string[] schemaFiles = new[] { TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_with_semisemantic_loss\source.xsd") }; new MappingImporter(new[] { mappingFile }, schemaFiles, ccLibrary, bLibrary, DocLibraryName, BieLibraryName, BdtLibraryName, Qualifier, RootElementName, cctsRepository).ImportMapping(); var bieLibrary = ShouldContainBieLibrary(BieLibraryName); var docLibrary = ShouldContainDocLibrary(DocLibraryName); IBdtLibrary bdtLibrary = ShouldContainBdtLibrary(BdtLibraryName); IBdt bdtText = ShouldContainBdt(bdtLibrary, "String_Text", "Text", null); Assert.That(bdtLibrary.Bdts.Count(), Is.EqualTo(1)); IAbie bieAddress = ShouldContainAbie(bieLibrary, "AddressType_Address", "Address", new[] { new BbieDescriptor("StreetName_StreetName", bdtText.Id), new BbieDescriptor("Town_CityName", bdtText.Id) }, null); IAbie biePerson = ShouldContainAbie(bieLibrary, "PersonType_Party", "Party", new[] { new BbieDescriptor("FirstName_Name", bdtText.Id), new BbieDescriptor("LastName_Name", bdtText.Id) }, new[] { new AsbieDescriptor("HomeAddress_Residence", bieAddress.Id), new AsbieDescriptor("WorkAddress_Residence", bieAddress.Id) }); ShouldContainMa(docLibrary, "test_Invoice", new[] { new AsmaDescriptor("Person", biePerson.Id), }); }
private void buttonGenerateBDT_Click(object sender, EventArgs e) { GatherUserInput(); if ((cache.PathIsValid(CacheConstants.PATH_CDTs, new[] { selectedCDTLName, selectedCDTName })) && (cache.PathIsValid(CacheConstants.PATH_BDTLs, new[] { selectedBDTLName }))) { ICdt cdt = repository.GetCdtById(cache.CDTLs[selectedCDTLName].CDTs[selectedCDTName].Id); IBdtLibrary bdtl = repository.GetBdtLibraryById(cache.BDTLs[selectedBDTLName].Id); BdtSpec bdtSpec = BdtSpec.CloneCdt(cdt, textBDTName.Text); var sups = new List <BdtSupSpec>(bdtSpec.Sups); foreach (cSUP sup in cache.CDTLs[selectedCDTLName].CDTs[selectedCDTName].SUPs.Values) { if (sup.State == CheckState.Unchecked) { var name = sup.Name; sups.RemoveAll(s => s.Name == name); } } bdtSpec.Sups = sups; IBdt newBDT = bdtl.CreateBdt(bdtSpec); cache.BDTLs[selectedBDTLName].BDTs.Add(newBDT.Name, new cBDT(newBDT.Name, newBDT.Id, newBDT.BasedOn.Id, CheckState.Unchecked)); textBDTName.Text = ""; textBDTName.Text = newBDT.Name; } }
private static void AssertHasSUP(IImporterContext context, IBdt bdtText, int index, string basicTypeName, string name) { var expectedBasicType = context.PRIMLibrary.GetPrimByName(basicTypeName); var sup = bdtText.Sups.ElementAt(index); Assert.That(sup.Name, Is.EqualTo(name)); Assert.That(sup.BasicType.Id, Is.EqualTo(expectedBasicType.Id)); }
public static string getConBasicTypeName(IBdt bdt) { if (bdt.Con != null && bdt.Con.BasicType != null) { return(TrimElementName(GetBasicTypeName(bdt.Con as UpccAttribute))); } return("Error_No_BasicType"); }
private static void AssertBDTIsBasedOn(IImporterContext context, IBdt bdt, string cdtName) { var cdt = context.CDTLibrary.GetCdtByName(cdtName); Assert.That(bdt.BasedOn, Is.Not.Null, "BasedOn is null"); Assert.That(bdt.BasedOn, Is.Not.Null, "BasedOn.CDT is null"); Assert.That(bdt.BasedOn.Id, Is.EqualTo(cdt.Id), string.Format("Based on wrong CDT:\nExpected: <{0}>\nBut was: <{1}>", cdt.Name, bdt.BasedOn.Name)); }
public PotentialBdt(string newBdtName) { mName = newBdtName; mChecked = false; mOriginalBDT = null; mItemReadOnly = false; mItemCursor = Cursors.IBeam; mItemFocusable = true; }
public PotentialBdt(IBdt originalBdt) { mName = originalBdt.Name; mChecked = false; mOriginalBDT = originalBdt; mItemReadOnly = true; mItemCursor = Cursors.Arrow; mItemFocusable = false; }
private static IBdt AssertThatBDTLibraryContainsBDT(IImporterContext context, string bdtName, string conBasicTypeName) { var expectedCONBasicType = context.PRIMLibrary.GetPrimByName(conBasicTypeName); IBdt bdtText = context.BDTLibrary.GetBdtByName(bdtName); Assert.That(bdtText, Is.Not.Null, string.Format("Expected BDT named '{0}' not generated.", bdtName)); Assert.That(bdtText.Con, Is.Not.Null, string.Format("CON of BDT {0} is null", bdtName)); Assert.That(bdtText.Con.BasicType, Is.Not.Null, string.Format("BasicType of BDT {0} is null", bdtName)); Assert.That(bdtText.Con.BasicType.Id, Is.EqualTo(expectedCONBasicType.Id), string.Format("Wrong basic type for CON of BDT {0}:\nExpected: <{1}>\nBut was: <{2}>", bdtName, expectedCONBasicType.Name, bdtText.Con.BasicType.Name)); return(bdtText); }
private void CompileXsdTypesFromBdt(IBdt bdt) { if (!alreadyCompiledTypes.Contains(bdt.Id)) { alreadyCompiledTypes.Add(bdt.Id); XsdType xsdType = AddXsdType(bdt.Name); foreach (IBdtSup sup in bdt.Sups) { xsdType.AddChild(sup.Name); } } }
/// <summary> /// [R A7B8] /// The name of a BDT that uses a primitive to define its content component BVD MUST be /// - the BDT ccts:DataTypeQualifier(s) if any, plus /// - the ccts:DataTypeTerm, plus /// - the primitive type name, /// - followed by the word ‘Type’ /// - with the separators removed and approved abbreviations and acronyms applied. /// Deviation: Separators ('_') are not removed. /// /// [R 90FB] /// The name of a BDT that includes one or more Supplementary Components MUST be: /// - The BDT ccts:DataTypeQualifier(s) if any, plus /// - The ccts:DataTypeTerm, plus /// - The suffix of the Content Component Business Value Domain where the suffix is /// the primitive type name, the code list token, the series of code list tokens, /// or the identifier scheme token. /// plus /// - The ccts:DictionaryEntryName for each Supplementary Component present following the order /// defined in the Data Type Catalogue, plus /// - The suffix that represents the Supplementary Component BVD where the suffix is the primitive /// type name, the code list token, the series of code list tokens, or the identifier scheme token, plus /// - The word ‘Type’. /// - With all separators removed and approved abbreviations and acronyms applied. /// Deviation: Ignoring the SUPs, which means that we name complex types in the same way as simple types. /// Deviation: Separators ('_') are not removed. /// </summary> /// <param name="bdt"></param> /// <returns></returns> public static string GetXsdTypeNameFromBdt(IBdt bdt) { if (bdt == null) { return("Error_No_BDT"); } var bdtToUse = bdt.SourceElement as IBdt; if (bdtToUse == null) { bdtToUse = bdt; } return(TrimElementName(bdtToUse.Name) + "_" + bdtToUse.UniqueIdentifier); }
private static void AssertHasSUPs(IBdt bdtText, int expectedCount) { if (expectedCount > 0) { Assert.That(bdtText.Sups, Is.Not.Null, string.Format("Expected {0} SUPs.", expectedCount)); Assert.That(bdtText.Sups.Count(), Is.EqualTo(expectedCount), string.Format("Wrong number of SUPs")); } else { if (bdtText.Sups != null) { Assert.That(bdtText.Sups.Count(), Is.EqualTo(0), "Expected no SUPs."); } } }
public static BbieSpec CloneBcc(IBcc bcc, IBdt bdt) { return(new BbieSpec { Name = bcc.Name, Bdt = bdt, LowerBound = bcc.LowerBound, UpperBound = bcc.UpperBound, BusinessTerms = new List <string>(bcc.BusinessTerms), Definition = bcc.Definition, LanguageCode = bcc.LanguageCode, SequencingKey = bcc.SequencingKey, UsageRules = new List <string>(bcc.UsageRules), }); }
protected override IEnumerable <BdtSupSpec> SpecifySUPs() { string baseTypeName = Restriction.BaseTypeName.Name; var supAttributes = new SUPXsdAttributes(Restriction.Attributes); IBdt parentBDT = GetBDTByXsdTypeName(baseTypeName); foreach (IBdtSup parentSUP in parentBDT.Sups) { var supSpec = BdtSupSpec.CloneBdtSup(parentSUP); if (!supAttributes.IsProhibited(supSpec)) { supAttributes.ApplyRestrictions(supSpec); yield return(supSpec); } } }
public static BdtSpec CloneBdt(IBdt bdt) { return(new BdtSpec { Name = bdt.Name, IsEquivalentTo = bdt.IsEquivalentTo, BasedOn = bdt.BasedOn, Con = BdtConSpec.CloneBdtCon(bdt.Con), Sups = new List <BdtSupSpec>(bdt.Sups.Convert(o => BdtSupSpec.CloneBdtSup(o))), BusinessTerms = new List <string>(bdt.BusinessTerms), Definition = bdt.Definition, LanguageCode = bdt.LanguageCode, VersionIdentifier = bdt.VersionIdentifier, UsageRules = new List <string>(bdt.UsageRules), }); }
private static IBdt ShouldContainBdt(IBdtLibrary bdtLibrary, string name, string cdtName, string[] generatedSups) { IBdt bdt = bdtLibrary.GetBdtByName(name); Assert.IsNotNull(bdt, "BDT '" + name + "' not generated"); Assert.That(bdt.BasedOn, Is.Not.Null, "BasedOn reference not specified"); Assert.AreEqual(cdtName, bdt.BasedOn.Name, "BasedOn wrong CDT"); if (generatedSups == null || generatedSups.Length == 0) { Assert.That(SupNames(bdt), Is.Empty); } else { Assert.That(SupNames(bdt), Is.EquivalentTo(generatedSups)); } return(bdt); }
private static XmlSchemaAnnotation GetTypeAnnotation(IBdt bdt) { var xml = new XmlDocument(); // Deviation from rule [R BFE5]: Generating only a subset of the defined annotations and added some additional annotations. var annNodes = new List <XmlNode>(); AddAnnotation(xml, annNodes, "UniqueID", bdt.UniqueIdentifier); AddAnnotation(xml, annNodes, "VersionID", bdt.VersionIdentifier); AddAnnotation(xml, annNodes, "DictionaryEntryName", bdt.DictionaryEntryName); AddAnnotation(xml, annNodes, "Definition", bdt.Definition); AddAnnotations(xml, annNodes, "BusinessTermName", bdt.BusinessTerms); AddAnnotation(xml, annNodes, "PropertyTermName", bdt.Name); AddAnnotation(xml, annNodes, "LanguageCode", bdt.LanguageCode); AddAnnotation(xml, annNodes, "AcronymCode", "BDT"); var ann = new XmlSchemaAnnotation(); ann.Items.Add(new XmlSchemaDocumentation { Language = "en", Markup = annNodes.ToArray() }); return(ann); }
public void Test_mapping_single_simple_typed_element_to_bcc() { string mappingFile = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_single_simple_typed_element_to_bcc\mapping.mfd"); string[] schemaFiles = new[] { TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_single_simple_typed_element_to_bcc\source.xsd") }; new MappingImporter(new[] { mappingFile }, schemaFiles, ccLibrary, bLibrary, DocLibraryName, BieLibraryName, BdtLibraryName, Qualifier, RootElementName, cctsRepository).ImportMapping(); var bieLibrary = ShouldContainBieLibrary(BieLibraryName); var docLibrary = ShouldContainDocLibrary(DocLibraryName); IBdtLibrary bdtLibrary = ShouldContainBdtLibrary(BdtLibraryName); IBdt bdtText = ShouldContainBdt(bdtLibrary, "String_Text", "Text", null); Assert.That(bdtLibrary.Bdts.Count(), Is.EqualTo(1)); IAbie bieParty = ShouldContainAbie(bieLibrary, "test_Party", "Party", new[] { new BbieDescriptor("PersonName_Name", bdtText.Id), }, null); ShouldContainMa(docLibrary, "test_Invoice", new[] { new AsmaDescriptor("test_Party", bieParty.Id), }); }
public void RemoveBdt(IBdt bdt) { throw new NotImplementedException(); }
public IBdt UpdateBdt(IBdt element, BdtSpec spec) { throw new NotImplementedException(); }
public UpccBdtCon(IUmlAttribute umlAttribute, IBdt bdt) { UmlAttribute = umlAttribute; Bdt = bdt; }
protected override BdtConSpec SpecifyCON() { IBdt parentBDT = GetBDTByXsdTypeName(Restriction.BaseTypeName.Name); return(ApplyCONRestrictions(BdtConSpec.CloneBdtCon(parentBDT.Con))); }
/// <summary> /// Updates a BDT to match the given <paramref name="specification"/>. /// <param name="bdt">A BDT.</param> /// <param name="specification">A new specification for the given BDT.</param> /// <returns>The updated BDT. Depending on the implementation, this might be the same updated instance or a new instance!</returns> /// </summary> public IBdt UpdateBdt(IBdt bdt, BdtSpec specification) { return(new UpccBdt(UmlPackage.UpdateClass(((UpccBdt)bdt).UmlClass, BdtSpecConverter.Convert(specification)))); }
public UpccBdtSup(IUmlAttribute umlAttribute, IBdt bdt) : base(umlAttribute) { Bdt = bdt; }
/// <summary> /// Returns an array of the names of all SUPs of the given BDT. /// </summary> /// <param name="bdt"></param> /// <returns></returns> private static string[] SupNames(IBdt bdt) { return((from sup in bdt.Sups select sup.Name).ToArray()); }
/// <summary> /// Removes a BDT from this BDTLibrary. /// <param name="bdt">A BDT.</param> /// </summary> public void RemoveBdt(IBdt bdt) { UmlPackage.RemoveClass(((UpccBdt)bdt).UmlClass); }
/// <summary> /// [R A7B8] /// The name of a BDT that uses a primitive to define its content component BVD MUST be /// - the BDT ccts:DataTypeQualifier(s) if any, plus /// - the ccts:DataTypeTerm, plus /// - the primitive type name, /// - followed by the word ‘Type’ /// - with the separators removed and approved abbreviations and acronyms applied. /// Deviation: Separators ('_') are not removed. /// /// [R 90FB] /// The name of a BDT that includes one or more Supplementary Components MUST be: /// - The BDT ccts:DataTypeQualifier(s) if any, plus /// - The ccts:DataTypeTerm, plus /// - The suffix of the Content Component Business Value Domain where the suffix is /// the primitive type name, the code list token, the series of code list tokens, /// or the identifier scheme token. /// plus /// - The ccts:DictionaryEntryName for each Supplementary Component present following the order /// defined in the Data Type Catalogue, plus /// - The suffix that represents the Supplementary Component BVD where the suffix is the primitive /// type name, the code list token, the series of code list tokens, or the identifier scheme token, plus /// - The word ‘Type’. /// - With all separators removed and approved abbreviations and acronyms applied. /// Deviation: Ignoring the SUPs, which means that we name complex types in the same way as simple types. /// Deviation: Separators ('_') are not removed. /// </summary> /// <param name="bdt"></param> /// <returns></returns> public static string GetXsdTypeNameFromBdt(IBdt bdt) { return(bdt.Name + bdt.Con.BasicType.Name + "Type"); }