private ClassInfo GetClassInfo(string fullClassName
                                       )
        {
            if (ODBType.GetFromName(fullClassName).IsNative())
            {
                return(null);
            }
            ISession  session   = storageEngine.GetSession(true);
            MetaModel metaModel = session.GetMetaModel();

            if (metaModel.ExistClass(fullClassName))
            {
                return(metaModel.GetClassInfo(fullClassName, true));
            }
            ClassInfo     ci     = null;
            ClassInfoList ciList = null;

            ciList = classIntrospector.Introspect(fullClassName, true);
            // to enable junit tests
            if (storageEngine != null)
            {
                storageEngine.AddClasses(ciList);
                // For client Server : reset meta model
                if (!storageEngine.IsLocal())
                {
                    metaModel = session.GetMetaModel();
                }
            }
            else
            {
                metaModel.AddClasses(ciList);
            }
            ci = metaModel.GetClassInfo(fullClassName, true);
            return(ci);
        }
Exemple #2
0
        /// <param name="type"> The class to introspect </param>
        /// <param name="recursive"> If true, goes does the hierarchy to try to analyze all classes </param>
        /// <param name="classInfoList"> map with class name that are being introspected, to avoid recursive calls </param>
        private static ClassInfoList InternalIntrospect(Type type, bool recursive, ClassInfoList classInfoList)
        {
            if (classInfoList != null)
            {
                var existingClassInfo = classInfoList.GetClassInfoBy(type);

                if (existingClassInfo != null)
                {
                    return(classInfoList);
                }
            }

            var classInfo = new ClassInfo(type);

            if (classInfoList == null)
            {
                classInfoList = new ClassInfoList(classInfo);
            }
            else
            {
                classInfoList.AddClassInfo(classInfo);
            }

            var fields     = GetAllFieldsFrom(type);
            var attributes = new OdbList <ClassAttributeInfo>(fields.Count);

            for (var i = 0; i < fields.Count; i++)
            {
                var field = fields[i];

                ClassInfo classInfoByName;

                if (OdbType.GetFromClass(field.FieldType).IsNative())
                {
                    classInfoByName = null;
                }
                else
                {
                    if (recursive)
                    {
                        classInfoList   = InternalIntrospect(field.FieldType, true, classInfoList);
                        classInfoByName = classInfoList.GetClassInfoBy(field.FieldType);
                    }
                    else
                    {
                        classInfoByName = new ClassInfo(field.FieldType);
                    }
                }

                attributes.Add(new ClassAttributeInfo((i + 1), field.Name, field.FieldType,
                                                      OdbClassNameResolver.GetFullName(field.FieldType), classInfoByName));
            }

            classInfo.Attributes     = attributes;
            classInfo.MaxAttributeId = fields.Count;

            return(classInfoList);
        }
Exemple #3
0
        /// <summary> </summary>
        /// <param name="clazz">The class to instrospect
        /// </param>
        /// <param name="recursive">If true, goes does the hierarchy to try to analyse all classes
        /// </param>
        /// <param name="A">map with classname that are being introspected, to avoid recursive calls
        ///
        /// </param>
        /// <returns>
        /// </returns>
        private ClassInfoList InternalIntrospect(System.Type clazz, bool recursive, ClassInfoList classInfoList)
        {
            if (classInfoList != null)
            {
                ClassInfo existingCi = (ClassInfo)classInfoList.GetClassInfoWithName(OdbClassUtil.GetFullName(clazz));
                if (existingCi != null)
                {
                    return(classInfoList);
                }
            }

            ClassInfo classInfo = new ClassInfo(OdbClassUtil.GetFullName(clazz));

            classInfo.SetClassCategory(GetClassCategory(OdbClassUtil.GetFullName(clazz)));
            if (classInfoList == null)
            {
                classInfoList = new ClassInfoList(classInfo);
            }
            else
            {
                classInfoList.AddClassInfo(classInfo);
            }

            // Field[] fields = clazz.getDeclaredFields();
            //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
            //m by cristi
            IOdbList <FieldInfo>          fields     = GetAllFields(OdbClassUtil.GetFullName(clazz));
            IOdbList <ClassAttributeInfo> attributes = new OdbArrayList <ClassAttributeInfo>(fields.Count);

            ClassInfo ci = null;

            for (int i = 0; i < fields.Count; i++)
            {
                System.Reflection.FieldInfo field = (System.Reflection.FieldInfo)fields[i];
                //Console.WriteLine("Field " + field.Name + " , type = " + field.FieldType);
                if (!ODBType.GetFromClass(field.FieldType).IsNative())
                {
                    if (recursive)
                    {
                        classInfoList = InternalIntrospect(field.FieldType, recursive, classInfoList);
                        ci            = classInfoList.GetClassInfoWithName(OdbClassUtil.GetFullName(field.FieldType));
                    }
                    else
                    {
                        ci = new ClassInfo(OdbClassUtil.GetFullName(field.FieldType));
                    }
                }
                else
                {
                    ci = null;
                }
                attributes.Add(new ClassAttributeInfo((i + 1), field.Name, field.FieldType, OdbClassUtil.GetFullName(field.FieldType), ci));
            }
            classInfo.SetAttributes(attributes);
            classInfo.SetMaxAttributeId(fields.Count);
            return(classInfoList);
        }
        private void Fetch()
        {
            ClassInfoList pl = new ClassInfoList();
            pl.GetClassInfoList();

            JavaScriptSerializer js = new JavaScriptSerializer();
            Response.Clear();
            Response.Write(js.Serialize(pl));
            Response.End();
        }
        /// <param name="type"> The class to introspect </param>
        /// <param name="recursive"> If true, goes does the hierarchy to try to analyze all classes </param>
        /// <param name="classInfoList"> map with class name that are being introspected, to avoid recursive calls </param>
        private static ClassInfoList InternalIntrospect(Type type, bool recursive, ClassInfoList classInfoList)
        {
            if (classInfoList != null)
            {
                var existingClassInfo = classInfoList.GetClassInfoBy(type);

                if (existingClassInfo != null)
                    return classInfoList;
            }

            var classInfo = new ClassInfo(type);

            if (classInfoList == null)
                classInfoList = new ClassInfoList(classInfo);
            else
                classInfoList.AddClassInfo(classInfo);

            var fields = GetAllFieldsFrom(type);
            var attributes = new OdbList<ClassAttributeInfo>(fields.Count);

            for (var i = 0; i < fields.Count; i++)
            {
                var field = fields[i];

                ClassInfo classInfoByName;

                if (OdbType.GetFromClass(field.FieldType).IsNative())
                {
                    classInfoByName = null;
                }
                else
                {
                    if (recursive)
                    {
                        classInfoList = InternalIntrospect(field.FieldType, true, classInfoList);
                        classInfoByName = classInfoList.GetClassInfoBy(field.FieldType);
                    }
                    else
                        classInfoByName = new ClassInfo(field.FieldType);
                }

                attributes.Add(new ClassAttributeInfo((i + 1), field.Name, field.FieldType,
                                                      OdbClassNameResolver.GetFullName(field.FieldType), classInfoByName));
            }

            classInfo.Attributes = attributes;
            classInfo.MaxAttributeId = fields.Count;

            return classInfoList;
        }
 public void Sort()
 {
     ClassInfoList.OrderBy(x => x.BlocksCovered).ToList();
 }
