Ejemplo n.º 1
0
        public virtual void Test1()
		{
			NeoDatis.Odb.ODB odb = Open(FileName);
			NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where.Equal("name", "function 10"));
			NeoDatis.Odb.Objects<Function> l = odb.GetObjects<Function>(query);
			int size = l.Count;
			AssertFalse(l.Count==0);
			Function f = (Function)l.GetFirst
				();
			NeoDatis.Odb.OID id = odb.GetObjectId(f);
			AssertEquals("function 10", f.GetName());
			string newName = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs().ToString();
			f.SetName(newName);
			odb.Store(f);
			odb.Close();
			odb = Open(FileName);
			l = odb.GetObjects<Function>(query);
			query = new CriteriaQuery(Where.Equal("name", newName));
			AssertTrue(size == l.Count + 1);
			l = odb.GetObjects<Function>(query);
			AssertFalse(l.Count==0);
			AssertEquals(1, l.Count);
			AssertEquals(id, odb.GetObjectId(l.GetFirst()));
			odb.Close();
		}
Ejemplo n.º 2
0
        public virtual void Test4Sort()
		{
            string baseName = GetBaseName();
            SetUp(baseName);
			int d = NeoDatis.Odb.OdbConfiguration.GetDefaultIndexBTreeDegree();
			try
			{
				NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(40);
				NeoDatis.Odb.ODB odb = Open(baseName);
				CriteriaQuery aq = new CriteriaQuery
					(typeof(Function), Where
					.Not(Where.Or().Add(Where
					.Equal("name", "function 2")).Add(Where.Equal("name"
					, "function 3"))));
				aq.OrderByDesc("name");
				// aq.orderByAsc("name");
				NeoDatis.Odb.Objects<Function> l = odb.GetObjects<Function>(aq, true, -1, -1);
                odb.Close();

				AssertEquals(48, l.Count);
				Function f = (Function)l.GetFirst
					();
				AssertEquals("function 9", f.GetName());
			}
			finally
			{
				NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(d);
			}
		}
Ejemplo n.º 3
0
        public virtual void Test2()
		{
			NeoDatis.Odb.ODB odb = Open(FileName);
			int nbProfiles = odb.GetObjects<Profile>().Count;
			NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where.Equal("profile.name", "profile 10"));
			NeoDatis.Odb.Objects<User> l = odb.GetObjects<User>(query);
			int size = l.Count;
			AssertFalse(l.Count==0);
			User u = (User)l.GetFirst();
			AssertEquals("profile 10", u.GetProfile().GetName());
			Profile p2 = u.GetProfile();
			string newName = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs().ToString() +
				 "-";
			p2.SetName(newName);
			odb.Store(p2);
			odb.Close();
			odb = Open(FileName);
			l = odb.GetObjects<User>(query);
			AssertTrue(l.Count == size - 1);
			if (!isLocal)
			{
				query = new CriteriaQuery(Where.Equal("profile.name", newName));
			}
			else
			{
				query = new _SimpleNativeQuery_134(newName);
			}
			l = odb.GetObjects<User> (query);
			AssertFalse(l.Count==0);
			Objects<Profile> l2 = odb.GetObjects<Profile>(false);
			AssertEquals(nbProfiles, l2.Count);
			odb.Close();
		}
Ejemplo n.º 4
0
        public virtual void TestCriteriaQueryQueryWithObject()
		{
			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);
			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();
		}
Ejemplo n.º 5
0
		public virtual void Test3()
		{
			string baseName = GetBaseName();
			NeoDatis.Odb.ODB odb = Open(baseName);
			int size = 500;
			for (int i = 0; i < size; i++)
			{
				odb.Store(new Class1("c1"));
			}
			for (int i = 0; i < size; i++)
			{
				odb.Store(new Class1("c2"));
			}
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery();
			// q.orderByAsc("name");
			NeoDatis.Odb.Objects<Class1> objects = odb.GetObjects<Class1>(q);
			AssertEquals(size * 2, objects.Count);
			for (int i = 0; i < size; i++)
			{
				Class1 c1 = (Class1
					)objects.Next();
				AssertEquals("c1", c1.GetName());
			}
			for (int i = 0; i < size; i++)
			{
				Class1 c1 = (Class1
					)objects.Next();
				AssertEquals("c2", c1.GetName());
			}
			odb.Close();
		}
