public void TranslateSchema(Schema pimSchema, bool translateAsOldVersion = false) { List <PIMBridgeClass> classToProcess = new List <PIMBridgeClass>(); //vytvoreni prazdnych trid //musi predchazet propertam a associacim, aby se neodkazovalo na neexistujici typy // JM: usporadani trid tak, aby predkove byli zalozeni pred potomky List <PIMClass> pimClassesHierarchy = ModelIterator.GetPIMClassesInheritanceBFS((PIMSchema)pimSchema).ToList(); foreach (PIMClass pimClass in pimClassesHierarchy) { // JM: parent - predek v PIM modelu PIMBridgeClass parent = pimClass.GeneralizationAsSpecific != null ? PIMClasses[pimClass.GeneralizationAsSpecific.General] : null; string nameOverride = translateAsOldVersion ? pimClass.Name + @"_old" : null; PIMBridgeClass newClass = new PIMBridgeClass(TypesTable, TypesTable.Library.RootNamespace, pimClass, parent, nameOverride); // tt.Library.RootNamespace.NestedClassifier.Add(newClass); TypesTable.RegisterType(newClass); classToProcess.Add(newClass); //Hack newClass.Tag = pimClass; //Registred to find PIMClasses.Add(pimClass, newClass); } //Translates classes members classToProcess.ForEach(cl => cl.TranslateMembers()); }
/// <summary> /// Creates instance which represents <paramref name="sourceClass"/> in OCL type system. /// </summary> /// <param name="tt">Destination OCL type system.</param> /// <param name="sourceClass">Source class</param> /// <param name="parent">Parent of <paramref name="sourceClass"/> in inheritance hierarchy (if it has any)</param> /// <param name="nameOverride">Use this parameter when the class in the OCL should be registered under a /// different name than <paramref name="sourceClass"/>.<see cref="PIMClass.Name"/></param> public PIMBridgeClass(TypesTable.TypesTable tt, Namespace ns, PIMClass sourceClass, PIMBridgeClass parent = null, string nameOverride = null) : base(tt, ns, nameOverride ?? sourceClass.Name, parent ?? tt.Library.Any) { this.SourceClass = sourceClass; PIMAttribute = new Dictionary <PIMAttribute, PIMBridgeAttribute>(); PIMAssociations = new Dictionary <PIMAssociationEnd, PIMBridgeAssociation>(); PIMOperations = new Dictionary <ModelOperation, Operation>(); }