Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 83182 invoked from network); 29 May 2004 14:59:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 29 May 2004 14:59:06 -0000 Received: (qmail 69148 invoked by uid 500); 29 May 2004 14:59:04 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 69099 invoked by uid 500); 29 May 2004 14:59:04 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 69085 invoked by uid 99); 29 May 2004 14:59:04 -0000 Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.27.1) with SMTP; Sat, 29 May 2004 07:59:04 -0700 Received: (qmail 16312 invoked by uid 65534); 29 May 2004 14:58:58 -0000 Received: from adsl-62-167-127-151.adslplus.ch (EHLO gmx.ch) (62.167.127.151) by mail.gmx.net (mp027) with SMTP; 29 May 2004 16:58:58 +0200 X-Authenticated: #15507884 Message-ID: <40B8A549.6030302@gmx.ch> Date: Sat, 29 May 2004 16:59:21 +0200 From: Jakob Braeuchi User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: OJB Developers List , Phil Warrick Subject: Re: query Criteria: per path-segment alias References: <40B5623F.5090708@mcgill.ca> In-Reply-To: <40B5623F.5090708@mcgill.ca> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N hi phil, i added the new testcase to PathTest and it passed WITHOUT the modification in ClassDescriptor !? jakob Phil Warrick wrote: > Hi Jakob, > > I've added a new test case to PathTest that uncovered a problem with the > definition of segment: with criteria we associate pathHints with > segmentPaths (e.g. "As.Bs.C") whereas in > > o.a.o.broker.metadata.ClassDescriptor# > getAttributeDescriptorsForCleanPath(String aPath, Map pathHints) > > the pathhints are associated with single segments ("As" or "Bs" or "C"). > I modified this method to be consistent with the Criteria use (and my > new test case), but I'm not sure if this affects the assumptions that > other clients have about this method. > > Phil > > > ------------------------------------------------------------------------ > > /** > * return all AttributeDescriptors for the path
> * ie: partner.addresses.street returns a Collection of 3 AttributeDescriptors > * (ObjectReferenceDescriptor, CollectionDescriptor, FieldDescriptor)
> * ie: partner.addresses returns a Collection of 2 AttributeDescriptors > * (ObjectReferenceDescriptor, CollectionDescriptor) > * @param aPath the cleaned path to the attribute > * @param pathHints a Map containing the class to be used for a segment > * @return ArrayList of AttributeDescriptors > */ > private ArrayList getAttributeDescriptorsForCleanPath(String aPath, Map pathHints) > { > ArrayList result = new ArrayList(); > ClassDescriptor cld = this; > ObjectReferenceDescriptor ord = null; > FieldDescriptor fld = null; > String currPath = aPath; > String segment; > int sepPos; > Class itemClass = null; > > // PAW > int segmentPathPos = -1; > String segmentPath = null; > > while (currPath.length() > 0) > { > sepPos = currPath.indexOf("."); > if (sepPos >= 0) > { > segment = currPath.substring(0, sepPos); > currPath = currPath.substring(sepPos + 1); > // PAW > segmentPathPos += sepPos + 1; > segmentPath = aPath.substring(0, segmentPathPos); > } > else > { > segment = currPath; > currPath = ""; > // PAW > segmentPath = aPath; > } > > // look for 1:1 or n:1 Relationship > ord = cld.getObjectReferenceDescriptorByName(segment); > if (ord == null) > { > // look for 1:n or m:n Relationship > ord = cld.getCollectionDescriptorByName(segment); > } > > if (ord != null) > { > // BRJ : look for hint > //List hintClasses = (List) pathHints.get(segment); > // PAW > List hintClasses = (List) pathHints.get(segmentPath); > if (hintClasses != null && hintClasses.get(0) != null) > { > itemClass = (Class) hintClasses.get(0); > } > else > { > itemClass = ord.getItemClass(); > } > > cld = cld.getRepository().getDescriptorFor(itemClass); > result.add(ord); > } > else > { > // look for Field > fld = cld.getFieldDescriptorByName(segment); > if (fld != null) > { > result.add(fld); > } > } > } > > return result; > } > > > ------------------------------------------------------------------------ > > /* > * Find all Bs having a particular C1-D combination > * Works > */ > public void testPathClassReferenceAttrib() throws Exception > { > try > { > // c1_a criteria > Criteria crit1 = new Criteria(); > crit1.addEqualTo("cSet.c1Attrib", new Integer("10001")); > crit1.addEqualTo("cSet.d.dAttrib", new Integer("10010")); > crit1.addPathClass("cSet", C1.class); > > QueryByCriteria query = new QueryByCriteria(B.class, crit1); > > Collection allBs = broker.getCollectionByQuery(query); > > java.util.Iterator itr = allBs.iterator(); > > assertEquals(1, allBs.size()); > System.out.println("testPathClassReferenceAttrib() iteration size:" + allBs.size()); > while (itr.hasNext()) > { > B b = (B) itr.next(); > System.out.println("Found B: " + b.getId() + " " + b.getBAttrib()); > } > } > catch (Throwable t) > { > t.printStackTrace(System.out); > fail("testPathClassReferenceAttrib: " + t.getMessage()); > } > } > > > ------------------------------------------------------------------------ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org > For additional commands, e-mail: ojb-dev-help@db.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org