public ConnectMessageResponse(string baseId, string connectionId, NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel, NeoDatis.Odb.TransactionId transactionId) : base(NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Command .Connect, baseId, connectionId) { this.metaModel = metaModel; this.transactionId = transactionId; }
public ConnectMessageResponse(string baseId, string connectionId, NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel, NeoDatis.Odb.TransactionId transactionId) : base(NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Command .Connect, baseId, connectionId) { this.metaModel = metaModel; this.transactionId = transactionId; }
public CheckMetaModelCompatibilityMessageResponse(string baseId, string sessionId , NeoDatis.Odb.Core.Layers.Layer3.Engine.CheckMetaModelResult result, NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel) : base(NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Command.CheckMetaModelCompatibility , baseId, sessionId) { this.result = result; this.updatedMetaModel = metaModel; }
public CheckMetaModelCompatibilityMessageResponse(string baseId, string sessionId , NeoDatis.Odb.Core.Layers.Layer3.Engine.CheckMetaModelResult result, NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel) : base(NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Command.CheckMetaModelCompatibility , baseId, sessionId) { this.result = result; this.updatedMetaModel = metaModel; }
/// <exception cref="System.IO.IOException"></exception> public virtual void RenameClass(string fullClassName, string newFullClassName) { NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = storageEngine.GetSession (true).GetMetaModel(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = metaModel.GetClassInfo(fullClassName , true); ci.SetFullClassName(newFullClassName); storageEngine.GetObjectWriter().UpdateClassInfo(ci, true); }
/// <exception cref="System.Exception"></exception> public virtual void TestSaveIndex() { string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB @base = Open(baseName); NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3 )); string[] indexFields1 = new string[] { "i1", "i2", "i3" }; clazz.AddUniqueIndexOn("index1", indexFields1, true); string[] indexFields2 = new string[] { "s1", "s2", "s3" }; clazz.AddUniqueIndexOn("index2", indexFields2, true); string[] indexFields3 = new string[] { "dt1", "dt2", "dt3" }; clazz.AddUniqueIndexOn("index3", indexFields3, true); string[] indexFields4 = new string[] { "i1", "i2", "i3", "s1", "s2", "s3", "dt1", "dt2", "dt3" }; clazz.AddUniqueIndexOn("index4", indexFields4, true); @base.Close(); @base = Open(baseName); NeoDatis.Odb.Core.Transaction.ISession session = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(@base).GetSession(true); NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = session.GetStorageEngine ().GetSession(true).GetMetaModel(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = metaModel.GetClassInfo(typeof( NeoDatis.Odb.Test.Index.IndexedObject3).FullName, true); AssertEquals(4, ci.GetNumberOfIndexes()); AssertEquals(ci.GetIndex(0).GetName(), "index1"); AssertEquals(3, ci.GetIndex(0).GetAttributeIds().Length); AssertEquals(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex.Enabled, ci.GetIndex (0).GetStatus()); AssertEquals(ci.GetIndex(1).GetName(), "index2"); AssertEquals(3, ci.GetIndex(1).GetAttributeIds().Length); AssertEquals(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex.Enabled, ci.GetIndex (1).GetStatus()); AssertEquals(ci.GetIndex(2).GetName(), "index3"); AssertEquals(3, ci.GetIndex(2).GetAttributeIds().Length); AssertEquals(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex.Enabled, ci.GetIndex (2).GetStatus()); AssertEquals(ci.GetIndex(3).GetName(), "index4"); AssertEquals(9, ci.GetIndex(3).GetAttributeIds().Length); AssertEquals(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex.Enabled, ci.GetIndex (3).GetStatus()); @base.Close(); @base = Open(baseName); for (int i = 0; i < 10; i++) { NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3 (1 + i, 2, 3, "1" + i, "2", "3", new System.DateTime(2009, i, 1), new System.DateTime (), new System.DateTime()); @base.Store(io); } @base.Close(); DeleteBase(baseName); }
// TODO Auto-generated method stub /// <exception cref="System.IO.IOException"></exception> public virtual void RemoveField(string className, string attributeName) { NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = storageEngine.GetSession (true).GetMetaModel(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = metaModel.GetClassInfo(className , true); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo cai2 = ci.GetAttributeInfoFromName (attributeName); ci.RemoveAttribute(cai2); storageEngine.GetObjectWriter().UpdateClassInfo(ci, true); }
public virtual void AddField(string className, System.Type fieldType, string fieldName ) { NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = storageEngine.GetSession (true).GetMetaModel(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = metaModel.GetClassInfo(className , true); // The real attribute id (-1) will be set in the ci.addAttribute NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo cai = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo (-1, fieldName, fieldType.FullName, ci); ci.AddAttribute(cai); storageEngine.GetObjectWriter().UpdateClassInfo(ci, true); }
/// <summary> /// Create objects, then create index, then execute a select with index, then /// rebuild index e execute /// </summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestDeleteIndex() { string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB @base = Open(baseName); for (int i = 0; i < 2500; i++) { NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3 (1 + i, 2, 3, "1" + i, "2", "3", new System.DateTime(2009, i, 1), new System.DateTime (), new System.DateTime()); @base.Store(io); } @base.Close(); @base = Open(baseName); NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3 )); string[] indexFields1 = new string[] { "i1", "i2", "i3" }; clazz.AddUniqueIndexOn("index1", indexFields1, true); @base.Close(); @base = Open(baseName); NeoDatis.Odb.Core.Transaction.ISession session = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(@base).GetSession(true); NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = session.GetStorageEngine ().GetSession(true).GetMetaModel(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = metaModel.GetClassInfo(typeof( NeoDatis.Odb.Test.Index.IndexedObject3).FullName, true); AssertEquals(1, ci.GetNumberOfIndexes()); AssertEquals(ci.GetIndex(0).GetName(), "index1"); AssertEquals(3, ci.GetIndex(0).GetAttributeIds().Length); AssertEquals(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex.Enabled, ci.GetIndex (0).GetStatus()); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Index.IndexedObject3), NeoDatis.Odb.Core.Query.Criteria.Where .And().Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("i1", 10)).Add(NeoDatis.Odb.Core.Query.Criteria.Where .Equal("i2", 2)).Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("i3", 3))); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Index.IndexedObject3> objects = @base.GetObjects (q); AssertEquals(true, q.GetExecutionPlan().UseIndex()); @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3)).DeleteIndex ("index1", true); @base.Close(); @base = Open(baseName); objects = @base.GetObjects(q); AssertEquals(false, q.GetExecutionPlan().UseIndex()); @base.Close(); DeleteBase(baseName); }
public virtual NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel GetMetaModel() { if (metaModel == null) { // MetaModel can be null (this happens at the end of the // Transaction.commitMetaModel() method)when the user commited the // database // And continue using it. In this case, after the commit, the // metamodel is set to null // and lazy-reloaded when the user use the odb again. metaModel = new NeoDatis.Odb.Core.Layers.Layer2.Meta.SessionMetaModel(); try { GetStorageEngine().GetObjectReader().ReadMetaModel(metaModel, true); } catch (System.Exception e) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError .AddParameter("Session.getMetaModel"), e); } } return(metaModel); }
/// <summary> /// Used to commit meta model : classes This is useful when running in client /// server mode TODO Check this /// </summary> protected virtual void CommitMetaModel() { NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel sessionMetaModel = session.GetMetaModel (); // If meta model has not been modified, there is nothing to do if (!sessionMetaModel.HasChanged()) { return; } if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Debug("Start commitMetaModel"); } NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel lastCommitedMetaModel = new NeoDatis.Odb.Core.Layers.Layer2.Meta.SessionMetaModel (); if (isLocal) { // In local mode, we must not reload the meta model as there is no // concurrent access lastCommitedMetaModel = sessionMetaModel; } else { // In ClientServer mode, re-read the meta-model from the database // base to get last update. lastCommitedMetaModel = session.GetStorageEngine().GetObjectReader().ReadMetaModel (lastCommitedMetaModel, false); } // Gets the classes that have changed (that have modified ,deleted or // inserted objects) System.Collections.Generic.IEnumerator <NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo > cis = sessionMetaModel.GetChangedClassInfo().GetEnumerator(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo newCi = null; NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo lastCommittedCI = null; NeoDatis.Odb.Core.Layers.Layer3.IObjectWriter writer = session.GetStorageEngine() .GetObjectWriter(); NeoDatis.Odb.OID lastCommittedObjectOIDOfThisTransaction = null; NeoDatis.Odb.OID lastCommittedObjectOIDOfPrevTransaction = null; // for all changes between old and new meta model while (cis.MoveNext()) { newCi = cis.Current; if (lastCommitedMetaModel.ExistClass(newCi.GetFullClassName())) { // The last CI represents the last committed meta model of the // database lastCommittedCI = lastCommitedMetaModel.GetClassInfoFromId(newCi.GetId()); // Just be careful to keep track of current CI committed zone // deleted objects lastCommittedCI.GetCommitedZoneInfo().SetNbDeletedObjects(newCi.GetCommitedZoneInfo ().GetNbDeletedObjects()); } else { lastCommittedCI = newCi; } lastCommittedObjectOIDOfThisTransaction = newCi.GetCommitedZoneInfo().last; lastCommittedObjectOIDOfPrevTransaction = lastCommittedCI.GetCommitedZoneInfo().last; NeoDatis.Odb.OID lastCommittedObjectOID = lastCommittedObjectOIDOfPrevTransaction; // If some object have been created then if (lastCommittedObjectOIDOfPrevTransaction != null) { // Checks if last object of committed meta model has not been // deleted if (session.GetCache().IsDeleted(lastCommittedObjectOIDOfPrevTransaction)) { // TODO This is wrong: if a committed transaction deleted a // committed object and creates x new // objects, then all these new objects will be lost: // if it has been deleted then use the last object of the // session class info lastCommittedObjectOID = lastCommittedObjectOIDOfThisTransaction; newCi.GetCommitedZoneInfo().last = lastCommittedObjectOID; } } // Connect Unconnected zone to connected zone // make next oid of last committed object point to first // uncommitted object // make previous oid of first uncommitted object point to // last committed object if (lastCommittedObjectOID != null && newCi.GetUncommittedZoneInfo().HasObjects()) { if (newCi.GetCommitedZoneInfo().HasObjects()) { // these 2 updates are executed directly without // transaction, because // We are in the commit process. writer.UpdateNextObjectFieldOfObjectInfo(lastCommittedObjectOID, newCi.GetUncommittedZoneInfo ().first, false); writer.UpdatePreviousObjectFieldOfObjectInfo(newCi.GetUncommittedZoneInfo().first , lastCommittedObjectOID, false); } else { // Committed zone has 0 object writer.UpdatePreviousObjectFieldOfObjectInfo(newCi.GetUncommittedZoneInfo().first , null, false); } } // The number of committed objects must be updated with the number // of the last committed CI because a transaction may have been // committed changing this number. // Notice that the setNbObjects receive the full CommittedCIZoneInfo // object // because it will set the number of objects and the number of // deleted objects newCi.GetCommitedZoneInfo().SetNbObjects(lastCommittedCI.GetCommitedZoneInfo()); // and don't forget to set the deleted objects // This sets the number of objects, the first object OID and the // last object OID newCi = BuildClassInfoForCommit(newCi); writer.UpdateInstanceFieldsOfClassInfo(newCi, false); if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Debug("Analysing class " + newCi.GetFullClassName()); NeoDatis.Tool.DLogger.Debug("\t-Commited CI = " + newCi); NeoDatis.Tool.DLogger.Debug("\t-connect last commited object with oid " + lastCommittedObjectOID + " to first uncommited object " + newCi.GetUncommittedZoneInfo().first); NeoDatis.Tool.DLogger.Debug("\t-Commiting new Number of objects = " + newCi.GetNumberOfObjects ()); } } sessionMetaModel.ResetChangedClasses(); // To guarantee integrity after commit, the meta model is set to null // If the user continues using odb instance after commit the meta model // will be lazy-reloaded. Only for Client Server mode if (!isLocal) { session.SetMetaModel(null); } }
public abstract void SetMetaModel(NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel arg1);
public virtual void SetUpdatedMetaModel(NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel updatedMetaModel) { this.updatedMetaModel = updatedMetaModel; }
public virtual void SetMetaModel(NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel2 ) { this.metaModel = metaModel2; }
public virtual NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel GetMetaModel() { if (metaModel == null) { // MetaModel can be null (this happens at the end of the // Transaction.commitMetaModel() method)when the user commited the // database // And continue using it. In this case, after the commit, the // metamodel is set to null // and lazy-reloaded when the user use the odb again. metaModel = new NeoDatis.Odb.Core.Layers.Layer2.Meta.SessionMetaModel(); try { GetStorageEngine().GetObjectReader().ReadMetaModel(metaModel, true); } catch (System.Exception e) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError .AddParameter("Session.getMetaModel"), e); } } return metaModel; }
public virtual void SetMetaModel(NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel ) { }
public virtual void SetUpdatedMetaModel(NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel updatedMetaModel) { this.updatedMetaModel = updatedMetaModel; }
public virtual void SetMetaModel(NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel2 ) { this.metaModel = metaModel2; }