public virtual void TestDeleteListElements() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("name" ); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("f1")); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("f2")); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("3")); odb.Store(p); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects <Profile> objects = odb.GetObjects <Profile>(); while (objects.HasNext()) { NeoDatis.Odb.Test.VO.Login.Profile profile = objects.Next(); System.Collections.Generic.IList <Function> functions = profile.GetFunctions(); for (int j = 0; j < functions.Count; j++) { odb.Delete(functions[j]); } odb.Delete(profile); } odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void TestCriteriaQueryQueryWithObject() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); Profile p0 = new Profile("profile0" ); p0.AddFunction(null); p0.AddFunction(new Function("f1")); p0.AddFunction(new Function("f2")); Profile p1 = new Profile("profile1" ); p1.AddFunction(null); p1.AddFunction(new Function("f12")); p1.AddFunction(new Function("f22")); User user = new User("The user" , "themail", p0); User user2 = new User("The user2" , "themail2", p1); odb.Store(user); odb.Store(user2); odb.Close(); odb = Open(baseName); Profile pp = (Profile)odb.GetObjects<Profile> (new CriteriaQuery(Where.Equal("name", "profile0"))).GetFirst(); CriteriaQuery query = new CriteriaQuery(Where.Equal("profile", pp)); NeoDatis.Odb.Objects<User> l = odb.GetObjects<User>(query); AssertEquals(1, l.Count); user = (User)l.GetFirst(); AssertEquals("The user", user.GetName()); odb.Close(); }
public virtual void TestCriteriaQueryQueryWithValueInList() { string baseName = GetBaseName(); SetUp(baseName); NeoDatis.Odb.ODB odb = Open(baseName); Profile p0 = new Profile("profile0" ); p0.AddFunction(null); p0.AddFunction(new Function("f1")); p0.AddFunction(new Function("f2")); Profile p1 = new Profile("profile1" ); p1.AddFunction(null); p1.AddFunction(new Function("f12")); p1.AddFunction(new Function("f22")); User user = new User("The user" , "themail", p0); User user2 = new User("The user2" , "themail2", p1); odb.Store(user); odb.Store(user2); odb.Close(); odb = Open(baseName); Function f2bis = (Function) odb.GetObjects<Function> (new CriteriaQuery(Where.Equal("name", "f2"))).GetFirst(); CriteriaQuery query = odb.CriteriaQuery(typeof( User), Where.Contain ("profile.functions", f2bis)); NeoDatis.Odb.Objects<User> l = odb.GetObjects<User>(query); AssertEquals(1, l.Count); user = (User)l.GetFirst(); AssertEquals("The user", user.GetName()); odb.Close(); }
public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); System.Collections.Generic.IList<Profile> profiles = new System.Collections.Generic.List<Profile>(); profiles.Add(new Profile("p1", new Function ("f1"))); profiles.Add(new Profile("p2", new Function ("f2"))); ClassB cb = new ClassB ("name", profiles); odb.Store(cb); odb.Close(); odb = Open(baseName); // this object is not known y NeoDatis so the query will not return anything Profile p = new Profile("p1", (System.Collections.Generic.IList<Function>)null); CriteriaQuery query = odb.CriteriaQuery(typeof( ClassB), Where .Contain("profiles", p)); NeoDatis.Odb.Objects<ClassB> l = odb.GetObjects<ClassB>( query); odb.Close(); AssertEquals(0, l.Count); }
public virtual void TestDeleteListElements() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("name" ); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("f1")); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("f2")); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("3")); odb.Store(p); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects<Profile> objects = odb.GetObjects<Profile>(); while (objects.HasNext()) { NeoDatis.Odb.Test.VO.Login.Profile profile = objects.Next(); System.Collections.Generic.IList<Function> functions = profile.GetFunctions(); for (int j = 0; j < functions.Count; j++) { odb.Delete(functions[j]); } odb.Delete(profile); } odb.Close(); }
public virtual void Test2() { DeleteBase("t2.neodatis"); NeoDatis.Odb.ODB odb = Open("t2.neodatis"); int nbUsers = odb.GetObjects<User>().Count; int nbProfiles = odb.GetObjects<Profile>(true).Count; int nbFunctions = odb.GetObjects<Function>(true).Count; Function login = new Function ("login"); Function logout = new Function ("logout"); System.Collections.Generic.IList<Function> list = new System.Collections.Generic.List<Function>(); list.Add(login); list.Add(logout); Profile profile = new Profile("operator", list); User olivier = new User("olivier smadja" , "*****@*****.**", profile); User aisa = new User("Aísa Galvão Smadja" , "*****@*****.**", profile); odb.Store(olivier); odb.Store(aisa); odb.Commit(); NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true); NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(true); NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(true); odb.Close(); // println("Users:"+users); Println("Profiles:" + profiles); Println("Functions:" + functions); odb = Open("t2.neodatis"); NeoDatis.Odb.Objects<User> l = odb.GetObjects<User>(true); odb.Close(); AssertEquals(nbUsers + 2, users.Count); User user2 = (User)users.GetFirst (); AssertEquals(olivier.ToString(), user2.ToString()); AssertEquals(nbProfiles + 1, profiles.Count); AssertEquals(nbFunctions + 2, functions.Count); NeoDatis.Odb.ODB odb2 = Open("t2.neodatis"); Objects<Function> l2 = odb2.GetObjects<Function>(true); Function function = l2.GetFirst(); function.SetName("login function"); odb2.Store(function); odb2.Close(); NeoDatis.Odb.ODB odb3 = Open("t2.neodatis"); NeoDatis.Odb.Objects<User> l3 = odb3.GetObjects<User>(true); int i = 0; while (l3.HasNext() && i < System.Math.Min(2, l3.Count)) { User user = (User)l3.Next(); AssertEquals("login function", string.Empty + user.GetProfile().GetFunctions()[0] ); i++; } odb3.Close(); DeleteBase("t2.neodatis"); }
public virtual void Test1WithCommit3() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function 1"); Println(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( User)))); NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number 0" , f1); p.AddFunction(new Function("f1")); User user = new User("user name 0" , "user email 0", p); odb.Store(user); NeoDatis.Odb.Test.VO.Login.Profile p2 = new NeoDatis.Odb.Test.VO.Login.Profile("profile number 0" , f1); p2.AddFunction(new Function("f2")); User user2 = new User("user name 0" , "user email 0", p2); odb.Store(user2); odb.Close(); odb = Open(FileName); NeoDatis.Odb.Objects <User> objects = null; for (int k = 0; k < 2; k++) { System.Console.Out.WriteLine(":" + k); objects = odb.GetObjects <User>(); while (objects.HasNext()) { user = (User)objects.Next(); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated"); Println(user.GetProfile().GetName()); odb.Store(user); } } odb.Close(); odb = Open(FileName); objects = odb.GetObjects <User>(); AssertEquals(2, objects.Count); odb.Close(); }
private object GetInstance() { NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function ("login"); NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function ("logout"); System.Collections.Generic.List<Function> list = new System.Collections.Generic.List<Function>(); list.Add(login); list.Add(logout); NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile ("operator", list); NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja" , "*****@*****.**", profile); return user; }
private object GetInstance(int i) { NeoDatis.Odb.Test.VO.Login.Function login = new NeoDatis.Odb.Test.VO.Login.Function ("login " + i); NeoDatis.Odb.Test.VO.Login.Function logout = new NeoDatis.Odb.Test.VO.Login.Function ("logout" + i); System.Collections.Generic.IList <Function> list = new System.Collections.Generic.List <Function>(); list.Add(login); list.Add(logout); NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile ("operator" + i, list); NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("kiko" + i, "*****@*****.**" + i, profile); return(user); }
private object GetInstance(string @string) { if (simpleObject) { return(new NeoDatis.Odb.Test.VO.Login.Function(@string)); } NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile(@string ); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("function " + @string + "1" )); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("function " + @string + "2" )); NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User(@string , "email" + @string, p); return(user); }
private object GetInstance(string @string) { if (simpleObject) { return new NeoDatis.Odb.Test.VO.Login.Function(@string); } NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile(@string ); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("function " + @string + "1" )); p.AddFunction(new NeoDatis.Odb.Test.VO.Login.Function("function " + @string + "2" )); NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User(@string , "email" + @string, p); return user; }
static public void Test2() { String baseName = "t1.neodatis"; ODB odb = ODBFactory.Open(baseName); Function f = new Function("f1"); Profile profile = new Profile("profile1", f); User user = new User("user name", "email", profile); odb.Store(user); odb.Close(); odb = ODBFactory.Open(baseName); Objects<User> users = odb.GetObjects<User>(new CriteriaQuery(Where.Equal("name", "user name"))); Console.WriteLine(users.Count + " users"); odb.Close(); Console.ReadLine(); }
public virtual void Test2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); long nbFunctions = odb.Count(new CriteriaQuery (typeof(Function))); decimal nbProfiles = odb.Count(new CriteriaQuery (typeof(Profile))); Function function1 = new Function ("function1"); Function function2 = new Function ("function2"); Function function3 = new Function ("function3"); System.Collections.Generic.List<Function> functions = new System.Collections.Generic.List<Function>(); functions.Add(function1); functions.Add(function2); functions.Add(function3); Profile profile1 = new Profile("profile1", functions); Profile profile2 = new Profile("profile2", function1); odb.Store(profile1); odb.Store(profile2); odb.Close(); odb = Open(baseName); // checks functions NeoDatis.Odb.Objects<Function> lfunctions = odb.GetObjects<Function>(true); AssertEquals(nbFunctions + 3, lfunctions.Count); NeoDatis.Odb.Objects<Function> l = odb.GetObjects<Function>(new CriteriaQuery(Where.Equal("name", "function2"))); Function function = l.GetFirst(); odb.Delete(function); odb.Close(); odb = Open(baseName); AssertEquals(nbFunctions + 2, odb.Count(new CriteriaQuery (typeof(Function)))); NeoDatis.Odb.Objects<Function> l2 = odb.GetObjects<Function>(true); // check Profile 1 NeoDatis.Odb.Objects<Profile> lprofile = odb.GetObjects<Profile>(new CriteriaQuery(Where.Equal("name", "profile1"))); Profile p1 = lprofile.GetFirst(); AssertEquals(2, p1.GetFunctions().Count); odb.Close(); DeleteBase(baseName); }
public virtual void TestCompositeCollection2DifferentObjects() { DeleteBase("ti1.neodatis"); NeoDatis.Odb.ODB odb = Open("ti1.neodatis"); int nbUsers = odb.GetObjects<User>(true).Count; int nbProfiles = odb.GetObjects<Profile>(true).Count; int nbFunctions = odb.GetObjects<Function>(true).Count; Function login = new Function("login"); Function logout = new Function("logout"); Function disconnect = new Function("disconnect"); System.Collections.Generic.IList<Function> list = new System.Collections.Generic.List<Function>(); list.Add(login); list.Add(logout); System.Collections.Generic.IList<Function> list2 = new System.Collections.Generic.List<Function>(); list.Add(login); list.Add(logout); Profile profile1 = new Profile ("operator 1", list); Profile profile2 = new Profile ("operator 2", list2); User user = new User("olivier smadja" , "*****@*****.**", profile1); User userB = new User("A√°sa Galv√£o Smadja" , "*****@*****.**", profile2); odb.Store(user); odb.Store(userB); odb.Commit(); NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(true); NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(true); NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true); odb.Close(); // assertEquals(nbUsers+2,users.size()); User user2 = (User)users.GetFirst (); AssertEquals(user.ToString(), user2.ToString()); AssertEquals(nbProfiles + 2, profiles.Count); AssertEquals(nbFunctions + 2, functions.Count); DeleteBase("ti1.neodatis"); }
public virtual void Test2() { if (!isLocal) { return; } NeoDatis.Odb.ODB odb = null; DeleteBase("trigger.neodatis"); NeoDatis.Odb.Test.Trigger.MyTrigger myTrigger = new NeoDatis.Odb.Test.Trigger.MyTrigger (); try { odb = Open("trigger.neodatis"); odb.AddInsertTrigger(typeof(Function), myTrigger); Function f1 = new Function( "function1"); Function f2 = new Function( "function2"); Profile profile = new Profile ("profile1", f1); User user = new User("oli", "*****@*****.**", profile); odb.Store(user); odb.Store(f2); } finally { if (odb != null) { odb.Close(); } } odb = Open("trigger.neodatis"); odb.Close(); DeleteBase("trigger.neodatis"); AssertEquals(2, myTrigger.nbInsertsBefore); AssertEquals(2, myTrigger.nbInsertsAfter); }
public virtual void TestCompositeCollection1() { DeleteBase("t31.neodatis"); NeoDatis.Odb.ODB odb = Open("t31.neodatis"); Function login = new Function ("login"); System.Collections.Generic.IList<Function> list = new System.Collections.Generic.List<Function>(); list.Add(login); Profile profile1 = new Profile ("operator 1", list); User user = new User("olivier smadja" , "*****@*****.**", profile1); odb.Store(user); odb.Close(); odb = Open("t31.neodatis"); NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true); odb.Close(); // assertEquals(nbUsers+2,users.size()); User user2 = (User)users.GetFirst (); AssertEquals(user.ToString(), user2.ToString()); DeleteBase("t31.neodatis"); }
public virtual void TestUpdateRelation() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); // first create a function Function f = new Function("f1" ); odb.Store(f); odb.Close(); odb = Open(baseName); // reloads the function NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(new CriteriaQuery(Where.Equal("name", "f1"))); Function f1 = functions.GetFirst(); // Create a profile with the loaded function Profile profile = new Profile ("test", f1); odb.Store(profile); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(); functions = odb.GetObjects<Function>(); odb.Close(); DeleteBase(baseName); AssertEquals(1, functions.Count); AssertEquals(1, profiles.Count); }
public virtual void TestCompositeCollection3() { DeleteBase("t4.neodatis"); NeoDatis.Odb.ODB odb = Open("t4.neodatis"); // Configuration.addLogId("ObjectWriter"); // Configuration.addLogId("ObjectReader"); // Configuration.addLogId("FileSystemInterface"); int nbUsers = odb.GetObjects<User>(true).Count; int nbProfiles = odb.GetObjects<Profile>(true).Count; int nbFunctions = odb.GetObjects<Function>(true).Count; Function login = new Function("login"); Function logout = new Function("logout"); System.Collections.Generic.IList<Function> list = new System.Collections.Generic.List<Function>(); list.Add(login); list.Add(logout); Profile profile1 = new Profile ("operator 1", list); User user = new User("olivier smadja" , "*****@*****.**", profile1); User userB = new User("Aísa Galvão Smadja" , "*****@*****.**", profile1); odb.Store(user); odb.Store(userB); odb.Close(); odb = Open("t4.neodatis"); NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true); NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(true); NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(true); // assertEquals(nbUsers+2,users.size()); User user2 = (User)users.GetFirst (); AssertEquals(user.ToString(), user2.ToString()); AssertEquals(nbProfiles + 1, profiles.Count); AssertEquals(nbFunctions + 2, functions.Count); odb.Close(); DeleteBase("t4.neodatis"); }
public virtual void TestBufferSize() { int size = NeoDatis.Odb.OdbConfiguration.GetDefaultBufferSizeForData(); NeoDatis.Odb.OdbConfiguration.SetDefaultBufferSizeForData(5); DeleteBase("ti1.neodatis"); NeoDatis.Odb.ODB odb = Open("ti1.neodatis"); System.Text.StringBuilder b = new System.Text.StringBuilder(); for (int i = 0; i < 1000; i++) { b.Append("login - login "); } Function login = new Function (b.ToString()); Profile profile1 = new Profile ("operator 1", login); User user = new User("olivier smadja" , "*****@*****.**", profile1); odb.Store(user); odb.Commit(); NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true); NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(true); NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>(true); odb.Close(); // assertEquals(nbUsers+2,users.size()); User user2 = (User)users.GetFirst (); AssertEquals(user.ToString(), user2.ToString()); AssertEquals(b.ToString(), user2.GetProfile().GetFunctions().GetEnumerator().Current .ToString()); DeleteBase("ti1.neodatis"); NeoDatis.Odb.OdbConfiguration.SetDefaultBufferSizeForData(size); }
/// <exception cref="System.Exception"></exception> public virtual void Test1WithCommit3() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function 1"); Println(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( User)))); NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number 0" , f1); p.AddFunction(new Function("f1")); User user = new User("user name 0" , "user email 0", p); odb.Store(user); NeoDatis.Odb.Test.VO.Login.Profile p2 = new NeoDatis.Odb.Test.VO.Login.Profile("profile number 0" , f1); p2.AddFunction(new Function("f2")); User user2 = new User("user name 0" , "user email 0", p2); odb.Store(user2); odb.Close(); odb = Open(FileName); NeoDatis.Odb.Objects<User> objects = null; for (int k = 0; k < 2; k++) { System.Console.Out.WriteLine(":" + k); objects = odb.GetObjects<User>(); while (objects.HasNext()) { user = (User)objects.Next(); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated"); Println(user.GetProfile().GetName()); odb.Store(user); } } odb.Close(); odb = Open(FileName); objects = odb.GetObjects<User>(); AssertEquals(2, objects.Count); odb.Close(); }
private object GetUserInstance() { Function login = new Function ("login"); Function logout = new Function ("logout"); List list = new System.Collections.ArrayList(); list.Add(login); list.Add(logout); Profile profile = new Profile("operator", list); User user = new User("olivier smadja" , "*****@*****.**", profile); return user; }
/// <summary> /// 1) insert 10000 objects 2) update 5000 * 10 times 3) delete other 5000 /// 4) check count : must be 5000 5) re-update 5000 * 10 times 6) delete the /// other 5000 7) check count - must be zero /// </summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void Test1WithoutCommit() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); int size = 10000; int size2 = 5000; int nbFunctions = 10; DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function 1"); // Create Objects for (int i = 0; i < size; i++) { NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number " + i, f1); for (int j = 0; j < nbFunctions; j++) { p.AddFunction(new Function(" inner function of profile : number " + i + " - " + j)); } User user = new User("user name " + i, "user email " + i, p); odb.Store(user); } Println("created"); // Updates 10 times the objects NeoDatis.Odb.Objects<User> objects = odb.GetObjects<User>(); for (int k = 0; k < 10; k++) { objects.Reset(); for (int i = 0; i < size2; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated"); odb.Store(user); } } Println("updated"); // Delete the rest of the objects for (int i = size2; i < size; i++) { odb.Delete(objects.Next()); } Println("deleted"); // Check object count objects = odb.GetObjects<User>(); AssertEquals(size2, objects.Count); // Check data of the objects int a = 0; while (objects.HasNext()) { User user = (User)objects.Next (); AssertEquals("user name " + a, user.GetName()); AssertEquals("user email " + a, user.GetEmail()); AssertEquals("profile number " + a + "-updated-updated-updated-updated-updated-updated-updated-updated-updated-updated" , user.GetProfile().GetName()); a++; } Println("checked"); for (int k = 0; k < 10; k++) { objects.Reset(); for (int i = 0; i < size2; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-"); odb.Store(user); } } Println("re-updated"); objects = odb.GetObjects<User>(); NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(odb); NeoDatis.Odb.Core.Layers.Layer2.Meta.CIZoneInfo uncommited = engine.GetSession(true ).GetMetaModel().GetClassInfo(typeof(User).FullName, true).GetUncommittedZoneInfo(); NeoDatis.Odb.Core.Layers.Layer2.Meta.CIZoneInfo commited = engine.GetSession(true ).GetMetaModel().GetClassInfo(typeof(User).FullName, true).GetCommitedZoneInfo(); Println("Before commit : uncommited=" + uncommited); Println("Before commit : commited=" + commited); a = 0; while (objects.HasNext()) { // println("a="+a); odb.Delete(objects.Next()); a++; } AssertEquals(size2, a); AssertEquals(0, odb.GetObjects<User>().Count); AssertEquals(0, odb.Count(new CriteriaQuery(typeof(User)))); Println("deleted"); odb.Close(); stopWatch.End(); Println("Total time 2 = " + stopWatch.GetDurationInMiliseconds()); if (stopWatch.GetDurationInMiliseconds() > 108438) { Fail("time is > than " + 108438 + " = " + stopWatch.GetDurationInMiliseconds()); } }
/// <exception cref="System.Exception"></exception> public virtual void Test1WithCommit2() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); int size = 2; int size2 = 1; int nbFunctions = 1; DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function 1"); Println(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( User)))); // Create Objects for (int i = 0; i < size; i++) { NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number " + i, f1); for (int j = 0; j < nbFunctions; j++) { p.AddFunction(new Function(" inner function of profile : number " + i + " - " + j)); } User user = new User("user name " + i, "user email " + i, p); odb.Store(user); if (i % 100 == 0) { Println("insert " + i); } } odb.Close(); Println("created"); // Updates 10 times the objects odb = Open(FileName); NeoDatis.Odb.Objects<User> objects = odb.GetObjects<User>(); Println("got the object " + objects.Count); for (int k = 0; k < 3; k++) { objects.Reset(); long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); for (int i = 0; i < size; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated"); odb.Store(user); if (i % 100 == 0) { Println("update " + i + " - " + k); } } Println("Update " + k + " - " + (NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs () - start) + " ms"); } Println("updated"); Println("deleted"); odb.Close(); // Check object count odb = Open(FileName); objects = odb.GetObjects<User>(); AssertEquals(objects.Count, size); // Check data of the objects int a = 0; while (objects.HasNext()) { User user = (User)objects.Next (); AssertEquals("user name " + a, user.GetName()); AssertEquals("user email " + a, user.GetEmail()); AssertEquals("profile number " + a + "-updated-updated-updated", user.GetProfile( ).GetName()); a++; } Println("checked"); for (int k = 0; k < 10; k++) { objects.Reset(); for (int i = 0; i < size2; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-"); odb.Store(user); } } Println("re-updated"); odb.Close(); // delete objects odb = Open(FileName); objects = odb.GetObjects<User>(); a = 0; while (objects.HasNext()) { odb.Delete(objects.Next()); a++; } AssertEquals(size, a); odb.Close(); odb = Open(FileName); AssertEquals(0, odb.GetObjects<User>().Count); AssertEquals(0, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(User)))); Println("deleted"); odb.Close(); stopWatch.End(); Println("Total time 1 = " + stopWatch.GetDurationInMiliseconds()); if (stopWatch.GetDurationInMiliseconds() > 90700) { Fail("time is > than " + 90700 + " = " + stopWatch.GetDurationInMiliseconds()); } }
public virtual void Test1WithoutCommit() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); int size = 10000; int size2 = 5000; int nbFunctions = 10; DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function 1"); // Create Objects for (int i = 0; i < size; i++) { NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number " + i, f1); for (int j = 0; j < nbFunctions; j++) { p.AddFunction(new Function(" inner function of profile : number " + i + " - " + j)); } User user = new User("user name " + i, "user email " + i, p); odb.Store(user); } Println("created"); // Updates 10 times the objects NeoDatis.Odb.Objects <User> objects = odb.GetObjects <User>(); for (int k = 0; k < 10; k++) { objects.Reset(); for (int i = 0; i < size2; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated"); odb.Store(user); } } Println("updated"); // Delete the rest of the objects for (int i = size2; i < size; i++) { odb.Delete(objects.Next()); } Println("deleted"); // Check object count objects = odb.GetObjects <User>(); AssertEquals(size2, objects.Count); // Check data of the objects int a = 0; while (objects.HasNext()) { User user = (User)objects.Next (); AssertEquals("user name " + a, user.GetName()); AssertEquals("user email " + a, user.GetEmail()); AssertEquals("profile number " + a + "-updated-updated-updated-updated-updated-updated-updated-updated-updated-updated" , user.GetProfile().GetName()); a++; } Println("checked"); for (int k = 0; k < 10; k++) { objects.Reset(); for (int i = 0; i < size2; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-"); odb.Store(user); } } Println("re-updated"); objects = odb.GetObjects <User>(); NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(odb); NeoDatis.Odb.Core.Layers.Layer2.Meta.CIZoneInfo uncommited = engine.GetSession(true ).GetMetaModel().GetClassInfo(typeof(User).FullName, true).GetUncommittedZoneInfo(); NeoDatis.Odb.Core.Layers.Layer2.Meta.CIZoneInfo commited = engine.GetSession(true ).GetMetaModel().GetClassInfo(typeof(User).FullName, true).GetCommitedZoneInfo(); Println("Before commit : uncommited=" + uncommited); Println("Before commit : commited=" + commited); a = 0; while (objects.HasNext()) { // println("a="+a); odb.Delete(objects.Next()); a++; } AssertEquals(size2, a); AssertEquals(0, odb.GetObjects <User>().Count); AssertEquals(0, odb.Count(new CriteriaQuery(typeof(User)))); Println("deleted"); odb.Close(); stopWatch.End(); Println("Total time 2 = " + stopWatch.GetDurationInMiliseconds()); if (stopWatch.GetDurationInMiliseconds() > 108438) { Fail("time is > than " + 108438 + " = " + stopWatch.GetDurationInMiliseconds()); } }
/// <exception cref="System.Exception"></exception> public virtual void TestComplexInstance() { DeleteBase("t-complex-instance.neodatis"); NeoDatis.Odb.ODB odb = Open("t-complex-instance.neodatis"); Function login = new Function ("login"); Function logout = new Function ("logout"); List<Function> functions = new List<Function>(); functions.Add(login); functions.Add(logout); Profile profile = new Profile("profile1", functions); NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("oliver" , "*****@*****.**", profile); NeoDatis.Odb.Test.VO.Login.User user22 = new NeoDatis.Odb.Test.VO.Login.User("oliver2" , "*****@*****.**", profile); odb.Store(user); odb.Store(user22); odb.Close(); odb = Open("t-complex-instance.neodatis"); NeoDatis.Odb.Objects<NeoDatis.Odb.Test.VO.Login.User> l = odb.GetObjects<NeoDatis.Odb.Test.VO.Login.User>(true); NeoDatis.Odb.Test.VO.Login.User user2 = l.GetFirst(); // println("#### " + l.size() + " : " + l); AssertEquals(user.GetName(), user2.GetName()); AssertEquals(user.GetEmail(), user2.GetEmail()); AssertEquals(user.GetProfile().GetName(), user2.GetProfile().GetName()); AssertEquals(user.GetProfile().GetFunctions()[0].ToString(), user2.GetProfile().GetFunctions ()[0].ToString()); odb.Close(); DeleteBase("t-complex-instance.neodatis"); }
private object GetUserInstance(int i) { Function login = new Function("login" + i); Function logout = new Function("logout" + i); System.Collections.Generic.List<Function> list = new System.Collections.Generic.List<Function>(); list.Add(login); list.Add(logout); Profile profile = new Profile("operator" + i, list); User user = new User("olivier smadja" + i, "*****@*****.**", profile); return user; }
public virtual void Test5() { DeleteBase("t5.neodatis"); NeoDatis.Odb.ODB odb = Open("t5.neodatis"); long nbFunctions = odb.Count(new CriteriaQuery(typeof(Function))); long nbProfiles = odb.Count(new CriteriaQuery(typeof(Profile))); long nbUsers = odb.Count(new CriteriaQuery(typeof(User))); Function login = new Function ("login"); Function logout = new Function ("logout"); System.Collections.Generic.List<Function> list = new System.Collections.Generic.List<Function>(); list.Add(login); list.Add(logout); Profile profile = new Profile("operator", list); User olivier = new User("olivier smadja" , "*****@*****.**", profile); User aisa = new User("Aísa Galvão Smadja" , "*****@*****.**", profile); odb.Store(olivier); odb.Store(profile); odb.Commit(); odb.Close(); odb = Open("t5.neodatis"); NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true); NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(true); NeoDatis.Odb.Objects<Function> functions = odb.GetObjects<Function>( true); odb.Close(); AssertEquals(nbUsers + 1, users.Count); AssertEquals(nbProfiles + 1, profiles.Count); AssertEquals(nbFunctions + 2, functions.Count); }
public virtual void Test1WithCommit2() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); int size = 2; int size2 = 1; int nbFunctions = 1; DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function 1"); Println(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( User)))); // Create Objects for (int i = 0; i < size; i++) { NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number " + i, f1); for (int j = 0; j < nbFunctions; j++) { p.AddFunction(new Function(" inner function of profile : number " + i + " - " + j)); } User user = new User("user name " + i, "user email " + i, p); odb.Store(user); if (i % 100 == 0) { Println("insert " + i); } } odb.Close(); Println("created"); // Updates 10 times the objects odb = Open(FileName); NeoDatis.Odb.Objects <User> objects = odb.GetObjects <User>(); Println("got the object " + objects.Count); for (int k = 0; k < 3; k++) { objects.Reset(); long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); for (int i = 0; i < size; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated"); odb.Store(user); if (i % 100 == 0) { Println("update " + i + " - " + k); } } Println("Update " + k + " - " + (NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs () - start) + " ms"); } Println("updated"); Println("deleted"); odb.Close(); // Check object count odb = Open(FileName); objects = odb.GetObjects <User>(); AssertEquals(objects.Count, size); // Check data of the objects int a = 0; while (objects.HasNext()) { User user = (User)objects.Next (); AssertEquals("user name " + a, user.GetName()); AssertEquals("user email " + a, user.GetEmail()); AssertEquals("profile number " + a + "-updated-updated-updated", user.GetProfile( ).GetName()); a++; } Println("checked"); for (int k = 0; k < 10; k++) { objects.Reset(); for (int i = 0; i < size2; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-"); odb.Store(user); } } Println("re-updated"); odb.Close(); // delete objects odb = Open(FileName); objects = odb.GetObjects <User>(); a = 0; while (objects.HasNext()) { odb.Delete(objects.Next()); a++; } AssertEquals(size, a); odb.Close(); odb = Open(FileName); AssertEquals(0, odb.GetObjects <User>().Count); AssertEquals(0, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(User)))); Println("deleted"); odb.Close(); stopWatch.End(); Println("Total time 1 = " + stopWatch.GetDurationInMiliseconds()); if (stopWatch.GetDurationInMiliseconds() > 90700) { Fail("time is > than " + 90700 + " = " + stopWatch.GetDurationInMiliseconds()); } }
public virtual void TestUpdateObjectReference4() { DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function function = new Function ("login"); User user = new User("olivier smadja" , "*****@*****.**", null); odb.Store(user); odb.Close(); Profile profile2 = new Profile ("new operator", function); odb = Open(FileName); odb.Store(profile2); User user2 = odb.GetObjects<User>().GetFirst(); user2.SetProfile(profile2); odb.Store(user2); odb.Close(); odb = Open(FileName); user2 = odb.GetObjects<User>().GetFirst(); AssertEquals("new operator", user2.GetProfile().GetName()); AssertEquals(1, odb.GetObjects<Profile>().Count); odb.Close(); }
public virtual void Test8() { DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function function = new Function ("login"); Profile profile = new Profile ("operator", function); User user = new User("olivier smadja" , "*****@*****.**", profile); odb.Store(user); odb.Close(); odb = Open(FileName); User user2 = (User)odb.GetObjects<User>().GetFirst(); user2.SetProfile(null); odb.Store(user2); odb.Close(); odb = Open(FileName); User user3 = (User)odb.GetObjects<User>().GetFirst(); AssertNull(user3.GetProfile()); odb.Close(); }
public virtual void Test6() { // LogUtil.objectWriterOn(true); DeleteBase("t6.neodatis"); NeoDatis.Odb.ODB odb = Open("t6.neodatis"); Function login = new Function ("login"); Function logout = new Function ("logout"); System.Collections.Generic.List<Function> list = new System.Collections.Generic.List<Function>(); list.Add(login); list.Add(logout); Profile profile = new Profile ("operator", list); User olivier = new User("olivier smadja" , "*****@*****.**", profile); odb.Store(olivier); odb.Close(); Println("----------"); odb = Open("t6.neodatis"); NeoDatis.Odb.Objects<User> users = odb.GetObjects<User>(true); User u1 = (User)users.GetFirst (); u1.GetProfile().SetName("operator 234567891011121314"); odb.Store(u1); odb.Close(); odb = Open("t6.neodatis"); NeoDatis.Odb.Objects<Profile> profiles = odb.GetObjects<Profile>(true); AssertEquals(1, profiles.Count); Profile p1 = (Profile)profiles .GetFirst(); AssertEquals(u1.GetProfile().GetName(), p1.GetName()); }
static public void Test3() { String baseName = "t2.neodatis"; File.Delete(baseName); ODB odb = ODBFactory.Open(baseName); int size = 10000; DateTime now = DateTime.Now; for (int i = 0; i < size; i++) { Function f = new Function("f1 "+i); Profile profile = new Profile("profile1"+i, f); User user = new User("user name"+i, "email"+i, profile); odb.Store(user); } odb.Close(); Console.WriteLine("time for insert = " + (DateTime.Now - now).Ticks/10000); odb = ODBFactory.Open(baseName); long t0 = DateTime.Now.Ticks; //Objects<User> users = odb.GetObjects<User>(new CriteriaQuery(Where.Like("name", "user name"))); Objects<User> users = odb.GetObjects<User>(false); long t1 = DateTime.Now.Ticks; Console.WriteLine(users.Count + " users"); while (users.HasNext()) { users.Next(); } long t2 = DateTime.Now.Ticks; Console.WriteLine("Get=" + (t1 - t0) / 10000 + " - actual Get = " + (t2 - t1)/10000); odb.Close(); Console.ReadLine(); }
public virtual void Test7() { DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function function = new Function ("login"); Profile profile = new Profile ("operator", function); User user = new User("olivier smadja" , "*****@*****.**", profile); odb.Store(user); odb.Close(); odb = Open(FileName); User user2 = odb.GetObjects<User>().GetFirst(); user2.GetProfile().AddFunction(new Function("new Function" )); odb.Store(user2); odb.Close(); odb = Open(FileName); User user3 = (User)odb.GetObjects<User>().GetFirst(); AssertEquals(2, user3.GetProfile().GetFunctions().Count); Function f1 = (Function)user3 .GetProfile().GetFunctions()[0]; Function f2 = (Function)user3 .GetProfile().GetFunctions()[1]; AssertEquals("login", f1.GetName()); AssertEquals("new Function", f2.GetName()); odb.Close(); }
public virtual void TestCriteriaQueryQueryWithValueInList2_with_null_object() { string baseName = GetBaseName(); SetUp(baseName); NeoDatis.Odb.ODB odb = Open(baseName); Profile p0 = new Profile("profile0" ); p0.AddFunction(new Function("f1")); p0.AddFunction(new Function("f2")); Profile p1 = new Profile("profile1" ); p0.AddFunction(new Function("f12")); p0.AddFunction(new Function("f22")); User user = new User("The user" , "themail", p0); User user2 = new User("The user2" , "themail2", p1); odb.Store(user); odb.Store(user2); odb.Close(); odb = Open(baseName); Function f2bis = new Function ("f2"); CriteriaQuery query = new CriteriaQuery (typeof(Profile), Where .Contain("functions", null)); NeoDatis.Odb.Objects<Profile> l = odb.GetObjects<Profile>(query ); AssertEquals(1, l.Count); p1 = l.GetFirst(); AssertEquals("profile1", p1.GetName()); odb.Close(); }