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),
            });
        }
        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),
            });
        }
        private ObservableCollection <CheckableTreeViewItem> findChildren(CheckableTreeViewItem parent, IMa root)
        {
            var         tempList   = new ObservableCollection <CheckableTreeViewItem>();
            IEnumerator enumerator = root.Asmas.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var currentAsma = (IAsma)enumerator.Current;
                if (currentAsma.AssociatedBieAggregator.IsAbie)
                {
                    IAbie currentAbie = currentAsma.AssociatedBieAggregator.Abie;
                    if (findAbie(currentAbie.Name, rootElement.CandidateAbies) == null)
                    {
                        rootElement.CandidateAbies.Add(new CandidateAbie(currentAbie,
                                                                         AbieFindChildren(currentAbie)));
                    }
                    var currentItem = new CheckableTreeViewItem(true, currentAbie.Name, idCounter++);
                    currentItem.Children = findChildren(currentItem, currentAbie);
                    currentItem.Parent   = parent;
                    tempList.Add(currentItem);
                }
                else if (currentAsma.AssociatedBieAggregator.IsMa)
                {
                    IMa currentMa = currentAsma.AssociatedBieAggregator.Ma;

                    var currentItem = new CheckableTreeViewItem(currentMa.Name, idCounter++);
                    currentItem.Children = findChildren(currentItem, currentMa);
                    currentItem.Parent   = parent;
                    tempList.Add(currentItem);
                }
            }
            return(tempList);
        }
        public void ShouldLoadTemporaryAbieModelWithExistingAbieInEditMode()
        {
            IAbie abieToBeUpdated = null; // TODO: Initialize to an appropriate value

            target = new TemporaryAbieModel(cctsRepository, abieToBeUpdated);
            Assert.Fail("TODO: Implement code to verify target");
        }
Ejemplo n.º 5
0
        private static bool PruneAbie(IAbie abie)
        {
            if (!alreadyPrunedItems.Contains(abie.Id))
            {
                alreadyPrunedItems.Add(abie.Id);

                List <IAsbie> asbies = new List <IAsbie>(abie.Asbies);

                foreach (IAsbie asbie in asbies)
                {
                    IAbie associatedAbie = asbie.AssociatedAbie;

                    if (PruneAbie(associatedAbie))
                    {
                        abiesToBeRemoved.Add(associatedAbie.Id);
                        abie.RemoveAsbie(asbie);
                    }
                }

                if ((abie.Bbies.Count() + abie.Asbies.Count()) == 0)
                {
                    return(true);
                }

                return(false);
            }
            return(abiesToBeRemoved.Contains(abie.Id));
        }
        public void UpdateAbieTest()
        {
            IAbie abieToBeUpdated = null; // TODO: Initialize to an appropriate value

            target.UpdateAbie(abieToBeUpdated);
            Assert.Fail("A method that does not return a value cannot be verified.");
        }
        private static IAbie ShouldContainAbie(IBieLibrary bieLibrary, string name, string accName, BbieDescriptor[] bbieDescriptors, AsbieDescriptor[] asbieDescriptors)
        {
            IAbie abie = bieLibrary.GetAbieByName(name);

            Assert.IsNotNull(abie, "ABIE '" + name + "' not generated");

            if (accName != null)
            {
                Assert.That(abie.BasedOn, Is.Not.Null, "BasedOn reference not specified");
                Assert.AreEqual(accName, abie.BasedOn.Name, "BasedOn wrong ACC");
            }
            else
            {
                Assert.That(abie.BasedOn, Is.Null, "Unexpected BasedOn reference to ACC '" + abie.BasedOn + "'");
            }

            if (bbieDescriptors == null || bbieDescriptors.Length == 0)
            {
                Assert.That(BbieDescriptors(abie), Is.Empty);
            }
            else
            {
                Assert.That(BbieDescriptors(abie), Is.EquivalentTo(bbieDescriptors));
            }

            if (asbieDescriptors == null || asbieDescriptors.Length == 0)
            {
                Assert.That(AsbieDescriptors(abie), Is.Empty);
            }
            else
            {
                Assert.That(AsbieDescriptors(abie), Is.EquivalentTo(asbieDescriptors));
            }
            return(abie);
        }
 public void ShouldLaunchAndPopulateAbieEditorFormForParticularAbie()
 {
     ICctsRepository cctsRepository = CctsRepositoryFactory.CreateCctsRepository(new EARepositoryAbieEditor());           
     IAbie abieToBeUpdated = cctsRepository.GetAbieByPath(EARepositoryAbieEditor.PathToBIEPerson());
     //IAbie abieToBeUpdated = cctsRepository.GetAbieByPath(EARepositoryAbieEditor.PathToBIEAddress());
     
     var t = new Thread(() => new Application().Run(new AbieEditor(cctsRepository, abieToBeUpdated.Id)));                        
     t.SetApartmentState(ApartmentState.STA);
     t.Start();
     t.Join();
 }
