Exemple #1
0
 protected virtual void Init()
 {
     start = 0;
     end   = 0;
     // for instance, only manage index for one field query using 'equal'
     if (classInfo.HasIndex() && query.HasCriteria() && CanUseIndex(query.GetCriteria(
                                                                        )))
     {
         NeoDatis.Tool.Wrappers.List.IOdbList <string> fields = query.GetAllInvolvedFields(
             );
         if (fields.IsEmpty())
         {
             useIndex = false;
         }
         else
         {
             int[] fieldIds = GetAllInvolvedFieldIds(fields);
             classInfoIndex = classInfo.GetIndexForAttributeIds(fieldIds);
             if (classInfoIndex != null)
             {
                 useIndex = true;
             }
         }
     }
     // Keep the detail
     details = GetDetails();
 }
        public override void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                     values)
        {
            System.Collections.Generic.IList <object> l = (System.Collections.Generic.IList <object
                                                                                             >)values[attributeName];
            int localFromIndex = fromIndex;
            int localEndIndex  = fromIndex + size;

            // If not throw exception, we must implement
            // Index Out Of Bound protection
            if (!throwExceptionIfOutOfBound)
            {
                // Check from index
                if (localFromIndex > l.Count - 1)
                {
                    localFromIndex = 0;
                }
                // Check end index
                if (localEndIndex > l.Count)
                {
                    localEndIndex = l.Count;
                }
            }
            sublist = new NeoDatis.Odb.Impl.Core.Query.List.Objects.LazySimpleListOfAOI <object
                                                                                         >(size, GetInstanceBuilder(), ReturnInstance());
            sublist.AddAll(NeoDatis.Tool.Wrappers.List.NeoDatisCollectionUtil.SublistGeneric(
                               l, localFromIndex, localEndIndex));
        }
		public override void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
			 values)
		{
			System.Collections.Generic.IList<object> l = (System.Collections.Generic.IList<object
				>)values[attributeName];
			int localFromIndex = fromIndex;
			int localEndIndex = fromIndex + size;
			// If not throw exception, we must implement 
			// Index Out Of Bound protection
			if (!throwExceptionIfOutOfBound)
			{
				// Check from index
				if (localFromIndex > l.Count - 1)
				{
					localFromIndex = 0;
				}
				// Check end index
				if (localEndIndex > l.Count)
				{
					localEndIndex = l.Count;
				}
			}
			sublist = new NeoDatis.Odb.Impl.Core.Query.List.Objects.LazySimpleListOfAOI<object
				>(size, GetInstanceBuilder(), ReturnInstance());
			sublist.AddAll(NeoDatis.Tool.Wrappers.List.NeoDatisCollectionUtil.SublistGeneric(
				l, localFromIndex, localEndIndex));
		}
Exemple #4
0
 public virtual void Clear()
 {
     if (writeActions != null)
     {
         writeActions.Clear();
         writeActions = null;
     }
 }
Exemple #5
0
 public virtual NeoDatis.Odb.Core.IError AddParameter(long l)
 {
     if (parameters == null)
     {
         parameters = new NeoDatis.Tool.Wrappers.List.OdbArrayList <object>();
     }
     parameters.Add(l);
     return(this);
 }