Ejemplo n.º 6
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1()
		{
			NeoDatis.Odb.ODB odb = Open(BaseName);
			CriteriaQuery query = new CriteriaQuery(Where.Equal("profile.name", "profile2"));
			NeoDatis.Odb.Objects<User> l = odb.GetObjects<User>(query);
			AssertEquals(1, l.Count);
			odb.Close();
		}
Ejemplo n.º 7
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test2()
		{
			NeoDatis.Odb.ODB odb = Open(BaseName);
			CriteriaQuery aq = new CriteriaQuery(Where.Not(Where.Equal("string1", "test class 2")));
			NeoDatis.Odb.Objects<TestClass> l = odb.GetObjects<TestClass>(aq, true, -1, -1);
			AssertEquals(49, l.Count);
			TestClass testClass = l.GetFirst();
			AssertEquals("test class 0", testClass.GetString1());
			odb.Close();
		}
Ejemplo n.º 8
0
        public virtual void Test2()
		{
			NeoDatis.Odb.ODB odb = Open("map.neodatis");
			NeoDatis.Odb.Objects<Dictionnary> l = odb.GetObjects<Dictionnary>();
			CriteriaQuery aq = new CriteriaQuery(typeof(Dictionnary), Where.Equal("name", "test2"));
			l = odb.GetObjects<Dictionnary>(aq);
			Dictionnary dictionnary = l.GetFirst();
			AssertEquals("function2", ((Function)dictionnary.Get("f2")).GetName());
			odb.Close();
		}
Ejemplo n.º 9
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestSodaWithBoolean()
		{
			NeoDatis.Odb.ODB odb = Open(BaseName);
			CriteriaQuery query = new CriteriaQuery(Where.Equal("boolean1", true));
			NeoDatis.Odb.Objects<TestClass> l = odb.GetObjects<TestClass>(query);
			AssertTrue(l.Count > 1);
			query = new CriteriaQuery(Where.Equal("boolean1", true));
			l = odb.GetObjects<TestClass>(query);
			AssertTrue(l.Count > 1);
			odb.Close();
		}
Ejemplo n.º 10
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1()
		{
			NeoDatis.Odb.ODB odb = Open(BaseName);
			CriteriaQuery aq = new CriteriaQuery(Where.Or().Add(Where.Equal("string1", "test class 1")).Add(Where.Equal("string1", "test class 3")));
            aq.OrderByAsc("string1");
			NeoDatis.Odb.Objects<TestClass> l = odb.GetObjects<TestClass>(aq, true, -1, -1);
			AssertEquals(2, l.Count);
			TestClass testClass = l.GetFirst();
			AssertEquals("test class 1", testClass.GetString1());
			odb.Close();
		}
Ejemplo n.º 11
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test3()
		{
			NeoDatis.Odb.ODB odb = Open(BaseName);
			CriteriaQuery aq = new CriteriaQuery(Where.Not(Where.Or().Add(Where
				.Equal("string1", "test class 0")).Add(Where.Equal
				("bigDecimal1", new System.Decimal(5)))));
			NeoDatis.Odb.Objects<TestClass> l = odb.GetObjects<TestClass>(aq, true, -1, -1);
			AssertEquals(48, l.Count);
			TestClass testClass = (TestClass
				)l.GetFirst();
			AssertEquals("test class 1", testClass.GetString1());
			odb.Close();
		}
