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); }
public void SetUp() { cctsRepository = CctsRepositoryFactory.CreateCctsRepository(new EARepositoryBdtEditor()); target = new TemporaryBdtModel(cctsRepository); var candidateCdtLibraryIndex = 0; target.mCandidateCdtLibraries[candidateCdtLibraryIndex].mCandidateCdts = new List <CandidateCdt>(); target.CandidateCdtNames = new List <string>(); target.CandidateConItems = new List <CheckableItem>(); target.CandidateSupItems = new List <CheckableItem>(); foreach (ICdt cdt in cctsRepository.GetCdtLibraryByPath((Path)"test model" / "blib1" / "cdtlib1").Cdts) { var candidateCdt = new CandidateCdt(cdt); target.mCandidateCdtLibraries[candidateCdtLibraryIndex].mCandidateCdts.Add(candidateCdt); target.CandidateCdtNames.Add(cdt.Name); int candidateCdtIndex = target.mCandidateCdtLibraries[candidateCdtLibraryIndex].mCandidateCdts.IndexOf(candidateCdt); target.mCandidateCdtLibraries[candidateCdtLibraryIndex].mCandidateCdts[candidateCdtIndex]. mPotentialCon.OriginalCdtCon = cdt.Con; target.CandidateConItems.Add(new CheckableItem(false, cdt.Con.Name, false, false, Cursors.Arrow)); target.mCandidateCdtLibraries[candidateCdtLibraryIndex].CandidateCdts[candidateCdtIndex].mPotentialSups = new List <PotentialSup>(); foreach (ICdtSup cdtSup in cdt.Sups) { target.mCandidateCdtLibraries[candidateCdtLibraryIndex].mCandidateCdts[candidateCdtIndex].mPotentialSups.Add(new PotentialSup(cdtSup)); target.CandidateSupItems.Add(new CheckableItem(false, cdtSup.Name, false, false, Cursors.Arrow)); } } }
public void Test_mapping_ubl_to_ccl() { string repoPath = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\Invoice.eap"); File.Copy(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\Repository-with-CDTs-and-CCs.eap"), repoPath, true); var repo = new Repository(); repo.OpenFile(repoPath); var mappingFileNames = new List <string> { "ubl2cll_1_1.mfd", "ubl2cll_2_1.mfd", "ubl2cll_3_1.mfd", "ubl2cll_4_1.mfd", "ubl2cll_5_1.mfd", "ubl2cll_6_1.mfd", "ubl2cll_7_1.mfd", "ubl2cll_8_1.mfd", "ubl2cll_9_1.mfd", "ubl2cll_10_1.mfd", "ubl2cll_11_1.mfd", "ubl2cll_12_1.mfd", "ubl2cll_13_1.mfd" }; var mappingFiles = new List <string>(); foreach (var mappingFile in mappingFileNames) { mappingFiles.Add(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\" + mappingFile)); } string[] schemaFiles = new[] { TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\invoice\maindoc\UBL-Invoice-2.0.xsd") }; Console.Out.WriteLine("Starting mapping"); var repository = CctsRepositoryFactory.CreateCctsRepository(repo); var ccLib = repository.GetCcLibraries().FirstOrDefault(); new MappingImporter(mappingFiles, schemaFiles, ccLib, ccLib.BLibrary, DocLibraryName, BieLibraryName, BdtLibraryName, Qualifier, RootElementName, repository).ImportMapping(); }
public void ShouldOpenAndPopulateForm() { var t = new Thread(() => new Application().Run(new TransformerUI(CctsRepositoryFactory.CreateCctsRepository(new TemporaryFileBasedRepository(TestUtils.PathToTestResource(@"XSDExporterTest\\transformer\\transforming_ebinterface_to_ubl\\repository_containing_ubl_and_ebinterface_invoice.eap")))))); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); }
public void ShouldOpenAndPopulateForm() { var t = new Thread(() => new Application().Run(new SubSettingWizard(CctsRepositoryFactory.CreateCctsRepository(new TemporaryFileBasedRepository(TestUtils.PathToTestResource(@"simple_model.eap")))))); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); }
public void ShouldLaunchAndPopulateBdtModelerForm() { var t = new Thread(() => new Application().Run(new BdtEditor(CctsRepositoryFactory.CreateCctsRepository(new EARepositoryBdtEditor())))); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); }
public void ShouldOpenAndPopulateForm() { var t = new Thread(() => new Application().Run(new XsdImporterForm(CctsRepositoryFactory.CreateCctsRepository(new EARepositoryModelCreator())))); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); }
public void CreateExpectedSourceElementTree() { ccRepository = CctsRepositoryFactory.CreateCctsRepository(new MappingTestRepository()); ccLibrary = ccRepository.GetCcLibraryByPath((Path)"test" / "bLibrary" / "CCLibrary"); accParty = ccLibrary.GetAccByName("Party"); bccPartyName = accParty.Bccs.First(bcc => bcc.Name == "Name"); asccPartyResidence = accParty.Asccs.First(ascc => ascc.Name == "Residence"); mapForceMapping = LinqToXmlMapForceMappingImporter.ImportFromFiles(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\TargetElementStoreTests\mapping.mfd")); }
public void ShouldLaunchAndPopulateAbieEditorForm() { ICctsRepository cctsRepository = CctsRepositoryFactory.CreateCctsRepository(new EARepositoryAbieEditor()); var t = new Thread(() => new Application().Run(new AbieEditor(cctsRepository))); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); }
public void TestGenerateSchemas() { var ccRepository = CctsRepositoryFactory.CreateCctsRepository(new EARepository2()); var docLibrary = ccRepository.GetDocLibraryByPath((Path)"test model" / "bLibrary" / "DOCLibrary"); string outputDirectory = PathToTestResource( "\\XSDExporterTest\\cctsndr\\all"); AddInSettings.LoadRegistryEntries(); VIENNAAddIn.upcc3.export.cctsndr.XSDGenerator.GenerateSchemas(new GeneratorContext(ccRepository, "urn:test:namespace", "test", true, true, outputDirectory, docLibrary)); }
public void ShouldOpenAndPopulateForm() { var repository = new Repository(); repository.OpenFile(TestUtils.PathToTestResource(@"full_initial.eap")); var t = new Thread(() => new Application().Run(new XsltGeneratorForm(CctsRepositoryFactory.CreateCctsRepository(repository)))); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); }
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(); }
public void TestCreatingLibrariesAndImportingStandardLibrariesWithinParticularEmptyModelAmongSeveralModels() { Repository eaRepository = new TemporaryFileBasedRepository(new EARepositoryModelCreator()); ModelCreator creator = new ModelCreator(eaRepository, CctsRepositoryFactory.CreateCctsRepository(eaRepository)); creator.CreateUpccModel("New Test Model", "BDTLibrary", "BIELibrary", "DOCLibrary", resourceDescriptor); AssertEmptyStandardCcLibrariesInBusinessLibrary(eaRepository, "Test Model 1", "New Test Model"); AssertStandardCcLibrariesContentInBusinessLibrary(eaRepository, "Test Model 1", "New Test Model"); AssertEmptyBieLibrariesinBusinessLibrary(eaRepository, "Test Model 1", "New Test Model"); }
public void AccessCctsRepositoryAndLoadNamesOfAllElements() { ICctsRepository cctsRepository = CctsRepositoryFactory.CreateCctsRepository(new TemporaryFileBasedRepository("C:/Temp/test.eap")); foreach (ICcLibrary ccLibrary in cctsRepository.GetCcLibraries()) { foreach (IAcc acc in ccLibrary.Accs) { Console.WriteLine(acc.Name); } } }
public void TestCreatingEmptyLibrariesWithinParticularEmptyModelAmongSeveralModels() { Repository eaRepository = new TemporaryFileBasedRepository(new EARepositoryModelCreator()); ModelCreator creator = new ModelCreator(eaRepository, CctsRepositoryFactory.CreateCctsRepository(eaRepository)); creator.CreateUpccModel("New Test Model", "PRIMLibrary", "ENUMLibrary", "CDTLibrary", "CCLibrary", "BDTLibrary", "BIELibrary", "DOCLibrary"); AssertEmptyStandardCcLibrariesInBusinessLibrary(eaRepository, "Test Model 1", "New Test Model"); AssertEmptyBieLibrariesinBusinessLibrary(eaRepository, "Test Model 1", "New Test Model"); }
public void TestSchemaGenerator() { using (var tempFileBasedRepository = new TemporaryFileBasedRepository(TestUtils.PathToTestResource("cc-for-ebInterface-0.5.eap"))) { var ccRepository = CctsRepositoryFactory.CreateCctsRepository(tempFileBasedRepository); var docLibrary = ccRepository.GetDocLibraryByPath((Path)"Model" / "ebInterface Data Model" / "DOCLibrary"); AddInSettings.LoadRegistryEntries(); var context = VIENNAAddIn.upcc3.export.cctsndr.XSDGenerator.GenerateSchemas(new GeneratorContext(ccRepository, "ebInterface", "eb", false, true, "C:\\dump\\", docLibrary)); Assert.AreEqual(5, context.Schemas.Count); XmlSchema schema = context.Schemas[1].Schema; schema.Write(Console.Out); } }
public void ShouldOnlyAutoGenerateUnspecifiedTaggedValues() { ICctsRepository ccRepository = CctsRepositoryFactory.CreateCctsRepository(new CdtLibraryTestRepository()); ICdtLibrary cdtLibrary = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary()); CdtSpec cdtSpec = new CdtSpec { Name = "cdt1", UniqueIdentifier = "{x-123-456-789-x}", DictionaryEntryName = "shouldNotBeReplaced" }; ICdt cdt = cdtLibrary.CreateCdt(cdtSpec); Assert.That(cdt.UniqueIdentifier, Is.EqualTo("{x-123-456-789-x}")); Assert.That(cdt.DictionaryEntryName, Is.EqualTo("shouldNotBeReplaced")); }
public void TestRootSchemaGenerator() { using (var tempFileBasedRepository = new TemporaryFileBasedRepository(TestUtils.PathToTestResource("cc-for-ebInterface-0.5.eap"))) { var ccRepository = CctsRepositoryFactory.CreateCctsRepository(tempFileBasedRepository); var docLibrary = ccRepository.GetDocLibraryByPath((Path)"Model" / "ebInterface Data Model" / "DOCLibrary"); var context = new GeneratorContext(ccRepository, "urn:test:namespace", "cc", true, false, "C:\\Dokumente und Einstellungen\\fkromer\\workspace\\ccts\\", docLibrary); RootSchemaGenerator.GenerateXSD(context); Assert.AreEqual(1, context.Schemas.Count); XmlSchema schema = context.Schemas[0].Schema; schema.Write(Console.Out); //AssertSchema("root.xsd", schema); } }
public void ShouldAutoGenerateTaggedValues() { ICctsRepository ccRepository = CctsRepositoryFactory.CreateCctsRepository(new CdtLibraryTestRepository()); ICdtLibrary cdtLibrary = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary()); CdtSpec cdtSpec = new CdtSpec { Name = "cdt1" }; ICdt cdt = cdtLibrary.CreateCdt(cdtSpec); Assert.That(cdt.UniqueIdentifier, Is.Not.Null); Assert.That(cdt.UniqueIdentifier, Is.Not.Empty); Assert.That(cdt.DictionaryEntryName, Is.EqualTo("cdt1. Type")); }
private static ICctsRepository GetFileBasedTestRepository() { string repositoryDirectory = Directory.GetCurrentDirectory() + "\\..\\..\\testresources\\XSDImporterTest\\ccts\\simpleXSDs\\"; const string repositoryFile = "import_repository.eap"; Console.WriteLine("Repository file: \"{0}\"\n", repositoryDirectory + repositoryFile); string backupFile = BackupFileBasedRepository(repositoryDirectory, repositoryFile); eaRepository = (new Repository()); eaRepository.OpenFile(backupFile); return(CctsRepositoryFactory.CreateCctsRepository(eaRepository)); }
public BdtEditor(string cdtLibrary, string cdtName, string bdtLibrary, int diagramId, Repository repository) { InitializeComponent(); EditorMode = "createFromCDT"; CdtLibraryName = cdtLibrary; CdtName = cdtName; BdtLibraryName = bdtLibrary; DiagramId = diagramId; Repository = repository; Model = new TemporaryBdtModel(CctsRepositoryFactory.CreateCctsRepository(repository)); DataContext = this; comboboxCdts.IsEnabled = false; comboboxCdtLibraries.IsEnabled = false; comboboxBdtLibraries.IsEnabled = false; }
/// <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(); }
public void Test_exporting_subset_of_ubl() { string schemaFileComplete = TestUtils.PathToTestResource(@"XSDExporterTest\mapping\SubsetExporter\exporting_subset_of_ubl\invoice\UBL-Invoice-2.0.xsd"); string schemaDirectorySubset = TestUtils.PathToTestResource(@"XSDExporterTest\mapping\SubsetExporter\exporting_subset_of_ubl\subset\"); string repositoryFile = TestUtils.PathToTestResource(@"XSDExporterTest\mapping\SubsetExporter\exporting_subset_of_ubl\Invoice_complete.eap"); Repository eaRepository = new Repository(); eaRepository.OpenFile(repositoryFile); ICctsRepository cctsRepository = CctsRepositoryFactory.CreateCctsRepository(eaRepository); IDocLibrary docLibrary = cctsRepository.GetDocLibraryByPath((Path)"Model" / "bLibrary" / "Test DOC Library"); SubsetExporter.ExportSubset(docLibrary, schemaFileComplete, schemaDirectorySubset); }
public void TestBIESchemaGenerator() { var docLibraryMock = new Mock <IDocLibrary>(); docLibraryMock.SetupGet(l => l.VersionIdentifier).Returns("2"); var ccRepository = CctsRepositoryFactory.CreateCctsRepository(new EARepository2()); var context = new GeneratorContext(ccRepository, "urn:test:namespace", "test", true, true, "C:\\dump\\", docLibraryMock.Object); BIESchemaGenerator.GenerateXSD(context, VIENNAAddIn.upcc3.export.cctsndr.XSDGenerator.CollectABIEs(context)); Assert.AreEqual(1, context.Schemas.Count); XmlSchema schema = context.Schemas[0].Schema; // schema.Write(Console.Out); AssertSchema("bies.xsd", schema); }
public void ShouldNotAutoGenerateSpecifiedTaggedValues() { ICctsRepository ccRepository = CctsRepositoryFactory.CreateCctsRepository(new CdtLibraryTestRepository()); ICdtLibrary cdtLibrary = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary()); ICdt cdtText = ccRepository.GetCdtByPath(CdtLibraryTestRepository.PathToCdtText()); CdtSpec cdtSpec = CdtSpec.CloneCdt(cdtText); cdtSpec.DictionaryEntryName = "cdt1"; cdtSpec.UniqueIdentifier = "{1-2-3}"; ICdt updatedCdt = cdtLibrary.UpdateCdt(cdtText, cdtSpec); Assert.That(updatedCdt.UniqueIdentifier, Is.EqualTo("{1-2-3}")); Assert.That(updatedCdt.DictionaryEntryName, Is.EqualTo("cdt1")); }
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 CreateExpectedSourceElementTree() { cctsRepository = CctsRepositoryFactory.CreateCctsRepository(new MappingTestRepository()); cdtl = cctsRepository.GetCdtLibraryByPath((Path)"test" / "bLibrary" / "CDTLibrary"); cdtText = cdtl.GetCdtByName("Text"); supTextLanguage = cdtText.Sups.FirstOrDefault(sup => sup.Name == "Language"); supTextLanguageLocale = cdtText.Sups.FirstOrDefault(sup => sup.Name == "LanguageLocale"); cdtCode = cdtl.GetCdtByName("Code"); supCodeLanguage = cdtCode.Sups.FirstOrDefault(sup => sup.Name == "Language"); cdtDateTime = cdtl.GetCdtByName("DateTime"); ccl = cctsRepository.GetCcLibraryByPath((Path)"test" / "bLibrary" / "CCLibrary"); accAddress = ccl.GetAccByName("Address"); bccCityName = accAddress.Bccs.FirstOrDefault(bcc => bcc.Name == "CityName"); bccCountryName = accAddress.Bccs.FirstOrDefault(bcc => bcc.Name == "CountryName"); bccBuildingNumber = accAddress.Bccs.FirstOrDefault(bcc => bcc.Name == "BuildingNumber"); bccStreetName = accAddress.Bccs.FirstOrDefault(bcc => bcc.Name == "StreetName"); bccCountry = accAddress.Bccs.FirstOrDefault(bcc => bcc.Name == "Country"); accDocument = ccl.GetAccByName("Document"); bccIssue = accDocument.Bccs.FirstOrDefault(bcc => bcc.Name == "Issue"); accNote = ccl.GetAccByName("Note"); bccContent = accNote.Bccs.FirstOrDefault(bcc => bcc.Name == "Content"); accParty = ccl.GetAccByName("Party"); bccPartyName = accParty.Bccs.FirstOrDefault(bcc => bcc.Name == "Name"); asccPartyResidenceAddress = accParty.Asccs.FirstOrDefault(ascc => ascc.Name == "Residence"); asccPartyChildren = accParty.Asccs.FirstOrDefault(ascc => ascc.Name == "Children"); }
private static IImporterContext CreateContext(string testCase) { XmlSchema bdtSchema = XmlSchema.Read(XmlReader.Create(TestUtils.RelativePathToTestResource(typeof(BDTXsdImporterTests), string.Format(@"BDTImporterTestResources\BusinessDataType_{0}.xsd", testCase))), null); var eaRepository = new EARepository(); eaRepository.AddModel("Model", m => m.AddPackage("bLibrary", bLibrary => { bLibrary.Element.Stereotype = Stereotype.bLibrary; bLibrary.AddPackage("PRIMLibrary", primLib => { primLib.Element.Stereotype = Stereotype.PRIMLibrary; primLib.AddPRIM("String"); primLib.AddPRIM("Decimal"); primLib.AddPRIM("Date"); }); bLibrary.AddPackage("CDTLibrary", cdtLib => { cdtLib.Element.Stereotype = Stereotype.CDTLibrary; cdtLib.AddCDT("Text"); }); bLibrary.AddPackage("BDTLibrary", bdtLib => { bdtLib.Element.Stereotype = Stereotype.BDTLibrary; }); })); ICctsRepository cctsRepository = CctsRepositoryFactory.CreateCctsRepository(eaRepository); var primLibrary = cctsRepository.GetPrimLibraryByPath((Path)"Model" / "bLibrary" / "PRIMLibrary"); var bdtLibrary = cctsRepository.GetBdtLibraryByPath((Path)"Model" / "bLibrary" / "BDTLibrary"); var cdtLibrary = cctsRepository.GetCdtLibraryByPath((Path)"Model" / "bLibrary" / "CDTLibrary"); var contextMock = new Mock <IImporterContext>(); contextMock.SetupGet(c => c.PRIMLibrary).Returns(primLibrary); contextMock.SetupGet(c => c.CDTLibrary).Returns(cdtLibrary); contextMock.SetupGet(c => c.BDTLibrary).Returns(bdtLibrary); contextMock.SetupGet(c => c.BDTSchema).Returns(bdtSchema); return(contextMock.Object); }
public void Context() { cctsRepository = CctsRepositoryFactory.CreateCctsRepository(new MappingTestRepository()); ccLibrary = cctsRepository.GetCcLibraries().FirstOrDefault(); bLibrary = ccLibrary.BLibrary; }
private static void ImportCCL(string cclVersion) { var eaRepository = new Repository(); string originalRepoPath = Directory.GetCurrentDirectory() + string.Format(@"\..\..\resources\{0}\Repository-with-CDTs.eap", cclVersion); string targetRepoPath = originalRepoPath.WithoutSuffix(".eap") + "-and-CCs.eap"; File.Copy(originalRepoPath, targetRepoPath, true); eaRepository.OpenFile(targetRepoPath); ICctsRepository cctsRepository = CctsRepositoryFactory.CreateCctsRepository(eaRepository); var bLibrary = cctsRepository.GetBLibraryByPath((Path)"Model" / "bLibrary"); var cdtLibrary = bLibrary.GetCdtLibraryByName("CDTLibrary"); var cdts = new Dictionary <string, ICdt>(); foreach (ICdt cdt in cdtLibrary.Cdts) { cdts[cdt.Name] = cdt; } ICcLibrary ccLibrary = bLibrary.CreateCcLibrary(new CcLibrarySpec { Name = "CCLibrary", VersionIdentifier = cclVersion }); StreamReader reader = File.OpenText(string.Format(@"..\..\resources\{0}\{0}-CCs.txt", cclVersion)); String line; var accSpecs = new List <AccSpec>(); var asccSpecs = new Dictionary <string, List <AsccSpecWithAssociatedAccName> >(); AccSpec accSpec = null; while ((line = reader.ReadLine()) != null) { LineNumber++; if (LineNumber < 2) { continue; } if (Debug) { if (LineNumber > 150) { break; } } Record record = GetRecord(line); switch (record.ElementType) { case "ACC": CheckACCRecord(record); accSpec = new AccSpec { UniqueIdentifier = record.UniqueUNAssignedID, Name = GetACCName(record), Definition = record.Definition.LimitTo(MaximumTaggedValueLength), BusinessTerms = ToArray(record.BusinessTerms.LimitTo(MaximumTaggedValueLength)), UsageRules = ToArray(record.UsageRules.LimitTo(MaximumTaggedValueLength)), VersionIdentifier = record.Version, Bccs = new List <BccSpec>(), Asccs = new List <AsccSpec>(), }; accSpecs.Add(accSpec); break; case "BCC": if (accSpec == null) { throw new Exception("The first record must specify an ACC."); } CheckBCCRecord(record, accSpec.Name); var bccSpec = new BccSpec { UniqueIdentifier = record.UniqueUNAssignedID, Definition = record.Definition.LimitTo(MaximumTaggedValueLength), DictionaryEntryName = record.DictionaryEntryName, Name = QualifiedName(record.PropertyTermQualifiers, record.PropertyTerm), BusinessTerms = ToArray(record.BusinessTerms.LimitTo(MaximumTaggedValueLength)), UsageRules = ToArray(record.UsageRules.LimitTo(MaximumTaggedValueLength)), SequencingKey = record.SequenceNumber, LowerBound = MapOccurrence(record.OccurrenceMin), UpperBound = MapOccurrence(record.OccurrenceMax), VersionIdentifier = record.Version, Cdt = FindCDT(record.RepresentationTerm.AsName(), cdts) }; if (bccSpec.Cdt == null) { Console.WriteLine("WARNING: Skipping line {0}: CDT not found: <{1}>.", LineNumber, record.RepresentationTerm); continue; } accSpec.Bccs.Add(bccSpec); break; case "ASCC": if (accSpec == null) { throw new Exception("The first record must specify an ACC."); } CheckASCCRecord(record, accSpec.Name); var asccSpec = new AsccSpecWithAssociatedAccName { UniqueIdentifier = record.UniqueUNAssignedID, Definition = record.Definition.LimitTo(MaximumTaggedValueLength), Name = QualifiedName(record.PropertyTermQualifiers, record.PropertyTerm), BusinessTerms = ToArray(record.BusinessTerms.LimitTo(MaximumTaggedValueLength)), UsageRules = ToArray(record.UsageRules.LimitTo(MaximumTaggedValueLength)), SequencingKey = record.SequenceNumber, LowerBound = MapOccurrence(record.OccurrenceMin), UpperBound = MapOccurrence(record.OccurrenceMax), VersionIdentifier = record.Version, AssociatedAccName = record.AssociatedObjectClass.AsName(), }; asccSpecs.GetAndCreate(accSpec.Name).Add(asccSpec); break; default: Console.WriteLine("WARNING: Skipping line {0}.", LineNumber); break; } } reader.Close(); try { ACCImporter.ImportACCs(ccLibrary, accSpecs, asccSpecs); } finally { eaRepository.CloseFile(); } Console.WriteLine("INFO: Number of ACCs: " + accSpecs.Count); Console.WriteLine("Press a key to continue..."); Console.ReadKey(); }