Exemple #6
0
        protected virtual void Init()
        {
            CheckRuntimeCompatibility();
            isClosed = false;
            isLocal  = baseIdentification.IsLocal();
            // The check if it is a new Database must be executed before object
            // writer initialization. Because Object Writer Init
            // Creates the file so the check (which is based on the file existence
            // would always return false*/
            bool isNewDatabase = IsNewDatabase();

            commitListeners   = new OdbArrayList <ICommitListener>();
            classIntrospector = provider.GetClassIntrospector();
            ISession session = BuildDefaultSession();

            // Object Writer must be created before object Reader
            objectWriter = BuildObjectWriter();
            // Object writer is a two Phase init object
            objectWriter.Init2();
            objectReader = BuildObjectReader();
            AddSession(session, false);
            // If the file does not exist, then a default header must be created
            if (isNewDatabase)
            {
                objectWriter.CreateEmptyDatabaseHeader(OdbTime.GetCurrentTimeInMs(), baseIdentification.GetUserName(), baseIdentification.GetPassword());
            }
            else
            {
                try
                {
                    GetObjectReader().ReadDatabaseHeader(baseIdentification.GetUserName(), baseIdentification.GetPassword());
                }
                catch (ODBAuthenticationRuntimeException e)
                {
                    Close();
                    throw;
                }
            }
            objectWriter.AfterInit();
            objectIntrospector  = BuildObjectIntrospector();
            this.triggerManager = BuildTriggerManager();
            // This forces the initialization of the meta model
            MetaModel metaModel = GetMetaModel();

            if (OdbConfiguration.CheckModelCompatibility())
            {
                CheckMetaModelCompatibility(classIntrospector.Instrospect(metaModel.GetAllClasses()));
            }
            // logically locks access to the file (only for this Virtual machine)
            FileMutex.GetInstance().OpenFile(GetStorageDeviceName());
            // Updates the Transaction Id in the file
            objectWriter.WriteLastTransactionId(GetCurrentTransactionId());
            this.objectWriter.SetTriggerManager(this.triggerManager);
            this.introspectionCallbackForInsert = new DefaultInstrumentationCallbackForStore(this, triggerManager, false);
            this.introspectionCallbackForUpdate = new DefaultInstrumentationCallbackForStore(this, triggerManager, true);
        }
Exemple #7
0
 public ClientObjectIntrospector(NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine storageEngine
                                 , string connectionId) : base(storageEngine)
 {
     clientOids = new NeoDatis.Tool.Wrappers.List.OdbArrayList <NeoDatis.Odb.OID>();
     aois       = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <NeoDatis.Odb.OID, NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo
                                                             >();
     objects        = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <NeoDatis.Odb.OID, object>();
     sessionManager = NeoDatis.Odb.OdbConfiguration.GetCoreProvider().GetClientServerSessionManager
                          ();
     this.connectionId = connectionId;
 }
		public ClientObjectIntrospector(NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine storageEngine
			, string connectionId) : base(storageEngine)
		{
			clientOids = new NeoDatis.Tool.Wrappers.List.OdbArrayList<NeoDatis.Odb.OID>();
			aois = new NeoDatis.Tool.Wrappers.Map.OdbHashMap<NeoDatis.Odb.OID, NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo
				>();
			objects = new NeoDatis.Tool.Wrappers.Map.OdbHashMap<NeoDatis.Odb.OID, object>();
			sessionManager = NeoDatis.Odb.OdbConfiguration.GetCoreProvider().GetClientServerSessionManager
				();
			this.connectionId = connectionId;
		}
Exemple #9
0
        /// <summary>Transform a list of field names into a list of field ids</summary>
        /// <param name="fields"></param>
        /// <returns>The array of field ids</returns>
        protected virtual int[] GetAllInvolvedFieldIds(NeoDatis.Tool.Wrappers.List.IOdbList
                                                       <string> fields)
        {
            int nbFields = fields.Count;

            int[] fieldIds = new int[nbFields];
            for (int i = 0; i < nbFields; i++)
            {
                fieldIds[i] = classInfo.GetAttributeId(fields[i].ToString());
            }
            return(fieldIds);
        }
		public MetaModel()
		{
			this.classPool = NeoDatis.Odb.OdbConfiguration.GetCoreProvider().GetClassPool();
			rapidAccessForUserClassesByName = new NeoDatis.Tool.Wrappers.Map.OdbHashMap<string
				, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo>(10);
			rapidAccessForSystemClassesByName = new NeoDatis.Tool.Wrappers.Map.OdbHashMap<string
				, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo>(10);
			rapidAccessForClassesByOid = new NeoDatis.Tool.Wrappers.Map.OdbHashMap<NeoDatis.Odb.OID
				, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo>(10);
			allClassInfos = new NeoDatis.Tool.Wrappers.List.OdbArrayList<NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
				>();
		}
 public MetaModel()
 {
     this.classPool = NeoDatis.Odb.OdbConfiguration.GetCoreProvider().GetClassPool();
     rapidAccessForUserClassesByName = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <string
                                                                                  , NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo>(10);
     rapidAccessForSystemClassesByName = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <string
                                                                                    , NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo>(10);
     rapidAccessForClassesByOid = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <NeoDatis.Odb.OID
                                                                             , NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo>(10);
     allClassInfos = new NeoDatis.Tool.Wrappers.List.OdbArrayList <NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                                                                   >();
 }
