/// <summary>
        /// Gets shapes for element on a specific diagram.
        /// </summary>
        /// <param name="modelElementTypeId">Model element type.</param>
        /// <returns>List of guid for shape types or null if none are present.</returns>
        public virtual List <Guid> GetRootShapeTypesForElement(Guid modelElementTypeId)
        {
            System.Collections.Generic.List <System.Guid> ret;
            ClassShapesMapping.TryGetValue(modelElementTypeId, out ret);

            if (ret == null)
            {
                return(new List <Guid>());
            }

            List <Guid> retFiltered = new List <Guid>();

            foreach (Guid d in ret)
            {
                foreach (List <Guid> col in DiagramRootChildrenShapesMapping.Values)
                {
                    if (col.Contains(d))
                    {
                        retFiltered.Add(d);
                        break;
                    }
                }
            }
            return(retFiltered);
        }
        /// <summary>
        /// Gets shapes for element on.
        /// </summary>
        /// <param name="modelElementTypeId">Model element type.</param>
        /// <returns>List of guid for shape types.</returns>
        public virtual List <Guid> GetShapeTypesForElement(Guid modelElementTypeId)
        {
            System.Collections.Generic.List <System.Guid> ret;
            ClassShapesMapping.TryGetValue(modelElementTypeId, out ret);

            if (ret == null)
            {
                return(new List <Guid>());
            }

            return(ret);
        }
        /// <summary>
        /// Verifies if there is a shape for the given element type.
        /// </summary>
        /// <param name="modelElementTypeId">Model element type.</param>
        /// <returns>True if there is a shape for the specified element type. False otherwise.</returns>
        public virtual bool HasShapeForElement(Guid modelElementTypeId)
        {
            if (ClassShapesMapping.ContainsKey(modelElementTypeId))
            {
                if (ClassShapesMapping[modelElementTypeId].Count > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Merges the current directory with an additional directory.
        /// </summary>
        /// <param name="data">Directory</param>
        public void Merge(IDomainDataExtensionDirectory data)
        {
            if (!(data is DiagramDomainDataDirectory))
            {
                throw new InvalidOperationException("Can not merge with " + data.ToString());
            }

            DiagramDomainDataDirectory domainData = data as DiagramDomainDataDirectory;

            foreach (KeyValuePair <Guid, Guid> pair in domainData.ClassShapesDependenciesMapping)
            {
                ClassShapesDependenciesMapping.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.ParentChildrenShapesMapping)
            {
                ParentChildrenShapesMapping.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.DiagramChildrenShapesMapping)
            {
                DiagramChildrenShapesMapping.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.DiagramRootChildrenShapesMapping)
            {
                DiagramRootChildrenShapesMapping.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.DiagramRSChildren)
            {
                DiagramRSChildren.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.DiagramMappingRSChildren)
            {
                DiagramMappingRSChildren.Add(pair.Key, pair.Value);
            }

            // class shape mappings
            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.ClassShapesMapping)
            {
                if (ClassShapesMapping.ContainsKey(pair.Key))
                {
                    ClassShapesMapping[pair.Key].AddRange(pair.Value);
                }
                else
                {
                    ClassShapesMapping.Add(pair.Key, pair.Value);
                }
            }


            foreach (KeyValuePair <Guid, DiagramClassInfo> pair in domainData.DiagramClassInfos)
            {
                DiagramClassInfos.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, ShapeClassInfo> pair in domainData.ShapeClassInfos)
            {
                ShapeClassInfos.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, RelationshipShapeInfo> pair in domainData.RelationshipShapeInfos)
            {
                RelationshipShapeInfos.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, MappingRelationshipShapeInfo> pair in domainData.MappingRelationshipShapeInfos)
            {
                MappingRelationshipShapeInfos.Add(pair.Key, pair.Value);
            }
        }
        /// <summary>
        /// Process and initialize the contained data.
        /// </summary>
        public void Process()
        {
            DiagramClassInfo[] diagramInfos = GetDiagramClassInfo();
            if (diagramInfos != null)
            {
                foreach (DiagramClassInfo info in diagramInfos)
                {
                    DiagramChildrenShapesMapping.Add(info.DiagramClassType, new List <Guid>());
                    DiagramRootChildrenShapesMapping.Add(info.DiagramClassType, new List <Guid>());
                    DiagramRSChildren.Add(info.DiagramClassType, new List <Guid>());
                    DiagramMappingRSChildren.Add(info.DiagramClassType, new List <Guid>());

                    DiagramClassInfos.Add(info.DiagramClassType, info);
                }
            }

            Guid[] classIds = GetClassesRelevantForSM();
            if (classIds != null)
            {
                foreach (Guid id in classIds)
                {
                    ClassShapesMapping.Add(id, new List <Guid>());
                }
            }

            ShapeClassInfo[] shapeInfos = GetShapeClassInfo();
            if (shapeInfos != null)
            {
                foreach (ShapeClassInfo info in shapeInfos)
                {
                    ShapeClassInfos.Add(info.ShapeClassType, info);
                    ClassShapesMapping[info.DomainClassType].Add(info.ShapeClassType);

                    if (info.UsedInDependencyView)
                    {
                        ClassShapesDependenciesMapping.Add(info.DomainClassType, info.ShapeClassType);
                    }

                    ParentChildrenShapesMapping.Add(info.ShapeClassType, new List <Guid>());

                    DiagramChildrenShapesMapping[info.DiagramClassType].Add(info.ShapeClassType);
                    if (info.ParentShapeClassType == null)
                    {
                        DiagramRootChildrenShapesMapping[info.DiagramClassType].Add(info.ShapeClassType);
                    }
                }
                foreach (ShapeClassInfo info in shapeInfos)
                {
                    if (info.ParentShapeClassType != null)
                    {
                        ParentChildrenShapesMapping[info.ParentShapeClassType.Value].Add(info.ShapeClassType);
                    }
                }
            }

            RelationshipShapeInfo[] rsInfos = GetRelationshipShapeInfo();
            if (rsInfos != null)
            {
                foreach (RelationshipShapeInfo info in rsInfos)
                {
                    RelationshipShapeInfos.Add(info.ShapeClassType, info);
                    ClassShapesMapping[info.DomainClassType].Add(info.ShapeClassType);

                    DiagramRSChildren[info.DiagramClassType].Add(info.ShapeClassType);
                }
            }

            MappingRelationshipShapeInfo[] mrsInfos = GetMappingRelationshipShapeInfo();
            if (rsInfos != null)
            {
                foreach (MappingRelationshipShapeInfo info in mrsInfos)
                {
                    MappingRelationshipShapeInfos.Add(info.ShapeClassType, info);
                    ClassShapesMapping[info.DomainClassType].Add(info.ShapeClassType);

                    DiagramMappingRSChildren[info.DiagramClassType].Add(info.ShapeClassType);
                }
            }
        }