Ejemplo n.º 9
0
        ///<summary>
        ///</summary>
        ///<param name="abieComplexType">
        ///</param>
        ///<param name="allElementDefinitions">
        ///</param>
        ///<returns>
        ///</returns>
        public static IList <AsbieSpec> CumulateAbiesSpecsFromComplexType(ComplexType abieComplexType, IDictionary <string, string> allElementDefinitions)
        {
            IList <AsbieSpec> newAsbieSpecs = new List <AsbieSpec>();

            string abieName = abieComplexType.Name.Substring(0, abieComplexType.Name.Length - 4);

            foreach (Element element in abieComplexType.Items)
            {
                if (!(element.Ref.Name.Equals("")))
                {
                    string associatedABIEName = allElementDefinitions[element.Ref.Name];
                    associatedABIEName = associatedABIEName.Substring(0, associatedABIEName.Length - 4);

                    IAbie associatedAbie = BieLibrary.GetAbieByName(associatedABIEName);

                    string asbieName = NDR.GetAsbieNameFromXsdElement(element, associatedABIEName);

                    AsbieSpec asbieSpec = MatchAsbieToAscc(FindBaseACCForABIE(abieName), asbieName,
                                                           associatedAbie);

                    if (asbieSpec == null)
                    {
                        asbieSpec = CumulateAsbieSpec(element, asbieName, associatedAbie, AggregationKind.Shared);
                    }

                    newAsbieSpecs.Add(asbieSpec);
                }
                else
                {
                    if (element.Type.Prefix.Equals("tns"))
                    {
                        string associatedAbieName = element.Type.Name;
                        associatedAbieName = associatedAbieName.Substring(0, associatedAbieName.Length - 4);

                        IAbie associatedAbie = BieLibrary.GetAbieByName(associatedAbieName);

                        string asbieName = element.Name.Substring(0, element.Name.Length - associatedAbieName.Length);

                        AsbieSpec asbieSpec = MatchAsbieToAscc(FindBaseACCForABIE(abieName), asbieName,
                                                               associatedAbie);

                        if (asbieSpec == null)
                        {
                            asbieSpec = CumulateAsbieSpec(element, asbieName, associatedAbie,
                                                          AggregationKind.Composite);
                        }

                        newAsbieSpecs.Add(asbieSpec);
                    }
                }
            }

            return(newAsbieSpecs);
        }
        public CandidateAbie(IAbie originalAbie)
        {
            mName            = originalAbie.Name;
            mChecked         = false;
            mOriginalAbie    = originalAbie;
            mSelected        = false;
            mPotentialAsbies = null;

            mItemReadOnly  = true;
            mItemCursor    = Cursors.Arrow;
            mItemFocusable = false;
        }