Exemple #12
0
 public DefaultWriteAction(long position, byte[] bytes, string label)
 {
     this.byteArrayConverter = NeoDatis.Odb.OdbConfiguration.GetCoreProvider().GetByteArrayConverter
                                   ();
     this.position = position;
     //TODO:perf should init with no default size?
     listOfBytes = new NeoDatis.Tool.Wrappers.List.OdbArrayList <byte[]>(20);
     if (bytes != null)
     {
         listOfBytes.Add(bytes);
         this.size = bytes.Length;
     }
 }
		public DefaultWriteAction(long position, byte[] bytes, string label)
		{
			this.byteArrayConverter = NeoDatis.Odb.OdbConfiguration.GetCoreProvider().GetByteArrayConverter
				();
			this.position = position;
			//TODO:perf should init with no default size?
			listOfBytes = new NeoDatis.Tool.Wrappers.List.OdbArrayList<byte[]>(20);
			if (bytes != null)
			{
				listOfBytes.Add(bytes);
				this.size = bytes.Length;
			}
		}
        /// <summary>Builds a meta model from a list of class infos</summary>
        /// <param name="classInfos"></param>
        /// <returns>The new Metamodel</returns>
        public static NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel FromClassInfos(NeoDatis.Tool.Wrappers.List.IOdbList
                                                                                    <NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo> classInfos)
        {
            NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = new NeoDatis.Odb.Core.Layers.Layer2.Meta.SessionMetaModel
                                                                           ();
            int nbClasses = classInfos.Count;

            for (int i = 0; i < nbClasses; i++)
            {
                metaModel.AddClass(classInfos[i]);
            }
            return(metaModel);
        }
Exemple #15
0
 public virtual void Init(NeoDatis.Odb.Core.Transaction.ISession session)
 {
     this.provider    = NeoDatis.Odb.OdbConfiguration.GetCoreProvider();
     this.session     = session;
     this.isCommited  = false;
     creationDateTime = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
     writeActions     = new NeoDatis.Tool.Wrappers.List.OdbArrayList <NeoDatis.Odb.Core.Transaction.IWriteAction
                                                                      >(1000);
     hasAllWriteActionsInMemory = true;
     numberOfWriteActions       = 0;
     hasBeenPersisted           = false;
     wasRollbacked            = false;
     currentWritePositionInWA = -1;
 }
Exemple #16
0
 public NonNativeObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader
                            oip, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo classInfo) : base(null)
 {
     // private List attributeValues;
     this.classInfo    = classInfo;
     this.objectHeader = oip;
     if (classInfo != null)
     {
         this.maxNbattributes = classInfo.GetMaxAttributeId();
         this.attributeValues = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                [maxNbattributes];
     }
     this.allNonNativeObjects = null;
 }
		public NonNativeObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader 
			oip, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo classInfo) : base(null)
		{
			// private List attributeValues;
			this.classInfo = classInfo;
			this.objectHeader = oip;
			if (classInfo != null)
			{
				this.maxNbattributes = classInfo.GetMaxAttributeId();
				this.attributeValues = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
					[maxNbattributes];
			}
			this.allNonNativeObjects = null;
		}
		public NonNativeObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo classInfo
			) : base(null)
		{
			//new OdbArrayList<NonNativeObjectInfo>();
			this.classInfo = classInfo;
			this.objectHeader = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader(-1, 
				null, null, (classInfo != null ? classInfo.GetId() : null), null, null);
			if (classInfo != null)
			{
				this.maxNbattributes = classInfo.GetMaxAttributeId();
				this.attributeValues = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
					[maxNbattributes];
			}
			this.allNonNativeObjects = null;
		}