Exemple #7
0
        /// <summary>Store an object with the specific id</summary>
        /// <param name="oid"></param>
        /// <param name="@object"></param>
        /// <returns></returns>
        /// <></>
        protected virtual NeoDatis.Odb.OID InternalStore(OID oid, object o)
        {
            if (GetSession(true).IsRollbacked())
            {
                throw new ODBRuntimeException(NeoDatisError.OdbHasBeenRollbacked.AddParameter(GetBaseIdentification().ToString()));
            }
            if (o == null)
            {
                throw new ODBRuntimeException(NeoDatisError.OdbCanNotStoreNullObject);
            }
            Type clazz = o.GetType();

            if (ODBType.IsNative(clazz))
            {
                throw new ODBRuntimeException(NeoDatisError.OdbCanNotStoreNativeObjectDirectly
                                              .AddParameter(clazz.FullName).AddParameter(ODBType.GetFromClass(clazz).GetName()).AddParameter(clazz.FullName));
            }
            // The object must be transformed into meta representation
            ClassInfo ci        = null;
            string    className = OdbClassUtil.GetFullName(clazz);

            // first checks if the class of this object already exist in the
            // metamodel
            if (GetMetaModel().ExistClass(className))
            {
                ci = GetMetaModel().GetClassInfo(className, true);
            }
            else
            {
                ClassInfoList ciList = classIntrospector.Introspect(o.GetType(), true);
                // All new classes found
                objectWriter.AddClasses(ciList);
                ci = ciList.GetMainClassInfo();
            }
            // first detects if we must perform an insert or an update
            // If object is in the cache, we must perform an update, else an insert
            bool   mustUpdate = false;
            ICache cache      = GetSession(true).GetCache();

            if (o != null)
            {
                OID cacheOid = cache.IdOfInsertingObject(o);
                if (cacheOid != null)
                {
                    return(cacheOid);
                }
                // throw new ODBRuntimeException("Inserting meta representation of
                // an object without the object itself is not yet supported");
                mustUpdate = cache.ExistObject(o);
            }
            // The introspection callback is used to execute some specific task (like calling trigger, for example) while introspecting the object
            IIntrospectionCallback callback = introspectionCallbackForInsert;

            if (mustUpdate)
            {
                callback = introspectionCallbackForUpdate;
            }
            // Transform the object into an ObjectInfo
            NonNativeObjectInfo nnoi = (NonNativeObjectInfo)objectIntrospector.GetMetaRepresentation(o, ci, true, null, callback);

            // During the introspection process, if object is to be updated, then the oid has been set
            mustUpdate = nnoi.GetOid() != null;
            if (mustUpdate)
            {
                return(objectWriter.UpdateNonNativeObjectInfo(nnoi, false));
            }
            return(objectWriter.InsertNonNativeObject(oid, nnoi, true));
        }