Ejemplo n.º 12
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestSodaWithDouble()
		{
			NeoDatis.Odb.ODB odb = Open(BaseName);
			CriteriaQuery query = new CriteriaQuery(Where.Equal("double1", 190.99));
			NeoDatis.Odb.Objects<TestClass> l = odb.GetObjects<TestClass>(query);
			AssertEquals(1, l.Count);
			query = new CriteriaQuery(Where.Gt("double1", (double)189));
			l = odb.GetObjects<TestClass>(query);
			AssertTrue(l.Count >= 1);
			query = new CriteriaQuery(Where.Lt("double1", (double)191));
            l = odb.GetObjects<TestClass>(query);
			AssertTrue(l.Count >= 1);
			odb.Close();
		}
Ejemplo n.º 13
0
        public virtual void Test4Sort()
		{
            string BaseName = GetBaseName();
            SetUp(BaseName);
            NeoDatis.Odb.ODB odb = Open(BaseName);
			CriteriaQuery aq = new CriteriaQuery(Where.Not(Where.Or().Add(Where.Equal("string1", "test class 2")).Add(Where.Equal("string1", "test class 3"))));
			aq.OrderByDesc("double1,int1");
			NeoDatis.Odb.Objects<TestClass> l = odb.GetObjects<TestClass> (aq, true, -1, -1);
			// println(l);
			AssertEquals(48, l.Count);
			TestClass testClass = l.GetFirst();
			AssertEquals("test class 9", testClass.GetString1());
			odb.Close();
		}
Ejemplo n.º 14
0
        public virtual void Test2()
		{
            string baseName = GetBaseName();
            SetUp(baseName);
			NeoDatis.Odb.ODB odb = Open(baseName);
			CriteriaQuery aq = new CriteriaQuery
				(typeof(Function), Where
				.Not(Where.Equal("name", "function 2")));
            NeoDatis.Odb.Objects<Function> l = odb.GetObjects<Function>(aq, true, -1, -1);
			AssertEquals(49, l.Count);
			Function f = (Function)l.GetFirst
				();
			AssertEquals("function 0", f.GetName());
			odb.Close();
		}
Ejemplo n.º 15
0
        public virtual void Test1()
		{
            string baseName = GetBaseName();
            SetUp(baseName);
			NeoDatis.Odb.ODB odb = Open(baseName);
			CriteriaQuery aq = new CriteriaQuery(Where
				.Or().Add(Where.Equal("name", "function 2")).Add
				(Where.Equal("name", "function 3")));
			NeoDatis.Odb.Objects<Function> l = odb.GetObjects<Function>(aq, true, -1, -1);
			AssertEquals(2, l.Count);
			Function f = l.GetFirst
				();
			AssertEquals("function 2", f.GetName());
            Println(l);
			odb.Close();
            Console.ReadLine();
		}
Ejemplo n.º 16
0
        public virtual void TestInsert()
		{
			DeleteBase(NewbieOdb);
			odb = Open(NewbieOdb);
			Driver marcelo = new Driver
				("marcelo");
			Car car = new Car("car1", 
				4, "ranger", marcelo);
			Car car1 = new Car("car2"
				, 2, "porche");
			Car car2 = new Car("car3"
				, 2, "fusca");
			Car car3 = new Car("car4"
				, 4, "opala");
			Car car4 = new Car("car5"
				, 4, "vectra", marcelo);
			try
			{
				// open is called on NewbieTest
				// insert 5 car's
				odb.Store(car);
				odb.Store(car1);
				odb.Store(car2);
				odb.Store(car3);
				odb.Store(car4);
				// find for all car objects
				NeoDatis.Odb.Objects<Car> cars = odb.GetObjects<Car>();
				AssertEquals("The objects weren't added correctly", 5, cars.Count);
				// find for a specific car object
				CriteriaQuery query = new CriteriaQuery(typeof(Car), Where.Equal("name", "car1"));
				cars = odb.GetObjects<Car>(query);
				AssertEquals("The objects couldn't be found correctly", 1, cars.Count);
				// find for a specific composition
				query = new CriteriaQuery(typeof(Car), Where.Equal("driver.name", "marcelo"));
				cars = odb.GetObjects<Car>(query);
				AssertEquals("The objects couldn't be found correctly", 2, cars.Count);
				odb.Commit();
				odb.Close();
				DeleteBase(NewbieOdb);
			}
			catch (System.Exception e)
			{
                Console.WriteLine(e);
			}
		}
