Exemplo n.º 1
0
        private static void PruneUpccModel(IDocLibrary docLibrary, IBieLibrary bieLibrary)
        {
            abiesToBeRemoved.Clear();
            masToBeRemoved.Clear();
            alreadyPrunedItems.Clear();

            PruneMa(docLibrary.DocumentRoot);

            List <IAbie> abies = new List <IAbie>(bieLibrary.Abies);

            foreach (IAbie abie in abies)
            {
                if (abiesToBeRemoved.Contains(abie.Id))
                {
                    bieLibrary.RemoveAbie(abie);
                }
            }

            List <IMa> mas = new List <IMa>(docLibrary.Mas);

            foreach (IMa ma in mas)
            {
                if (masToBeRemoved.Contains(ma.Id))
                {
                    docLibrary.RemoveMa(ma);
                }
            }
        }
 public AsbieToGenerate(IBieLibrary bieLibrary, IAscc ascc, string asbieName, string associatedAbieName)
 {
     this.bieLibrary         = bieLibrary;
     this.ascc               = ascc;
     this.asbieName          = asbieName;
     this.associatedAbieName = associatedAbieName;
 }
        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);
        }
Exemplo n.º 4
0
        public void Test_roundtrip_ebinterface_to_ubl_and_back()
        {
            string ebiInvoiceSchema = TestUtils.PathToTestResource(@"XSDExporterTest\transformer\roundtrip_ebinterface_to_ubl_and_back\original_ebinterface_invoice_xml_schema\Invoice.xsd");
            string ebiXmlSchemaExportDirectory_1 = TestUtils.PathToTestResource(@"XSDExporterTest\transformer\roundtrip_ebinterface_to_ubl_and_back\imported_ebinterface_model_exported_as_ebinterface_xml_schema\");
            string ebiXmlSchemaExportDirectory_2 = TestUtils.PathToTestResource(@"XSDExporterTest\transformer\roundtrip_ebinterface_to_ubl_and_back\transformed_ebinterface_as_ubl_as_ebinterface_xml_schema\");
            string repositoryFile = TestUtils.PathToTestResource(@"XSDExporterTest\transformer\roundtrip_ebinterface_to_ubl_and_back\repository_containing_roundtripped_models.eap");

            Repository eaRepository = new Repository();

            eaRepository.OpenFile(repositoryFile);

            ICctsRepository cctsRepository = CctsRepositoryFactory.CreateCctsRepository(eaRepository);

            IBieLibrary ebiBieLibrary = cctsRepository.GetBieLibraryByPath((Path)"Model" / "bLibrary" / "ebInterface BIELibrary");
            IBieLibrary ublBieLibrary = cctsRepository.GetBieLibraryByPath((Path)"Model" / "bLibrary" / "UBL BIE Library");

            IDocLibrary ebiDocLibrary = cctsRepository.GetDocLibraryByPath((Path)"Model" / "bLibrary" / "ebInterface DOCLibrary");
            IDocLibrary ublDocLibrary = cctsRepository.GetDocLibraryByPath((Path)"Model" / "bLibrary" / "UBL DOC Library");

            SubsetExporter.ExportSubset(ebiDocLibrary, ebiInvoiceSchema, ebiXmlSchemaExportDirectory_1);

            Transformer.Transform(ebiBieLibrary, ublBieLibrary, ebiDocLibrary, ublDocLibrary);

            Transformer.Transform(ublBieLibrary, ebiBieLibrary, ublDocLibrary, ebiDocLibrary);

            SubsetExporter.ExportSubset(ebiDocLibrary, ebiInvoiceSchema, ebiXmlSchemaExportDirectory_2);
        }
Exemplo n.º 5
0
        public static void Transform(IBieLibrary sourceBieLibrary, IBieLibrary targetBieLibrary, IDocLibrary sourceDocLibrary, IDocLibrary targetDocLibrary)
        {
            // ************** ANSATZ 1 **************************
            // 0. BDTs und ASBIEs werden derzeit ignoriert.

            HashSet <int> existingBccs = new HashSet <int>();

            // 1. Hashset von allen BCCs => dazu muessen wir:
            //    => in der source BIE (i.e. ebInterface) library alle ABIEs durchlaufen, darin die BBIEs durchlaufen,
            //       und fuer jeden BBIE den basedOn BCC im Hashset speichern

            foreach (IAbie abie in sourceBieLibrary.Abies)
            {
                foreach (IBbie bbie in abie.Bbies)
                {
                    existingBccs.Add(bbie.BasedOn.Id);
                }
            }

            // 2. Durchlaufen aller ABIEs in der BIE Library von target (i.e. UBL), fuer jeden ABIE die BBIEs durchlaufen und
            //    fuer jeden BBIE folgenden Schritt durchführen
            //    => ist der BCC, auf welchem der BBIE basiert im Hashset vorhanden?
            //         nein => loeschen des BBIEs
            //         ja => nix tun
            //
            //    The same alrogithm is used for BDT/SUP as well as ASBIEs.

            foreach (IAbie abie in targetBieLibrary.Abies)
            {
                List <IBbie> bbies = new List <IBbie>(abie.Bbies);

                foreach (IBbie bbie in bbies)
                {
                    if (!existingBccs.Contains(bbie.BasedOn.Id))
                    {
                        abie.RemoveBbie(bbie);
                    }
                }
            }

            // 3. Durchlaufen des DOC Library Baumes, und bei den Blättern beginnend: existiert ein BBIE oder an ASBIE innherhalb
            //    des aktuellen ABIEs?
            //
            //    Nein? Dann wird der ABIE gelöscht. Es müssen auch die ASMAs oder ASBIEs welche auf den ABIE zeigen, entfernt werden.

            PruneUpccModel(targetDocLibrary, targetBieLibrary);


            // ************** ANSATZ 2 **************************
            // Prinzipiell ist der Algorithmus gleich nur dass in diesem Ansatz nicht ueber die BIE Libraries iteriert wird
            // sondern rekursiv ueber die DOC Baeume.
        }
 private void treeTargetBie_SelectionChanged(object sender, RoutedEventArgs e)
 {
     if (treeTargetBie.SelectedItem != null)
     {
         var item = (TreeViewItem)treeTargetBie.SelectedItem;
         if (item.Tag is IBieLibrary)
         {
             var lib = (IBieLibrary)item.Tag;
             selectedTargetBieLibrary = lib;
             buttonTargetBie.Content  = lib.Name;
             UpdateUI();
             popupTargetBie.IsOpen = false;
         }
     }
 }
Exemplo n.º 7
0
 public static BieLibrarySpec CloneBieLibrary(IBieLibrary bieLibrary)
 {
     return(new BieLibrarySpec
     {
         Name = bieLibrary.Name,
         BusinessTerms = new List <string>(bieLibrary.BusinessTerms),
         Copyrights = new List <string>(bieLibrary.Copyrights),
         Owners = new List <string>(bieLibrary.Owners),
         References = new List <string>(bieLibrary.References),
         Status = bieLibrary.Status,
         VersionIdentifier = bieLibrary.VersionIdentifier,
         BaseURN = bieLibrary.BaseURN,
         NamespacePrefix = bieLibrary.NamespacePrefix,
     });
 }
 private void buttonClose_Click(object sender, RoutedEventArgs e)
 {
     selectedSourceBieLibrary = null;
     selectedSourceDocLibrary = null;
     selectedTargetBieLibrary = null;
     selectedTargetDocLibrary = null;
     xsdFilename  = "";
     targetFolder = "";
     buttonXsdDocument.IsEnabled  = true;
     buttonTargetModel.IsEnabled  = true;
     buttonSourceModel.IsEnabled  = true;
     buttonTargetFolder.IsEnabled = true;
     popupFinished.Visibility     = Visibility.Collapsed;
     ShowShield(false);
     UpdateUI();
     //this.Close();
 }
        private void buttonTransform_Click(object sender, RoutedEventArgs e)
        {
            innerCanvas.Visibility = Visibility.Visible;
            innerCanvas.Dispatcher.Invoke(DispatcherPriority.Render, new Action(delegate { }));

            Mouse.OverrideCursor = Cursors.Wait;

            IDocLibrary sourceDocLibrary = null;
            IDocLibrary targetDocLibrary = null;
            IBieLibrary sourceBieLibrary = null;
            IBieLibrary targetBieLibrary = null;

            foreach (var library in cctsR.GetAllLibraries())
            {
                if (library is IDocLibrary)
                {
                    var doclibrary = (IDocLibrary)library;
                    if (doclibrary.Name.Equals(selectedSourceDocLibrary))
                    {
                        sourceDocLibrary = doclibrary;
                    }
                    else if (doclibrary.Name.Equals(selectedTargetDocLibrary))
                    {
                        targetDocLibrary = doclibrary;
                    }
                }
                else if (library is IBieLibrary)
                {
                    var bieLibrary = (IBieLibrary)library;
                    if (bieLibrary.Name.Equals(selectedSourceBieLibrary))
                    {
                        sourceBieLibrary = bieLibrary;
                    }
                    else if (bieLibrary.Name.Equals(selectedTargetBieLibrary))
                    {
                        targetBieLibrary = bieLibrary;
                    }
                }
            }
            Transformer.Transform(sourceBieLibrary, targetBieLibrary, sourceDocLibrary, targetDocLibrary);
            SubsetExporter.ExportSubset(targetDocLibrary, targetXSDFilename, outputDirectory);

            innerCanvas.Visibility = Visibility.Collapsed;
            Mouse.OverrideCursor   = Cursors.Arrow;
        }
        /// <summary>
        /// Takes the names of the libraries to be created as well as a qualifier as input and creates the
        /// libraries.
        /// </summary>
        public void GenerateLibraries()
        {
            bdtLibrary = bLibrary.CreateBdtLibrary(new BdtLibrarySpec
            {
                Name = bdtLibraryName
            });
            bieLibrary = bLibrary.CreateBieLibrary(new BieLibrarySpec
            {
                Name = bieLibraryName
            });
            docLibrary = bLibrary.CreateDocLibrary(new DocLibrarySpec
            {
                Name = docLibraryName
            });
            GenerateBdtsAndAbiesAndMas();

            GenerateRootABIE();
        }
Exemplo n.º 11
0
        public void ShouldGetAndCacheBieLibraryByName()
        {
            // Setup
            var bieLibraryMock = new Mock <IBieLibrary>();

            bieLibraryMock.SetupGet(l => l.Name).Returns("bielib1");
            var cctsRepositoryMock = new Mock <ICctsRepository>();

            cctsRepositoryMock.Setup(r => r.GetAllLibraries()).Returns(new[] { bieLibraryMock.Object });

            // Events
            CcCache     ccCache    = CcCache.GetInstance(cctsRepositoryMock.Object);
            IBieLibrary bieLibrary = ccCache.GetBieLibraryByName("bielib1");

            ccCache.GetBieLibraryByName("bielib1");

            // Assertion and Verification
            Assert.That(bieLibrary, Is.SameAs(bieLibraryMock.Object));
            cctsRepositoryMock.Verify(r => r.GetAllLibraries(), Times.Exactly(1));
        }
Exemplo n.º 12
0
        public void Test_transforming_ebinterface_to_ubl()
        {
            string ublInvoiceSchema = TestUtils.PathToTestResource(@"XSDExporterTest\transformer\transforming_ebinterface_to_ubl\ubl_invoice\UBL-Invoice-2.0.xsd");
            string ebInterfaceAsUblSchemaDirectory = TestUtils.PathToTestResource(@"XSDExporterTest\transformer\transforming_ebinterface_to_ubl\ebinterface_as_ubl\");
            string repositoryFile = TestUtils.PathToTestResource(@"XSDExporterTest\transformer\transforming_ebinterface_to_ubl\invoice.eap");

            Repository eaRepository = new Repository();

            eaRepository.OpenFile(repositoryFile);

            ICctsRepository cctsRepository = CctsRepositoryFactory.CreateCctsRepository(eaRepository);

            IBieLibrary ebiBieLibrary = cctsRepository.GetBieLibraryByPath((Path)"Model" / "bLibrary" / "ebInterface BIELibrary");
            IBieLibrary ublBieLibrary = cctsRepository.GetBieLibraryByPath((Path)"Model" / "bLibrary" / "UBL BIE Library");

            IDocLibrary ebiDocLibrary = cctsRepository.GetDocLibraryByPath((Path)"Model" / "bLibrary" / "ebInterface DOCLibrary");
            IDocLibrary ublDocLibrary = cctsRepository.GetDocLibraryByPath((Path)"Model" / "bLibrary" / "UBL DOC Library");

            Transformer.Transform(ebiBieLibrary, ublBieLibrary, ebiDocLibrary, ublDocLibrary);

            SubsetExporter.ExportSubset(ublDocLibrary, ublInvoiceSchema, ebInterfaceAsUblSchemaDirectory);
        }
        public void Test_mapping_simple_element_and_attributes_to_acc_with_mapping_function_split()
        {
            string mappingFile = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_simple_element_and_attributes_to_acc_with_mapping_function_split\mapping.mfd");

            string[] schemaFiles = new[] { TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_simple_element_and_attributes_to_acc_with_mapping_function_split\source.xsd") };

            new MappingImporter(new[] { mappingFile }, schemaFiles, ccLibrary, bLibrary, DocLibraryName, BieLibraryName, BdtLibraryName, Qualifier, RootElementName, cctsRepository).ImportMapping();

            IBdtLibrary bdtLibrary = ShouldContainBdtLibrary(BdtLibraryName);
            IBdt        bdtText    = ShouldContainBdt(bdtLibrary, "String_Text", "Text", null);

            Assert.That(bdtLibrary.Bdts.Count(), Is.EqualTo(1));

            IBieLibrary bieLibrary = ShouldContainBieLibrary(BieLibraryName);
            IAbie       bieAddress = ShouldContainAbie(bieLibrary, "AddressType_Address", "Address", new[] { new BbieDescriptor("Street_StreetName", bdtText.Id), new BbieDescriptor("Street_BuildingNumber", bdtText.Id), new BbieDescriptor("Town_CityName", bdtText.Id) }, null);

            Assert.That(bieLibrary.Abies.Count(), Is.EqualTo(1));

            var docLibrary = ShouldContainDocLibrary(DocLibraryName);

            ShouldContainMa(docLibrary, "test_Invoice", new[] { new AsmaDescriptor("Address", bieAddress.Id) });
            Assert.That(docLibrary.Mas.Count(), Is.EqualTo(1));
        }
 public AsmaToGenerate(IBieLibrary bieLibrary, string name, string associatedAbieName)
 {
     this.bieLibrary   = bieLibrary;
     this.name         = name;
     associatedBieName = associatedAbieName;
 }
Exemplo n.º 15
0
 public CandidateBieLibrary(IBieLibrary bieLibrary)
 {
     mOriginalBieLibrary = bieLibrary;
     mSelected           = false;
 }
Exemplo n.º 16
0
 public static void InitLibraries(ImporterContext context)
 {
     ExistingAccs = context.CCLibrary;
     ExistingBdts = context.BDTLibrary;
     BieLibrary   = context.BIELibrary;
 }
 internal CacheItemBieLibrary(IBieLibrary library)
 {
     BieLibrary = library;
 }
Exemplo n.º 18
0
 public void RemoveBieLibrary(IBieLibrary bieLibrary)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 19
0
 /// <summary>
 /// Removes a BieLibrary from this bLibrary.
 /// <param name="bieLibrary">A BieLibrary.</param>
 /// </summary>
 public void RemoveBieLibrary(IBieLibrary bieLibrary)
 {
     UmlPackage.RemovePackage(((UpccBieLibrary)bieLibrary).UmlPackage);
 }
Exemplo n.º 20
0
 public IBieLibrary UpdateBieLibrary(IBieLibrary bieLibrary, BieLibrarySpec specification)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 21
0
 /// <summary>
 /// Updates a BIELibrary to match the given <paramref name="specification"/>.
 /// <param name="bieLibrary">A BIELibrary.</param>
 /// <param name="specification">A new specification for the given BIELibrary.</param>
 /// <returns>The updated BIELibrary. Depending on the implementation, this might be the same updated instance or a new instance!</returns>
 /// </summary>
 public IBieLibrary UpdateBieLibrary(IBieLibrary bieLibrary, BieLibrarySpec specification)
 {
     return(new UpccBieLibrary(UmlPackage.UpdatePackage(((UpccBieLibrary)bieLibrary).UmlPackage, BieLibrarySpecConverter.Convert(specification))));
 }