Esempio n. 1
0
        /// <summary>This method is used to make sure that client oids and server oids are equal.
        ///     </summary>
        /// <remarks>
        /// This method is used to make sure that client oids and server oids are equal.
        /// <pre>
        /// When storing an object, the client side does nt know the oid that each object will receive. So the client create
        /// temporary (sequencial) oids. These oids are sent to the server in the object meta-representations. On the server side,
        /// real OIDs are created and associated to the objects and to the client side ids. After calling the store on the server side
        /// The client use the the synchronizeIds method to replace client ids by the right server side ids.
        /// </pre>
        /// </remarks>
        public virtual void SynchronizeIds(NeoDatis.Odb.OID[] clientIds, NeoDatis.Odb.OID
                                           [] serverIds)
        {
            if (clientIds.Length != clientOids.Count)
            {
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ClientServerSynchronizeIds
                                                           .AddParameter(clientOids.Count).AddParameter(clientIds.Length));
            }
            NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = null;
            NeoDatis.Odb.Core.Transaction.ICache cache = GetSession().GetCache();
            object @object = null;

            NeoDatis.Odb.OID id = null;
            NeoDatis.Odb.Core.Transaction.ICrossSessionCache crossSessionCache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
                                                                                 .GetCrossSessionCache(storageEngine.GetBaseIdentification().GetIdentification());
            for (int i = 0; i < clientIds.Length; i++)
            {
                id      = clientIds[i];
                cnnoi   = aois[id];
                @object = objects[id];
                // Server ids may be null when an object or part of an object has been updated.
                // In these case local objects have already the correct ids
                if (serverIds[i] != null)
                {
                    cnnoi.SetOid(serverIds[i]);
                    cache.AddObject(serverIds[i], @object, cnnoi.GetHeader());
                }
                // As serverIds may be null, we need to check it
                if (NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession() && serverIds[i] !=
                    null)
                {
                    crossSessionCache.AddObject(@object, serverIds[i]);
                }
            }
        }
Esempio n. 2
0
 public override NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo BuildNnoi
     (object o, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo info, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
     [] values, long[] attributesIdentification, int[] attributeIds, System.Collections.Generic.IDictionary
     <object, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo> alreadyReadObjects
     )
 {
     NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = new
                                                                                   NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo(null, info
                                                                                                                                                         , values, attributesIdentification, attributeIds);
     cnnoi.SetLocalOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(alreadyReadObjects
                                                                       .Count + 1));
     NeoDatis.Odb.OID id = cnnoi.GetLocalOid();
     NeoDatis.Odb.Core.Transaction.ICache cache = GetSession().GetCache();
     // Check if object is in the cache, if so sets its id
     NeoDatis.Odb.OID oid = cache.GetOid(o, false);
     if (oid != null)
     {
         cnnoi.SetOid(oid);
     }
     clientOids.Add(id);
     aois.Add(id, cnnoi);
     objects.Add(id, o);
     return(cnnoi);
 }
		public override NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo BuildNnoi
			(object o, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo info, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
			[] values, long[] attributesIdentification, int[] attributeIds, System.Collections.Generic.IDictionary
			<object, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo> alreadyReadObjects
			)
		{
			NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = new 
				NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo(null, info
				, values, attributesIdentification, attributeIds);
			cnnoi.SetLocalOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(alreadyReadObjects
				.Count + 1));
			NeoDatis.Odb.OID id = cnnoi.GetLocalOid();
			NeoDatis.Odb.Core.Transaction.ICache cache = GetSession().GetCache();
			// Check if object is in the cache, if so sets its id
			NeoDatis.Odb.OID oid = cache.GetOid(o, false);
			if (oid != null)
			{
				cnnoi.SetOid(oid);
			}
			clientOids.Add(id);
			aois.Add(id, cnnoi);
			objects.Add(id, o);
			return cnnoi;
		}
 public override NeoDatis.Odb.OID UpdateNonNativeObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                            nnoi, bool forceUpdate)
 {
     // To enable object auto-reconnect on the server side
     if (NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession() && nnoi.GetHeader()
         .GetOid() != null)
     {
         NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
                                                                            )sessionManager.GetSession(storageEngine.GetBaseIdentification().GetIdentification
                                                                                                           (), true);
         NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = session.GetCache().GetObjectInfoHeaderFromOid
                                                                         (nnoi.GetOid(), false);
         // only add in th cache if object does not exist in the cache
         if (oih == null)
         {
             session.GetCache().AddObjectInfo(nnoi.GetHeader());
         }
     }
     NeoDatis.Odb.OID roid = base.UpdateNonNativeObjectInfo(nnoi, forceUpdate);
     if (nnoi is NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo)
     {
         NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = (NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo
                                                                                        )nnoi;
         NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
                                                                            )GetSession();
         session.AssociateIds(cnnoi.GetOid(), cnnoi.GetLocalOid());
     }
     return(roid);
 }
 public override NeoDatis.Odb.OID WriteNonNativeObjectInfo(NeoDatis.Odb.OID existingOid
                                                           , NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo objectInfo, long position
                                                           , bool writeDataInTransaction, bool isNewObject)
 {
     // To enable object auto-reconnect on the server side
     if (NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession() && objectInfo.GetHeader
             ().GetOid() != null)
     {
         NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
                                                                            )sessionManager.GetSession(storageEngine.GetBaseIdentification().GetIdentification
                                                                                                           (), true);
         NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = session.GetCache().GetObjectInfoHeaderFromOid
                                                                         (objectInfo.GetOid(), false);
         // only add in th cache if object does not exist in the cache
         if (oih == null)
         {
             session.GetCache().AddObjectInfo(objectInfo.GetHeader());
         }
     }
     NeoDatis.Odb.OID roid = base.WriteNonNativeObjectInfo(existingOid, objectInfo, position
                                                           , writeDataInTransaction, isNewObject);
     if (objectInfo is NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo)
     {
         NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = (NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo
                                                                                        )objectInfo;
         NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
                                                                            )GetSession();
         session.AssociateIds(roid, cnnoi.GetLocalOid());
         // Adds the abstract Objectinfo in the cache
         session.GetCache().AddObjectInfo(cnnoi.GetHeader());
     }
     return(roid);
 }