Ejemplo n.º 11
0
        ///<summary>
        ///</summary>
        ///<param name="acc">
        ///</param>
        ///<param name="asbieName">
        ///</param>
        ///<param name="associatedAbie">
        ///</param>
        ///<returns>
        ///</returns>
        private static AsbieSpec MatchAsbieToAscc(IAcc acc, string asbieName, IAbie associatedAbie)
        {
            foreach (IAscc ascc in acc.Asccs)
            {
                if (ascc.Name.Equals(asbieName))
                {
                    return(AsbieSpec.CloneAscc(ascc, asbieName, associatedAbie));
                }
            }

            return(null);
        }
Ejemplo n.º 12
0
        ///<summary>
        ///</summary>
        ///<param name="element">
        ///</param>
        ///<param name="asbieName">
        ///</param>
        ///<param name="associatedAbie">
        ///</param>
        ///<param name="aggregationKind">
        ///</param>
        ///<returns>
        ///</returns>
        public static AsbieSpec CumulateAsbieSpec(Element element, string asbieName, IAbie associatedAbie, AggregationKind aggregationKind)
        {
            AsbieSpec asbieSpec = new AsbieSpec
            {
                AssociatedAbie  = associatedAbie,
                Name            = asbieName,
                LowerBound      = ResolveMinOccurs(element.MinOccurs),
                UpperBound      = ResolveMaxOccurs(element.MaxOccurs),
                AggregationKind = aggregationKind
            };

            return(asbieSpec);
        }
Ejemplo n.º 13
0
 public CandidateAbie(IAbie originalAbie, List <CandidateAbie> potenAbies)
 {
     Name            = originalAbie.Name;
     Checked         = false;
     OriginalAbie    = originalAbie;
     Selected        = false;
     PotentialAbies  = potenAbies;
     PotentialBbies  = null;
     PotentialAsbies = null;
     mItemReadOnly   = true;
     mItemCursor     = Cursors.Arrow;
     mItemFocusable  = false;
 }
        private static List <CandidateAbie> AbieFindChildren(IAbie root)
        {
            var         tempList   = new List <CandidateAbie>();
            IEnumerator enumerator = root.Asbies.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var   currentAsbie = (IAsbie)enumerator.Current;
                IAbie currentAbie  = currentAsbie.AssociatedAbie;
                tempList.Add(new CandidateAbie(currentAbie, AbieFindChildren(currentAbie)));
            }
            return(tempList);
        }
 public static AsbieSpec CloneAscc(IAscc ascc, string name, IAbie associatedAbie)
 {
     return(new AsbieSpec
     {
         BusinessTerms = new List <string>(ascc.BusinessTerms),
         Definition = ascc.Definition,
         LanguageCode = ascc.LanguageCode,
         SequencingKey = ascc.SequencingKey,
         UsageRules = new List <string>(ascc.UsageRules),
         Name = name,
         AssociatedAbie = associatedAbie,
         LowerBound = ascc.LowerBound,
         UpperBound = ascc.UpperBound,
     });
 }
        /// <summary>
        /// This constructor should only be used when an ACC is dragged into an BIE library.
        /// </summary>
        /// <param name="cclibName">The name of the CC library containing the selected ACC</param>
        /// <param name="accName">The name of the selected ACC</param>
        /// <param name="bieLibName">The name of the target BIE library (drag target)</param>
        /// <param name="diagramID">The ID of the target BIE library diagram (needed for EA workaround)</param>
        /// <param name="repository">The EA repository which contains all previous elements</param>
        public UmlClassCustomizer(string cclibName, string accName, string bieLibName, int diagramID, Repository repository)
        {
            InitializeComponent();
            AbieEditorMode  = EditorModes.AbieEditorModes.CreateFromAcc;
            abieToBeUpdated = null;
            presetCcLib     = cclibName;
            presetAcc       = accName;
            presetBieLib    = bieLibName;
            Model           = new TemporaryAbieModel(CctsRepositoryFactory.CreateCctsRepository(repository));
            Repository      = repository;
            DiagramId       = diagramID;
            DataContext     = this;

            UpdateFormState();
        }
        private ObservableCollection <CheckableTreeViewItem> findChildren(CheckableTreeViewItem parent, IAbie root)
        {
            var         tempList   = new ObservableCollection <CheckableTreeViewItem>();
            IEnumerator enumerator = root.Asbies.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var   currentAsbie = (IAsbie)enumerator.Current;
                IAbie currentAbie  = currentAsbie.AssociatedAbie;
                var   currentItem  = new CheckableTreeViewItem(true, currentAbie.Name, idCounter++);
                currentItem.Children = findChildren(currentItem, currentAbie);
                currentItem.Parent   = parent;
                tempList.Add(currentItem);
            }
            return(tempList);
        }
