Esempio n. 1
0
        public static Cardinality GetCardinality(this GraphMap graphMap, RoleMap roleMap, DataDictionary dataDictionary, string fixedIdentifierBoundary)
        {
            ClassTemplateMap ctm = graphMap.GetClassTemplateMap(roleMap.classMap.id, roleMap.classMap.index);

            if (ctm == null || ctm.classMap == null)
            {
                return(Cardinality.Self);
            }

            // determine cardinality to related class
            foreach (string identifier in roleMap.classMap.identifiers)
            {
                if (!(identifier.StartsWith(fixedIdentifierBoundary) && identifier.EndsWith(fixedIdentifierBoundary)))
                {
                    string[] propertyParts = identifier.Split('.');

                    if (propertyParts.Length > 2)
                    {
                        DataObject       dataObject       = dataDictionary.dataObjects.First(c => c.objectName == propertyParts[0]);
                        DataRelationship dataRelationship = dataObject.dataRelationships.First(c => c.relationshipName == propertyParts[1]);

                        if (dataRelationship.relationshipType == RelationshipType.OneToMany)
                        {
                            return(Cardinality.OneToMany);
                        }
                    }
                }
            }

            return(Cardinality.OneToOne);
        }
Esempio n. 2
0
        public static void DeleteRoleMap(this GraphMap graphMap, TemplateMap templateMap, string roleId)
        {
            RoleMap roleMap = templateMap.roleMaps.Where(c => c.id == roleId).FirstOrDefault();

            if (roleMap != null)
            {
                if (roleMap.classMap != null)
                {
                    graphMap.DeleteClassMap(roleMap.classMap.id, roleMap.classMap.index);
                    roleMap.value    = null;
                    roleMap.classMap = null;
                }
            }
        }
Esempio n. 3
0
        public static RoleMap Clone(this RoleMap roleMap)
        {
            RoleMap clone = new RoleMap
            {
                type          = roleMap.type,
                id            = roleMap.id,
                name          = roleMap.name,
                dataType      = roleMap.dataType,
                propertyName  = roleMap.propertyName,
                value         = roleMap.value,
                valueListName = roleMap.valueListName,
                classMap      = roleMap.classMap,
            };

            return(clone);
        }
Esempio n. 4
0
        public static bool IsMapped(this RoleMap roleMap)
        {
            if (roleMap.type == RoleType.Unknown)
            {
                return(false);
            }

            if ((roleMap.type == RoleType.Property ||
                 roleMap.type == RoleType.DataProperty ||
                 roleMap.type == RoleType.ObjectProperty) &&
                string.IsNullOrEmpty(roleMap.propertyName))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 5
0
        public static void DeleteClassMap(this GraphMap graphMap, string classId, int classIndex)
        {
            ClassTemplateMap classTemplateMap = graphMap.GetClassTemplateMap(classId, classIndex);

            if (classTemplateMap != null && classTemplateMap.classMap != null)
            {
                List <TemplateMap> templateMaps = classTemplateMap.templateMaps;

                foreach (TemplateMap templateMap in templateMaps)
                {
                    RoleMap classRole = templateMap.roleMaps.Where(c => c.classMap != null).FirstOrDefault();
                    if (classRole != null)
                    {
                        graphMap.DeleteClassMap(classRole.classMap.id, classRole.classMap.index);
                        classRole.classMap = null;
                    }
                }

                templateMaps.Clear();
                graphMap.classTemplateMaps.Remove(classTemplateMap);
            }

            //RearrangeClassMapIndex(graphMap, classId);
        }
Esempio n. 6
0
        public static void AddClassMap(this GraphMap graphMap, RoleMap roleMap, ClassMap classMap)
        {
            ClassTemplateMap ctm = graphMap.GetClassTemplateMap(classMap.id, classMap.index);

            if (ctm == null)
            {
                graphMap.classTemplateMaps.Add(
                    new ClassTemplateMap
                {
                    classMap     = classMap,
                    templateMaps = new TemplateMaps()
                }
                    );
            }
            else
            {
                ctm.classMap = classMap;
            }

            if (roleMap != null)
            {
                roleMap.classMap = classMap;
            }
        }
Esempio n. 7
0
        public static string BuildClassPath(this GraphMap graphMap, ClassMap parentClassMap, TemplateMap templateMap, RoleMap roleMap)
        {
            string path = string.Format("{0}/{1}/{2}({3})/{4}", parentClassMap.path, parentClassMap.id, templateMap.id, templateMap.index, roleMap.id).Trim('/');

            return(path);
        }