[Cosmo-dev] Re: [commits-sandbox] [sandbox] (edbindl) [732] Refactored the Jcr/Xpath specific stuff, put constants in User and did "mapping" in JcrXpathQueryBuilder (submit patch)

Ed Bindl ebindl1 at osafoundation.org
Wed Aug 23 15:29:52 PDT 2006


>
> ideally you'd have a JcrQueryBuilder interface and then make
> JcrXpathQueryBuilder implement that interface by building xpath
> queries. this allows us, should we need, to implement the same
> interface with a JcrSqlQueryBuilder.
>

Agreed, but which methods should I force an implementer of  
JcrSqlQueryBuilder to implement.  My thoughts are:

     /**
      * Builds a query to query all Users
      * @return the query
      */
     public StringBuffer buildUserQuery();

     /**
      * Builds a query to query all users with the supplied email
      * @param email
      * @return the query
      */
     public StringBuffer buildUserQueryByEmail(String email);

     /**
      * Users the supplied PageCriteria to build a query for Users.
      * @param pageCriteria
      * @return the query
      */
     public StringBuffer buildUserQuery(PageCriteria pageCriteria);


>
> there's an i18n problem here. some locales may want to sort in the
> opposite order. i don't think we need to deal with the issue now, just
> noting it.
>

There is support for i18n problems like this in the JcrSortType.  We  
could add a prefix to the name for the locale and then the string  
(with prefix) will map to a different JcrSortType.  The JcrSortType  
is set up so that there is a mapping from a String to a JcrSortType.  
The JcrSortType allows for the user to rank the properties in order  
of precedence for the sort, and in which order to sort them (asc/desc).

> also, for reasons of both brevity and i18n, i like using numeric
> constants for sort attributes rather than strings. eg:
>
> public static final String NAME_SORT_STRING = 1;
> public static final USERNAME_SORT_STRING = NAME_SORT_STRING + 1;
>
> and so forth.

I started out using the numbers but this made the jsp files very hard  
to follow.  The link would have localhost:8080/cosmo/users?SortType=1  
instead of SortType=Name.  IMO the cost of using the numbers  
outweighs the advantages.

>
> eek! you're polluting our nice clean storage-independent model with
> jcr-isms! :) note the JcrConstants class that already defines these
> constants - you can have JcrUserDao (or whatever other class needs to
> map the sort attributes to jcr properties) use JcrConstants directly.

Oops, didn't realize those constants were there already.


Bobby: I fixed some things pointed out in this email and did some  
other re-factoring.  I will submit another patch for your review.

-Ed

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osafoundation.org/pipermail/cosmo-dev/attachments/20060823/cbedfec9/attachment-0001.html


More information about the cosmo-dev mailing list