001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.test.legacy.soda.experiments;
022:
023: import java.util.*;
024:
025: import com.db4o.query.*;
026: import com.db4o.test.legacy.soda.*;
027: import com.db4o.test.legacy.soda.collections.*;
028:
029: public class STCurrent implements STClass {
030:
031: public static transient SodaTest st;
032:
033: SodaTest pm;
034:
035: String mystr;
036:
037: public STCurrent() {
038: }
039:
040: public STCurrent(String str) {
041: this .mystr = str;
042: }
043:
044: public String toString() {
045: return "STCurrent: " + mystr;
046: }
047:
048: public Object[] store() {
049: return new Object[] {
050: new STVectorEU(new Object[] { new Integer(17) }),
051: new STVectorEU(new Object[] { new Integer(3),
052: new Integer(17), new Integer(25),
053: new Integer(Integer.MAX_VALUE - 2) }),
054: new STVectorT(new Object[] { new Integer(17) }),
055: new STVectorU(new Object[] { new Integer(3),
056: new Integer(17), new Integer(25),
057: new Integer(Integer.MAX_VALUE - 2) }), };
058: }
059:
060: public void testDescendOne() {
061: Query q = st.query();
062: Object[] r = store();
063: q.constrain(STVectorEU.class);
064: q.descend("col").constrain(new Integer(17));
065: st.expect(q, new Object[] { r[0] });
066: }
067:
068: // public void testIdentity(){
069: // Query q = SodaTest.query();
070: // Constraint c = q.constrain(new STCurrent("hi"));
071: // ObjectSet set = q.execute();
072: // STCurrent identityConstraint = (STCurrent)set.next();
073: // identityConstraint.mystr = "jdjdjd";
074: // q = SodaTest.query();
075: // q.constrain(identityConstraint).identity();
076: // identityConstraint.mystr = "hi";
077: // SodaTest.expectOne(q,new STCurrent("hi"));
078: // }
079:
080: // public void all_Depts_that_have_no_emp(){
081: // Query q = pm.query();
082: // q.constrain(Department.class);
083: // Query qEmps = q.descendant("emps");
084: // qEmps.constrain(null).or(
085: // qEmps.constrain(new Integer(0)).length()
086: // );
087: // ObjectSet noEmps = q.execute();
088: // }
089: //
090: // public void all_Depts_that_have_exaclty_one_emp(){
091: // Query q = pm.query();
092: // q.constrain(Department.class);
093: // Query qEmps = q.descendant("emps");
094: // qEmps.constrain(new Integer(1)).length();
095: // ObjectSet oneEmp = q.execute();
096: // }
097: //
098: // public void tiger_teams(){
099: // Query q = pm.query();
100: // q.constrain(Department.class);
101: // Query qEmps = q.descendant("emps");
102: // qEmps.constrain(new Integer(2)).length().greater();
103: // qEmps.constrain(new Integer(5)).length().smaller();
104: // qEmps.descendant("salary").constrain(new Float(50000)).greater();
105: // ObjectSet tigerTeams = q.execute();
106: // }
107:
108: }
109:
110: class Employee {
111: String name;
112: Float salary;
113: Department dept;
114: Employee boss;
115: }
116:
117: class Department {
118: String name;
119: Collection emps;
120:
121: Department() {
122: }
123:
124: Department(String name) {
125: }
126: }
|