Exemple #19
0
 public NonNativeObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo classInfo
                            ) : base(null)
 {
     //new OdbArrayList<NonNativeObjectInfo>();
     this.classInfo    = classInfo;
     this.objectHeader = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader(-1,
                                                                                   null, null, (classInfo != null ? classInfo.GetId() : null), null, null);
     if (classInfo != null)
     {
         this.maxNbattributes = classInfo.GetMaxAttributeId();
         this.attributeValues = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                [maxNbattributes];
     }
     this.allNonNativeObjects = null;
 }
 public LazyODBBTreePersister(NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine
                              )
 {
     // See the map strategy performance test at
     // test/org.neodatis.odb.test.performance.TestMapPerf
     // TODO create a boolean value to know if data must be saved on update or
     // only at the end
     oids = new System.Collections.Generic.Dictionary <NeoDatis.Odb.OID, object>();
     modifiedObjectOids    = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <object, int>();
     modifiedObjectOidList = new NeoDatis.Tool.Wrappers.List.OdbArrayList <NeoDatis.Odb.OID
                                                                           >(500);
     this.engine = engine;
     this.engine.AddCommitListener(this);
     smap             = oids;
     smodifiedObjects = modifiedObjectOids;
 }
 public virtual NeoDatis.Odb.Core.IError AddParameter(string s)
 {
     if (parameters == null)
     {
         parameters = new NeoDatis.Tool.Wrappers.List.OdbArrayList <object>();
     }
     if (s == null)
     {
         parameters.Add("[null object]");
     }
     else
     {
         parameters.Add(s);
     }
     return(this);
 }
		public LazyODBBTreePersister(NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine
			)
		{
			// See the map strategy performance test at
			// test/org.neodatis.odb.test.performance.TestMapPerf
			// TODO create a boolean value to know if data must be saved on update or
			// only at the end
			oids = new System.Collections.Generic.Dictionary<NeoDatis.Odb.OID, object>();
			modifiedObjectOids = new NeoDatis.Tool.Wrappers.Map.OdbHashMap<object, int>();
			modifiedObjectOidList = new NeoDatis.Tool.Wrappers.List.OdbArrayList<NeoDatis.Odb.OID
				>(500);
			this.engine = engine;
			this.engine.AddCommitListener(this);
			smap = oids;
			smodifiedObjects = modifiedObjectOids;
		}
 public override NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel Duplicate()
 {
     NeoDatis.Odb.Core.Layers.Layer2.Meta.SessionMetaModel model = new NeoDatis.Odb.Core.Layers.Layer2.Meta.SessionMetaModel
                                                                       ();
     NeoDatis.Tool.Wrappers.List.IOdbList <NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                                           > classes = GetAllClasses();
     foreach (NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci in classes)
     {
         model.AddClass((NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo)ci.Duplicate(false
                                                                                     ));
     }
     model.changedClasses = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                                                                       , NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo>();
     model.changedClasses.PutAll(changedClasses);
     return(model);
 }
 public virtual void AddSelectTriggerFor(string className, NeoDatis.Odb.Core.Trigger.SelectTrigger
                                         trigger)
 {
     if (className == null)
     {
         className = AllClassTrigger;
     }
     NeoDatis.Tool.Wrappers.List.IOdbList <NeoDatis.Odb.Core.Trigger.Trigger> c = listOfSelectTriggers
                                                                                  [className];
     if (c == null)
     {
         c = new NeoDatis.Tool.Wrappers.List.OdbArrayList <NeoDatis.Odb.Core.Trigger.Trigger
                                                           >();
         listOfSelectTriggers.Add(className, c);
     }
     c.Add(trigger);
 }
Exemple #25
0
 private void ManageCommitListenersBefore()
 {
     NeoDatis.Tool.Wrappers.List.IOdbList <NeoDatis.Odb.Core.Layers.Layer3.ICommitListener
                                           > listeners = session.GetStorageEngine().GetCommitListeners();
     if (listeners == null || listeners.IsEmpty())
     {
         return;
     }
     System.Collections.Generic.IEnumerator <NeoDatis.Odb.Core.Layers.Layer3.ICommitListener
                                             >       iterator       = listeners.GetEnumerator();
     NeoDatis.Odb.Core.Layers.Layer3.ICommitListener commitListener = null;
     while (iterator.MoveNext())
     {
         commitListener = iterator.Current;
         commitListener.BeforeCommit();
     }
 }
		public NonNativeObjectInfo(object @object, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
			 info, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo[] values, long[] 
			attributesIdentification, int[] attributeIds) : base(NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType
			.GetFromName(info.GetFullClassName()))
		{
			//new OdbArrayList<NonNativeObjectInfo>();
			this.@object = @object;
			this.classInfo = info;
			this.attributeValues = values;
			this.maxNbattributes = classInfo.GetMaxAttributeId();
			if (attributeValues == null)
			{
				this.attributeValues = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
					[maxNbattributes];
			}
			this.objectHeader = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader(-1, 
				null, null, (classInfo != null ? classInfo.GetId() : null), attributesIdentification
				, attributeIds);
			this.allNonNativeObjects = new NeoDatis.Tool.Wrappers.List.OdbArrayList<NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				>();
		}
