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(); }