Exemplo n.º 1
0
        public static IList <String> GetMappedProperties(this GraphMap graphMap, String templateId, int templateIndex, String parentClassId, int parentClassIndex, IList <String> propertyList = null)
        {
            if (propertyList == null)
            {
                propertyList = new List <String>();
            }

            var classTemplateMap = graphMap.GetClassTemplateMap(parentClassId, parentClassIndex);

            if (classTemplateMap != null)
            {
                var template = classTemplateMap.templateMaps.SingleOrDefault(x => (x.id == templateId && x.index == templateIndex));
                if (template != null)
                {
                    foreach (var role in template.roleMaps.Where(x => !String.IsNullOrWhiteSpace(x.propertyName)))
                    {
                        propertyList.Add(role.propertyName);
                    }
                    foreach (var role in template.roleMaps.Where(x => x.classMap != null))
                    {
                        var classTemplate = graphMap.GetClassTemplateMap(role.classMap.id, role.classMap.index);
                        foreach (var tmpl in classTemplate.templateMaps)
                        {
                            if (tmpl != null)
                            {
                                graphMap.GetMappedProperties(tmpl.id, tmpl.index, role.classMap.id, role.classMap.index, propertyList);
                            }
                        }
                    }
                }
            }
            return(propertyList);
        }
Exemplo n.º 2
0
        public static IDictionary <String, IDictionary <String, ValueList> > GetMappedValueListsWithPath(this GraphMap graphMap, ValueListMaps valueListMaps, String templateId, int templateIndex, String parentClassId, int parentClassIndex, IDictionary <String, IDictionary <String, ValueList> > valueList = null)
        {
            if (valueList == null)
            {
                valueList = new Dictionary <String, IDictionary <String, ValueList> >();
            }

            var classTemplateMap = graphMap.GetClassTemplateMap(parentClassId, parentClassIndex);



            if (classTemplateMap != null)
            {
                var template = classTemplateMap.templateMaps.SingleOrDefault(x => (x.id == templateId && x.index == templateIndex));
                if (template != null)
                {
                    foreach (var role in template.roleMaps.Where(x => !String.IsNullOrWhiteSpace(x.propertyName)))
                    {
                        if (role.type == RoleType.ObjectProperty)
                        {
                            string path = (string.IsNullOrEmpty(classTemplateMap.classMap.path) ? "" : classTemplateMap.classMap.path) + "/" + classTemplateMap.classMap.id.ToString() + "/" + template.id.ToString() + "/" + role.id.ToString();
                            Dictionary <String, ValueList> valListDict = new Dictionary <String, ValueList>();
                            ValueMaps       valueMaps = GetValueListMap(valueListMaps, role.valueListName);
                            ValueList       valList   = new ValueList();
                            ValueCollection valCol    = new ValueCollection();
                            valList.name = role.valueListName;
                            foreach (var item in valueMaps)
                            {
                                ValueItem valItem = new ValueItem();
                                valItem.label = item.label;
                                valItem.value = item.internalValue;
                                valItem.uri   = item.uri;
                                valCol.Add(valItem);
                            }
                            valList.values = valCol;
                            valListDict.Add(role.propertyName, valList);
                            valueList.Add(path, valListDict);
                        }
                    }
                    foreach (var role in template.roleMaps.Where(x => x.classMap != null))
                    {
                        var classTemplate = graphMap.GetClassTemplateMap(role.classMap.id, role.classMap.index);
                        foreach (var tmpl in classTemplate.templateMaps)
                        {
                            if (tmpl != null)
                            {
                                graphMap.GetMappedValueListsWithPath(valueListMaps, tmpl.id, tmpl.index, role.classMap.id, role.classMap.index, valueList);
                            }
                        }
                    }
                }
            }
            return(valueList);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public static IDictionary <String, IDictionary <String, Identifiers> > GetMappedPropertiesWithPath(this GraphMap graphMap, String templateId, int templateIndex, String parentClassId, int parentClassIndex, IDictionary <String, IDictionary <String, Identifiers> > propertyList = null)
        {
            if (propertyList == null)
            {
                propertyList = new Dictionary <String, IDictionary <String, Identifiers> >();
            }

            var classTemplateMap = graphMap.GetClassTemplateMap(parentClassId, parentClassIndex);

            if (classTemplateMap != null)
            {
                var template = classTemplateMap.templateMaps.SingleOrDefault(x => (x.id == templateId && x.index == templateIndex));
                if (template != null)
                {
                    foreach (var role in template.roleMaps.Where(x => !String.IsNullOrWhiteSpace(x.propertyName)))
                    {
                        //   if (role.type != RoleType.ObjectProperty)
                        //  {
                        string path = (string.IsNullOrEmpty(classTemplateMap.classMap.path) ? "" : classTemplateMap.classMap.path) + "/" + classTemplateMap.classMap.id.ToString() + "/" + template.id.ToString() + "/" + role.id.ToString();
                        Dictionary <String, Identifiers> identifierList = new Dictionary <String, Identifiers>();
                        identifierList.Add(role.propertyName, classTemplateMap.classMap.identifiers);
                        propertyList.Add(path, identifierList);
                        //  }
                    }
                    foreach (var role in template.roleMaps.Where(x => x.classMap != null))
                    {
                        var classTemplate = graphMap.GetClassTemplateMap(role.classMap.id, role.classMap.index);
                        foreach (var tmpl in classTemplate.templateMaps)
                        {
                            if (tmpl != null)
                            {
                                graphMap.GetMappedPropertiesWithPath(tmpl.id, tmpl.index, role.classMap.id, role.classMap.index, propertyList);
                            }
                        }
                    }
                }
            }
            return(propertyList);
        }
Exemplo n.º 5
0
        public static void DeleteTemplateMap(this GraphMap graphMap, string parentClassId, int parentClassIndex, int templateMapIndex)
        {
            ClassTemplateMap ctm = graphMap.GetClassTemplateMap(parentClassId, parentClassIndex);
            TemplateMap      tm  = ctm.templateMaps[templateMapIndex];

            foreach (RoleMap rm in tm.roleMaps)
            {
                DeleteRoleMap(graphMap, tm, rm.id);
            }

            ctm.templateMaps.RemoveAt(templateMapIndex);

            //int newIndex = 0;
            //foreach (TemplateMap tMap in ctm.templateMaps.Where(x => x.id == tm.id))
            //{
            //  tMap.index = newIndex++;
            //}

            graphMap.SetClassPath();
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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;
            }
        }