Exemple #27
0
 public NonNativeObjectInfo(object @object, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                            info, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo[] values, long[]
                            attributesIdentification, int[] attributeIds) : base(NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType
                                                                                 .GetFromName(info.GetFullClassName()))
 {
     //new OdbArrayList<NonNativeObjectInfo>();
     this.@object         = @object;
     this.classInfo       = info;
     this.attributeValues = values;
     this.maxNbattributes = classInfo.GetMaxAttributeId();
     if (attributeValues == null)
     {
         this.attributeValues = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
                                [maxNbattributes];
     }
     this.objectHeader = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader(-1,
                                                                                   null, null, (classInfo != null ? classInfo.GetId() : null), attributesIdentification
                                                                                   , attributeIds);
     this.allNonNativeObjects = new NeoDatis.Tool.Wrappers.List.OdbArrayList <NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                              >();
 }
        /// <summary>The main query execution method</summary>
        /// <param name="query"></param>
        /// <param name="inMemory"></param>
        /// <param name="startIndex"></param>
        /// <param name="endIndex"></param>
        /// <param name="returnObjects"></param>
        /// <returns></returns>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual NeoDatis.Odb.Objects <T> Execute <T>(bool inMemory, int startIndex,
                                                            int endIndex, bool returnObjects, NeoDatis.Odb.Core.Query.Execution.IMatchingObjectAction
                                                            queryResultAction)
        {
            if (executor.GetStorageEngine().IsClosed())
            {
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.OdbIsClosed
                                                           .AddParameter(executor.GetStorageEngine().GetBaseIdentification().GetIdentification
                                                                             ()));
            }
            if (executor.GetStorageEngine().GetSession(true).IsRollbacked())
            {
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.OdbHasBeenRollbacked
                                                           );
            }
            // Get the main class
            string fullClassName = NeoDatis.Odb.Core.Query.QueryManager.GetFullClassName(executor
                                                                                         .GetQuery());

            // this is done once.
            queryResultAction.Start();
            NeoDatis.Tool.Wrappers.List.IOdbList <NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                                                  > allClassInfos = executor.GetStorageEngine().GetSession(true).GetMetaModel().GetPersistentSubclassesOf
                                                                        (fullClassName);
            int nbClasses = allClassInfos.Count;

            NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = null;
            for (int i = 0; i < nbClasses; i++)
            {
                ci = allClassInfos[i];
                // Sets the class info to the current
                executor.SetClassInfo(ci);
                // Then execute query
                executor.Execute <T>(inMemory, startIndex, endIndex, returnObjects, queryResultAction
                                     );
            }
            queryResultAction.End();
            return(queryResultAction.GetObjects <T>());
        }
                                                      > GetListOfUpdateTriggersFor(string className)
 {
     NeoDatis.Tool.Wrappers.List.IOdbList <NeoDatis.Odb.Core.Trigger.Trigger> l1 = listOfUpdateTriggers
                                                                                   [className];
     NeoDatis.Tool.Wrappers.List.IOdbList <NeoDatis.Odb.Core.Trigger.Trigger> l2 = listOfUpdateTriggers
                                                                                   [AllClassTrigger];
     if (l2 != null)
     {
         int size = l2.Count;
         if (l1 != null)
         {
             size = size + l1.Count;
         }
         NeoDatis.Tool.Wrappers.List.IOdbList <NeoDatis.Odb.Core.Trigger.Trigger> r = new NeoDatis.Tool.Wrappers.List.OdbArrayList
                                                                                      <NeoDatis.Odb.Core.Trigger.Trigger>(size);
         if (l1 != null)
         {
             r.AddAll(l1);
         }
         r.AddAll(l2);
         return(r);
     }
     return(l1);
 }