Ejemplo n.º 17
0
		public virtual void Test2()
		{
			string baseName = GetBaseName();
			NeoDatis.Odb.ODB odb = Open(baseName);
			odb.Store(new Class1("c1"));
			odb.Store(new Class1("c1"));
			odb.Store(new Class1("c2"));
			odb.Store(new Class1("c2"));
			odb.Store(new Class1("c3"));
			odb.Store(new Class1("c4"));
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery();
			// q.orderByAsc("name");
			NeoDatis.Odb.Objects<Class1> objects = odb.GetObjects<Class1>(q);
			AssertEquals(6, objects.Count);
			Println(objects);
			odb.Close();
		}
        private void PageTitle_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
        {

            Helper.CopyBinaryFile(IsolatedStorageFile.GetUserStoreForApplication(), "Data/kanjidic2.neodatis", "Data/kanjidic2.neodatis", true);

            ODB odb = ODBFactory.Open("Data/kanjidic2.neodatis");

            IQuery query = new CriteriaQuery(typeof(KanjiData), Where.Equal("Literal", "愛"));

            var data = odb.GetObjects<KanjiDatabase.KanjiData>(query);

       //     var data = odb.GetObjects<TestClass>();

//            TestClass test = new TestClass();
 //           test.Test = "Hello";

   //         odb.Store(test);

            odb.Close();
        }
Ejemplo n.º 19
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestSodaWithDate()
		{
			NeoDatis.Odb.ODB odb = Open(BaseName);
			CriteriaQuery query = new CriteriaQuery(Where.And().Add(Where.Equal("string1", "test class with values"
				)).Add(Where.Equal("date1", new System.DateTime(correctDate.Millisecond))));
			NeoDatis.Odb.Objects<TestClass> l = odb.GetObjects<TestClass>(query);
			// assertEquals(1,l.size());
			query = new CriteriaQuery(Where.And().Add(Where.Equal("string1", "test class with values")).Add(Where.Ge("date1", new System.DateTime(correctDate.Millisecond))));
			l = odb.GetObjects<TestClass>(query);
			if (l.Count != 1)
			{
				query = new CriteriaQuery(Where.Equal("string1", "test class with null BigDecimal"
					));
				NeoDatis.Odb.Objects<TestClass> l2 = odb.GetObjects<TestClass>(query);
				Println(l2);
				Println(correctDate.Millisecond);
				l = odb.GetObjects<TestClass>(query);
			}
			AssertEquals(1, l.Count);
			odb.Close();
		}
Ejemplo n.º 20
0
		public virtual void Test1()
		{
			string baseName = GetBaseName();
			NeoDatis.Odb.ODB odb = Open(baseName);
			odb.Store(new Class1("c1"));
			odb.Store(new Class1("c1"));
			odb.Store(new Class1("c2"));
			odb.Store(new Class1("c2"));
			odb.Store(new Class1("c3"));
			odb.Store(new Class1("c4"));
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery();
			q.OrderByAsc("name");
			NeoDatis.Odb.Objects<Class1> objects = odb.GetObjects<Class1>(q);
			AssertEquals(6, objects.Count);
			while (objects.HasNext())
			{
				System.Console.Out.WriteLine(objects.Next());
			}
			// println(objects);
			odb.Close();
		}
Ejemplo n.º 21
0
        public virtual void TestGetLimitedResult()
		{
			string baseName = GetBaseName();
			int size = 1000;
			NeoDatis.Odb.ODB odb = Open(baseName);
			for (int i = 0; i < size; i++)
			{
				odb.Store(new Function("function " + i));
			}
			odb.Close();
			odb = Open(baseName);
			NeoDatis.Odb.Core.Query.IQuery q = new CriteriaQuery();
			NeoDatis.Odb.Objects<Function> os = odb.GetObjects<Function>(q, true, 0, 10);
			AssertEquals(10, os.Count);
			for (int i = 0; i < 10; i++)
			{
				Function f = (Function)os.Next
					();
				AssertEquals("function " + i, f.GetName());
			}
			odb.Close();
			DeleteBase(baseName);
		}
