Beispiel #1
0
        /// <summary>
        /// Create a flat class from a serialized class
        /// </summary>
        private Class CreateFlatClass(SerializedClass serializedClass, GlobalStaticModel ownedModel)
        {
            // Convert SerializedClass to regular class
            Class cele = new Class()
            {
                Annotations         = serializedClass.Annotations,
                Attribute           = serializedClass.Attribute,
                Behavior            = serializedClass.Behavior,
                BusinessName        = serializedClass.BusinessName,
                Container           = ownedModel,
                DerivedFrom         = serializedClass.DerivedFrom,
                InterestedCommittee = serializedClass.InterestedCommittee,
                IsAbstract          = serializedClass.IsAbstract,
                Name                     = serializedClass.Name,
                SortKey                  = serializedClass.SortKey,
                StewardCommittee         = serializedClass.StewardCommittee,
                SupplierStructuralDomain = serializedClass.SupplierStructuralDomain
            };

            cele.SpecializationChild = CreateSpecializationChildren(serializedClass.SpecializationChild, ownedModel);

            // Process associations
            if (serializedClass.Association != null)
            {
                if (ownedModel.OwnedAssociation == null)
                {
                    ownedModel.OwnedAssociation = new List <Association>(serializedClass.Association.Count);
                }

                // Create owned associations
                ownedModel.OwnedAssociation.AddRange(CreateFlatAssociations(serializedClass.Association, ownedModel));
            }

            return(cele);
        }
Beispiel #2
0
        internal static void ParseClassFromPackage(string ClassName, PackageRepository mifRepo, ClassRepository repo)
        {
            // Class and package location
            string classNamePart       = ClassName.Substring(ClassName.IndexOf(".") + 1);
            string packageLocationPart = ClassName.Substring(0, ClassName.IndexOf("."));

            // Find the package that contains the class we want
            GlobalStaticModel pkg = mifRepo.Find(p => (p is GlobalStaticModel) &&
                                                 (p as GlobalStaticModel).OwnedClass.Find(c => c.Choice is MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class &&
                                                                                          (c.Choice as MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class).Name == classNamePart) != null &&
                                                 p.PackageLocation.ToString(MifCompiler.NAME_FORMAT) == packageLocationPart) as GlobalStaticModel;


            // Process the package
            if (pkg == null)
            {
                throw new InvalidOperationException(string.Format("Can't find '{0}' in the package repository, cannot continue processing", ClassName));
            }

            StaticModelCompiler comp = new StaticModelCompiler();

            comp.ClassRepository   = repo;
            comp.Package           = pkg;
            comp.PackageRepository = pkg.MemberOfRepository;
            comp.Compile();
        }
Beispiel #3
0
        public static MohawkCollege.EHR.gpmr.COR.SubSystem Parse(GlobalStaticModel p)
        {
            MohawkCollege.EHR.gpmr.COR.SubSystem retVal = Parse(p as Package);

            // Backup copyright
            string copy = retVal.Documentation.Copyright;

            // Parse documentation
            if (p.Annotations != null)
            {
                retVal.Documentation = DocumentationParser.Parse(p.Annotations.Documentation);
            }
            else
            {
                retVal.Documentation = new MohawkCollege.EHR.gpmr.COR.Documentation();
            }

            retVal.Documentation.Copyright = copy;

            UpdateLegalInfo(retVal.Documentation, p.Header);

            // TODO: AppInfo here

            // Business name of the entry point overrides the business name of the subsystem
            if (retVal.BusinessName == null && p.OwnedEntryPoint != null && p.OwnedEntryPoint[0].BusinessName != null)
            {
                foreach (BusinessName bn in p.OwnedEntryPoint[0].BusinessName)
                {
                    if (bn.Language == MifCompiler.Language || bn.Language == "")
                    {
                        retVal.BusinessName = bn.Name;
                    }
                }
            }

            // Fire parsed event. This will trigger any class repositories in the current app domain
            // to add the feature to their repository
            retVal.FireParsed();

            return(retVal);
        }