Exemple #30
0
 private void Init()
 {
     objectActions = new NeoDatis.Tool.Wrappers.List.OdbArrayList <NeoDatis.Odb.Core.Query.Execution.IQueryFieldAction
                                                                   >();
     returnInstance = true;
 }
		public virtual void SetResults(NeoDatis.Tool.Wrappers.List.IOdbList<NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoCompareResult
			> results)
		{
			this.results = results;
		}
		public virtual void Clear()
		{
			listOfBytes.Clear();
			listOfBytes = null;
			NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.count--;
		}
Exemple #33
0
 /// <param name="incompatibleChanges">the incompatibleChanges to set</param>
 public virtual void SetIncompatibleChanges(NeoDatis.Tool.Wrappers.List.IOdbList <string
                                                                                  > incompatibleChanges)
 {
     this.incompatibleChanges = incompatibleChanges;
 }
		public virtual NeoDatis.Odb.Core.IError AddParameter(long l)
		{
			if (parameters == null)
			{
				parameters = new NeoDatis.Tool.Wrappers.List.OdbArrayList<object>();
			}
			parameters.Add(l);
			return this;
		}
Exemple #35
0
 public override void PrepareQuery()
 {
     criteriaQuery = (NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery)query;
     criteriaQuery.SetStorageEngine(storageEngine);
     involvedFields = criteriaQuery.GetAllInvolvedFields();
 }
Exemple #36
0
 public virtual void SetResults(NeoDatis.Tool.Wrappers.List.IOdbList <NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoCompareResult
                                                                      > results)
 {
     this.results = results;
 }
		public virtual void Clear()
		{
			if (writeActions != null)
			{
				writeActions.Clear();
				writeActions = null;
			}
		}
		protected virtual void Init()
		{
			CheckRuntimeCompatibility();
			isClosed = false;
			isLocal = baseIdentification.IsLocal();
			// The check if it is a new Database must be executed before object
			// writer initialization. Because Object Writer Init
			// Creates the file so the check (which is based on the file existence
			// would always return false*/
			bool isNewDatabase = IsNewDatabase();
			commitListeners = new OdbArrayList<ICommitListener>();
			classIntrospector = provider.GetClassIntrospector();
			ISession session = BuildDefaultSession();
			// Object Writer must be created before object Reader
			objectWriter = BuildObjectWriter();
			// Object writer is a two Phase init object
			objectWriter.Init2();
			objectReader = BuildObjectReader();
			AddSession(session, false);
			// If the file does not exist, then a default header must be created
			if (isNewDatabase)
			{
				objectWriter.CreateEmptyDatabaseHeader(OdbTime.GetCurrentTimeInMs(), baseIdentification.GetUserName(), baseIdentification.GetPassword());
			}
			else
			{
				try
				{
					GetObjectReader().ReadDatabaseHeader(baseIdentification.GetUserName(), baseIdentification.GetPassword());
				}
				catch (ODBAuthenticationRuntimeException e)
				{
					Close();
					throw;
				}
			}
			objectWriter.AfterInit();
			objectIntrospector = BuildObjectIntrospector();
			this.triggerManager = BuildTriggerManager();
			// This forces the initialization of the meta model
			MetaModel metaModel = GetMetaModel();
			if (OdbConfiguration.CheckModelCompatibility())
			{
				CheckMetaModelCompatibility(classIntrospector.Instrospect(metaModel.GetAllClasses()));
			}
			// logically locks access to the file (only for this Virtual machine)
			FileMutex.GetInstance().OpenFile(GetStorageDeviceName());
			// Updates the Transaction Id in the file
			objectWriter.WriteLastTransactionId(GetCurrentTransactionId());
			this.objectWriter.SetTriggerManager(this.triggerManager);
			this.introspectionCallbackForInsert = new DefaultInstrumentationCallbackForStore(this, triggerManager, false);
			this.introspectionCallbackForUpdate = new DefaultInstrumentationCallbackForStore(this, triggerManager, true);
		}
		public NewClassInfoListMessageResponse(string baseId, string connectionId, NeoDatis.Tool.Wrappers.List.IOdbList
			<NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo> classInfos) : base(NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Command
			.AddClassInfoList, baseId, connectionId)
		{
			this.classInfos = classInfos;
		}
		public virtual NeoDatis.Odb.Core.IError AddParameter(string s)
		{
			if (parameters == null)
			{
				parameters = new NeoDatis.Tool.Wrappers.List.OdbArrayList<object>();
			}
			if (s == null)
			{
				parameters.Add("[null object]");
			}
			else
			{
				parameters.Add(s);
			}
			return this;
		}
		/// <param name="incompatibleChanges">the incompatibleChanges to set</param>
		public virtual void SetIncompatibleChanges(NeoDatis.Tool.Wrappers.List.IOdbList<string
			> incompatibleChanges)
		{
			this.incompatibleChanges = incompatibleChanges;
		}
		public ClassInfoCompareResult(string fullClassName)
		{
			this.fullClassName = fullClassName;
			incompatibleChanges = new NeoDatis.Tool.Wrappers.List.OdbArrayList<string>(5);
			compatibleChanges = new NeoDatis.Tool.Wrappers.List.OdbArrayList<string>(5);
		}
		private void Init()
		{
			objectActions = new NeoDatis.Tool.Wrappers.List.OdbArrayList<NeoDatis.Odb.Core.Query.Execution.IQueryFieldAction
				>();
			returnInstance = true;
		}
		public ComposedExpression()
		{
			criteria = new NeoDatis.Tool.Wrappers.List.OdbArrayList<NeoDatis.Odb.Core.Query.Criteria.ICriterion
				>(5);
		}