Ejemplo n.º 18
0
 public static AbieSpec CloneAbie(IAbie abie)
 {
     return(new AbieSpec
     {
         Name = abie.Name,
         IsEquivalentTo = abie.IsEquivalentTo,
         BasedOn = abie.BasedOn,
         Bbies = new List <BbieSpec>(abie.Bbies.Convert(o => BbieSpec.CloneBbie(o))),
         Asbies = new List <AsbieSpec>(abie.Asbies.Convert(o => AsbieSpec.CloneAsbie(o))),
         BusinessTerms = new List <string>(abie.BusinessTerms),
         Definition = abie.Definition,
         LanguageCode = abie.LanguageCode,
         VersionIdentifier = abie.VersionIdentifier,
         UsageRules = new List <string>(abie.UsageRules),
     });
 }
Ejemplo n.º 19
0
        private void AddAbieToCandidateAbies(IAbie newAbie)
        {
            bool newAbieNotYetInCandidateAbies = true;

            foreach (CandidateAbie candidateAbie in mCandidateAbies)
            {
                if (candidateAbie.Name == newAbie.Name)
                {
                    newAbieNotYetInCandidateAbies = false;
                }
            }

            if (newAbieNotYetInCandidateAbies)
            {
                mCandidateAbies.Add(new CandidateAbie(newAbie));
            }
        }