Beispiel #4
0
 /// <summary>
 /// Create a class element
 /// </summary>
 /// <param name="modelElement"></param>
 /// <param name="gsm"></param>
 /// <returns></returns>
 private ModelElement CreateFlatModelElement(MohawkCollege.EHR.HL7v3.MIF.MIF20.ModelElement modelElement, GlobalStaticModel gsm)
 {
     if (modelElement is SerializedClass)
     {
         return(CreateFlatClass(modelElement as SerializedClass, gsm));
     }
     else if (modelElement is SerializedCommonModelElementRef)
     {
         return(CreateFlatCMETRef(modelElement as SerializedCommonModelElementRef, gsm));
     }
     else
     {
         return(modelElement);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Create specialization children
        /// </summary>
        private List <ClassGeneralization> CreateSpecializationChildren(List <SerializedClassGeneralization> childSpecializations, GlobalStaticModel ownedModel)
        {
            List <ClassGeneralization> retVal = new List <ClassGeneralization>(childSpecializations.Count);

            // Iterate through specializations
            foreach (var child in childSpecializations)
            {
                // Create class generialization
                ClassGeneralization cg = new ClassGeneralization()
                {
                    Annotations = child.Annotations,
                    Conformance = child.Conformance,
                    IsMandatory = child.IsMandatory,
                    SortKey     = child.SortKey
                };
                var classItem = CreateFlatModelElement(child.SpecializedClass.Content as ModelElement, ownedModel);
                if (classItem is Class)
                {
                    cg.ChildClassName = (classItem as Class).Name;
                }
                else if (classItem is CommonModelElementRef)
                {
                    Trace.WriteLine("fixme: Don't support CMET refs here", "warn"); // TODO: Create a common model element ref thingy here
                }
                ownedModel.OwnedClass.Add(new ClassElement()
                {
                    Choice = classItem
                });

                retVal.Add(cg);
            }
            return(retVal);
        }
Beispiel #6
0
        /// <summary>
        /// Create flat associations from the serialized models
        /// </summary>
        private IEnumerable <Association> CreateFlatAssociations(List <SerializedAssociationEnd> associations, GlobalStaticModel ownedModel)
        {
            List <Association> retVal = new List <Association>(associations.Count);

            foreach (var assoc in associations)
            {
                // Conver the serialized association to flat association
                Association flatAssoc = new Association()
                {
                    Annotations = assoc.Annotations,
                    SortKey     = assoc.SortKey
                };
                flatAssoc.Ends = new List <Relationship>()
                {
                    assoc.SourceConnection.Content
                };

                // Since a flat association simply points to a class name, we need to add the serialized class to the
                // owned model as a class and reference it by name
                var    classItem = CreateFlatModelElement(assoc.TargetConnection.ParticipantClass.Content as ModelElement, ownedModel);
                string assocName = null;
                if (classItem is Class)
                {
                    assocName = (classItem as Class).Name;
                }
                else if (classItem is CommonModelElementRef)
                {
                    assocName = (classItem as CommonModelElementRef).Name;
                }

                flatAssoc.Ends.Add(new AssociationEnd()
                {
                    Annotations         = assoc.TargetConnection.Annotations,
                    BusinessName        = assoc.TargetConnection.BusinessName,
                    ChoiceItem          = assoc.TargetConnection.ChoiceItem,
                    Conformance         = assoc.TargetConnection.Conformance,
                    DerivedFrom         = assoc.TargetConnection.DerivedFrom,
                    IsMandatory         = assoc.TargetConnection.IsMandatory,
                    MaximumMultiplicity = assoc.TargetConnection.MaximumMultiplicity,
                    MinimumMultiplicity = assoc.TargetConnection.MinimumMultiplicity,
                    Name = assoc.TargetConnection.Name,
                    ParticipantClassName = assocName,
                    ReferenceHistory     = assoc.TargetConnection.ReferenceHistory,
                    SortKey            = assoc.TargetConnection.SortKey,
                    UpdateModeDefault  = assoc.TargetConnection.UpdateModeDefault,
                    UpdateModesAllowed = assoc.TargetConnection.UpdateModesAllowed
                });
                ownedModel.OwnedClass.Add(new ClassElement()
                {
                    Choice = classItem
                });
                retVal.Add(flatAssoc);
            }
            return(retVal);
        }
Beispiel #7
0
        /// <summary>
        /// Create a flat CMET Ref
        /// </summary>
        private ModelElement CreateFlatCMETRef(SerializedCommonModelElementRef serializedCommonModelElementRef, GlobalStaticModel gsm)
        {
            CommonModelElementRef retVal = new CommonModelElementRef()
            {
                Annotations              = serializedCommonModelElementRef.Annotations,
                BusinessName             = serializedCommonModelElementRef.BusinessName,
                CmetName                 = serializedCommonModelElementRef.CmetName ?? serializedCommonModelElementRef.Name,
                DerivedFrom              = serializedCommonModelElementRef.DerivedFrom,
                IsAbstract               = serializedCommonModelElementRef.IsAbstract,
                Name                     = serializedCommonModelElementRef.Name,
                SortKey                  = serializedCommonModelElementRef.SortKey,
                SupplierStructuralDomain = serializedCommonModelElementRef.SupplierStructuralDomain
            };

            retVal.Argument = new List <ClassBindingArgument>(10);
            return(retVal);
        }