Ejemplo n.º 22
0
        public virtual void Test1()
		{
			DeleteBase("sict");
			NeoDatis.Odb.ODB odb = Open("sict");
			NeoDatis.Odb.Test.Update.Nullobject.User user = Popula(odb);
			AT at = CreateAT(user);
			odb.Store(at);
			odb.Store(CreateSensor(user, at, 1));
			odb.Store(CreateSensor(user, at, 2));
			odb.Store(CreateSensor(user, at, 3));
			odb.Store(CreateSensor(user, at, 4));
			odb.Close();
			odb = Open("sict");
			NeoDatis.Odb.Objects<AT> ats = odb.GetObjects<AT>();
			int nbAts = ats.Count;
			at = (AT)ats.GetFirst();
			AT newAT = null;
			SensorAT newSensor = null;
			NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where.Equal("at.name", at.GetName()));
			query.OrderByAsc("lane");
			NeoDatis.Odb.Objects<SensorAT> sensors = odb.GetObjects<SensorAT>(query);
			Println("Duplicando AT " + at.GetName());
			for (int i = 0; i < 10; i++)
			{
				newAT = DuplicateAT(at, nbAts + i + 1);
				odb.Store(newAT);
				sensors.Reset();
				while (sensors.HasNext())
				{
					newSensor = DuplicateSensor((SensorAT)sensors
						.Next(), newAT);
					odb.Store(newSensor);
				}
			}
			// println("AT " + newAT.getName()+" created");
			odb.Close();
		}
Ejemplo n.º 23
0
        public virtual void TestUpdate()
		{
			try
			{
				DeleteBase(NewbieOdb);
				odb = Open(NewbieOdb);
				Driver marcelo = new Driver("marcelo");
				Car car = new Car("car1", 4, "ranger", marcelo);
				odb.Store(car);
				CriteriaQuery query = new CriteriaQuery(Where.Equal("driver.name", "marcelo"));
				Car newCar = (Car)odb.GetObjects<Car>(query).GetFirst();
				newCar.SetDriver(new Driver("dani"));
				odb.Store(newCar);
				odb.Commit();
				query = new CriteriaQuery(Where.Equal("driver.name", "dani"));
				AssertEquals(1, odb.GetObjects<Car>(query).Count);
				odb.Close();
				DeleteBase(NewbieOdb);
			}
			catch (System.Exception e)
			{
                throw e;
			}
		}
Ejemplo n.º 24
0
        public virtual void Test4()
		{
			NeoDatis.Odb.ODB odb = Open("map.neodatis");
			long n = odb.Count(new CriteriaQuery(typeof(
				NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)));
			NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), Where
				.Equal("name", "test2"));
			NeoDatis.Odb.Objects<Dictionnary> l = odb.GetObjects<Dictionnary>(query);
			NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
				)l.GetFirst();
			dictionnary.SetMap(null);
			odb.Store(dictionnary);
			odb.Close();
			odb = Open("map.neodatis");
			AssertEquals(n, odb.Count(new CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))));
			NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
				)odb.GetObjects<Dictionnary>(query).GetFirst();
			AssertEquals(null, dic.GetMap());
			odb.Close();
		}
Ejemplo n.º 25
0
        public virtual void Test6updateChangingKeyValue()
		{
			// to monitor in place updates
			NeoDatis.Odb.ODB odb = Open("map.neodatis");
			long n = odb.Count(new CriteriaQuery(typeof(Dictionnary)));
			IQuery query = new CriteriaQuery(typeof(Dictionnary), Where.Equal("name", "test2"));
			NeoDatis.Odb.Objects<Dictionnary> l = odb.GetObjects<Dictionnary>(query);
			Dictionnary dictionnary = (Dictionnary)l.GetFirst();
			dictionnary.GetMap()["f1"] = "changed function";
			odb.Store(dictionnary);
			odb.Close();
			odb = Open("map.neodatis");
			AssertEquals(n, odb.Count(new CriteriaQuery(typeof(Dictionnary))));
			Dictionnary dic = (Dictionnary)odb.GetObjects<Dictionnary>(query).GetFirst();
			AssertEquals("changed function", dic.GetMap()["f1"]);
			odb.Close();
		}