Ejemplo n.º 20
0
        private void CalculateDiffForAbie(IAbie abieOfComplete, IAbie abieOfSubset, Dictionary <string, List <string> > diff)
        {
            HashSet <string> missingBbies = new HashSet <string>();

            foreach (IBbie bbie in abieOfComplete.Bbies)
            {
                missingBbies.Add(bbie.Name);
            }

            missingBbies.ExceptWith(abieOfSubset.Bbies.Select(b => b.Name));

            List <string> values = diff.GetAndCreate(abieOfComplete.Name.Substring(0, abieOfComplete.Name.IndexOf('_')));

            foreach (string bbie in missingBbies)
            {
                values.Add(bbie.Substring(0, bbie.IndexOf('_')));
            }
        }
        /// <summary>
        /// This is the default ABIE Editor constructor. It should be used anytime an ABIE is build up from scratch.
        /// </summary>
        /// <param name="cctsRepository">An implementation of the ICctsRepository interface containing the target libraries / Core Components</param>
        public UmlClassCustomizer(ICctsRepository cctsRepository)
        {
            //backgroundWorker = new BackgroundWorker
            //                       {
            //                           WorkerReportsProgress = false,
            //                           WorkerSupportsCancellation = false
            //                       };

            InitializeComponent();
            AbieEditorMode  = EditorModes.AbieEditorModes.Create;
            abieToBeUpdated = null;

            Model       = new TemporaryAbieModel(cctsRepository);
            DataContext = this;

            SelectDefaultLibraries();

            UpdateFormState();
        }
        public void ShouldCreateAbieInRepository()
        {
            target.SetSelectedCandidateCcLibrary("cclib1");
            target.SetSelectedCandidateAcc("Person");
            target.SetSelectedAndCheckedCandidateBcc("FirstName", true);
            target.SetSelectedAndCheckedPotentialBbie("FirstName", true);
            target.SetSelectedAndCheckedPotentialBdt("Text", true);
            target.AbiePrefix = "MyPrefix";
            target.AbieName   = "MyAbie";
            target.SetSelectedCandidateBdtLibrary("bdtlib1");
            target.SetSelectedCandidateBieLibrary("bielib1");
            target.SetSelectedAndCheckedPotentialAsbie("homeAddress", true);
            target.SetSelectedAndCheckedPotentialAsbie("workAddress", true);
            target.CreateAbie();
            IAbie testAbie = cctsRepository.GetAbieByPath((Path)"test model" / "blib1" / "bielib1" / "MyPrefixMyAbie");

            Assert.IsNotNull(testAbie);
            Assert.That(testAbie.BasedOn.Name, Is.EqualTo("Person"));
            foreach (IBbie bbie in testAbie.Bbies)
            {
                Assert.That(bbie.Name, Is.EqualTo("FirstName"));
                Assert.That(bbie.Bdt.Name, Is.EqualTo("Text"));
            }
            Assert.That(testAbie.BieLibrary.Name, Is.EqualTo("bielib1"));
            Assert.That(testAbie.BasedOn.CcLibrary.Name, Is.EqualTo("cclib1"));
            Assert.That(testAbie.Asbies.Count(), Is.EqualTo(2));
            int i = 0;

            foreach (IAsbie asbie in testAbie.Asbies)
            {
                Console.WriteLine(asbie.Name);
                if (i == 0)
                {
                    Assert.That(asbie.Name, Is.EqualTo("homeAddress"));
                }
                else
                {
                    Assert.That(asbie.Name, Is.EqualTo("workAddress"));
                }
                i++;
            }
        }
        private void buttonGenerate_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            richtextStatus.Text = "Starting to generate XML schemas ...\n\n";

            GatherUserInput();

            cBIV currentBIV = cache.BIVs[selectedBIVName];

            // TODO: check if path is valid
            IAbie rootAbie = null;
            cDOC  document = currentBIV.DOC;

            if (document != null && document.State == CheckState.Checked)
            {
                rootAbie = cctsR.GetAbieById(document.Id);
            }

            IDocLibrary docl = cctsR.GetDocLibraryById(currentBIV.Id);

            // TODO: xsd generator needs to be adapted - currently all doc libraries are being generated whereas
            // only the ones that are checked should be generated..

            //TODO: currently the wizard just takes the input from the text fields whereas the prefix and the
            // target namespace should be (a) stored in the cache and (b) read from there while generation..
            string targetNamespace   = textTargetNS.Text;
            string namespacePrefix   = textPrefixTargetNS.Text;
            bool   annotate          = checkboxAnnotations.CheckState == CheckState.Checked ? true : false;
            bool   allschemas        = checkboxAllschemas.CheckState == CheckState.Checked ? true : false;
            var    generationContext = new GeneratorContext(cctsR, targetNamespace,
                                                            namespacePrefix, annotate, allschemas,
                                                            outputDirectory, docl);

            generationContext.SchemaAdded += HandleSchemaAdded;
            export.cctsndr.XSDGenerator.GenerateSchemas(generationContext);

            richtextStatus.Text += "\nGenerating XML schemas completed!";
            progressBar.Value    = 100;
            Cursor.Current       = Cursors.Default;
        }
