public override NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo CreateCopy
     (System.Collections.Generic.IDictionary <NeoDatis.Odb.OID, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                              > cache, bool onlyData)
 {
     System.Collections.ICollection c = (System.Collections.ICollection)theObject;
     System.Collections.Generic.ICollection <NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                             > newCollection = new NeoDatis.Tool.Wrappers.List.OdbArrayList <NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                                                                                             >();
     // To keep track of non native objects
     NeoDatis.Tool.Wrappers.List.IOdbList <NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                           > nonNatives = new NeoDatis.Tool.Wrappers.List.OdbArrayList <NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                                                        >();
     System.Collections.IEnumerator iterator = c.GetEnumerator();
     while (iterator.MoveNext())
     {
         NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                                                        )iterator.Current;
         // create copy
         aoi = aoi.CreateCopy(cache, onlyData);
         newCollection.Add(aoi);
         if (aoi.IsNonNativeObject())
         {
             nonNatives.Add((NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo)aoi);
         }
     }
     NeoDatis.Odb.Core.Layers.Layer2.Meta.CollectionObjectInfo coi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.CollectionObjectInfo
                                                                         (newCollection, odbType, nonNatives);
     coi.SetRealCollectionClassName(realCollectionClassName);
     return(coi);
 }
Пример #2
0
 /// <summary>Create a copy oh this meta object</summary>
 /// <param name="onlyData">if true, only copy attributes values</param>
 /// <returns></returns>
 public override NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo CreateCopy
     (System.Collections.Generic.IDictionary <NeoDatis.Odb.OID, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                              > cache, bool onlyData)
 {
     NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                      )cache[objectHeader.GetOid()];
     if (nnoi != null)
     {
         return(nnoi);
     }
     if (onlyData)
     {
         NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader
                                                                         ();
         nnoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo(@object, classInfo
                                                                             , null, oih.GetAttributesIdentification(), oih.GetAttributeIds());
     }
     else
     {
         nnoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo(@object, classInfo
                                                                             , null, objectHeader.GetAttributesIdentification(), objectHeader.GetAttributeIds
                                                                                 ());
         nnoi.GetHeader().SetOid(GetHeader().GetOid());
     }
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo[] newAttributeValues = new
                                                                                    NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo[attributeValues.Length];
     for (int i = 0; i < attributeValues.Length; i++)
     {
         newAttributeValues[i] = attributeValues[i].CreateCopy(cache, onlyData);
     }
     nnoi.attributeValues = newAttributeValues;
     cache.Add(objectHeader.GetOid(), nnoi);
     return(nnoi);
 }
Пример #3
0
        /// <summary>Used to change the value of an attribute</summary>
        /// <param name="attributeName"></param>
        /// <param name="aoi"></param>
        public virtual void SetValueOf(string attributeName, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                       aoi)
        {
            int  attributeId = -1;
            bool isRelation  = attributeName.IndexOf(".") != -1;

            if (!isRelation)
            {
                attributeId = GetClassInfo().GetAttributeId(attributeName);
                SetAttributeValue(attributeId, aoi);
                return;
            }
            int    firstDotIndex      = attributeName.IndexOf(".");
            string firstAttributeName = NeoDatis.Tool.Wrappers.OdbString.Substring(attributeName
                                                                                   , 0, firstDotIndex);

            attributeId = GetClassInfo().GetAttributeId(firstAttributeName);
            object @object = attributeValues[attributeId];

            if (@object is NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo)
            {
                NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                                 )@object;
                nnoi.SetValueOf(NeoDatis.Tool.Wrappers.OdbString.Substring(attributeName, firstDotIndex
                                                                           + 1, attributeName.Length), aoi);
            }
            throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ClassInfoDoNotHaveTheAttribute
                                                       .AddParameter(GetClassInfo().GetFullClassName()).AddParameter(attributeName));
        }