Exemple #45
0
 public virtual void Clear()
 {
     listOfBytes.Clear();
     listOfBytes = null;
     NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.count--;
 }
		public override void PrepareQuery()
		{
			criteriaQuery = (NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery)query;
			criteriaQuery.SetStorageEngine(storageEngine);
			involvedFields = criteriaQuery.GetAllInvolvedFields();
		}
Exemple #47
0
 public CheckMetaModelResult()
 {
     this.modelHasBeenUpdated = false;
     this.results             = new NeoDatis.Tool.Wrappers.List.OdbArrayList <NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoCompareResult
                                                                              >();
 }
        /// <summary>
        /// Build a meta representation of an object
        /// <pre>
        /// warning: When an object has two fields with the same name (a private field with the same name in a parent class, the deeper field (of the parent) is ignored!)
        /// </pre>
        /// </summary>
        /// <param name="o"></param>
        /// <param name="ci"></param>
        /// <param name="recursive"></param>
        /// <returns>The ObjectInfo</returns>
        protected virtual NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo GetObjectInfoInternal
            (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo nnoi, object o, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
            ci, bool recursive, System.Collections.Generic.IDictionary <object, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                        > alreadyReadObjects, NeoDatis.Odb.Core.Layers.Layer1.Introspector.IIntrospectionCallback
            callback)
        {
            object value = null;

            if (o == null)
            {
                return(NeoDatis.Odb.Core.Layers.Layer2.Meta.NullNativeObjectInfo.GetInstance());
            }
            System.Type clazz = o.GetType();
            NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType type = NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType
                                                                .GetFromClass(clazz);
            string className = OdbClassUtil.GetFullName(clazz);

            if (type.IsNative())
            {
                return(GetNativeObjectInfoInternal(type, o, recursive, alreadyReadObjects,
                                                   callback));
            }
            // sometimes the clazz.getName() may not match the ci.getClassName()
            // It happens when the attribute is an interface or superclass of the
            // real attribute class
            // In this case, ci must be updated to the real class info
            if (ci != null && !clazz.FullName.Equals(ci.GetFullClassName()))
            {
                ci   = GetClassInfo(className);
                nnoi = null;
            }
            NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo mainAoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                                )nnoi;
            bool isRootObject = false;

            if (alreadyReadObjects == null)
            {
                alreadyReadObjects = new NeoDatis.Tool.Wrappers.Map.OdbHashMap <object, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                                >();
                isRootObject = true;
            }
            if (o != null)
            {
                NonNativeObjectInfo cachedNnoi = null;
                alreadyReadObjects.TryGetValue(o, out cachedNnoi);

                if (cachedNnoi != null)
                {
                    ObjectReference or = new ObjectReference(cachedNnoi);
                    return(or);
                }
                if (callback != null)
                {
                    callback.ObjectFound(o);
                }
            }
            if (mainAoi == null)
            {
                mainAoi = BuildNnoi(o, ci, null, null, null, alreadyReadObjects);
            }
            alreadyReadObjects[o] = mainAoi;
            NeoDatis.Tool.Wrappers.List.IOdbList <System.Reflection.FieldInfo> fields = classIntrospector.GetAllFields(className);
            NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo            aoi    = null;
            int attributeId = -1;

            // For all fields
            for (int i = 0; i < fields.Count; i++)
            {
                System.Reflection.FieldInfo field = fields[i];
                try
                {
                    value       = field.GetValue(o);
                    attributeId = ci.GetAttributeId(field.Name);
                    if (attributeId == -1)
                    {
                        throw new ODBRuntimeException(NeoDatisError.ObjectIntrospectorNoFieldWithName.AddParameter(ci.GetFullClassName()).AddParameter(field.Name));
                    }
                    ODBType valueType = null;
                    if (value == null)
                    {
                        // If value is null, take the type from the field type
                        // declared in the class
                        valueType = ODBType.GetFromClass(field.FieldType);
                    }
                    else
                    {
                        // Else take the real attribute type!
                        valueType = ODBType.GetFromClass(value.GetType());
                    }
                    // for native fields
                    if (valueType.IsNative())
                    {
                        aoi = GetNativeObjectInfoInternal(valueType, value, recursive, alreadyReadObjects, callback);
                        mainAoi.SetAttributeValue(attributeId, aoi);
                    }
                    else
                    {
                        //callback.objectFound(value);
                        // Non Native Objects
                        if (value == null)
                        {
                            ClassInfo clai = GetClassInfo(OdbClassUtil.GetFullName(field.GetType()));

                            aoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeNullObjectInfo(clai);
                            mainAoi.SetAttributeValue(attributeId, aoi);
                        }
                        else
                        {
                            ClassInfo clai = GetClassInfo(OdbClassUtil.GetFullName(value.GetType()));
                            if (recursive)
                            {
                                aoi = GetObjectInfoInternal(null, value, clai, recursive, alreadyReadObjects, callback
                                                            );
                                mainAoi.SetAttributeValue(attributeId, aoi);
                            }
                            else
                            {
                                // When it is not recursive, simply add the object
                                // values.add(value);
                                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError
                                                                           .AddParameter("Should not enter here - ObjectIntrospector - 'simply add the object'"
                                                                                         ));
                            }
                        }
                    }
                }
                catch (System.ArgumentException e)
                {
                    throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError
                                                               .AddParameter("in getObjectInfoInternal"), e);
                }
                catch (System.MemberAccessException e)
                {
                    throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError
                                                               .AddParameter("getObjectInfoInternal"), e);
                }
            }
            if (isRootObject)
            {
                alreadyReadObjects.Clear();
                alreadyReadObjects = null;
            }
            return(mainAoi);
        }
