示例#1
0
        /// <summary>
        /// Verifies if the given reference link belongs to the domain model (can be reached from the domain model element).
        /// </summary>
        /// <param name="modelLink">Model link.</param>
        /// <param name="modelContextId">Model context Id.</param>
        /// <returns>True if the refrence link belongs to the domain model. False otherwise.</returns>
        public bool IsReferenceIncludedInModel(Guid modelContextId, DomainModelLink modelLink)
        {
            if (modelLink.IsEmbedding)
            {
                return(false);
            }

            DomainModelElement m = DomainRoleInfo.GetSourceRolePlayer(modelLink) as DomainModelElement;

            if (IsIncludedInModel(modelContextId, m))
            {
                return(true);
            }

            m = DomainRoleInfo.GetTargetRolePlayer(modelLink) as DomainModelElement;
            if (IsIncludedInModel(modelContextId, m))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Processes a proto element representation of the element and adds required proto links.
        /// This method is called on base classes from derived classes.
        ///
        /// Hint: Properties do not need to be added in this method.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element.</param>
        /// <param name="protoGroup">Proto group the proto element belongs to.</param>
        public virtual void ModelProcessMergeCopy(ModelProtoElement protoElement, ModelProtoGroup protoGroup)
        {
            foreach (ElementLink link in DomainRoleInfo.GetAllElementLinks(this))
            {
                if (link is DomainModelLink)
                {
                    DomainModelLink modelLink           = link as DomainModelLink;
                    DomainRelationshipAdvancedInfo info = this.Store.DomainDataAdvDirectory.GetRelationshipInfo(modelLink.GetDomainClassId());
                    if (info is ReferenceRelationshipAdvancedInfo)
                    {
                        if (DomainRoleInfo.GetSourceRolePlayer(modelLink) == this)
                        {
                            if (!(info as ReferenceRelationshipAdvancedInfo).PropagatesCopyToTarget)
                            {
                                continue;
                            }
                        }
                        else
                        if (!(info as ReferenceRelationshipAdvancedInfo).PropagatesCopyToSource)
                        {
                            continue;
                        }

                        ModelProtoLink protoLink = new ModelProtoLink(link);
                        protoGroup.AddNewReferenceLink(protoLink);
                    }
                    else
                    {
                        DomainModelElement child = DomainRoleInfo.GetTargetRolePlayer(link) as DomainModelElement;
                        if (child == this || child == null)
                        {
                            continue;
                        }
                        if ((info as EmbeddingRelationshipAdvancedInfo).PropagatesCopyToChild)
                        {
                            if (!(info as EmbeddingRelationshipAdvancedInfo).IsTargetIncludedSubmodel)
                            {
                                ModelProtoLink protoLink = new ModelProtoLink(link);
                                protoGroup.AddNewEmbeddingLink(protoLink);
                                child.ModelCreateMergeCopy(protoGroup);
                            }
                            else if (child is IParentModelElement)
                            {
                                ModelProtoLink protoLink = new ModelProtoLink(link);
                                protoLink.IsTargetIncludedSubmodel = true;
                                protoLink.DomainFilePath           = (child as IParentModelElement).DomainFilePath;
                                protoGroup.AddNewReferenceLink(protoLink);
                            }
                        }
                    }
                }
            }

            /*
             * // process reference relationships
             * List<ReferenceRelationshipAdvancedInfo> infos = this.Store.DomainDataAdvDirectory.FindDomainClassSourceReferences(this.GetDomainClassId());
             * if (infos != null)
             *  foreach (ReferenceRelationshipAdvancedInfo info in infos)
             *  {
             *      if (info.PropagatesCopyToTarget)
             *      {
             *          System.Collections.ObjectModel.ReadOnlyCollection<ElementLink> links = DomainRoleInfo.GetElementLinks<ElementLink>(this, info.SourceRoleId);
             *          foreach (ElementLink link in links)
             *          {
             *              ModelProtoLink protoLink = new ModelProtoLink(link);
             *              protoGroup.AddNewReferenceLink(protoLink);
             *          }
             *      }
             *  }
             * infos = this.Store.DomainDataAdvDirectory.FindDomainClassTargetReferences(this.GetDomainClassId());
             * if (infos != null)
             *  foreach (ReferenceRelationshipAdvancedInfo info in infos)
             *  {
             *      if (info.PropagatesCopyToSource)
             *      {
             *          System.Collections.ObjectModel.ReadOnlyCollection<ElementLink> links = DomainRoleInfo.GetElementLinks<ElementLink>(this, info.TargetRoleId);
             *          foreach (ElementLink link in links)
             *          {
             *              ModelProtoLink protoLink = new ModelProtoLink(link);
             *              protoGroup.AddNewReferenceLink(protoLink);
             *          }
             *      }
             *  }
             *
             * // process embedding relationships
             * List<EmbeddingRelationshipAdvancedInfo> infosEmb = this.Store.DomainDataAdvDirectory.FindDomainClassSourceEmbeddings(this.GetDomainClassId());
             * if (infosEmb != null)
             *  foreach (EmbeddingRelationshipAdvancedInfo info in infosEmb)
             *  {
             *      if (info.PropagatesCopyToChild)
             *      {
             *          System.Collections.ObjectModel.ReadOnlyCollection<ElementLink> links = DomainRoleInfo.GetElementLinks<ElementLink>(this, info.SourceRoleId);
             *          foreach (ElementLink link in links)
             *          {
             *              ModelProtoLink protoLink = new ModelProtoLink(link);
             *              protoGroup.AddNewEmbeddingLink(protoLink);
             *
             *              DomainModelElement child = DomainRoleInfo.GetTargetRolePlayer(link) as DomainModelElement;
             *              if( child != null )
             *                  child.ModelCreateMergeCopy(protoGroup);
             *          }
             *      }
             *  }
             */
        }
示例#3
0
 /// <summary>
 /// Verifies if the given reference link belongs to the domain model (can be reached from the domain model element).
 /// </summary>
 /// <param name="modelLink">Model link.</param>
 /// <returns>True if the refrence link belongs to the domain model. False otherwise.</returns>
 public bool IsReferenceIncludedInModel(DomainModelLink modelLink)
 {
     return(IsReferenceIncludedInModel(Guid.Empty, modelLink));
 }