Пример #4
0
 public ChangedObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo oldCi, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                          newCi, int fieldIndex, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                          oldValue, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo newValue, int
                          objectRecursionLevel) : this(oldCi, newCi, fieldIndex, oldValue, newValue, null,
                                                       objectRecursionLevel)
 {
 }
Пример #5
0
 private bool CheckIfCollectionContainsValue(System.Collections.ICollection c)
 {
     NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = GetQuery().GetStorageEngine
                                                                 ();
     if (engine == null)
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.QueryEngineNotSet
                                                    );
     }
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = null;
     System.Collections.IEnumerator iterator = c.GetEnumerator();
     // If the object to compared is native
     if (objectIsNative)
     {
         while (iterator.MoveNext())
         {
             aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo)iterator.Current;
             if (aoi == null && criterionValue == null)
             {
                 return(true);
             }
             if (aoi != null && criterionValue == null)
             {
                 return(false);
             }
             if (criterionValue.Equals(aoi.GetObject()))
             {
                 return(true);
             }
         }
         return(false);
     }
     // Object is not native
     while (iterator.MoveNext())
     {
         aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo)iterator.Current;
         if (aoi.IsNull() && criterionValue == null && oid == null)
         {
             return(true);
         }
         if (aoi != null & oid != null)
         {
             if (aoi.IsNonNativeObject())
             {
                 NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi1 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                                   )aoi;
                 bool isEqual = nnoi1.GetOid() != null && oid != null && nnoi1.GetOid().Equals(oid
                                                                                               );
                 if (isEqual)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Пример #6
0
        public virtual bool Match(NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                  aoi)
        {
            NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                             )aoi;
            object aoiValue = nnoi.GetValueOf(attributeName);

            return(Match(aoiValue));
        }
Пример #7
0
		public ArrayModifyElement(NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
			 nnoi, int attributeId, int index, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
			 newValue, bool supportInPlaceUpdate) : base()
		{
			this.nnoi = nnoi;
			this.attributeId = attributeId;
			this.supportInPlaceUpdate = supportInPlaceUpdate;
			this.newValue = newValue;
			this.arrayElementIndexToChange = index;
		}
Пример #8
0
 public virtual void SetValueOf(string attributeName, object value)
 {
     //fixme : storage engine is null?
     NeoDatis.Odb.Core.Layers.Layer1.Introspector.IObjectIntrospector introspector = NeoDatis.Odb.OdbConfiguration
                                                                                     .GetCoreProvider().GetLocalObjectIntrospector(null);
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = introspector.GetMetaRepresentation
                                                                       (value, null, true, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrumentationCallback
                                                                           ());
     nnoi.SetValueOf(attributeName, aoi);
 }
Пример #9
0
 /// <summary>The performance of this method is bad.</summary>
 /// <remarks>The performance of this method is bad. But it is not used by the engine, only in the ODBExplorer
 ///     </remarks>
 /// <param name="aoi"></param>
 /// <returns></returns>
 public virtual int GetAttributeId(NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                   aoi)
 {
     for (int i = 0; i < attributeValues.Length; i++)
     {
         if (aoi == attributeValues[i])
         {
             return(i + 1);
         }
     }
     return(-1);
 }
Пример #10
0
 public ChangedObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo oldCi, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                          newCi, int fieldIndex, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                          oldValue, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo newValue, string
                          message, int objectRecursionLevel) : base()
 {
     this.oldCi                = oldCi;
     this.newCi                = newCi;
     this.fieldIndex           = fieldIndex;
     this.oldValue             = oldValue;
     this.newValue             = newValue;
     this.message              = message;
     this.objectRecursionLevel = objectRecursionLevel;
 }
		public ChangedObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo oldCi, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
			 newCi, int fieldIndex, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo 
			oldValue, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo newValue, string
			 message, int objectRecursionLevel) : base()
		{
			this.oldCi = oldCi;
			this.newCi = newCi;
			this.fieldIndex = fieldIndex;
			this.oldValue = oldValue;
			this.newValue = newValue;
			this.message = message;
			this.objectRecursionLevel = objectRecursionLevel;
		}