Ejemplo n.º 24
0
        private static bool PruneMa(IMa ma)
        {
            if (!alreadyPrunedItems.Contains(ma.Id))
            {
                alreadyPrunedItems.Add(ma.Id);

                List <IAsma> asmas = new List <IAsma>(ma.Asmas);

                foreach (IAsma asma in asmas)
                {
                    if (asma.AssociatedBieAggregator.IsMa)
                    {
                        IMa associatedMa = asma.AssociatedBieAggregator.Ma;

                        if (PruneMa(associatedMa))
                        {
                            masToBeRemoved.Add(associatedMa.Id);
                            ma.RemoveAsma(asma);
                        }
                    }
                    else if (asma.AssociatedBieAggregator.IsAbie)
                    {
                        IAbie abie = asma.AssociatedBieAggregator.Abie;

                        if (PruneAbie(abie))
                        {
                            abiesToBeRemoved.Add(abie.Id);
                            ma.RemoveAsma(asma);
                        }
                    }
                }

                if (ma.Asmas.Count() == 0)
                {
                    return(true);
                }

                return(false);
            }
            return(masToBeRemoved.Contains(ma.Id));
        }
Ejemplo n.º 25
0
        ///<summary>
        ///</summary>
        ///<param name="abie"></param>
        public static XmlSchemaAnnotation GetABIEAnnotation(IAbie abie)
        {
            // Contains all the documentation items such as DictionaryEntryName
            IList <XmlNode> documentation = new List <XmlNode>();

            AddDocumentation(documentation, "UniqueID", abie.UniqueIdentifier);
            AddDocumentation(documentation, "VersionID", abie.VersionIdentifier);
            AddDocumentation(documentation, "ObjectClassQualifierName", getObjectClassQualifier(abie.Name));
            AddDocumentation(documentation, "ObjectClassTermName", getObjectClassTerm(abie.Name));
            AddDocumentation(documentation, "DictionaryEntryName", abie.DictionaryEntryName);
            AddDocumentation(documentation, "Definition", abie.Definition);
            AddDocumentation(documentation, "BusinessTermName", abie.BusinessTerms);
            AddDocumentation(documentation, "AcronymCode", "ABIE");

            XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();

            annotation.Items.Add(new XmlSchemaDocumentation {
                Language = "en", Markup = documentation.ToArray()
            });

            return(annotation);
        }
        /// <summary>
        /// The ABIE Editor in update mode is used to edit an existing ABIE.
        /// Please note that this will load all data available from the target ABIE (including associations) which could lead to timeouts!
        /// </summary>
        /// <param name="cctsRepository">An implementation of the ICctsRepository interface containing the target libraries / Core Components</param>
        /// <param name="idOfAbieToBeUpdated">The element ID of the ABIE to edit.</param>
        public UmlClassCustomizer(ICctsRepository cctsRepository, int idOfAbieToBeUpdated)
        {
            //backgroundWorker = new BackgroundWorker
            //{
            //    WorkerReportsProgress = false,
            //    WorkerSupportsCancellation = false
            //};

            InitializeComponent();
            AbieEditorMode = EditorModes.AbieEditorModes.Update;

            abieToBeUpdated = cctsRepository.GetAbieById(idOfAbieToBeUpdated);

            buttonCreateOrUpdate.Content = "_Update ABIE";

            Model = new TemporaryAbieModel(cctsRepository, abieToBeUpdated);

            DataContext = this;

            SelectDefaultLibraries();

            UpdateFormState();
        }
        private void CompileXsdTypesFromAbie(IAbie abie)
        {
            if (!alreadyCompiledTypes.Contains(abie.Id))
            {
                alreadyCompiledTypes.Add(abie.Id);

                XsdType xsdType = AddXsdType(abie.Name);

                foreach (IBbie bbie in abie.Bbies)
                {
                    xsdType.AddChild(bbie.Name);

                    CompileXsdTypesFromBdt(bbie.Bdt);
                }

                foreach (IAsbie asbie in abie.Asbies)
                {
                    xsdType.AddChild(asbie.Name);

                    CompileXsdTypesFromAbie(asbie.AssociatedAbie);
                }
            }
        }
        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),
            });
        }