Ejemplo n.º 26
0
        public virtual void Test6updateDecreasingSize()
		{
			NeoDatis.Odb.ODB odb = Open("map.neodatis");
			long n = odb.Count(new CriteriaQuery(typeof(
				NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)));
			NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), Where
				.Equal("name", "test2"));
			NeoDatis.Odb.Objects<Dictionnary> l = odb.GetObjects<Dictionnary>(query);
			NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
				)l.GetFirst();
			int mapSize = dictionnary.GetMap().Count;
			dictionnary.GetMap().Remove("f1");
			odb.Store(dictionnary);
			odb.Close();
			odb = Open("map.neodatis");
			AssertEquals(n, odb.Count(new CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))));
			NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
				)odb.GetObjects<Dictionnary>(query).GetFirst();
			AssertEquals(mapSize - 1, dic.GetMap().Count);
			odb.Close();
		}
Ejemplo n.º 27
0
        public virtual void Test5updateIncreasingSize()
		{
			NeoDatis.Odb.ODB odb = Open("map.neodatis");
			long n = odb.Count(new CriteriaQuery(typeof(
				NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)));
			NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), Where
				.Equal("name", "test2"));
			NeoDatis.Odb.Objects<Dictionnary> l = odb.GetObjects<Dictionnary>(query);
			NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
				)l.GetFirst();
			dictionnary.SetMap(null);
			odb.Store(dictionnary);
			odb.Close();
			odb = Open("map.neodatis");
			AssertEquals(n, odb.Count(new CriteriaQuery
				(typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))));
			NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary
				)odb.GetObjects<Dictionnary>(query).GetFirst();
			AssertNull(dic.GetMap());
			odb.Close();
			odb = Open("map.neodatis");
			dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)odb.GetObjects<Dictionnary>(query).GetFirst();
			dic.AddEntry("olivier", "Smadja");
			odb.Store(dic);
			odb.Close();
			odb = Open("map.neodatis");
			dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)odb.GetObjects<Dictionnary>(query).
				GetFirst();
			AssertNotNull(dic.GetMap());
			AssertEquals("Smadja", dic.GetMap()["olivier"]);
			odb.Close();
		}