Пример #12
0
 public static NeoDatis.Tool.Wrappers.OdbComparable BuildIndexKey(string indexName
                                                                  , NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo oi, int[] fieldIds)
 {
     NeoDatis.Tool.Wrappers.OdbComparable[] keys = new NeoDatis.Tool.Wrappers.OdbComparable
                                                   [fieldIds.Length];
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = null;
     System.IComparable o = null;
     for (int i = 0; i < fieldIds.Length; i++)
     {
         // Todo : can we assume that the object is a Comparable
         try
         {
             aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo)oi.GetAttributeValueFromId
                       (fieldIds[i]);
             o = (System.IComparable)aoi.GetObject();
             // JDK1.4 restriction: Boolean is not Comparable in jdk1.4
             if (aoi.GetOdbType().IsBoolean())
             {
                 bool b = (bool)o;
                 if (b)
                 {
                     o = (byte)1;
                 }
                 else
                 {
                     o = (byte)0;
                 }
             }
             // If the index is on NonNativeObjectInfo, then the key is the oid
             // of the object
             if (aoi.IsNonNativeObject())
             {
                 NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                                  )aoi;
                 o = nnoi.GetOid();
             }
             keys[i] = new NeoDatis.Odb.Core.Query.SimpleCompareKey(o);
         }
         catch (System.Exception)
         {
             throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.IndexKeysMustImplementComparable
                                                        .AddParameter(fieldIds[i]).AddParameter(oi.GetAttributeValueFromId(fieldIds[i]).
                                                                                                GetType().FullName));
         }
     }
     if (keys.Length == 1)
     {
         return(keys[0]);
     }
     return(new NeoDatis.Odb.Core.Query.ComposedCompareKey(keys));
 }
Пример #13
0
        /// <summary>
        /// Check if the object at position currentPosition matches the query, returns true
        /// This method must compute the next object position and the orderBy key if it exists!
        /// </summary>
        public override bool MatchObjectWithOid(NeoDatis.Odb.OID oid, bool loadObjectInfo
                                                , bool inMemory)
        {
            NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoitemp = objectReader.ReadNonNativeObjectInfoFromOid
                                                                                  (classInfo, oid, true, true);
            bool objectMatches = false;

            if (!aoitemp.IsDeletedObject())
            {
                currentNnoi   = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo)aoitemp;
                currentObject = instanceBuilder.BuildOneInstance(currentNnoi);
                objectMatches = query == null || NeoDatis.Odb.Core.Query.QueryManager.Match(query
                                                                                            , currentObject);
                nextOID = currentNnoi.GetNextObjectOID();
            }
            return(objectMatches);
        }
        public override T Get(int index)
        {
            object o = base[index];

            NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                                                           )o;
            try
            {
                if (aoi.IsNull())
                {
                    return(default(T));
                }
                if (returnInstance)
                {
                    if (aoi.IsNative())
                    {
                        return((T)aoi.GetObject());
                    }
                    if (instanceBuilder == null)
                    {
                        // Lookup the instance builder
                        instanceBuilder = (NeoDatis.Odb.Core.Layers.Layer2.Instance.IInstanceBuilder)NeoDatis.Odb.Core.Lookup.LookupFactory
                                          .Get(sessionId).Get(NeoDatis.Odb.Impl.Core.Lookup.Lookups.InstanceBuilder);
                        if (instanceBuilder == null)
                        {
                            throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.LookupKeyNotFound
                                                                       .AddParameter(NeoDatis.Odb.Impl.Core.Lookup.Lookups.InstanceBuilder));
                        }
                    }
                    return((T)instanceBuilder.BuildOneInstance((NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                )aoi));
                }
                // No need to return Instance return the layer 2 representation
                o = aoi;
                return((T)o);
            }
            catch (System.Exception e)
            {
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ErrorWhileGettingObjectFromListAtIndex
                                                           .AddParameter(index), e);
            }
        }