Ejemplo n.º 29
0
        internal static XmlSchemaComplexType GenerateComplexTypeABIE(GeneratorContext context, XmlSchema schema, IAbie abie, string abiePrefix)
        {
            // R A4CE, R AF95: a complex type must be defined for each ABIE
            XmlSchemaComplexType complexTypeBIE = new XmlSchemaComplexType();

            // R 9D83: the name of the ABIE must be the DictionaryEntryName with all whitespace and separators
            //         removed. The 'Details' suffix is replaced with 'Type'.
            complexTypeBIE.Name = abie.Name + "Type";

            if (context.Annotate)
            {
                complexTypeBIE.Annotation = GetABIEAnnotation(abie);
            }

            // create the sequence for the BBIEs within the ABIE
            XmlSchemaSequence sequenceBBIEs = new XmlSchemaSequence();

            foreach (IBbie bbie in abie.Bbies)
            {
                // R 89A6: for every BBIE a named element must be locally declared
                XmlSchemaElement elementBBIE = new XmlSchemaElement();

                // R AEFE, R 96D9, R9A40, R A34A are implemented in GetXsdElementNameFromBbie(...)
                elementBBIE.Name = NDR.GetXsdElementNameFromBbie(bbie);

                // R 8B85: every BBIE type must be named the property term and qualifiers and the
                //         representation term of the basic business information entity (BBIE) it represents
                //         with the word 'Type' appended.
                elementBBIE.SchemaTypeName =
                    new XmlQualifiedName(NSPREFIX_BDT + ":" + NDR.GetXsdTypeNameFromBdt(bbie.Bdt));


                // R 90F9: cardinality of elements within the ABIE
                elementBBIE.MinOccursString = AdjustLowerBound(bbie.LowerBound);
                elementBBIE.MaxOccursString = AdjustUpperBound(bbie.UpperBound);

                if (context.Annotate)
                {
                    elementBBIE.Annotation = GetBBIEAnnotation(bbie);
                }

                // add the element created to the sequence
                sequenceBBIEs.Items.Add(elementBBIE);
            }


            foreach (IAsbie asbie in abie.Asbies.OrderBy(a => a.Name))
            {
                XmlSchemaElement elementASBIE = new XmlSchemaElement();

                // R A08A: name of the ASBIE
                elementASBIE.Name           = NDR.GetXsdElementNameFromAsbie(asbie);
                elementASBIE.SchemaTypeName =
                    new XmlQualifiedName(abiePrefix + ":" + asbie.AssociatedAbie.Name + "Type");

                if (context.Annotate)
                {
                    elementASBIE.Annotation = GetASBIEAnnotiation(asbie);
                }

                if (asbie.AggregationKind == AggregationKind.Shared)
                {
                    XmlSchemaElement refASBIE = new XmlSchemaElement();
                    refASBIE.RefName = new XmlQualifiedName(abiePrefix + ":" + elementASBIE.Name);

                    // every shared ASCC may only appear once in the XSD file
                    if (!globalASBIEs.Contains(elementASBIE.Name))
                    {
                        // R 9241: for ASBIEs with AggregationKind = shared a global element must be declared.
                        schema.Items.Add(elementASBIE);
                        globalASBIEs.Add(elementASBIE.Name);
                    }
                    sequenceBBIEs.Items.Add(refASBIE);
                }
                else
                {
                    //R 9025: ASBIEs with Aggregation Kind = composite a local element for the
                    //        associated ABIE must be declared in the associating ABIE complex type.
                    sequenceBBIEs.Items.Add(elementASBIE);
                }
            }

            // add the sequence created to the complex type
            complexTypeBIE.Particle = sequenceBBIEs;
            return(complexTypeBIE);
        }
Ejemplo n.º 30
0
 internal static XmlSchemaComplexType GenerateComplexTypeABIE(GeneratorContext context, XmlSchema schema, IAbie abie)
 {
     return(GenerateComplexTypeABIE(context, schema, abie, NSPREFIX_TNS));
 }