Exemple #49
0
 public ClassInfoCompareResult(string fullClassName)
 {
     this.fullClassName  = fullClassName;
     incompatibleChanges = new NeoDatis.Tool.Wrappers.List.OdbArrayList <string>(5);
     compatibleChanges   = new NeoDatis.Tool.Wrappers.List.OdbArrayList <string>(5);
 }
		public virtual void Init(NeoDatis.Odb.Core.Transaction.ISession session)
		{
			this.provider = NeoDatis.Odb.OdbConfiguration.GetCoreProvider();
			this.session = session;
			this.isCommited = false;
			creationDateTime = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			writeActions = new NeoDatis.Tool.Wrappers.List.OdbArrayList<NeoDatis.Odb.Core.Transaction.IWriteAction
				>(1000);
			hasAllWriteActionsInMemory = true;
			numberOfWriteActions = 0;
			hasBeenPersisted = false;
			wasRollbacked = false;
			currentWritePositionInWA = -1;
		}
Exemple #51
0
 public NewClassInfoListMessageResponse(string baseId, string connectionId, NeoDatis.Tool.Wrappers.List.IOdbList
                                        <NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo> classInfos) : base(NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Command
                                                                                                            .AddClassInfoList, baseId, connectionId)
 {
     this.classInfos = classInfos;
 }
		public CheckMetaModelResult()
		{
			this.modelHasBeenUpdated = false;
			this.results = new NeoDatis.Tool.Wrappers.List.OdbArrayList<NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoCompareResult
				>();
		}