/// <summary> /// Creates a ACC based on the given <paramref name="specification"/>. /// <param name="specification">A specification for a ACC.</param> /// <returns>The newly created ACC.</returns> /// </summary> public IAcc CreateAcc(AccSpec specification) { return(new UpccAcc(UmlPackage.CreateClass(AccSpecConverter.Convert(specification)))); }
internal static UmlClassSpec Convert(AccSpec accSpec) { var umlClassSpec = new UmlClassSpec { Stereotype = "ACC", Name = accSpec.Name, TaggedValues = new[] { new UmlTaggedValueSpec("businessTerm", accSpec.BusinessTerms), new UmlTaggedValueSpec("definition", accSpec.Definition), new UmlTaggedValueSpec("dictionaryEntryName", accSpec.DictionaryEntryName) { DefaultValue = GenerateDictionaryEntryNameDefaultValue(accSpec) }, new UmlTaggedValueSpec("languageCode", accSpec.LanguageCode), new UmlTaggedValueSpec("uniqueIdentifier", accSpec.UniqueIdentifier) { DefaultValue = GenerateUniqueIdentifierDefaultValue(accSpec) }, new UmlTaggedValueSpec("versionIdentifier", accSpec.VersionIdentifier), new UmlTaggedValueSpec("usageRule", accSpec.UsageRules), }, }; var dependencySpecs = new List <UmlDependencySpec>(); if (accSpec.IsEquivalentTo != null) { dependencySpecs.Add(new UmlDependencySpec { Stereotype = "isEquivalentTo", Target = ((UpccAcc)accSpec.IsEquivalentTo).UmlClass, LowerBound = "0", UpperBound = "1", }); } umlClassSpec.Dependencies = dependencySpecs; var attributeSpecs = new List <UmlAttributeSpec>(); if (accSpec.Bccs != null) { foreach (var bccSpec in accSpec.Bccs) { attributeSpecs.Add(BccSpecConverter.Convert(bccSpec, accSpec.Name)); } } umlClassSpec.Attributes = MakeAttributeNamesUnique(attributeSpecs); var associationSpecs = new List <UmlAssociationSpec>(); if (accSpec.Asccs != null) { foreach (var asccSpec in accSpec.Asccs) { associationSpecs.Add(AsccSpecConverter.Convert(asccSpec, accSpec.Name)); } } umlClassSpec.Associations = MakeAssociationNamesUnique(associationSpecs); return(umlClassSpec); }
/// <summary> /// Updates a ACC to match the given <paramref name="specification"/>. /// <param name="acc">A ACC.</param> /// <param name="specification">A new specification for the given ACC.</param> /// <returns>The updated ACC. Depending on the implementation, this might be the same updated instance or a new instance!</returns> /// </summary> public IAcc UpdateAcc(IAcc acc, AccSpec specification) { return(new UpccAcc(UmlPackage.UpdateClass(((UpccAcc)acc).UmlClass, AccSpecConverter.Convert(specification)))); }
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(); }
private static string GenerateUniqueIdentifierDefaultValue(AccSpec accSpec) { return(Guid.NewGuid().ToString()); }
private static string GenerateDictionaryEntryNameDefaultValue(AccSpec accSpec) { return(accSpec.Name + ". Details"); }
public IAcc UpdateAcc(IAcc element, AccSpec spec) { throw new NotImplementedException(); }
public IAcc CreateAcc(AccSpec spec) { throw new NotImplementedException(); }