Пример #15
0
        public override AbstractObjectInfo CreateCopy(IDictionary <OID, AbstractObjectInfo> cache, bool onlyData)
        {
            IDictionary <AbstractObjectInfo, AbstractObjectInfo> m      = GetMap();
            IDictionary <AbstractObjectInfo, AbstractObjectInfo> newMap = new OdbHashMap <AbstractObjectInfo, AbstractObjectInfo>();

            System.Collections.IEnumerator iterator = m.Keys.GetEnumerator();
            while (iterator.MoveNext())
            {
                NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo keyAoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                                                                  )iterator.Current;
                NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo valueAoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                                                                    )m[keyAoi];
                // create copies
                keyAoi   = keyAoi.CreateCopy(cache, onlyData);
                valueAoi = valueAoi.CreateCopy(cache, onlyData);
                newMap.Add(keyAoi, valueAoi);
            }
            MapObjectInfo moi = new MapObjectInfo(newMap, odbType, realMapClassName);

            return(moi);
        }
Пример #16
0
        public override NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo CreateCopy
            (System.Collections.Generic.IDictionary <NeoDatis.Odb.OID, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                                     > cache, bool onlyData)
        {
            object[] array  = GetArray();
            int      length = array.Length;

            NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo[] aois = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AtomicNativeObjectInfo
                                                                             [length];
            for (int i = 0; i < length; i++)
            {
                NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                                                               )array[i];
                aois[i] = aoi.CreateCopy(cache, onlyData);
            }
            NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo arrayOfAoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo
                                                                                  (aois);
            arrayOfAoi.SetRealArrayComponentClassName(realArrayComponentClassName);
            arrayOfAoi.SetComponentTypeId(componentTypeId);
            return(arrayOfAoi);
        }
Пример #17
0
        private bool CheckIfArrayContainsValue(object valueToMatch)
        {
            int arrayLength = NeoDatis.Tool.Wrappers.OdbReflection.GetArrayLength(valueToMatch
                                                                                  );
            object element = null;

            NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = null;
            for (int i = 0; i < arrayLength; i++)
            {
                element = NeoDatis.Tool.Wrappers.OdbReflection.GetArrayElement(valueToMatch, i);
                if (element == null && criterionValue == null)
                {
                    return(true);
                }
                aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo)element;
                if (aoi != null && aoi.GetObject() != null && aoi.GetObject().Equals(criterionValue
                                                                                     ))
                {
                    return(true);
                }
            }
            return(false);
        }
		/// <summary>Create a copy oh this meta object</summary>
		/// <param name="onlyData">if true, only copy attributes values</param>
		/// <returns></returns>
		public override NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo CreateCopy
			(System.Collections.Generic.IDictionary<NeoDatis.Odb.OID, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
			> cache, bool onlyData)
		{
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)cache[objectHeader.GetOid()];
			if (nnoi != null)
			{
				return nnoi;
			}
			if (onlyData)
			{
				NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader
					();
				nnoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo(@object, classInfo
					, null, oih.GetAttributesIdentification(), oih.GetAttributeIds());
			}
			else
			{
				nnoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo(@object, classInfo
					, null, objectHeader.GetAttributesIdentification(), objectHeader.GetAttributeIds
					());
				nnoi.GetHeader().SetOid(GetHeader().GetOid());
			}
			NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo[] newAttributeValues = new 
				NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo[attributeValues.Length];
			for (int i = 0; i < attributeValues.Length; i++)
			{
				newAttributeValues[i] = attributeValues[i].CreateCopy(cache, onlyData);
			}
			nnoi.attributeValues = newAttributeValues;
			cache.Add(objectHeader.GetOid(), nnoi);
			return nnoi;
		}
Пример #19
0
 public virtual void SetAttributeValue(int attributeId, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                       aoi)
 {
     attributeValues[attributeId - 1] = aoi;
 }
Пример #20
0
 public virtual bool HasChanged(NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                aoi)
 {
     return(aoi.GetType() != typeof(NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeDeletedObjectInfo
                                    ));
 }