Ejemplo n.º 28
0
		/// <exception cref="System.Exception"></exception>
		public virtual void T1estInsertSimpleObjectODB(int size)
		{
			OdbFileName = "perf-" + size + ".neodatis";
			TestSize = size;
			bool doUpdate = true;
			bool doDelete = true;
			int commitInterval = 100;
			// Configuration.setUseLazyCache(true);
			bool inMemory = true;
			// Configuration.monitorMemory(true);
			// Configuration.setUseModifiedClass(true);
			// Deletes the database file
			DeleteBase(OdbFileName);
			long t1 = 0;
			long t2 = 0;
			long t3 = 0;
			long t4 = 0;
			long t5 = 0;
			long t6 = 0;
			long t7 = 0;
			long t77 = 0;
			long t8 = 0;
			NeoDatis.Odb.ODB odb = null;
			NeoDatis.Odb.Objects<SimpleObject> l = null;
			SimpleObject so = null;
			// Insert TEST_SIZE objects
			Println("Inserting " + TestSize + " objects");
			t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			odb = Open(OdbFileName);
			string[] fields = new string[] { "name" };
			odb.GetClassRepresentation(typeof(SimpleObject)).AddUniqueIndexOn
				("index1", fields, true);
			for (int i = 0; i < TestSize; i++)
			{
				object o = GetSimpleObjectInstance(i);
				odb.Store(o);
				if (i % 10000 == 0)
				{
					// println("i="+i);
					NeoDatis.Odb.Impl.Tool.MemoryMonitor.DisplayCurrentMemory(string.Empty + i, false
						);
				}
			}
			// println("Cache="+Dummy.getEngine(odb).getSession().getCache().toString());
			t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			// Closes the database
			odb.Close();
			// if(true)return;
			t3 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			Println("Retrieving " + TestSize + " objects");
			// Reopen the database
			odb = Open(OdbFileName);
			// Gets the TEST_SIZE objects
			t4 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			NeoDatis.Odb.Core.Query.IQuery q = null;
			for (int j = 0; j < TestSize; j++)
			{
				// println("Bonjour, comment allez vous?" + j);
				q = new CriteriaQuery(Where.Equal("name", "Bonjour, comment allez vous?" + j));
				NeoDatis.Odb.Objects<SimpleObject> objects = odb.GetObjects<SimpleObject>(q);
				AssertTrue(q.GetExecutionPlan().UseIndex());
				so = objects.GetFirst();
				if (!so.GetName().Equals("Bonjour, comment allez vous?" + j))
				{
					throw new System.Exception("error while getting object : expected = " + "Bonjour, comment allez vous?"
						 + j + " / actual = " + so.GetName());
				}
				if (j % 1000 == 0)
				{
					Println("got " + j + " objects");
				}
			}
			t5 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			odb.Close();
			odb = Open(OdbFileName);
			if (doUpdate)
			{
				Println("Updating " + TestSize + " objects");
				so = null;
				l = odb.GetObjects<SimpleObject>( inMemory);
				while (l.HasNext())
				{
					so = (SimpleObject)l.Next();
					so.SetName(so.GetName().ToUpper());
					odb.Store(so);
				}
			}
			t6 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			odb.Close();
			// if(true)return;
			t7 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			if (doDelete)
			{
				Println("Deleting " + TestSize + " objects");
				odb = Open(OdbFileName);
				Println("After open - before delete");
				l = odb.GetObjects<SimpleObject>(inMemory);
				t77 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				Println("After getting objects - before delete");
				int i = 0;
				while (l.HasNext())
				{
					so = (SimpleObject)l.Next();
					if (!so.GetName().StartsWith("BONJOUR"))
					{
						throw new System.Exception("Update  not ok for " + so.GetName());
					}
					odb.Delete(so);
					if (i % 10000 == 0)
					{
						Println("s=" + i);
					}
					// println("Cache="+Dummy.getEngine(odb).getSession().getCache().toString());
					i++;
				}
				odb.Close();
			}
			t8 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			// t4 2 times
			DisplayResult("ODB " + TestSize + " SimpleObject objects ", t1, t2, t4, t4, t5, t6
				, t7, t77, t8);
		}
Ejemplo n.º 29
0
        private static void Step3()
        {
            var odb1 = ODBFactory.Open(DBName);
            {
                var query = new CriteriaQuery(typeof (IItem));
                query.SetPolymorphic(true);

                IList<IItem> items = odb1.GetObjects<IItem>(query).ToList();

                foreach (var item in items)
                    Console.WriteLine(item);
            }

            odb1.Close();
        }
Ejemplo n.º 30
0
        public virtual void TestCriteriaQueryQueryWithValueInList6()
		{
			string baseName = GetBaseName();
            SetUp(baseName);
			NeoDatis.Odb.ODB odb = Open(baseName);
			IList<string> strings = new List
				<string>();
			ClassWithListOfString c = new ClassWithListOfString
				("name", strings);
			c.GetStrings().Add("s1");
			c.GetStrings().Add(null);
			c.GetStrings().Add("s3");
			IList<string> strings2 = new List
				<string>();
			ClassWithListOfString c2 = new ClassWithListOfString
				("name", null);
			odb.Store(c);
			odb.Store(c2);
			odb.Close();
			odb = Open(baseName);
			CriteriaQuery query = new CriteriaQuery
				(typeof(ClassWithListOfString), Where
				.Contain("strings", "s4"));
			NeoDatis.Odb.Objects<ClassWithListOfString> l =
                odb.GetObjects <ClassWithListOfString>(query);
			odb.Close();
			AssertEquals(0, l.Count);
		}